Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I don't understand ... Why you are restricting this behavior to my...?

Every non-initialized variable is not defined.

DB<1> print $a // "undef" undef DB<2> my $a;print $a // "undef" undef DB<3> our $a;print $a // "undef" undef DB<4> $a=1;print $a // "undef" 1
UPDATE:

And in most cases accessing an undefined variable will be caught under use warning;.

DB<1> print $a DB<2> use warnings; print $a Use of uninitialized value $a in print at (eval 6)[/usr/share/perl/5.1 +0/perl5db.pl:638] line 2. .. DB<3> use warnings; $a=undef;print $a Use of uninitialized value $a in print at (eval 9)[/usr/share/perl/5.1 +0/perl5db.pl:638] line 2. .. DB<4> print $a++ 0

Notable exceptions of this warnings are some altering operators like ".=" and "++" and auto-vivication in hashes and arrays.¹

Cheers Rolf

1) anything else?

... of course boolean context including the defined operator won't throw a warning.


In reply to Re^2: Perl Style: Is initializing variables considered taboo? by LanX
in thread Perl Style: Is initializing variables considered taboo? by ait

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-19 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found