Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^5: var comparison

by LanX (Chancellor)
on Sep 08, 2012 at 18:42 UTC ( #992519=note: print w/replies, xml ) Need Help??


in reply to Re^4: var comparison
in thread var comparison

hmm, nobody gave you a code example ?

DB<100> @option{qw/a b c/}=() => (undef, undef, undef) DB<101> exists $option{a} => 1 #true DB<102> exists $option{d} => "" #false

but smart-match should be safe as long as you don't forget the quotes.

Cheers Rolf

Replies are listed 'Best First'.
Re^6: var comparison
by nemesisgus (Acolyte) on Sep 09, 2012 at 02:03 UTC

    Nice hash slice, thanks!

    Just let me polish up your code so other newbies don't get confused:

    my %option; @option{qw/a b c/}=(); # my %option = ( # 'a' => undef, # 'b' => undef, # 'c' => undef # ); exists $option{a} and print 'true'; exists $option{d} or print 'false';

    PS: what the h**l is DB <...> ?

      DB <...> : the code was run under the debugger. Example of a debugger session:
      $ perl -de 42 Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 42 DB<1> %hash = qw( a 1 b 2 c 3 d 4 ); DB<2> print %hash c3a1b2d4 DB<3> print scalar %hash 4/8 DB<4> $hash{e} = undef DB<5> print scalar %hash 5/8 DB<6> print "true" if defined $hash{e} DB<7> print "true" if exists $hash{e} true DB<8>

        So much to learn... Thank you again!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992519]
help
Chatterbox?
[perldigious]: A question since I'm ignorant of what's normal for database management... Do admins change column names a lot in databases?
[perldigious]: On occasion my scripts break, because they will do something that seems laregly pointless to me... like in this case, changing a column name from "ABC Category" to "ABC Category Override".
[perldigious]: Being the ignorant one, my initial reaction to that is, "that's sort of a dick move, a lot of people like me expect column names like that to stay the same, why the hell would you change them like that for seemingly no good reason?"
[perldigious]: Or is my irritation/ frustration well founded?
[Corion]: perldigious: That seems to be more the export and likely it's the recipients of that export that like the titles changes
[Corion]: ... "changed"
[Corion]: I usually expect fixed header names, but am sometimes lenient in the order of columns. But changing the report titles often sounds to me as if you are not the sole consument of the export ;)
[shmem]: perldigious: as always - if it ain't broke, don't fix it. Ther must be a very compelling reason for changing column names in a database. Those are rare.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-05-25 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?