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"; } }
In reply to Pattern matching against a variable by bonoboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |