> for ($i = 0; $i < @ARGV.""; ++$i) {
Why do you append an empty string? I can't figure out what condition would make that
necessary. Won't @ARGV *always* be evaluated in a scalar context by the '<' operator?
-- Brad
From: "Chris Hedemark" <[EMAIL PROTECTED]>
> #!/usr/bin/perl
> #
> # Name:
run faster with less resource overhead.
- Original Message -
From: "n6tadam" <[EMAIL PROTECTED]>
To: "Stéphane JEAN BAPTISTE" <[EMAIL PROTECTED]>;
"PERL" <[EMAIL PROTECTED]>
Sent: Thursday, June 21, 2001 10:04 AM
Subject: Re: to delete a
#!/usr/bin/perl
#
# Name:unlinkdemo.pl
# Author: Chris Hedemark <[EMAIL PROTECTED]>
# Purpose: Demonstrate use of the unlink function.
if (!@ARGV) {
die "No arguments!\n";
}
for ($i = 0; $i < @ARGV.""; ++$i) {
if (-e $ARGV[$i]) {
unlink ("$ARGV[$i]");
}
else {
print "File
To delete a file:
unlink($filename) or die "can't delete $filename:$!\n";
To delete lots of files:
unlink(@filenames) == @filenames or die "couldn't unlink all of @filenames: $!\n";
To delete a folder:
use File::Path;
rmtree($directory);
>>> Stéphane JEAN BAPTISTE <[EMAIL PROTECTED]> 06/21/01
It's allright!
thank you
Stéphane JEAN BAPTISTE a écrit :
> How can I delete a file ?
>
> thanks
MAIL PROTECTED]>
Sent: Thursday, June 21, 2001 3:11 PM
Subject: Re: to delete a file
> On Thu, Jun 21, 2001 at 03:04:21PM +0100, n6tadam
([EMAIL PROTECTED]) spew-ed forth:
> > Hi,
> >
>
> [snip]
>
> >
> > Of course, from a perl script, you can either use
On Thu, Jun 21, 2001 at 03:04:21PM +0100, n6tadam
([EMAIL PROTECTED]) spew-ed forth:
> Hi,
>
[snip]
>
> Of course, from a perl script, you can either use:
>
> system("/bin/rm -f /path/to/filename");
>
> or
>
> `rm -f filename`
Don't do that. Just use unlink()
perldoc -f unlink
Cheers,
K
Hi,
Usually, one uses the following command (from the shell prompt)
"rm /path/to/file/filename"
To supress the confirmation message, use:
"rm -f /path/to/file/filename"
To delete recursively (i.e. a directory), and make it verbose to the screen:
rm -rfv /path/to/directory
Does that help.
O
unix:
rm filename
winblows:
del filename
oh wait, do you mean in perl ;) (wise a$$ arent I?)
perldoc -f unlink
> -Original Message-
> From: Stéphane JEAN BAPTISTE
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 21, 2001 10:03 AM
> To: PERL
> Subject: to delete a file
>
>
>
>
>
try the unlink command.
Stéphane JEAN BAPTISTE wrote:
> How can I delete a file ?
>
> thanks
10 matches
Mail list logo