CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [raghupise] Pattern seacrh in Perl and redirecting to other file: Edit Log



Laurent_R
Veteran / Moderator

Oct 13, 2013, 2:50 AM


Views: 7478
Re: [raghupise] Pattern seacrh in Perl and redirecting to other file

Not absolutely sure to understand what you want, but if you are looking for items where the second column starts with X, you might do something like this:

Code
open my $FD, "<", "CSD.txt" or die "could not open file CSD.txt $!"; 
open my $OUT, ">", $outfile or die "could not open file $outfile $!";
my $list_name;
while (<$FD>) {
chomp;
$list_name = $1 if /LIST NAME\s+(\w+)/;
if (/GROUP\s+X/) {
my ($name, $transID, $time) = (split)[1..3] ;
print $OUT join " ", $list_name, $name, $transID, $time, "\n";
}
}
close $_ for ($FD, $OUT);



(This post was edited by Laurent_R on Oct 13, 2013, 2:54 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Oct 13, 2013, 2:54 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives