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;
In reply to Re^2: Arranging multiple lines
by r2ro
in thread Arranging multiple lines
by r2ro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |