read the content of a hidden folder in a list
read the content of a hidden folder in a list
am 08.05.2011 15:29:20 von guba
Hi,
I want to read the content of a hidden folder like
$path = '/home/user/.gnome2/folder/folder';
in a list but with
opendir(DIR, "$path") || die "folder not found" $!;
I got an error message.
Thanks for the help!
guba
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: read the content of a hidden folder in a list
am 08.05.2011 20:16:27 von Shawn H Corey
On 11-05-08 09:29 AM, guba@vi-anec.de wrote:
> opendir(DIR, "$path") || die "folder not found" $!;
If you are checking if the folder exists, use the -d file test:
if( -d $path ){
print "The folder $path exists\n";
}else{
print "Sorry, not path to $path\n";
}
See `perldoc perlfunc` and search for /-X/.
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: read the content of a hidden folder in a list
am 08.05.2011 20:40:04 von Uri Guttman
>>>>> "SHC" == Shawn H Corey writes:
SHC> On 11-05-08 09:29 AM, guba@vi-anec.de wrote:
>> opendir(DIR, "$path") || die "folder not found" $!;
SHC> If you are checking if the folder exists, use the -d file test:
SHC> if( -d $path ){
SHC> print "The folder $path exists\n";
SHC> }else{
SHC> print "Sorry, not path to $path\n";
SHC> }
that doesn't tell use any more than his call to opendir failing did. we
know it isn't a legal dir from his code so he needs to see why which is
what $! tells him. he didn't tell us what $! says which i asked him to
do.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: read the content of a hidden folder in a list
am 09.05.2011 05:00:18 von derykus
On May 8, 6:29=A0am, g...@vi-anec.de ("g...@vi-anec.de") wrote:
> Hi,
>
> I want to read the content of a hidden folder like
>
> $path =3D '/home/user/.gnome2/folder/folder';
>
> in a list but with
>
> opendir(DIR, "$path") || die "folder not found" $!;
> ... ^^^
There's a syntax error above so you would've seen an
error like this:
Scalar found where operator expected ...
near "'folder not found' $!"
(Missing operator before $!?)
syntax error at ..., near "'folder not found' $!"
'die' takes a list so you'll need a comma between
arguments or maybe just: die "folder not found: $!";
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/