Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Code Interpretation

by blue_cowdawg (Monsignor)
on Jul 28, 2014 at 15:43 UTC ( #1095380=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1095380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-08-12 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (65 votes). Check out past polls.

    Notices?