some terrible problems with glob

Z

Zoran

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

Eric J. Roode

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

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top