SPUG: Problem deleting files
Tim Maher/CONSULTIX
tim at consultix-inc.com
Thu Nov 30 01:35:11 CST 2000
On Wed, Nov 29, 2000 at 11:16:30PM -0800, Brittingham, John wrote:
> Sorry... Clicked before I should have .. Lets try this again..
>
>
> Ok.. I'm having a problem deleting files. I have tried:
>
> $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*";
> if ($week_day !~ /Mon/)
> {
> print "$oldfile\n";
> rm ($oldfile) || warn "having trouble deleting
What's rm? Are you using the Shell.pm model, or something similar?
If so, make sure you're clear on whether rm returns a shell-level
T/F value, or a Perl one; if it's the former case, you need rm && warn!
Any chance you're deleting the file correctly but incorrectly suspecting
a problem because of the warning being triggered improperly?
Also, you don't need that backslash in the $oldfile string; that might
make sense for a regular expression, but this is a filename
generation expression, in which . is not a special character. It won't
end up in $oldfile anyway, so that can't be your problem.
> $oldfile: $!";
> }
>
> I have also tried:
>
> $oldfile="../html/wrt_archive/weekly_archive/*to$twodaysback*\.*";
> if ($week_day !~ /Mon/)
> {
> unlink <$oldfile> || warn "having trouble deleting
This <$oldfile> expression could be misunderstood as a FILEHANDLE,
so you should pad it with some (unquoted) spaces so the interpreter gets the
right idea:
unlink < $oldfile > || warn "having trouble deleting
> $oldfile: $!";
> }
>
> I keep getting an error saying it can not find the file(s).
> I can run rm ../html/wrt_archive/weekly_archive/*to$twodaysback*\.* from the
> command line and it will work.
>
> What am I doing wrong?
I'm not sure, but I'd recommend trying the following variation to possibly
shed more light on what's visible at the shell end of things:
system " set -x; ls -l $oldfile " ;
As your teacher in a recent Perl class, I'm glad to see you writing
Perl programs and participating in the SPUG list! "Perl On"!
-Tim
*========================================================================*
| Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# |
| Email: tim at consultix-inc.com Web: http://www.consultix-inc.com |
|Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing |
|12/12: UNIX 1/15: Perl/DBI 2/20: Data Munging;Perl 2/22: Adv. OO Perl|
*========================================================================*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list