Re: problem using -f file operator



HL wrote:
> Hello,
>
> I am trying to use the -f operator in the following manner:
>
> # some $item manipulation here

That's rather vague. Why not simply tell us what $item contains?

> ....
> if ( -f $item )
> {
> unlink($item) || carp "Warning: couldn't remove file:
> '$item'\n$!";
> carp "Remove File: $item \n" if $debug;
> }
> elsif ( -d $item )
> {
> rmtree($item) || carp "Warning: couldn't remove dir:
> '$item'\n$!";
> carp "Remove Dir: $item \n" if $debug;
> }
> elsif ( -e $item )
> {
> unlink($item) || carp "Warning: couldn't remove item:
> '$item'\n$!";
> carp "Remove Item: $item \n" if $debug;
> }
> else
> {
> carp "Ignore Item: $item\n" if $debug;
> }
>
> the problem is that for a valid file, full path in $item perl doesn't
> enter the: if (-f $item)
> and I get the: "Ignore Item" message.

That's not the whole message, though. Your carp'ed message above
includes the value of $item. Please copy and paste the entire error
message. Does that value of $item correspond to what you think it
should be?

>
> I run perl 5.005_03 on unix,
> as I mentioned the file exists, using unix file command on it issues:
> commands text
> The directory is readable & writable to me.
> moreover using: perl -e '$item = "/.....Eth_Stum.eu"; unlink($item);'
> works!

You have a file in your root directory whose name begins with 6
periods? I find that just a bit unlikely.

> can anybody see what's wrong here ?

No, because you haven't shown us everything we should see.

Paul Lalli

.



Relevant Pages

  • problem using -f file operator
    ... I am trying to use the -f operator in the following manner: ... # some $item manipulation here ... I run perl 5.005_03 on unix, ... as I mentioned the file exists, using unix file command on it issues: ...
    (perl.beginners)
  • Re: Perl Audit Reports
    ... I am new to perl. ... report of a root directory and all subsequent sub-directories and ... the report should be able to ... an alert audit report. ...
    (perl.beginners)
  • Fake root dir with Perl
    ... I'm seeing if anyone can shed light on whether Perl can do what ... Perl monitor a given directory and force any executables in that ... any files in it will believe they are in the root directory. ...
    (comp.lang.perl.misc)
  • file access dates
    ... Hi, I am new to perl, and I want to search a root directory and find ... found that the stat function returns an array of file info. Could ...
    (perl.beginners)