I hate to post something so n00bish, but I'm pretty n00bish when it comes to perl so here it goes:
works the way I intend it to, breaking the infinite loop after the first time through, but:
results in what I can only assume is an infinite loop. My question is what changes scope-wise to the if statement when $var is instantiated outside of the while loop?
update:
Title is supposed to be "spot" not "stop" but apparently I'm dyslexic.
Last edited by thmnetwork; 11-16-2009 at 12:15 AM..
In the above
1) step 1 var =1 then goes to while loop
2) In the while loop in the first check var != 2 so doesnot get into the if loop then sets var = 2
3) In the next attempt var is 2 goes into if loop and the while loop ends
Now lets check the second block of code
1) goes into the while loop then sets var = 1 and checks if var == 2 so doesnot enter into the if loop
2) sets var =2 and then again goes to the while loop begining
3) Now here what is happening is it sets the variable var to 1 again . the condition of var=2 is never met. Hence the infinite loop.
Regarding the scope in the first instance if you print var outside the while loop it would be 1
in the second instance depending on where you declared the variable var like my $var will determine the value.
Hello,
I am trying to concatenate a string in a bash script like this:
runCmd="docker run -e \"IMAGE_NAME=$IMAGE_NAME\" "
env | grep "$ENV_SUFFIX" | while read line; do
envCmd="-e \"${line}\" "
runCmd=$runCmd$envCmd
echo $runCmd # here concatenation works fine
done
echo... (3 Replies)
I have Big brother script, which start/stop Big Brother processes. Something got change on server and now I am not able to start/stop it. There is no change in script, as I compared it from other server. This service is being managed by bb user (group is also bb).
root@tsazdq04:/#... (6 Replies)
Hello All
I am getting an issue which I want to share will all you guys
There is one windiows sercice running on my machine names Network Provisioning Service.
I developed the perl script which do
$service='Network Provisioning Service';
system('net stop $service');
When I manually... (1 Reply)
Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect.
Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is
redirected to welcome page.
My... (3 Replies)
This may be a stupid question, but was wondering if it is possible to make a variable local to a particular script and invisible to an external script that may source the script where it is defined? Thanks as always (2 Replies)
hi,
i have a script that coverts the file time in epoch time.but the problem is perl is not working inside the k-shell
----------------------------------------------------------------
#!/bin/ksh
echo "Enter the file"
read n
perl -e 'print ((stat("n")))'... (6 Replies)
Hi ,
I have one question, suppose i am a normal user and when i use 'w' command , it shows who is logged on and what they are doing .
Now i want to stop others users to know what i am doing accept the root ?
can i do this ?
thanks (5 Replies)