"system" is calling a command from OS, and "rm" is a unix command,
if you are using Windows, that doesn't work. Use unlink($filename)
is a real cross platform command =)
if you want to use "system" to remove a file in windows, write it as
system("del $filename"); or print `del $filename`
have
On Jan 12, Randolph S. Kahle said:
>The only line that is not working is
>
>system( rm -rf $file );
You (or they) have forgotten the quotes:
system("rm -rf $file");
But if you copied this from another source, that source was totally
unaware that deletion of files like THAT is TOTALLY unsafe.
> system( rm -rf $file );
> Any tips?
Try 'system("rm", "-rf", $file)'. The quotes are not really
necessary here (I think), but you should use them, because otherwise
"rm" and "rf" will be interpreted as barewords, and you might get in
conflict with the reserved ones.
HTH,
Elias
--
T
On Jan 12, Gary Hawkins said:
>> system("rm -rf $file");
>>
>> But if you copied this from another source, that source was totally
>> unaware that deletion of files like THAT is TOTALLY unsafe. A safer
>> approach is:
>>
>> system("rm", "-rf", $file);
>
>I'm not aware of the reason for it.
It's "perldoc -f system" not "perldoc system".
--Ahmed
Gary Hawkins wrote:
>> system("rm -rf $file");
>>
>>But if you copied this from another source, that source was totally
>>unaware that deletion of files like THAT is TOTALLY unsafe. A safer
>>approach is:
>>
>> system("rm", "-rf", $file);
The rm -rf $file should be in quotes
system( "rm -rf $file" )
but make sure file isn't / !!! :)
- Original Message -
From: "Randolph S. Kahle" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 11:21 AM
Subject: How do I delete a file from Perl?
> I am writi
> system("rm -rf $file");
>
> But if you copied this from another source, that source was totally
> unaware that deletion of files like THAT is TOTALLY unsafe. A safer
> approach is:
>
> system("rm", "-rf", $file);
I'm not aware of the reason for it.
What's a good way to find which perl doc
Randy,
You can delete a file, or a list of files, using "unlink". Example:
##
unlink $file;
##
perldoc -f unlink
Hope that helps.
Ahmed
[EMAIL PROTECTED] | http://www.photo.net/user/ahmed
Randolph S. Kahle wrote:
> I am writing my first perl program (copied from a magazine).
>
> The only li
try using unlink instead.
On 12 Jan 2002, Randolph S. Kahle wrote:
> I am writing my first perl program (copied from a magazine).
>
> The only line that is not working is
>
> system( rm -rf $file );
>
> The error message is:
>
> Can't call method "rm" with a package or object reference.
>
> Any
> -Original Message-
> From: Randolph S. Kahle [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 12, 2002 11:22 AM
> To: [EMAIL PROTECTED]
> Subject: How do I delete a file from Perl?
>
>
> I am writing my first perl program (copied from a magazine).
>
> The only line that is not wor
10 matches
Mail list logo