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

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






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