Cannot read directory c:\test

Discussion in 'Perl Misc' started by alexjaquet@gmail.com, Nov 1, 2005.

  1. Guest

    Hi,

    I wrote a simple test script but I could not read directory entries.

    Here is the code I use :

    #!/usr/bin/perl -w
    use strict;
    use File::Copy;

    my $dir_start;my $dir_dest;
    print "Donner le repertoire initial \n";
    $dir_start= <STDIN>;
    print "Donner le repertoire de destination \n";
    $dir_dest = <STDIN>;
    #affichage du contenu du repertoire
    opendir(DIR, $dir_start) or die "Cannot read directory $dir_start:
    $!\n";c:
    my @listarray = readdir(DIR);
    close (DIR);
    foreach my $f (@listarray) {
    print "$f \n";
    }
    print "Donner le nom fichier a copier\n";
    my $file_to_move = <STDIN>;
    if (-e $dir_dest/$file_to_move) { rename
    ($dir_dest/$file_to_move,"$dir_dest/$file_to_move.old");}
    copy("$dir_start","$dir_dest/$file_to_move");
     
    , Nov 1, 2005
    #1
    1. Advertising

  2. wrote in news:1130854991.703495.118280
    @o13g2000cwo.googlegroups.com:

    [ Hmmm ... so you get out of my killfile by changing your posting
    address. ]

    > I wrote a simple test script but I could not read directory entries.
    >
    > Here is the code I use :
    >
    > #!/usr/bin/perl -w
    > use strict;
    > use File::Copy;
    >
    > my $dir_start;my $dir_dest;
    > print "Donner le repertoire initial \n";
    > $dir_start= <STDIN>;


    Oh, for heaven's sake, you have been at this long enough to know that
    you need to chomp that string.

    Sinan

    PS: Bye.
    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Nov 1, 2005
    #2
    1. Advertising

  3. <> wrote:


    > $dir_start= <STDIN>;


    > opendir(DIR, $dir_start) or die "Cannot read directory $dir_start:
    > $!\n";c:



    If you get in the habit of properly formatting your diagnostic
    messages, you will never be mystified by this problem again.

    opendir(DIR, $dir_start) or
    die "Cannot read directory '$dir_start' $!\n";


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Nov 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J Gao
    Replies:
    0
    Views:
    1,245
    J Gao
    Jul 28, 2003
  2. Sting
    Replies:
    5
    Views:
    1,663
    Natty Gur
    Jun 8, 2004
  3. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    767
    Skybuck Flying
    Oct 4, 2009
  4. Peng Yu
    Replies:
    0
    Views:
    354
    Peng Yu
    Nov 6, 2009
  5. Guest
    Replies:
    1
    Views:
    566
    Andrea D'Onofrio [MSFT]
    May 21, 2004
Loading...

Share This Page