![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2008
Posts: 1
Rep Power: 0
![]() |
Perl Noob, regex
I just started Perl and can't find very many in depth tutorials, so I am not quite sure what is wrong exactly with the following script, and I desperately want to learn in-depth regex. Any help?
$file = 'C:\\Documents and Settings\\*My Name Here*\\Desktop\\Code\\Programming\\PerlfileText.txt';
$continue = 'y';
while ($continue eq 'y')
{
print 'Enter filename to search: ';
$file = <>;
chomp ($file)
open (search, $file) || die("Could not open specified file\n");
$text = <search>;
if($text =~ /is.d/);
{
print '\nA match was found\n';
close (search);
}
else
{
print "\nNo matching pattern\n";
close (search);
}
print "Continue?(y\/n): ";
$continue = <>;
chomp ($continue);
} |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
Re: Perl Noob, regex
What are you trying to match, and what is your script showing?
I see a couple issues to note.. print '\nA match was found\n'; print "\nA match was found\n"; also, the code $text = <search>; only reads the first line of the file. If you want to look for a match on any line in the file, you have to put that in a loop to check each line.
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi freelance scripts - http://ryanguthrie.com/index.html |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash or Perl? | titaniumdecoy | Other Scripting Languages | 9 | Jan 30th, 2006 4:42 PM |
| A simple perl script | satimis | Perl | 3 | Aug 15th, 2005 9:31 AM |
| Why do most shared hosting services offer php not perl? | Jonnno | Perl | 5 | May 19th, 2005 3:56 PM |
| Learning and Programming Perl | G.I.Josh | Perl | 2 | Mar 23rd, 2005 1:48 PM |