Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help with perl glob(*) function

Reply
Thread Tools

Help with perl glob(*) function

 
 
perlUSER
Guest
Posts: n/a
 
      03-21-2006
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.

 
Reply With Quote
 
 
 
 
Kraven
Guest
Posts: n/a
 
      03-21-2006
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";
}

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      03-21-2006
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?

 
Reply With Quote
 
perlUSER
Guest
Posts: n/a
 
      03-21-2006

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.

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      03-21-2006
"perlUSER" <(E-Mail Removed)> 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 <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html

 
Reply With Quote
 
Kraven
Guest
Posts: n/a
 
      03-21-2006
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.
 
Reply With Quote
 
perlUSER
Guest
Posts: n/a
 
      03-21-2006

A. Sinan Unur wrote:
> "perlUSER" <(E-Mail Removed)> 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 <(E-Mail Removed)>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://mail.augustmail.com/~tadmc/cl...uidelines.html


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

Sri.

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-21-2006
"perlUSER" <(E-Mail Removed)> 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
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      03-21-2006
perlUSER <(E-Mail Removed)> wrote:


> Since I am using Optiperl,



What is Optiperl?


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
robic0
Guest
Posts: n/a
 
      03-21-2006
On 21 Mar 2006 05:54:09 -0800, "perlUSER" <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 02-27-2011 11:00 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 02-03-2011 11:00 AM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 01-23-2011 05:00 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments