Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Scalar found where operator expected -- getting error - please help

by gjoshi (Sexton)
on Aug 17, 2015 at 03:54 UTC ( [id://1138818]=perlquestion: print w/replies, xml ) Need Help??

gjoshi has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

Hi have three variables I parse the string and find out different values and store it in variables as below: Example

$tmp = "37"; $tmp1 = "<="; $tmp2 = "4"; #Now I want to use all these variables in if condition. # I am trying to do following and I am getting an error if($tmp $tmp1 $tmp2) { # do some thing } else { # do some thing }
Could you please tell me how to do that. Is it possible?

thanks --girija
  • Comment on Scalar found where operator expected -- getting error - please help
  • Download Code

Replies are listed 'Best First'.
Re: Scalar found where operator expected -- getting error -- please help
by Athanasius (Archbishop) on Aug 17, 2015 at 04:14 UTC
      Hi, Yes it did work for me. Thanks a lot. thanks --girija
        However, you should ask your teacher before trying this out if your users can enter "operators" like this
        $tmp1 = ", system qw(rm -rf /), system qw(format c:),";
        (untested of course ;-))
Re: Scalar found where operator expected -- getting error - please help
by 1nickt (Canon) on Aug 17, 2015 at 04:33 UTC

    You already asked this question here. You should post follow-up questions there if the answer given didn't help you.

    The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1138818]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found