Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: no uninitialized warnings

by busunsl (Vicar)
on Aug 25, 2004 at 12:54 UTC ( #385668=note: print w/replies, xml ) Need Help??


in reply to Re: no uninitialized warnings
in thread no uninitialized warnings

Danger, Will Robinson. Danger!

If $var1 has the value 0, it will be set to '', which might not be what you want.

Replies are listed 'Best First'.
Re^3: no uninitialized warnings
by bronto (Priest) on Aug 25, 2004 at 16:14 UTC

    Mh... something like this?

    @x=(1..3) ; undef $x[1] ; $_ = defined $_? $_: '[__UNDEF__]' for @x ; print "@x" ;

    Ciao!
    --bronto


    The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
    --John M. Dlugosz

      or like this:

      $_ = '[undef]' for grep !defined, $var1, $var2, $var3; print "$var1, $var2, $var3";

      Update: I forgot that changing the values can affect program logic(as Aristotle mentioned). So, the best approach (imho) is just print with warnings or

      use Data::Dumper; print Data::Dumper->Dump([$var1, $var2, $var3], [qw(var1 var2 var3)]);

        Or non-destructively and unambiguously:

        print join " ", map { defined() ? "'\Q$_\E'" : 'undef' } $var1, $var2, + $var3;

        Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://385668]
help
Chatterbox?
[james28909]: seems like a person cant even have a belief without hurting someones feelings. i never said my way is the only way. i just said i have pretty good scientific evidence, and then asked for opposing side to present evidence
[james28909]: was downvoted and left without a reply. go figure
[holli]: but then you DO give a fuck
[1nickt]: I don;t think beliefs should be down-voted, just behaviours.
[james28909]: im not quite how to explain it any better nick. you evolved from ignorance to intelligence. not the other way. the universe evolves from gas coulds and debris into planets stars and galaxies ect. it doesnt happen any other way. hence it has ....
[james28909]: some kind of logic behind it
[james28909]: and that is also anothe rpoint i made, i think it has to do with perception of the world around you. most people think of evolution on a human scale. why could life evolve on this planet? because this planet evolved in this solar system. and so on.
[holli]: here's something for you to watch, James. I think you will like it
[erix]: for the record: I have not downvoted anyone on that subthread that was my fault
[james28909]: there are all kinds of things that had to happen to let life come to be. but at the same time, life may not be the end goal IF there is any kind of end goal lol

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2017-12-15 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (433 votes). Check out past polls.

    Notices?