Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Just for the sake of completeness, I'll offer one more option - instead of dereferencing the hash reference passed in to new_packages, back into hash %packages, you could just accept the hash reference and use that to refer to your hash elements, like:
sub new_packages { my $fcount = shift; # use shift instead of $_[0] my $packages_ref = shift; # use shift instead of $_[1] print "Found $fcount packages for download: $_\n" if $fcount > 1); print "Found $fcount package for download: $_\n" if $fcount == 1); print "Which one would you like to install?:\n"; foreach my $key (keys %{$packages_ref}) { print "$key) $packages_ref->{$key} \n"; } }
Of course this code is completely untested, as your code probably was since I saw one or two problems with it.


In reply to Re: Re: parse hash to sub by hmerrill
in thread parse hash to sub by atnonis

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2022-05-20 21:37 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (76 votes). Check out past polls.