Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: I could not use more than one IF ($_ = / /) condition for a single line

by davorg (Chancellor)
on Jul 01, 2009 at 16:26 UTC ( [id://776493]=note: print w/replies, xml ) Need Help??


in reply to I could not use more than one IF ($_ = / /) condition for a single line

$_ = /^(IPR\d+).*/

That doesn't do what you think it does.

To match against a variable, you use the binding operator (=~) not the assignment operator.

But, of course, you don't need to explicitly bind to $_ as that's the default operand for the match operator. So you can rewrite that as just:

/^(IPR\d+).*/
--

See the Copyright notice on my home node.

Perl training courses

  • Comment on Re: I could not use more than one IF ($_ = / /) condition for a single line
  • Download Code

Replies are listed 'Best First'.
Re^2: I could not use more than one IF ($_ = / /) condition for a single line
by jawsai1224 (Initiate) on Jul 01, 2009 at 16:37 UTC
    Now it's working... I used binding operator =~ instead of =. Thanks for your help guys
      you might want to look at the given/when block introduced in Perl 5.10 , it is very well suited for parsing , I like it more than the if blocks :)
Re^2: I could not use more than one IF ($_ = / /) condition for a single line
by jawsai1224 (Initiate) on Jul 01, 2009 at 16:32 UTC
    Sorry, I changed to ICR, it is not working still..

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-25 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found