Results 1 to 3 of 3
I want to make a Perl script that makes you type the word of the option you want via STDIN.
For example:
Suppose you are in a script where you ...
- 01-25-2009 #1
[SOLVED] Perl: Use STDIN to parse strings
I want to make a Perl script that makes you type the word of the option you want via STDIN.
For example:
Suppose you are in a script where you must type 'area' to activate 'Area.pl' or 'perimeter' to load 'Perimeter.pl'. As a matter of fact, that's what I'm trying to make. But when I test it out, I get an error saying that the STDIN inside the if statement only does kindly to numbers.
As you can see, instead of numbers, I wanted STDIN to respond to letters type in, but I get an error and stuff falls apart!Code:$root = '.'; if (<STDIN> == 'area') { system "/usr/bin/perl $root/Area.pl"; }
- 01-25-2009 #2
"==" is Perl's numeric comparison operator. To do a string comparison, use "eq":
Code:$root = '.'; if (<STDIN> eq 'area') { system "/usr/bin/perl $root/Area.pl"; }DISTRO=Arch
Registered Linux User #388732
- 01-29-2009 #3
Alright. That's all I needed.
The thread is now Case Closed.


