Hello Jenda,
I am getting weak on regex.
Could you please break this down for me /(.*?-?\d+(?:\.\d+)?)/g
That is:
my @last_line = ($report[-1] =~ /(.*?-?\d+(?:\.\d+)?)/g); # split the last line into fields (including spaces!)
Also, why did you use $report[-1] instead of $report[$#report]?
The easy one first - They are the same. -1 is shorter to type.
As far as /(.*?-?\d+(?:\.\d+)?)/g
It catures data in an options format; for example:
my @array = qw% this is an array %; push @array, "First -2 second 3.35 Last";
@last_line = ($array[-1] =~ /(.*?-?\d+(?:\.\d+)?)/g); # split the last
foreach $target (@last_line) { print "$target\n"; }
prints -
First -2 second 3.35
Or, from your example:
my @array = qw% this is an array %; push @array, "1974 9.2 3.4 10.5 8.8 9.7 4.6 13.0 11.5";
@last_line = ($array[-1] =~ /(.*?-?\d+(?:\.\d+)?)/g); # split the last
foreach $target (@last_line) { print "$target\n"; }
Prints -
1974 9.2 3.4 10.5 8.8 9.7 4.6 13.0 11.5
HTH/Sx
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>