[Israel.pm] Help: why does it warn me?
Chanan Berler
chananb at centerity.com
Wed Feb 4 07:35:43 PST 2009
Thanks for the help,
Using the array as return might work for me....more cleaner and next time I
will look at it, it will pop right off
Using hash although will work for me, it will be hard to understand
But thanks I will take ur advice
Chanan
-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
Of Gabor Szabo
Sent: Wednesday, February 04, 2009 5:32 PM
To: Perl in Israel
Subject: Re: [Israel.pm] Help: why does it warn me?
why not write:
sub update_event_log
{
my ($lv_reg) = @_;
my ( $lv_attemp_stmt, $lv_service_stmt, $lv_host_stmt,
$lv_hostgroup_stmt, $lv_servicegroup_stmt) =
_el_parse_reg_($lv_reg);
}
and let the _el_parse_reg_() return the values?
or even cleaner
sub update_event_log
{
my ($lv_reg) = @_;
my %lv = _el_parse_reg_($lv_reg);
}
and have
attemp, service, host, hostgroup and servicegroup be the keys of that
hash.
You should nearly never use anything else than "my".
Gabor
On Wed, Feb 4, 2009 at 4:58 PM, Chanan Berler <chananb at centerity.com> wrote:
> Hi All,
>
> I wrote this script:
>
>
> sub update_event_log
> {
> my ($lv_reg) = @_;
>
> local $lv_attemp_stmt;
> local $lv_service_stmt;
> local $lv_host_stmt;
> local $lv_hostgroup_stmt;
> local $lv_servicegroup_stmt;
>
> &_el_parse_reg_($lv_reg);
>
> }
>
> The idea that sub el_parse_reg will update these fields.
> I tired doing something like that as a test (but without warnings) and it
> worked.
> But when I tried to imply use warnings and use strict I get this kind of
> warning / error message:
>
> Global symbol "$lv_host_stmt" requires explicit package name at
event_log.pl
> line 162.
>
> Why is that?
> Thanks
> Chanan
>
> PS: correct me if I am wrong
> But as what I understood:
>
> my - applies to sub private variables
> local - protected scalars that can be updated by other sub called by the
sub
> which created the local variables
> our - more like a global like variables - which can be accessed from all
the
> module / script found on that file
>
>
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl
More information about the Perl
mailing list