J
John Black
Simple question I think. I have a string $line that has some number of fields separated by
one or more spaces. The filename is the last field on the line and I want to grab it. There
must be a way to write these two lines as one line (skipping the intermediate @line_arr
step):
@line_arr = split(/\s+/, $line);
$file = $line_arr[-1];
but I've tried various syntaxes like:
$file = split(/\s+/, $line)[-1];
but I have not hit upon a working syntax. What is it? Thanks.
John Black
one or more spaces. The filename is the last field on the line and I want to grab it. There
must be a way to write these two lines as one line (skipping the intermediate @line_arr
step):
@line_arr = split(/\s+/, $line);
$file = $line_arr[-1];
but I've tried various syntaxes like:
$file = split(/\s+/, $line)[-1];
but I have not hit upon a working syntax. What is it? Thanks.
John Black