in reply to New Problem
in thread Tagging the last elements
This provides HUGE clues as to what might be wrong!#!/usr/bin/perl -w use strict;
I think you'll find that the /\s+/ hint by graff is needed and also consider:
What happens if min and max are the same? i.e. just one position?$min = shift(@positions); $max = pop(@positions);
will handle that situation.$max = (@positions)[-1]; $min = (@positions)[0];
Update: a small update, also keep in mind that list slice allows multiple values to the left hand side, my ($min,$max) = (@positions)[0,-1]; would work also. The -1 index means the last one in the array, -2 would be second to last etc. But FAR AND AWAY, the best thing you can do to improve your code is religious use of warnings and strict!
|
|---|