in reply to Reg the split expression
use strict; use warnings; my $result = <<'EOT'; transaction 1234567; promote; 2014/08/01 10:22:37 ; user: john # Performing a "promote" on file. /./abc/desf/test.pl 138699/1 (138700/1) transaction 4578643; promote; 2014/08/01 10:22:37 ; user: sam /./abc/desf/test.pl 138699/1 (138700/1) EOT while ($result =~ /transaction (\d+).*user:\s*(\S+)\s*(?:#\s*(.*))?/g) + { my ($transaction, $user, $comment) = ($1, $2, $3); printf "%-12s %-10s %s\n", $1, $2, $3//''; }
Note the // (Logical Defined Or) to avoid an undef warning in your print.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reg the split expression
by AnomalousMonk (Archbishop) on Aug 04, 2014 at 21:51 UTC | |
|
Re^2: Reg the split expression
by sravs448 (Acolyte) on Aug 04, 2014 at 21:18 UTC |