Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
"... 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!

In reply to Re^3: perl eval by ww
in thread perl eval by paribasu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found