Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Passing array into a hash

by toolic (Chancellor)
on Mar 28, 2013 at 15:20 UTC ( #1025975=note: print w/ replies, xml ) Need Help??


in reply to Passing array into a hash

Here's one way (use $all_msgs instead of @all_msgs):

use warnings; use strict; my @all_files = 5..7; errors( all_msgs => \@all_files, msg_subject => 'Error files', mail_msg => 'Listed files for processing:', ); sub errors { my (%args) = @_; my $all_msgs = $args{all_msgs} || ''; my $msg_subject = $args{msg_subject} || ''; my $mail_msg = $args{mail_msg} || ''; foreach my $msgs (@{ $all_msgs }) { print "$msgs\n"; } } __END__ 5 6 7


Comment on Re: Passing array into a hash
Download Code
Re^2: Passing array into a hash
by Anonymous Monk on Mar 28, 2013 at 15:34 UTC
    Thank you! I spaced out on getting it with "$" and not with "@".

    Thats the way:
    my $all_msgs = $args{all_msgs} || '';
    and processing it:
    foreach my $msgs (@{ $all_msgs }) { ...
    Problem solved, thanks again!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-10-02 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (52 votes), past polls