|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Perl-Matching from a file [Help]
Hello all
i have this peace of code open(RULES,'rules.txt') or die $!; my @rules = <RULES>; close RULES or die $!; foreach my $rule(@rules) { if ($request =~ m/$rule/i) { open(ERROR,"error.html"); my @error=<ERROR>; close(ERROR); foreach $line(@error){ print C $line; } it match a text from a file or 'rules' written by regular expressions with a request but the problem that it's matching only the first line i mean my rules file content \.txt that will match any .txt extension but when i add nother line like \.txt \.php it matchs only .txt please i really need help |
|
#2
|
||||
|
||||
|
Need sample data from the rules.txt file and what is the value of $request?
|
|
#3
|
|||
|
|||
|
I'd have it print out @rules, make sure all the lines are getting into the array.
|
|
#4
|
||||
|
||||
|
assuming there's anything in the file the array should be populated.
I'm with Kevin, the question is about matching, so we'd need to see the data to match ...
__________________
--Ax without exception, there is no rule ... The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones ![]() 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl-Matching from a file [Help] |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|