in reply to Question on File position, pulling words

To get the last two whitespace-delimited fields, you could use split, like:
my @line_fields = split " ", $line; my $penultimate = $line_fields[-2]; my $last = $line_fields[-1];
or more succinctly:
my ($penultimate, $last) = (split " ", $line)[-2, -1];

Replies are listed 'Best First'.
Re^2: Question on File position, pulling words
by Narveson (Chaplain) on Mar 04, 2008 at 07:28 UTC

    Or

    my ($last, $penultimate) = reverse split " ", $line;

    or even

    my ($last, $penultimate) = reverse split for $line;
Re^2: Question on File position, pulling words
by taints169 (Initiate) on Mar 04, 2008 at 15:40 UTC
    This actually breaks them into seperate variables. Thank you!!!!!