Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Perl compare

by Random_Walk (Prior)
on Sep 26, 2014 at 14:18 UTC ( [id://1102140]=note: print w/replies, xml ) Need Help??


in reply to Perl compare

You already have some great advice on fixing your code. There is one thing I would like to add. When you have a construct like this: my ($number1,$number2,$number3,$number4) = split /\t/; it is time to learn about arrays.

use strict; use warnings; ... my @numbers = split /\t/; if ($number[3] == 42) { print "I got the answer\n"; } else { print "What was the question?\n"; } ...
Note Perl arrays start with index 0 as the first element, so $numbers3 is the fourth number. You'll get used to it.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-26 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found