in reply to Re: Whatever happened to chomp?
in thread Whatever happened to chomp?
2 is a number.
No, 2 could be a number or a string base on the context as how you use it. A better answer is to point out what he really misunderstood: the context.
It is pretty straight to simply change == to eq, and quot 2:
use Tk; use Tk::NoteBook; use strict; use warnings; use strict; use warnings; while (my $data = <DATA>) { chomp $data; print $data; if ($data eq "2"){print "->got 2\n"} } print "Enter a 2\n"; my $input = <>; chomp $input; if ($input eq "2"){print "->got 2\n"} __DATA__ 1 2 3 4
|
|---|