bonoboy has asked for the wisdom of the Perl Monks concerning the following question:
Of course, the $ in the $username matches and end-of-line character. How do I get round this?#!/usr/bin/perl -w my $pattern = <STDIN>; open (FILE, "< filename"); while (<FILE>) { if (/$username/) { print "$_ \n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pattern matching against a variable
by broquaint (Abbot) on Nov 04, 2003 at 11:11 UTC | |
by bonoboy (Sexton) on Nov 04, 2003 at 11:19 UTC | |
by broquaint (Abbot) on Nov 04, 2003 at 11:25 UTC | |
by bonoboy (Sexton) on Nov 04, 2003 at 11:35 UTC | |
|
Re: Pattern matching against a variable
by ysth (Canon) on Nov 04, 2003 at 12:21 UTC | |
|
Re: Pattern matching against a variable
by delirium (Chaplain) on Nov 04, 2003 at 12:31 UTC |