[Israel.pm] Fwd: FW: newbie question

bc.other bc.other at gmail.com
Thu Jan 15 07:48:37 PST 2009


Yea good idea, but all the warnings, errors that will float....hehehe


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
Of Avishalom Shalit
Sent: Thursday, January 15, 2009 5:33 PM
To: Perl in Israel
Subject: Re: [Israel.pm] Fwd: FW: newbie question

well you can "use strict" when you are writing your code, and erase
that just before you show it to others :-)


2009/1/15 Chanan Berler <chananb at centerity.com>:
> Hi All,
>
> Thanks for all the help on how to use / or not to use variables.
> I am only curious on how perl works so I do tend to ask weird questions
> (like these ones :-))
>
> In the past I always used to use strict and warnings, but since I am new
in
> my work, and ppl here never used it - it
> is somehow impossible for me to change too many things at once ;-)
> Anyhow, I tried re writing the plugin I am using, but it took me too long
to
> do it, so I stopped.....
>
> I will take your advises, as for how to write perl scripts....
> And sorry again on my weirdo questions....
>
> Thanks and have agreed shabat shalom
> Chanan
>
>
> -----Original Message-----
> From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
> Of Jason Elbaum
> Sent: Thursday, January 15, 2009 5:09 PM
> To: Perl in Israel
> Subject: [Israel.pm] Fwd: FW: newbie question
>
> On Thu, Jan 15, 2009 at 4:05 PM, bc.other <bc.other at gmail.com> wrote:
>
>>
>> By the way, my scripts are one exception when you must not use the strict
> /
>> warning modules.
>> Since it's coded for working with nagios engine, and needed some
variables
>> to be used in some stages where
>> The same variables couldn't be defined.
>
> I don't know what nagios is, but I don't understand how you can
> possibly need to use variables that can't be defined.
>
> But in any case you can still "use strict;" and then "no strict
> 'vars'" to turn off undefined variable checking.
>
>
>>
>> I know the if () statement compares the values to 0, same as in C, C++
>> But I wonder if defined does something with the arguments sent to it -
> like
>> check allocation to memory or so.
>
> Defined checks whether a variable has been assigned a value or not. By
> default all variables contain undef.
>
>
>>
>> Also I know @arr returned a ARRAY(address) - so why can I check it using
>> if() maybe because it returns the addres value.
>
> I don't know what you mean here. @arr does not return anything; it is
> the name of an array variable. if() checks if it is empty.
>
>
>>
>> So, does my @arr; return 0 ?
>
> Converting an array variable to a scalar value yields the length of the
> array.
>
>
>
>>
>> Also, can I compare @arr1 = @arr2 and check if they are allocated to same
>> place? Like addresses in C
>
> They can't be allocated to the same place, since they're different
> arrays. Each manages its own memory.
>
>
> Frankly, it sounds to me like you should refresh your memory about
> basic Perl concepts. Try the perldata man page for starters.
>
> Good luck,
>
> Jason Elbaum
>
>
>
>
>>
>> -----Original Message-----
>> From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
Behalf
>> Of Gaal Yahas
>> Sent: Thursday, January 15, 2009 3:41 PM
>> To: Perl in Israel
>> Subject: Re: [Israel.pm] FW: newbie question
>>
>> On Thu, Jan 15, 2009 at 3:22 PM, Chanan Berler <chananb at centerity.com>
>> wrote:
>> > Hi All,
>> >
>> > I am wondering if there is a difference between:
>> > The last one I believe I know the answer, empty string still defined,
> but
>> I
>> > sure wanna clear view..:-)
>> > PS: will use strict / warning will make a difference ?
>>
>> This question implicates you for not using strict. Use strict. :-)
>>
>> > do_somthing if ($legend);
>>
>> This is a good test if you don't know anything about $legend. It won't
>> cause a warning when $legend is undefined. You may omit the
>> parentheses here, BTW.
>>
>> > or
>> >
>> > do_something if (defined($legend));
>>
>> This will do_something when $legend is zero or the empty string.
>>
>> > or
>> >
>> > do_something if ($legend == "");
>>
>> Run this and read the warning. It should be valuable to you.
>>
>> If you really want string comparison, use eq, not ==.
>>
>> >
>> > another question:
>> > is there a difference between
>> >
>> > @arr = ();
>> >
>> > And
>> >
>> > @arr;
>>
>> "@arr" on a line of its own doesn't mean anything (except to give away
>> that you aren't using strict).
>>
>> @arr = () clears the array (sets it to length zero).
>>
>> my @arr and my @arr = () are equivalent.
>>
>> > Since both of them showed nothing when trying to do this:
>> > print "Yea" if (@arr);
>> >
>> >
>> > thanks
>> > Chanan
>> >
>> > _______________________________________________
>> > Perl mailing list
>> > Perl at perl.org.il
>> > http://perl.org.il/mailman/listinfo/perl
>> >
>>
>>
>>
>> --
>> Gaal Yahas <gaal at forum2.org>
>> http://gaal.livejournal.com/
>> _______________________________________________
>> Perl mailing list
>> Perl at perl.org.il
>> http://perl.org.il/mailman/listinfo/perl
>>
>> _______________________________________________
>> Perl mailing list
>> Perl at perl.org.il
>> http://perl.org.il/mailman/listinfo/perl
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>



-- 
-- vish
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl




More information about the Perl mailing list