On Wed, Mar 24, 2004 at 03:32:58PM -0800, Richard Crawford wrote:
> 
> This script is supposed to remove everything between <form and reset>. 
> Yet, when I run it, it gives me this error:
> 
> print() on closed filehandle THENEWFILE at boardclean.pl line 23.
> Cannot print!! Bad file number
> 
> I cannot see my programming error.  Can anyone help?

You're not recursing right?

> ======================================================
> #!/usr/local/bin/perl
> 
> use strict;
> 
> my $curdir = shift;
> my $file = "";
> my $tmprs = "";
> my $data = "";
> 
> opendir(DIR, $curdir) or die "Cannot open directory $curdir: $!";
> while (defined ($file = readdir(DIR))) {

        # skip directories and non-readable files
        next if (-d $file || !(-r $file));

>       open(THEFILE, "$file");
>       $tmprs = $/;
>       undef $/;
>       $data=<THEFILE>;
>       close(THEFILE);
>       $/ = $tmprs;
>       $data =~ s|<form.*reset>|<!-- form action removed -->|gm;
>       open(THENEWFILE, ">$file");
>       print THENEWFILE $data or die "Cannot print!! $!\n";
>       close (THENEWFILE);
> }
_______________________________________________
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech

Reply via email to