http://qs321.pair.com?node_id=1095380


in reply to Code Interpretation

Doesn't look like it does anything. Here is what I started with:

use strict; use Data::Dumper; my @allrefs; my %uni_refs = ( qw [ a 1 b 2 c 3 ] ); print Dumper \%uni_refs; my @refs = @allrefs[ sort {$a <=> $b} values %uni_refs ]; print Dumper \@allrefs; print Dumper \@refs;
and here is what the output looks like:
$VAR1 = { 'c' => '3', 'a' => '1', 'b' => '2' }; $VAR1 = []; $VAR1 = [ undef, undef, undef ];
Question is: what was the intended outcome?


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: Code Interpretation
by Perl_Ally (Novice) on Jul 28, 2014 at 15:55 UTC

    blue_cowdawg: Thanks for the attention.

    I wasn't sure of the intent, which is why I was looking for help interpreting. This is an existing script written by somebody else which I'm hoping to update to be more useful.

    The quoted line of code comes at the end of a sub. @allrefs should be an already populated array, which is why your output shows undef.

          @allrefs should be an already populated array, which is why your output shows undef.

      I had a hunch that was the case. This is why you need to include pre-assignments in your code sniglets.


      Peter L. Berghold -- Unix Professional
      Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg