#perl - Fri 20 Apr 2007 between 18:59 and 19:04



zOrKsorry.
pontixRPDrake: that gives you warnings if you access elements you haven't explicitly defined
Ani-_zOrK: doesn't matter. The solution remains the same
pontixan undef value defaults to zero right?
Ani-_pontix: not quite
pontixbut you still get a warning if you use warnings
Ani-_pontix: an undef value is false. 0 is false. But 0 != undef.
RPDrakepontix: how would you access non-existent elements?
Ani-_s/!=/is not the same as/;
pontixwell if you had a sparse array
and values that haven't been set should be 0
Ani-_pontix: basically: if you use an undefined value in a numeric context it will be treated as if it were 0.
RPDrakeeval: my @array; @array[5];
buubotRPDrake:
Ani-_pontix: if you use it in a string context it will be treated as the empty string
pontixAni-_: but you get a waring right?
Chris62vwRPDrake, of course you mean $array[5]
Ani-_RPDrake: $array[5]. @array[5] is an array slice of one element. Which is pointless.
pontix: if you enable warnings yes
RPDrakeeval: my @array; $array[5];
buubotRPDrake:
RPDrakeyeah
apr5eval: $_ = "One Two Three"; m/^([^ ]+) +([^ ]+)/; print $2." ".$1;
buubotapr5: Two One 1
apr5eval: $_ = "One Two Three"; m/^([^ ]+) +([^ ]+)/; $2." ".$1;
buubotapr5: Two One
pontixAni-_: if enable warnings, i need to do an explicit check then...
Ani-_apr5: make sure to always check the return value of your regex before using $1, $2, ... in real code.
apr5mmmm any ideas why's thats not doing Three One Two?
RPDrakebtw whats so great about python?
pontixunless i don't mind a warning
RPDrake: dicts for one
hobbsapr5: because you told it not to
Ani-_pontix: Or you can set the initial value of the variable to 0? or ""? or...?
apr5Ani-_: kk
buuapr5: Because you only return $1 and $2?
apr5hobbs: ? but doesnt the first bracket match any words?
hobbsapr5: no
Ani-_apr5: perldoc perlretut # look for greed or maximal
hobbsapr5: it matches a leading sequence of non-spaces

Page: 1 8 15 22 29 36 43 50 57 64 71 78 85 

IrcArchive