For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Re: Nested Loop









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Nested Loop
mgoland@optonline.net

2006-01-19, 6:58 pm



----- Original Message -----
From: overkill@six.com
Date: Thursday, January 19, 2006 3:19 pm
Subject: Nested Loop

> Greetings,

Hello
>
> Basically I deleted a portion of a mysql database and need to
> insert the
> subnet back in. The output is suppose to increment the first
> field
> starting with '8' until the IP is 10.168.17.255. I can't figure
> out my
> inside loops condition.

You have a Typo Sir.

>Maybe there is a perl module for this?
>
>
> Example:
>
> ...
>
>
>
> My Runaway Perl Script:
>
>
> $file = 'out.sql'; # sql script
> open(INFO, ">$file"); # open for output
>
>
> for($x=0;$x<=255;$x++){
>
> for($n=8;$n+1;$n++){

There is no terminated condition here, you probably wanted to say
for($n=1;$n<=8;$n++){

Alternative would be
for my $n (1...8){

>
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,1,'10.168.17.$x')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,2,'Unknown')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,3,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,4,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,5,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,6,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,7,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,8,'Unknown')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,9,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,10,'')\;\n";
> print INFO "INSERT INTO \`anyInventory_values\` VALUES
> ($n,14,'')\;\n";
>
> }
> }
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com