Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Is this the most elegant way to code directory lookup?

by shmem (Chancellor)
on Sep 29, 2006 at 17:15 UTC ( [id://575576]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    - unless (-d $srcdir && -d $destdir ) {die "Error: $!";}
    + for($srcdir,$destdir) { ! -d $_ and die "Directory '$_' - $!\n" }
    
  2. or download this
    - chdir $srcdir;
    - opendir(INDIR,$srcdir) || die "Can't open directory: $!";
    + chdir $srcdir or die "Can't chdir to '$srcdir': $!\n";
    + open my $indir, '.' or die "Can't read '.' in $srcdir: $!\n";
    
  3. or download this
    unless (-d || $_ eq "." || $_ eq "..") { # . and .. are always -d
    
  4. or download this
    my @files = grep { -f } readdir $indir;
    
  5. or download this
        `tar -cz $_ -f $_.tar.gz`;
        `mv *.gz $destdir`;
    
  6. or download this
    chdir $srcdir or die "Can't chdir to '$srcdir': $!\n";
    open my $indir, '.' or die "Can't read '.' in $srcdir: $!\n";
    ...
    
    system ('gzip', $tarfile)
        and die "Couldn't gzip $tarfile (exitcode $?)\n";
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://575576]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found