Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^6: trouble with regular expressions

by programmer.perl (Beadle)
on Nov 07, 2012 at 19:53 UTC ( [id://1002727]=note: print w/replies, xml ) Need Help??


in reply to Re^5: trouble with regular expressions
in thread trouble with regular expressions

Yes, I made as you wrote: I closed the file and re-open with > property and all are working)) this is our last code

#!/usr/bin/perl -w use strict; use warnings; use Cwd qw(); my $path = Cwd::cwd(); my $date = localtime(); my $count=0; my $count_file = 0; my $report = "$path/report_$date.txt"; open (FINDIT, "find $path -name '*.js' -type f -print |") || die "Coul +dn't execute find!\n"; while (my $filename = <FINDIT>) { $count_file++; open (TABLETKA, "$filename") || die "Can't open $filename: $!\n"; my @lines = <TABLETKA>; seek(TABLETKA,0,0); my @clean = <TABLETKA>; foreach (@lines) { if ($_ =~ m#(document\.write\('<iframe.*)(</iframe>'\);)#) + { foreach (@clean) { $count++; if ( s{([[:space:]];document\.write\('<iframe.*)(</iframe> +'\);)}{ //eof} ) { close (TABLETKA); open (APP, ">$filename") || die "Can't open FOR WRITING $f +ilename: $!\n"; print APP @clean; close (APP); open (REPORT, ">>$report") || die "Can't open a report.txt +: $!\n"; chomp($filename); print REPORT "$count_file. FILE: $filename\nINFECTED LINE +NUMBER: $count\nCLEANING DATE: $date\n\n"; close (REPORT); $count = 0; } elsif ( s{([^[:space:]])(;document\.write\('<iframe.*)(</i +frame>'\);)}{$1; //eof} ) { close (TABLETKA); open (APP, ">$filename") || die "Can't open FOR WRITING $f +ilename: $!\n"; print APP @clean; close (APP); open (REPORT, ">>$report") || die "Can't open a report.txt +: $!\n"; chomp($filename); print REPORT "$count_file. FILE: $filename\nINFECTED LINE +NUMBER: $count\nCLEANING DATE: $date\n\n"; close (REPORT); $count = 0; } elsif ( s{(;document\.write\('<iframe.*)(</iframe>'\);)}{ +//eof} ) { close (TABLETKA); open (APP, ">$filename") || die "Can't open FOR WRITING $f +ilename: $!\n"; print APP @clean; close (APP); open (REPORT, ">>$report") || die "Can't open a report.txt +: $!\n"; chomp($filename); print REPORT "$count_file. FILE: $filename\nINFECTED LINE +NUMBER: $count\nCLEANING DATE: $date\n\n"; close (REPORT); $count = 0; } } } } }
Enough codes make shapes. (Hamidjon)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1002727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2024-04-18 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found