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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expressions do you have a gun? 1

Status
Not open for further replies.

siswjh

MIS
Dec 6, 2001
63
US
I have read chapter 7 in Programming Perl and still don't have a clue. I am looking for a pattern like this.

if (/hscsunp1/) {
print $_;

The only problem is that it prints everything on that line I just want the pattern I have specified. If I'm writing korn shell nawk works great, I just can't figure it out for whatever reason in perl.
 
Try this

if (/(hscsunp1)/) {
print $1;
}

The () save the string match

$1 accesses the string match.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top