Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025975]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2018-06-19 22:49 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (115 votes). Check out past polls.