CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [mohan] Searching for a string: Edit Log



Tejas
User

Jan 27, 2015, 3:32 AM


Views: 34156
Re: [mohan] Searching for a string


Code
#!/usr/bin/perl 

$file = 'style.csv';
#my $regex = qr/
# (?=.*font-size) &&
# (?!.*%)
# /ix;
open(txt, $file);
while($line = <txt>) {

if ($line =~ /font-size/) {
if($line !~ /%/){
print "Forced Font is found ,$line\n";
}
else {
print "Line has % in it , $line \n"
}
}
}
close(txt);


Please do not worry about the regex in the code.i tried to match the regex in the if condition first

Code
if  ($line =~ /$regex/)


it does work but it wont print any line with % in it, which i dont think is ur requirement

Thanks
Tejas


(This post was edited by Tejas on Jan 27, 2015, 3:32 AM)


Edit Log:
Post edited by Tejas (User) on Jan 27, 2015, 3:32 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives