Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: regex needed

by McDarren (Abbot)
on Nov 18, 2008 at 13:37 UTC ( #724263=note: print w/replies, xml ) Need Help??


in reply to regex needed

"If I'm trying to do an exact match..."
Exact match for what?
You didn't specify what $var contains.

Anyway, does this do what you want?

#!/usr/bin/perl -l use strict; use warnings; my $var = 'Sensor30'; while (<DATA>) { chomp; print if m/^\Q$var\E$/; } __DATA__ >Sensor30 >FooSensor30 > Sensor30 Sensor300 Sensor30 >Sensor3
Cheers,
Darren

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://724263]
help
Chatterbox?
[Discipulus]: New Zeland and Italy share a simila faith!
[Discipulus]: same shape, earthquakes and premier dimissions the same day

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2016-12-05 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (80 votes). Check out past polls.