Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Code Interpretation

by blue_cowdawg (Monsignor)
on Jul 28, 2014 at 15:43 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1095380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (None)
    As of 2024-04-25 00:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found