and loadFabricantProperties is called from another package LoadPage within a code like thispackage LoadProperties; use SharedVariable qw (%ARTICLE)
in this package I also make a use of the package SharedVariable$fabricant = $lp->loadFabricantProperties($ARTICLE{'marque'},'',$value +);
In this package I want to share the global variable to the other package $articleClass is a variable that define the usage of another package Article.pm where some functions are defined like the call to thispackage SharedVariable; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Time::HiRes qw(gettimeofday); use Compress::Zlib; use CGI::Session qw/-ip-match/; use vars qw (%ENV $session_dir $page $dir $dirLang $dirError $imgdir $ +action $t0 $session_id $can_do_gzip $current_ip $lang $LANG %ARTICLE +%SESSION %SERVER %USER $CGISESSID %LABEL %ERROR %VALUE $COMMANDID %CO +MMAND %DATE %PAYPALL $INDEX %LINK $query $session $host $t0 $client +); #Set the values to the global variables $query = CGI->new ; $current_ip = $ENV{'REMOTE_ADDR'}; $client = $ENV{'HTTP_USER_AGENT'}; $t0 = gettimeofday(); $host = "http://avant-garde.no-ip.biz"; %ERROR = ();%LABEL = ();$LANG = "";%LINK = ();%ARTICLE = ();%SESSION = + ();%SERVER = (); % $action = $query->param('action'); $page = $query->param("page"); $session_id = $query->param('session'); $can_do_gzip = ($ENV{'HTTP_ACCEPT_ENCODING'} =~ /gzip/i) ? 1 : 0; $dir = "/home/alexandre/apache/site/recordz1/"; $dirLang = "/home/alexandre/apache/site/recordz1/lang"; $dirError = "/home/alexandre/apache/site/recordz1/lang"; $imgdir= "/home/alexandre/apache/site/recordz1/upload"; $session_dir = "/home/alexandre/apache/site/recordz/sessions"; $action = $query->param('action'); $session_id = $query->param('session'); if ($session_id eq '' or $session_id eq '$SESSIONID') { $session = new CGI::Session("driver:File", undef, {Directory=>"$se +ssion_dir"}); $session_id = $session->id(); } #load html label loadLanguage (); #load error label loadError(); sub new { my $class = shift; my ($opts)= @_; my $self = {}; return bless $self, $class; } sub loadLanguage { $lang = $query->param("lang"); #$lang = substr ($ENV{'HTTP_ACCEPT_LANGUAGE'},0,2); #$lang =~ s/[^A-Za-z0-9 ]//; $lang = uc ($lang); open (FILE, "<$dirLang/$lang.conf") or die "cannot open file $dirL +ang/$lang.conf"; while (<FILE>) { (local our $label, local our $value) = split(/=/); $SERVER{$label} = $value; } close (FILE); } sub loadError { $lang = lc ($query->param('lang'));#=~ s/[^A-Za-z0-9 ]//; #$lang=~ s/[^A-Za-z0-9 ]//; open (FILE, "<$dirError/$lang.conf") or die "cannot open file $dir +Error/$lang.conf"; while (<FILE>) { (local our $label, local our $value) = split(/=/); $SERVER{$label} = $value; } close (FILE); } BEGIN { use Exporter (); @SharedVariable::ISA = qw(Exporter); @SharedVariable::EXPORT = qw(gettimeofday()); @SharedVariable::EXPORT_OK = qw ($session_dir $page $action $di +r $dirLang $dirError $imgdir $session_id $can_do_gzip $current_ip $la +ng $LANG %ARTICLE %SESSION %SERVER %USER $CGISESSID %LABEL %ERROR %VA +LUE $COMMANDID %COMMAND %DATE %PAYPALL $INDEX %LINK $query $session +$host $t0 $client); } 1;
Where $ARTICLE are also been shared within the use of SharedVariablesub getLastEnchereurDetail { local our $string;local our $article = $query->param("article"); local our $ref_max_enchereur; local our $max_enchere; ($ARTICLE{'max_enchere'})=$mydb->sqlSelect1("MAX(prix)", "enchere" +, "ref_article = '$article'"); if ($ARTICLE{'max_enchere'} ne '') { ($ARTICLE{'max_enchereur'},$ARTICLE{'id_enchere'})=$mydb-> +sqlSelect1("ref_enchereur,id_enchere", "enchere", "ref_article = '$ar +ticle' AND prix = $ARTICLE{'max_enchere'}"); ($ARTICLE{'nom_utilisateur_acheteur'},$ARTICLE{'email_acheteur +'},$ARTICLE{'acheteur_lang'},$ARTICLE{'acheteur_adresse'},$ARTICLE{'a +cheteur_ville'},$ARTICLE{'acheteur_npa'},$ARTICLE{'acheteur_telephone +'},$ARTICLE{'acheteur_nom'},$ARTICLE{'acheteur_prenom'})= sqlSelect(" +nom_utilisateur,email,lang,adresse,ville,npa,no_telephone,nom,prenom" +, "personne", "id_personne = '$ref_max_enchereur'"); } $string .= "<td align=\"left\" width=\"200\"><label id=\"label_cat +egory_name\">$SERVER{'last_enchereur'}</label></td>"; $string .= "<td align=\"left\"><a href=\"/cgi-bin/recordz.cgi?lang +=$lang&session=$session_id&page=profil_vendeur&username=$ARTICLE{ +'nom_utilisateur_acheteur'}\" class=\"menulink\" >$ARTICLE{'nom_utili +sateur_acheteur'}</a></label></td>"; return $string; }
In reply to Re^2: perl variable displayed as a hash value
by *alexandre*
in thread perl variable displayed as a hash value
by *alexandre*
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |