Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

simple reg ex matching
Hi,
The value of $_ is 62. In the script below, I just wonder why the default va
riable match the number 6. What I wanted to say is that if the default varia
ble $_ 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"};

Report this thread to moderator Post Follow-up to this message
Old Post
itshardtogetone@hotmail.com
04-02-08 09:30 AM


Re: simple reg ex matching
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"};


Report this thread to moderator Post Follow-up to this message
Old Post
itshardtogetone@hotmail.com
04-02-08 01:08 PM


RE: simple reg ex matching
<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

Report this thread to moderator Post Follow-up to this message
Old Post
T Baetzler
04-02-08 01:08 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:59 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.