Howdy Monks,
I am having difficultly with user defined functions in that they return data but not when using strict pragma. How do you use strict correctly when defining your own functions and returning data. I have provided the code and it works if I comment out the use strict pragma. I read the definitions about strict pragma but I am just not getting it in terms of user defined function returning results.
Here is my code and many thanks for the help
#!/usr/local/bin/perl -w
use Net::MySQL;
use strict;
sub get_all_records{
my $mysql = Net::MySQL->new(
hostname => 'tspform02.sbms.sbc.com', # Default use UNIX soc
+ket
database => 'RTSERVER',
user => 'nco',
password => 'xxxxxxxx'
);
$mysql->query(q{SELECT * FROM RTSERVER.SITESCOPE});
my $a_record_iterator = $mysql->create_record_iterator();
my @db;
while (my $record = $a_record_iterator->each) {
push(@db, "$record->[0]:$record->[1]:$record->[2]:$record->[3]
+:$record->[4]:$record->[5]:$record->[6]:$record->[7]");
}
$mysql->close;
return @db;
}
get_all_records();
my $count = 1;
foreach my $item (my @db){ # THIS IS PROBLEM,DIFFERENT array
print "Record #$count: $item\n";
$count++;
}