Click here to get back home

Re: called too early to check prototype at

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: called too early to check prototype at Jürgen Exner 03-18-2008
Posted by Jürgen Exner on March 18, 2008, 9:01 pm
Please log in for more thread options
>Hi,
>
>I get a "called too early to check prototype at" in my script and i have no
>idea what this is referring to.It is pointing to this line:
>for(my $count = 0; $count < scalar(@dbset); $count++)

This can be rewritten in a much easier to read way as
        for my $count (0..@dbset-1)

>for(my $count = 0; $count < scalar(@dbset); $count++){
> my $myDBI = 'DBI:mysql:' . $dbset[$count] . ':localhost';
> my $dbh = DBI->connect($myDBI,'root','novax')
> or die "Couldn't connect to database: " . DBI->errstr . "\n";

However, as you don't do anything with $count but to index the array in a
linear fashion it is even easier to use a simple

for(@dbset){
my $myDBI = "DBI:mysql:$_ :localhost";
        ....

jue

Posted by Dr.Ruud on March 19, 2008, 10:43 pm
Please log in for more thread options
Jürgen Exner schreef:

> for my $count (0..@dbset-1)


Alternatives:

for my $count ( 0 .. $#dbset )

for my $count ( $[ .. $#dbset )

--
Affijn, Ruud

"Gewoon is een tijger."


Posted by Abigail on March 20, 2008, 6:29 am
Please log in for more thread options
_
Jürgen Exner (jurgenex@hotmail.com) wrote on VCCCXIV September MCMXCIII
,, >Hi,
,, >
,, >I get a "called too early to check prototype at" in my script and i have no
,, >idea what this is referring to.It is pointing to this line:
,, >for(my $count = 0; $count < scalar(@dbset); $count++)
,,
,, This can be rewritten in a much easier to read way as
,,         for my $count (0..@dbset-1)


What's easier is a matter of personal preference.

99 times out of 100, I prefer:

for (my $i = 0; $i < @array; $i ++) { .. }

over

for my $i (0 .. @array - 1) { .. }


The '- 1' ruffles my feathers. And I don't like $#array very much either.



Abigail
--
use lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";

Similar ThreadsPosted
APL2007 reminder: early (cheaper) registration ends Thursday 9/13 September 8, 2007, 10:53 pm
looking to prototype a grammar need suggestions. June 20, 2007, 10:44 am
Prototype mismatch under ModPerl::PerlRun September 6, 2005, 5:59 pm
Using Perl to check-out check-in in Clearcase December 22, 2006, 2:20 pm
DESTROY isn't called June 23, 2006, 12:33 pm
Indirectly called code August 24, 2006, 3:02 am
SIGCHLD not called under Windows October 27, 2006, 8:13 pm
Is it ok to change $ENV before "use CGI;" is called..? March 4, 2007, 9:31 am
"Undefined subroutine &main:: called." from nowhere?? August 11, 2004, 2:45 pm
How to locate my script file itself when it is called by others. August 1, 2005, 8:02 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap