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

Re: Returning data from an eval

by (anonymized user) (Curate)
on Aug 02, 2005 at 10:26 UTC ( #480139=note: print w/replies, xml ) Need Help??


in reply to Returning data from an eval

The first example is simply throwing the result away; this modification simply prints it out instead:
# process analysis rules foreach( @$analysis_rules ) { print eval( $_ ) . "\n"; }
The second example has two errors. Firstly the number of declarations do not match the number of assignments and secondly the argument to return, while syntactically acceptable, doesn't DWIM, because the list will be coerced twice, first into an array and from that to a single scalar. Moreover it will force the return during the first iteration of the loop. The 'map' function provides a rather quick alternative.
# process analysis rules my @results = map( eval, @analysis_rules );

One world, one people

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2020-12-05 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?