Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > some terrible problems with glob

Reply
Thread Tools

some terrible problems with glob

 
 
Zoran
Guest
Posts: n/a
 
      07-08-2003

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";


 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      07-08-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Zoran <(E-Mail Removed)-aachen.de> wrote in
news:(E-Mail Removed):

>
> 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/AwUBPwqxgmPeouIeTNHoEQLTnwCbBwVDuKCuUZ4FCYWguGm19j 9aEvIAoJ2n
4092UqAWX+H3TZuyeDPi8zxn
=HDT4
-----END PGP SIGNATURE-----
 
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
glob.glob output Hitesh Python 6 03-13-2007 03:45 PM
glob.glob unicode bug or feature Elbert Lev Python 5 08-02-2004 12:09 AM
Question about glob.glob <--newbie Sean Berry Python 3 05-04-2004 05:34 PM
RE: Bug in glob.glob for files w/o extentions in Windows Tim Peters Python 1 12-01-2003 09:22 AM
Bug in glob.glob for files w/o extentions in Windows Georgy Pruss Python 15 12-01-2003 04:04 AM



Advertisments