[ale] scripts

Chris Hamilton chrish at ifsintl.com
Wed May 13 10:33:39 EDT 1998


> Would Perl be able to open a file, parse it for certain data (similar to gawk)
> and then pass the parsed data to an external program (gawk), a shell script or
> an executable?  Hope this makes sense but I'm trying to avoid writing a C
> program as this takes longer and warp speed is not required.
> 
> Thanks.
> 

Hello there Lisa,

In regards to your question, my experience and advocacy of perl has lead
me to this answer: absoposolutely.

Here's an example:

text_file:
chrish:500:500:Chris Hamilton
mivey:501:501:Michael Ivey
gweez:-1:-1:Mr. Gweezlebur

perl script:
open(FH,'text_file')||die;
while(<FH>){
   if(/^(\S+):\d+:\d+:/){
      system("finger $1");
   }
}
close(FH);

It's that simple. Perl's built in regular expression matching makes
parsing so very easy.

:q!

--
Christopher Hamilton            Internal System Administrator
chrish at ifsintl.com              IFS International, Inc.






More information about the Ale mailing list