in reply to [Solved] Avoiding repeated undefs
It sounds like you already have a good solution, but for me, the obvious one is to pop the output from split into an array, then take the first and last values.
That approach doesn't care if the number of values changes -- you always get the first and the last values. Also, the split could be simplified to justmy @array = split(/\s+/, $_); my ( $key, $value ) = @array[ 0, -1 ];
because $_ is the default parameter for this function.my @array = split(/\s+/);
|
|---|