Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Please advise how I get the loop to pull $line1, $line2 etc? NB I'm very new to Perl so would appreciate v simple suggestions - my previous experience is SAS, Matlab and a little VBA..Thanks!!my $line1 = "use pricedb;"; my $linename = "line"; my $dbh = DBI->connect("DBI:mysql:host=localhost;database=mysql","root +","root"); # set up a loop to make submitting lines easier ; for(my $counter = 1; $counter <=10; $counter ++) { my $concatline = $linename.$counter; my $rowsaffected = $dbh ->do(${$concatline}); if ($rowsaffected && $rowsaffected == 0E0) { print "Operations ws successful but no rows were affecte +d \n"; } elsif($rowsaffected) { print "Operation was successful ($rowsaffected rows)\n"; } else { print "Operation failed: $DBI::errstr\n"; } } $dbh -> disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: concatenating variables
by brx (Pilgrim) on Jul 31, 2012 at 17:37 UTC | |
by Anonymous Monk on Aug 02, 2012 at 09:01 UTC | |
|
Re: concatenating variables
by suaveant (Parson) on Jul 31, 2012 at 17:41 UTC | |
|
Re: concatenating variables
by Khen1950fx (Canon) on Jul 31, 2012 at 21:18 UTC | |
by Anonymous Monk on Aug 01, 2012 at 01:25 UTC | |
|
Re: concatenating variables
by DStaal (Chaplain) on Aug 01, 2012 at 20:16 UTC |