Perl (91 Views)
Reply
Occasional Contributor
Stephen_175
Posts: 8
Registered: ‎09-16-2005
Message 1 of 3 (91 Views)

Perl

I am trying to write some perl code to convert this into a strictly Perl script.

Instead of using the system calls, is it possible to do this strictly in Perl without relying on sed and awk?

Example:

system "awk '/dat/ { print $9 }' /export/home/soglesby/gents_processed | sed 's/\.dat//g' | sed 's/\return_*//g'"

How would I be able to do this without sed and
awk?

Thanks


I am not having much luck and cannot find
any examples in the book to do the equivalent
Please use plain text.
Honored Contributor
Rodney Hills
Posts: 1,679
Registered: ‎09-09-1996
Message 2 of 3 (91 Views)

Re: Perl

How about-

open(INP,"while() {
chomp;
next unless /dat/;
@a=split('\s+',$_);
$a[8]=~s/\.dat//g;
$a[8]=~s/\return_*//g'
}

HTH

-- Rod Hills
There be dragons...
Please use plain text.
Occasional Contributor
Stephen_175
Posts: 8
Registered: ‎09-16-2005
Message 3 of 3 (91 Views)

Re: Perl

Thanks Rod, I'll try this and let you know.


Stef
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation