Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stupid perl question.



Frank J.Ramsay wrote:
| On Sunday 11 November 2001 10:19, John Chambers wrote:
| > Frank J.Ramsay asks:
| > | Why doesn't this work?
   ...
| > I'd  wonder  why  you
| > would even bother with awk from a perl script.
|
| Well it worked from the command line... and I don't use perl often enough to
| do much without a book nearby for reference (and all my perl books are at the
| office.  But it looks like I'll have to remember the syntax for doing it in
| perl.

Yeah; it's really worthwhile learning enough perl to run commands and
grovel through their output, printing something interesting. Consider
this scripts:

#!/usr/bin/perl
for $line (`/sbin/ifconfig`) {
	if ($line =~ /inet addr:([\d\.]+)/) {
		print "$1\n";
	}
}

The only thing tricky here is mastering perl's patterns.  That's much
like  anyone  else's  REs,  but even more complicated, due to all the
fancy bells & whistles that perl has accreted. Of course, when you do
it  this  way, you do away with tools like grep, sed and awk.  All of
their capabilities have been included in perl.  This is no  accident,
of course.





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org