Hi teddy6507,
The code and input you show do not match the behavior you describe - please see How do I post a question effectively? and Short, Self Contained, Correct Example.
When I fix the capitalization of "pin" and "layer", and add the missing while(<>) {...} loop, the code works for me, and I can get the maximum layer number with the code
use List::Util qw/max/; print max(@num), "\n";
I can only guess as to why you get the output "210": maybe you're doing print @num; instead of print "@num"; (see $,), or you've got $" set to the empty string.
In any case, to avoid such ambiguities it's usually much better to use a module like Data::Dumper or Data::Dump to debug your data structures.
use Data::Dump 'pp'; pp \@num; __END__ [2, 1, 0]
Hope this helps,
-- Hauke D
In reply to Re: how to capture the max value of the array
by haukex
in thread how to capture the max value of the array
by teddy6507
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |