Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Passing array into a hash

by toolic (Bishop)
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
Replies are listed 'Best First'.
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 pondering the Monastery: (9)
As of 2015-07-29 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls