Home > Archive > PERL Beginners > April 2008 > simple reg ex matching
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
simple reg ex matching
|
|
| itshardtogetone@hotmail.com 2008-04-02, 4:30 am |
| Hi,
The value of $_ is 62. In the script below, I just wonder why the default variable match the number 6. What I wanted to say is that if the default variable $_ holding the value of 62, if match the number 6, then print Yes match. So what is the right way to right.
Thanks
use strict;
use warnings;
my $_ = 62;
if( $_ =~ /6/){
print "Yes match \n";
}else{print "no"};
| |
| itshardtogetone@hotmail.com 2008-04-02, 8:08 am |
| ok, I found my error, it should be as follows if I want to match number 6:-
my $_ = 62; if( $_ =~ /^6$/){
----- Original Message -----
From: <itshardtogetone@hotmail.com>
To: <beginners@perl.org>
Sent: Wednesday, April 02, 2008 5:07 PM
Subject: simple reg ex matching
Hi,
The value of $_ is 62. In the script below, I just wonder why the default
variable match the number 6. What I wanted to say is that if the default
variable $_ holding the value of 62, if match the number 6, then print Yes
match. So what is the right way to right.
Thanks
use strict;
use warnings;
my $_ = 62;
if( $_ =~ /6/){
print "Yes match \n";
}else{print "no"};
| |
| T Baetzler 2008-04-02, 8:08 am |
| <itshardtogetone@hotmail.com> wrote:
> ok, I found my error, it should be as follows if I want to=20
> match number 6:- my $_ =3D 62; if( $_ =3D~ /^6$/){
Of course you could also just use "if( $_ =3D=3D 6 )".
HTH,
Thomas
|
|
|
|
|