in reply to Re: Arranging multiple lines
in thread Arranging multiple lines
Thank you very much hdb,
but again you have to forgive my ignorance on this, I got lost in incorporating your code with input and output file arguments. :(
Please bear with me, I just started studying perl 2 days ago.
use strict; use warnings; my $infile = $ARGV[0]; my $outfile = $ARGV[1]; open my $in, "<", $infile or die $!; open my $out, ">", $outfile or die $!; sub printdata { my $data = shift; $$data{"User-Agent"} //= "--"; print join "|", @$data{ ( "Arrival Time", "From", "To", "User- +Agent" ) }; print "\n\n"; %$data = (); } my %data; my ($item, $value); print "Arrival Time|From|To|User-Agent\n\n"; while(<$in>){ chomp; next unless ($item, $value) = /^(.*?): (.*)/; printdata \%data if $item eq "Arrival Time" and %data; $data{$item} = $value; } printdata \%data; close $in; close $out;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Arranging multiple lines
by hdb (Monsignor) on Jun 03, 2013 at 13:13 UTC |