in reply to how to capture the max value of the array
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to capture the max value of the array
by teddy6507 (Initiate) on May 20, 2016 at 01:15 UTC | |
by AnomalousMonk (Archbishop) on May 20, 2016 at 05:46 UTC |