Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Conditionally Changing a Variable

by Rhose (Priest)
on Dec 17, 2001 at 23:01 UTC ( #132615=note: print w/ replies, xml ) Need Help??


in reply to Conditionally Changing a Variable

Might want to move the $

$c=0 if ($c < 0);


Comment on Re: Conditionally Changing a Variable
Download Code
Re: Re: Conditionally Changing a Variable
by Anonymous Monk on Dec 17, 2001 at 23:44 UTC
    Typo. That's what I get for trying to do something quickly before lunch. Shades of old Basic programming shinning through. However, I could not get this to work last night....now it does....at work. Maybe my Perl interpreter on the home machine is broken. I had a similar problem in the past with variables such as: $n = $filenameB if ($n = $filenameA);
      I had a similar problem in the past with variables such as: $n = $filenameB if ($n = $filenameA);

      No wonder you are having problems with this, two errors in the same line :). First of all you are doing an assignment in the if-condition so this should be '==' instead of '='. And second '==' only works for numbers which is probably not what you want ($filename !!). You should use 'eq' instead. $n = $filenameB if ($n eq $filenameA);

      -- Hofmator

        Ah....the answers I had forgotten and needed. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-08-29 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls