Hi,
I' writing a code to get the files that match a string from directory
my code works fine to some extent
it couldnt match the whole string
for example - it matches admin/1.1 and admin but i need it to match only admin/1.1
I couldn't achieve it with ^ in front and $ at the back
please help me in this regard
Thanks in advance
Code is given below
my $str = "string to be matched";
opendir(TEMP,'/ade/nachekur_view2/oracle/work/hosts/brhost3/br/xcr')or
+ die "cannot open dude \n" ;
my @FILES=readdir TEMP;
my $fi = scalar (@FILES);
for (my $k = 0; $k < $fi ; $k++)
{
open (F,$FILES[$k]) or die " rey ledhu ra \n";
my @lines = <F>;
for (@lines) {
if ($_ =~ m/$str/) {
print "$_\n";
print "Lined that matched $str in $FILES[$k] \n";
last ;
}
}
}
closedir(TEMP);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.