#perl - Thu 15 Mar 2007 between 11:28 and 11:35



perlbotunicode doesn't have any karma
froggytroatmy $logfile = $opt{l} or $arg_list->{l}[2];
This gives me a warning, Useless use of array element in void context
any suggestions?
if I use || instead of or, it works fine.
LeoNerdYes.
( my $logfile = $opt{l} ) or ( $arglist->{l}[2] )
^-- that's how it parses.
or is very low precidence; lower even than =
tybalt89eval: $_ = "HONG KONG"; s/\w+/\u\L$&/g; $_
buubottybalt89: Hong Kong
poppyerhi, does perl have some kind of array filter function. like @a=filter(@b, "x>=3") say
LeoNerdmy $value = thing() or die "...";
my $value = thing() || "default";
is generally how you'd use them
froggytroatLeoNerd: Thanks, so it's actually evaulatign $arglis->{l}[2] and doing nothing with it, right?
tybalt89poppyer: grep()
froggytroatand that's why it's complaining
LeoNerdfroggytroat: Basically, yup
froggytroatthanks
poppyertybalt89, the array @a is basically numbers, and i want to apply a bool function f(x) as the conditions
LeoNerdeval: @numbers_above_ten = grep ( sub { $_ > 10 }, ( 1, 10, 13, 5, 7, 14 ); \@numbers_above_ten
buubotLeoNerd: Error: syntax error at eval line 1, at EOF
LeoNerdeval: @numbers_above_ten = grep ( sub { $_ > 10 }, ( 1, 10, 13, 5, 7, 14 ) ); \@numbers_above_ten
buubotLeoNerd: [1,10,13,5,7,14]
LeoNerdErr....
eval: @numbers_above_ten = grep { $_ > 10 } ( 1, 10, 13, 5, 7, 14 ); \@numbers_above_ten
buubotLeoNerd: [13,14]
LeoNerdMuch better
poppyerthx, i will try :)
annothe sub is always true
LeoNerdYeah..
annosub { $_ > 10}->()
tybalt89perl -le '@a=qw(1 3 5 4 2 7 6 4 5 2); @b = grep $_ < 5, @a; print "@b"'
LeoNerdYes, this is grep with its weird magic first argument
That somehow knows to defer execution
Bogaurdif i want to run a reverse dns on something, and if it returns a value set $revdns to that string, can i do it in an if() something like this?
if (gethostbyaddr(inet_aton($src),AF_INET)) { $revdns = $_; }
actionLeoNerd incidentally, would recommend getnameinfo() in Socket6 instead
LeoNerdincidentally, would recommend getnameinfo() in Socket6 instead
Bogaurdi dont quite have the hang of the way things are done in perl

Page: 3 10 17 24 31 38 45 52 59 66 73 80 87 94 

IrcArchive