Thanks David!
Works perfect with regex. -)

----- Original Message ----- From: "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]>
To: "Vladimir Lemberg" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc: "Perl Beginners" <beginners@perl.org>
Sent: Tuesday, June 07, 2005 4:57 PM
Subject: RE: problem with assigning a value


Vladimir Lemberg wrote:
Hi Mark,

Yes, I defined them outside of the while loop but it should not be a
problem because I assigned them after changing directory.

Here some debugging prints:

I have for example 3 directories: a, b, c. Each one has .vsn file:
a.vsn, b.vsn, c.vsn,

on first iteration
cwd =  /home/vladimir/scripts/test/a
$vsn = a.vsn                                                 woks ok


on second iteration
cwd =  /home/vladimir/scripts/test/b
$vsn = uninitialized                                       not working


on second iteration
cwd =  /home/vladimir/scripts/test/c
$vsn = c.ver                                                works ok


If I'll define them inside while loop, it wont work either.

Vladimir

I tried a couple of things and I don't believe that glob is working as you would expect it to work. If you do not want the vsn or ver, then I would do a simple regex like ( $file =~ /.+\.(ver|vsn)/ ) If the file name portion needs to be ralted the directory you are working out, then it becomes a little harder, but I use glob very infrequently and when I have I have only used the <glob> against a directory that I want to work specific files otherwise a regex doing what I need to check is the way.

Wags ;)

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Vladimir Lemberg" <[EMAIL PROTECTED]>
Cc: "Perl Beginners" <beginners@perl.org>
Sent: Tuesday, June 07, 2005 2:23 PM
Subject: Re: problem with assigning a value




----- Original Message -----
From: Vladimir Lemberg <[EMAIL PROTECTED]>
Date: Tuesday, June 7, 2005 5:13 pm
Subject: problem with assigning a value

Hi,
Hello

I have a problem with assigning value to string. I'll be really
grateful if someone will help me.

use strict;
use warnings;
use Cwd;
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;

####code fragment####

foreach (@dirs){
chdir $_;
my $curdir = cwd();
my $vsn = glob ("*.vsn");
my $ver = glob ("*.ver");

print BLUE "\n[$_]\n";

opendir(DIR, "$curdir") or die RED "Unable to open $curdir: $!";
 while (defined (my $file = readdir DIR)) {

   next if -d "$curdir/$file" or $file eq "zone.cfg" or $file eq
$vsn or $file eq $ver;

   #compressing
   system($program, $ARGV[0], $ARGV[1], $file) if $ARGV[0] eq "-c";
   #decompressing system($program, $ARGV[0], $file) if $ARGV[0] eq
"-d";  }

closedir(DIR);
chdir $cwd;
}

The problem is that on each even iteration of loop, strings my
$vsn and $ver cannot be initialized.
That is because you have already defined these variables outside of
your loop. you can simpley say $vsn = "Fooooo" in your loop. By the
way my $vsn = glob ("*.vsn"); may not due what you expact of it.
HTH,
mark G.

Thanks in advance,
Vladimir










--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to