Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: perl eval

by ww (Archbishop)
on Jul 05, 2010 at 18:29 UTC ( #848096=note: print w/replies, xml ) Need Help??


in reply to Re^2: perl eval
in thread perl eval

"... atleast that is what I want..!"

and I want a pony... but I've never found a hayburner in my Christmas stocking.

Others monks have explained the shortcomings of your eval print $param; but, for emphasis:

>perl 848064_xyz.pl 'egal("20090316","7006")' 'egal(20090316,7006)' is $param at line 10 'egal(20090316,7006)' Line 11 $param: |'egal(20090316,7006)'| At 13, $test: 'egal(20090316,7006)' Use of uninitialized value in concatenation (.) or string at 848064_xy +z.pl line 22. ++++ >

And, just BTW, note that your double_quotes -- the "s -- don't pass through the windows shell (my Linux box is down, but IIRC, you'll have a mirror-image issue there).

Here's your code, slightly modified at 5, 6, 9, 10, 12, 19 and 34 for illustration (thus, "line 26" in my previous reply is now line 38).

#!/usr/bin/perl use strict; use warnings; # OP says: Now I am calling the script : # 001: perl xyz.pl 'egal("20090316","7006")' my $param = shift; chomp $param; print "\n\n\t $param is \$param at line 10\n\n"; eval print $param; print "\n\tLine 11 \$param: |$param| \n"; sub egal { my $result; my @arg = @_; my $test = $arg[0]; print "\n At 13, \$test: $test\n\n"; my @test = grep (/$test/i, @arg); print "\t $test[0] \n"; print "++++"; if ($#test == $#arg) { $result = 'true'; } else { $result = 'false'; } return $result; print " $result\n"; } egal($param); # call the sub!

Replies are listed 'Best First'.
Re^4: perl eval
by paribasu (Initiate) on Jul 05, 2010 at 18:47 UTC

    I have updated my problem. Hope it will make u understand the real problem... U run the second piece of code and will find the desired output i am expecting from the first piece... Please understand the problem first before answering.

      Your eval fails and you never check for it. But you were told that already. So please read the answers first before asking again.

        I have already checked it but could not find anything. That's why I have added a second piece of code for further clarification.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-07-20 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (441 votes). Check out past polls.

    Notices?