Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question - concise syntax for pattern matching 1

Status
Not open for further replies.

GrSw

Programmer
Feb 13, 2003
60
PL
Hi,

I have the following code:

// ...
if ( /$from_pattern/ ) {
s/$from_pattern/$to_string/g;
print "Changed: $from_pattern --> $to_string\n";
}

I would like to have:

// ...
s/$from_pattern/$to_string/g;
if ($WHAT_TO_CHECK_HERE) {
print "Changed: $from_pattern --> $to_string\n";
}

Thanks in Advance
Grzegorz

 
If you're asking what I think you're asking:
[tt]if (s/$from_pattern/$to_string/g) {[/tt]

That would do the if block if there was at least one substitution.
 
Yes, exactly I was asking about it.
(I did not program in Perl for quite a lot time,
and I just starting slowly remind it)

Thanks a lot
Grzegorz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top