>> Now the code:
>> #!/usr/bin/perl 
>> use Strict;
>> use CGI qw(:standard);
>> use DBI;
> 
> Honour deserved for using 'strict', but you have forgotten
> to enable warnings.  Strict ***MUST*** be lowercase otherwise
> on systems with case-sensitive filenames it will barf.
> 
>> my $dbh = DBI->connect("DBI:mysql:database=nuug;host=localhost", tor,
>> password, {'RaiseError' => 1 });
> 
> I can't remember the syntax for this, but the string looks wrong to
> my eye.

Nope, it's correct :)
 
> Don't forget to turn on autoflushing with "$|=1", or for long queries
> it will timeout.

Thanks for the tip. I guess I will find information about it in man DBI?
 
> Try using:
> 
> die "Managed to get to the waypoint!";
> 
> to find out what code is actually getting run - there is better ways,
> but this is a beginners list :)

That is great advice :)
 
The code again:
#!/usr/bin/perl 
use Strict;
use CGI qw(:standard);
use DBI;

my @arrangement;
my $tabell = "Oslo_220602_Vika";
my $navn = "Tor Hildrum";
my $epost = "tor\@whatever.com";

my $dbh = DBI->connect("DBI:mysql:database=nuug;host=localhost", tor,
password, {'RaiseError' => 1 });
my $sth = $dbh->prepare("select * from $tabell");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
push(@arrangement, $ref->{'epost'});}

while (@arrangement) {   ## HANGS
chomp;                           ## HERE
my $test = 1 if $_ eq $epost;   ## HMM? :)
}

If we look at how @arrangement is created:
while (my $ref = $sth->fetchrow_hashref()) {
push(@arrangement, $ref->{'epost'});}

I know this is correct, because I am using it in another sub in the same
script(this script is just a sub that I made to be independent for
troubleshooting). 
@arrangement = qw([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]);
That is how @arrangement should look like. And, I believe it looks like
that.

If I do:
# $sth->execute();
# while (my $ref = $sth->fetchrow_hashref()) {
# push(@arrangement, $ref->{'epost'});}
@arrangement = qw([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]);

while (@arrangement) {
chomp;
my $test = 1 if $_ eq $epost;
}

die ("Hooray, didn't hang.");

It still hangs on the while(@arrangement) loop.

Any idea why this while loop doesn't want to quit?

Tor


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to