in reply to Non-regex Methods of Extracting the Last Field from a Record
the primary question is why doesn't the following construct work: (@junk, $ads) = (split(/\s+/, $rec));Think of the @junk array as being "greedy": it swallows up all of the list elements returned by split, leaving none for your $ads scalar.
Update: yet another way, without the temporary @junk array:
use strict; use warnings; my $rec = 'a b c d 96'; my $ads = (split /\s+/, $rec)[-1]; print "ads=$ads\n"; __END__ ads=96
|
|---|