some terrible problems with glob

Discussion in 'Perl Misc' started by Zoran, Jul 8, 2003.

  1. Zoran

    Zoran Guest

    Hello guys,some things in my code are happening,which I don't
    understand.I am trying to open different directories and to load a
    bunch of files.But this don't work.
    It is all fine,when I am working in my home directoy.But if I change
    it the glob-function don't work.

    Here is the code:

    #!/usr/local/bin/perl -w

    print "\nHi please tell me your directory!\n";
    chomp ($directory = <STDIN>);
    print "\nOK now tell me the glob name!\n";
    chomp ($opname = <STDIN>);
    print "\nWorking ... \n";
    ###########################


    if (!opendir VH,$directory)
    {
    print "\nThe directory $directory was not found !!\n";
    return;}

    print "\nEnter 2 \n";

    $MJJ=-1;
    foreach $datei (readdir VH){
    $MJJ=$MJJ+1;
    $files[$MJJ]=$datei;
    print "$files[$MJJ]\n";
    }

    print "\n@files \n";

    @files=glob "*$opname*";

    print "\n$opname \n";

    print "\nEnter 3 \n";

    print "\n@files \n";
     
    Zoran, Jul 8, 2003
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Zoran <-aachen.de> wrote in
    news::

    >
    > Hello guys,some things in my code are happening,which I don't
    > understand.I am trying to open different directories and to load a
    > bunch of files.But this don't work.
    > It is all fine,when I am working in my home directoy.But if I change
    > it the glob-function don't work.
    >
    > Here is the code:

    ....
    > $MJJ=-1;
    > foreach $datei (readdir VH){
    > $MJJ=$MJJ+1;
    > $files[$MJJ]=$datei;
    > print "$files[$MJJ]\n";
    > }


    FYI, this whole loop is unnecessary. You could just do:

    @files = readdir VH;


    > print "\n@files \n";
    >
    > @files=glob "*$opname*";


    This glob happens in the current directory, not in $directory.
    Perhaps you should do

    chdir $directory;

    first.

    - --
    Eric
    $_ = reverse sort qw p ekca lre Js reh ts
    p, $/.r, map $_.$", qw e p h tona e; print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBPwqxgmPeouIeTNHoEQLTnwCbBwVDuKCuUZ4FCYWguGm19j9aEvIAoJ2n
    4092UqAWX+H3TZuyeDPi8zxn
    =HDT4
    -----END PGP SIGNATURE-----
     
    Eric J. Roode, Jul 8, 2003
    #2
    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. Georgy Pruss
    Replies:
    15
    Views:
    757
    Tim Roberts
    Dec 1, 2003
  2. Tim Peters
    Replies:
    1
    Views:
    383
    Duncan Booth
    Dec 1, 2003
  3. Sean Berry

    Question about glob.glob <--newbie

    Sean Berry, May 4, 2004, in forum: Python
    Replies:
    3
    Views:
    359
    David M. Cooke
    May 4, 2004
  4. Elbert Lev

    glob.glob unicode bug or feature

    Elbert Lev, Jul 31, 2004, in forum: Python
    Replies:
    5
    Views:
    419
    Neil Hodgson
    Aug 2, 2004
  5. Hitesh

    glob.glob output

    Hitesh, Mar 12, 2007, in forum: Python
    Replies:
    6
    Views:
    418
    Hitesh
    Mar 13, 2007
Loading...

Share This Page