Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Nested While Loop Problem

by Smith (Initiate)
on Feb 06, 2009 at 15:06 UTC ( #741909=note: print w/replies, xml ) Need Help??


in reply to Re: Nested While Loop Problem
in thread Nested While Loop Problem

Thank you very much. Im still a little green on hashes and wasnt sure if it would work in this situation without introducing yet another loop.

I had the two print statements to show that it prints fine from within the if statement. (it gives me the three directories like it should)
if ($fsline =~ /(.:\\.*)/){ $dir = $1; print "$dir\n"; #works fine here }
But if I print outside of the if statement I get the redundancies. And if there are then this command will repeat against the remote host multiple times for the same directory.

$badhost = "$logdir\\BADHOST.csv"; open (BADHOST,">>$badhost"); $dest = "$dir\\$file"; #will print redundancies here $dest =~ s/[\s]//g; $md5sumtmp = `rctrlx.exe $target /u "domain\\username" /p "password" / +c md5sum.exe /app md5sum.exe $dest`;

Replies are listed 'Best First'.
Re^3: Nested While Loop Problem
by kennethk (Abbot) on Feb 06, 2009 at 15:49 UTC
    I am having a little difficulty interpreting your question, so if this answer is off point I apologize. I think what is happening is that since you are accessing the $dir variable outside of the conditional loop, you are caching a value of $dir from a previous traverse of the loop. Perhaps this could be fixed with something along the lines of

    if ($fsline =~ /(.:\\.*)/){ $dir = $1; print "$dir\n"; #works fine here } else { next; }

      You interpreted my question perfectly, thank you. This fixes my problem. I had tried using next but not with the else. So close but so far away.

      Thanks very much for your help and fast response.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://741909]
help
Chatterbox?
[Tanktalus]: or posting the last hour of cb... well, maybe I should double check that first :)
[Tanktalus]: yup, it's working. :)
[choroba]: https://github. com/choroba/pm-cb/ commit/7b57f513596 7bf8a29d74f1c307de 9a76894cdcf
[choroba]: Also, a thread here on PM mentioned that one of perlmonks.com or www.perlmonks.com should now work
[choroba]: Tidings
[Tanktalus]: So, I can log in, I can update last hour of cb, I can read the cb, I just can't post a message to it :(

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-07-15 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (326 votes). Check out past polls.

    Notices?