in reply to Will regex work here?
#!/usr/bin/perl
my $file = shift;
my $dDate = shift;
open (IN, "$file") or die "Couldn't open file: $file for reading\n";
my $slurp = join('',<IN>);
close(IN);
while ($slurp =~ /(<DAY DATE=\"(\d?\/\d\d\/\d\d\d\d)\">(.|\s)+<\/DAY>)/){
# $1 Contains the whole match now.
# $2 Contains the date in the current match.
if(isOlder($dDate, $2)){
$slurp =~ s/$1//g;
}
}
print $slurp;
sub isOlder{
#implement your own date compare
return 1;
}
I used the XML text from your message and put it in a file called test.txt. Usage was: tester.pl test.txt '04/24/2001'
You may have to play with it a bit since it is currently too greedy (it substitutes with "nothing" more than I want), but I think this should give you a good start. Good Luck.
-Matt
|
|---|