Help with perl glob(*) function

Discussion in 'Perl Misc' started by perlUSER, Mar 21, 2006.

  1. perlUSER

    perlUSER Guest

    Hello all;
    I am trying to write a perl script to list the files on our network
    drive. First I used the glob on the local, c:\ drive and it worked
    fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    listed even though my network directory is not empyt.

    Could someone please help me with this issue or please suggest an
    alternative approach.

    Regards,
    Sri.
    perlUSER, Mar 21, 2006
    #1
    1. Advertising

  2. perlUSER

    Kraven Guest

    perlUSER wrote:
    > Hello all;
    > I am trying to write a perl script to list the files on our network
    > drive. First I used the glob on the local, c:\ drive and it worked
    > fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    > listed even though my network directory is not empyt.
    >
    > Could someone please help me with this issue or please suggest an
    > alternative approach.
    >
    > Regards,
    > Sri.
    >

    try this

    foreach (glob "k:/*.*") {
    print $_,"\n";
    }

    or this

    foreach (<k:/*.*>) {
    print $_,"\n";
    }
    Kraven, Mar 21, 2006
    #2
    1. Advertising

  3. perlUSER wrote:

    > I am trying to write a perl script to list the files on our network
    > drive. First I used the glob on the local, c:\ drive and it worked
    > fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    > listed even though my network directory is not empyt.


    Are you running the script as youself or as some other user?

    If the latter does this other user have the drive mapped and do they
    have permission to list the directory?
    Brian McCauley, Mar 21, 2006
    #3
  4. perlUSER

    perlUSER Guest

    Kraven wrote:
    > perlUSER wrote:
    > > Hello all;
    > > I am trying to write a perl script to list the files on our network
    > > drive. First I used the glob on the local, c:\ drive and it worked
    > > fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    > > listed even though my network directory is not empyt.
    > >
    > > Could someone please help me with this issue or please suggest an
    > > alternative approach.
    > >
    > > Regards,
    > > Sri.
    > >

    > try this
    >
    > foreach (glob "k:/*.*") {
    > print $_,"\n";
    > }
    >
    > or this
    >
    > foreach (<k:/*.*>) {
    > print $_,"\n";
    > }


    First of all thanks for taking my question. Your suggestion worked when
    I executed my script in the console. However didn't display in my
    perl-cgi script. Any thoughts?

    Regards,
    Sri.
    perlUSER, Mar 21, 2006
    #4
  5. "perlUSER" <> wrote in news:1142963760.469299.138900
    @t31g2000cwb.googlegroups.com:

    > First of all thanks for taking my question. Your suggestion worked when
    > I executed my script in the console. However didn't display in my
    > perl-cgi script. Any thoughts?


    perldoc -q "My CGI script runs from the command line"

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

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Mar 21, 2006
    #5
  6. perlUSER

    Kraven Guest

    perlUSER wrote:
    > Kraven wrote:
    >
    >>perlUSER wrote:
    >>
    >>>Hello all;
    >>>I am trying to write a perl script to list the files on our network
    >>>drive. First I used the glob on the local, c:\ drive and it worked
    >>>fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    >>>listed even though my network directory is not empyt.
    >>>
    >>>Could someone please help me with this issue or please suggest an
    >>>alternative approach.
    >>>
    >>>Regards,
    >>>Sri.
    >>>

    >>
    >>try this
    >>
    >>foreach (glob "k:/*.*") {
    >> print $_,"\n";
    >>}
    >>
    >>or this
    >>
    >>foreach (<k:/*.*>) {
    >> print $_,"\n";
    >>}

    >
    >
    > First of all thanks for taking my question. Your suggestion worked when
    > I executed my script in the console. However didn't display in my
    > perl-cgi script. Any thoughts?
    >
    > Regards,
    > Sri.
    >


    Some example of what you have would help, but you could try...

    use CGI qw(header start_html end_html);

    print header('text/html');
    print start_html('K Directory');
    print "<h1 align=center>Welcome to the Directory of K:\\</h1>\n";
    print "<hr width=70%>\n";

    foreach $filename (glob "k:/*.*") {
    print "$filename\n";
    }


    print "<br><br><center><a href=# onClick=window.close()>Close
    Window</a></center><br>";

    print end_html;


    anyway, the above is untested, hope it works for you.
    Kraven, Mar 21, 2006
    #6
  7. perlUSER

    perlUSER Guest

    A. Sinan Unur wrote:
    > "perlUSER" <> wrote in news:1142963760.469299.138900
    > @t31g2000cwb.googlegroups.com:
    >
    > > First of all thanks for taking my question. Your suggestion worked when
    > > I executed my script in the console. However didn't display in my
    > > perl-cgi script. Any thoughts?

    >
    > perldoc -q "My CGI script runs from the command line"
    >
    > Sinan
    > --
    > A. Sinan Unur <>
    > (remove .invalid and reverse each component for email address)
    >
    > comp.lang.perl.misc guidelines on the WWW:
    > http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


    Since I am using Optiperl, I guess I "can" run the script in console
    mode.

    Sri.
    perlUSER, Mar 21, 2006
    #7
  8. perlUSER

    Guest

    "perlUSER" <> wrote:
    > Hello all;
    > I am trying to write a perl script to list the files on our network
    > drive. First I used the glob on the local, c:\ drive and it worked
    > fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    > listed even though my network directory is not empyt.


    Is this FAQ relevant?

    perldoc -q "\*.\*"
    Why doesn't glob("*.*") get all the files?


    > Could someone please help me with this issue or please suggest an
    > alternative approach.


    Check $! after the glob. It may be able to tell you something about why
    glob is failing. At least on my machine it does:

    perl -le 'print foreach glob "/does/not/exist/*"; print $!'
    No such file or directory

    perl -le 'print $_ foreach glob "/tmp/no_permissions/*"; print $!'
    Permission denied


    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Mar 21, 2006
    #8
  9. perlUSER <> wrote:


    > Since I am using Optiperl,



    What is Optiperl?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Mar 21, 2006
    #9
  10. perlUSER

    robic0 Guest

    On 21 Mar 2006 05:54:09 -0800, "perlUSER" <> wrote:

    >Hello all;
    >I am trying to write a perl script to list the files on our network
    >drive. First I used the glob on the local, c:\ drive and it worked
    >fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    >listed even though my network directory is not empyt.
    >
    >Could someone please help me with this issue or please suggest an
    >alternative approach.
    >
    >Regards,
    >Sri.


    Sri, the bottom line is this:

    Perl's 'glob' function is the buggiest thing since the
    Ford Pinto. Its gassoline tank will catch fire when a rock hits it.
    My advice to you is:
    Instead of taking a bunch of 'try this', to face the threat head
    on and ask when will the Perl gods fix the goddamed thing ???

    Thats my advice...

    Oh, btw, try using it in windows with, not only long names but with
    spaces...

    gluk
    robic0, Mar 21, 2006
    #10
  11. perlUSER

    robic0 Guest

    On Tue, 21 Mar 2006 15:26:36 -0800, robic0 wrote:

    >On 21 Mar 2006 05:54:09 -0800, "perlUSER" <> wrote:
    >
    >>Hello all;
    >>I am trying to write a perl script to list the files on our network
    >>drive. First I used the glob on the local, c:\ drive and it worked
    >>fine. Then I changed glob(c:/*.*) to glob(k:/*.*) and no files were
    >>listed even though my network directory is not empyt.
    >>
    >>Could someone please help me with this issue or please suggest an
    >>alternative approach.
    >>
    >>Regards,
    >>Sri.

    >
    >Sri, the bottom line is this:
    >
    >Perl's 'glob' function is the buggiest thing since the
    >Ford Pinto. Its gassoline tank will catch fire when a rock hits it.
    >My advice to you is:
    >Instead of taking a bunch of 'try this', to face the threat head
    >on and ask when will the Perl gods fix the goddamed thing ???
    >
    >Thats my advice...
    >
    >Oh, btw, try using it in windows with, not only long names but with
    >spaces...
    >
    >gluk


    Oh, there seems to be an issue between single/double quotes.
    Geez, why is that ?????

    Robic0
    robic0, Mar 21, 2006
    #11
    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:
    724
    Tim Roberts
    Dec 1, 2003
  2. Tim Peters
    Replies:
    1
    Views:
    357
    Duncan Booth
    Dec 1, 2003
  3. Sean Berry

    Question about glob.glob <--newbie

    Sean Berry, May 4, 2004, in forum: Python
    Replies:
    3
    Views:
    345
    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:
    393
    Neil Hodgson
    Aug 2, 2004
  5. Hitesh

    glob.glob output

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

Share This Page