read the content of a hidden folder in a list

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 [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
guba [ So, 08 Mai 2011 15:29 ] [ ID #2059267 ]

Re: read the content of a hidden folder in a list

On 11-05-08 09:29 AM, guba [at] 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 [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Shawn H Corey [ So, 08 Mai 2011 20:16 ] [ ID #2059268 ]

Re: read the content of a hidden folder in a list

>>>>> "SHC" == Shawn H Corey <shawnhcorey [at] ncf.ca> writes:

SHC> On 11-05-08 09:29 AM, guba [at] 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 [at] 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 [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Uri Guttman [ So, 08 Mai 2011 20:40 ] [ ID #2059269 ]

Re: read the content of a hidden folder in a list

On May 8, 6:29=A0am, g... [at] vi-anec.de ("g... [at] 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 [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
derykus [ Mo, 09 Mai 2011 05:00 ] [ ID #2059291 ]
Perl » gmane.comp.lang.perl.beginners » read the content of a hidden folder in a list

Vorheriges Thema: how do I pass arrays from mainscript into the subroutine
Nächstes Thema: Re: read the content of a hidden folder in a list