Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: STRICT question

by TheHobbit (Pilgrim)
on Oct 23, 2003 at 11:27 UTC ( #301540=note: print w/replies, xml ) Need Help??


in reply to STRICT question

Hi,
I'd like to know why you asked that. Did you run against a problem for "too many variables"? If so it could depends on your system imposing a limit on either the length of a line (see the update in liz answer) or some limit in the size of the parameter list for subs in the implementation of perl.

Remember that

use vars qw($foo @bar %foobar);

is (almost) equivalent to

require vars; vars->import('$foo','@bar','%foobar');

While this implies that a limit on the size of the parameter list (or the memory space occupied bu such a list) would impact on the 'number of variables that could be used in a use vars statement', this also implies that, should the problem arise, you could split your use vars like:

use vars '$foo'; use vars '@bar'; use vars '%foobar';

as require does not reload an already loaded module, but import is still called each time.

Hoping this helps.


Leo TheHobbit

Replies are listed 'Best First'.
Re: Re: STRICT question
by webstudioro (Acolyte) on Oct 23, 2003 at 11:44 UTC
    I have in my script variables with my $variableA and the use vars qw(............)
    , and when i put my variables in use vars qw(....) on 7 variables add , my script don't want to execute.
    Don't out none warnings. :(
    Update:
    This is my script:
    #!perl -w use CGI::Carp('fatalsToBrowser'); use CGI qw/:standard/; use strict; use DBI; use vars qw($query $dbase $userdb $passworddb $cgi_url $idProdus); $query = CGI->new(); $cgi_url = "http://localhost/cgi-bin/script.pl"; $dbase= "test"; $userdb = "admin"; $password = "123456"; my $count=0; my $driver = "dbi:mysql:" . $dbase; my $dbh = DBI->connect($driver, $userdb, $passworddb) or die "Error $D +BI::errstr\n"; my $statement = $dbh->prepare("SELECT id_produs, denumire FROM produse +") or die "Error $DBI::errstr\n"; $statement->execute or die "Error $DBI::errstr\n"; print $query->header(-type=>'text/html'); print <<ENDHTML; Pentru a vedea ce aveti in cos dati click <a href="$cgi_url/shop.pl?pr +oduct=viewCart">aici!</a> <br>Pentru check out dati click <a href="$cgi_url/shop.pl?product=chec +kOut">aici!</a><br><form action="$cgi_url/shop.pl" method="get"> <input type="hidden" name="product" value="viewProduct"><select name=" +id"><option value="none">Select product</option> ENDHTML while (($idProdus, $denumireProdus) = $statement->fetchrow_array) { print <<ENDHTML; <option value="$idProdus">$denumireProdus</option> ENDHTML my $count++; } print <<ENDHTML; </select><input type="submit" value="View Product"></form> ENDHTML $statement->finish; $dbh->disconnect; $dbh = DBI->connect($driver, $userdb, $passworddb) or die "Error $DBI: +:errstr\n"; $statement = $dbh->prepare("SELECT denumire, pret, url_demo, descriere +, url_download, foto FROM produse WHERE id_produs = $count") or die +"Error $DBI::errstr\n"; $statement->execute or die "Error $DBI::errstr\n"; ($denumire, $pret, $url_demo, $descriere, $url_download, $foto) = $sta +tement->fetchrow_array(); print <<ENDHTML; <br><br><table border=0> <form action="$cgi_url/shop.pl" method="get"> <input type=hidden name="product" value="add"> <input type=hidden name="canditate" value="1"> <input type=hidden name="idp" value="$count"> <input type=hidden name="title" value="$denumireProd"> <input type=hidden name="descriere" value="$descriere"> <input type=hidden name="price" value="$pret"> <input type=hidden name="fotoProdus" value="$foto"> <tr><td rowspan=3> <img src="$foto"> </td><td> <b>$denumireProd</b></td></tr> <tr><td> $descriere</td></tr> <tr><td align=right> <a href="$url_demo">Try demo!</a> Pret: $pret <input type=submit val +ue="Buy now!"> </td></tr></form></table><hr> ENDHTML $statement->finish; $dbh->disconnect; $newCount = $count - 1; $dbh = DBI->connect($driver, $userdb, $passworddb) or die "Error $DBI: +:errstr\n"; $statement = $dbh->prepare("SELECT denumire, pret, url_demo, descriere +, url_download, foto FROM produse WHERE id_produs = $newCount") or d +ie "Error $DBI::errstr\n"; $statement->execute or die "Error $DBI::errstr\n"; ($denumire, $pret, $url_demo, $descriere, $url_download, $foto) = $sta +tement->fetchrow_array(); print <<ENDHTML; <br><br><table border=0> <form action="$cgi_url/shop.pl" method="get"> <input type=hidden name="product" value="add"> <input type=hidden name="canditate" value="1"> <input type=hidden name="idp" value="$newCount"> <input type=hidden name="title" value="$denumire"> <input type=hidden name="descriere" value="$descriere"> <input type=hidden name="price" value="$pret"> <input type=hidden name="fotoProdus" value="$foto"> <tr><td rowspan=3> <img src="$foto"> </td><td> <b>$denumire</b></td></tr> <tr><td> $descriere</td></tr> <tr><td align=right> <a href="$url_demo">Try demo!</a> Pret: $pret <input type=submit val +ue="Buy now!"> </td></tr></form></table> ENDHTML print <<ENDHTML; <br><br>Total produse gasite: $count<br> ENDHTML exit; $statement->finish; $dbh->disconnect; print <<ENDHTML; Nu exista in baza de date <b>$dbase</b> nici un produs. ENDHTML exit;


    This is all my script.
      This line $password = "123456"; should be my $password = "123456"; or perhaps you meant to use $passworddb there. Since you don't tell us anything about the error you are getting, this is just a guess.
        I dont have some error message. The script don't work. Don't execute. My browser is blank(none).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://301540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2018-08-18 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (185 votes). Check out past polls.

    Notices?