logo
IRC Archive / Freenode / #perl / 2010 / January / 09 / 1
wongon
To get the last index of an array @a, it's $#a. If I've got a scalar, $ar, that is a reference to an array @a, how do I get the last index through $ar? What is the syntax?
icke
rule 2
GumbyPAN
(Action) CPAN Upload: UMLS-Interface-0.31 by BTMCINNES
(Action) CPAN Upload: App-ClusterSSH-4.00_01 by DUNCS
icke
$#$ar
wongon
thanks
icke
$ar->[-1] if you just want the last element
learn the ref ropes
Khisanth
ScHAmPi: for firefox you would need to install the activex plugin at the very least
ScHAmPi
Khisanth I see
well I'm not gonna bother, it makes no sense, and I can only study this perl stuff tonight
tomorrow I gotta start studying my theoretic part
it's gonna be a hell of a three days
Sp0oKeR
Khisanth, icke Net::DNS will work for me ... thanks a lot...just need to study that module =)
GumbyPAN
(Action) CPAN Upload: Log-Syslog-DangaSocket-1.04 by ATHOMASON
(Action) CPAN Upload: Form-Sensible-0.10000 by JAYK
spectre^
I'm invoking a perl script from another perl script via system(), and, in the invoked script I'm using exit 1; to return a 1 to the invoking script, but I keep getting a 255 in $? >> 8, when I expect a 1
I think I'm doing something wrong
What can I do to get the exit status to return a 1?
PerlJam
spectre^: perldoc -f system # it tells you in the docs
oh. /me should have read up a few lines.
spectre^: show your code somewhere.
spectre^
I think that exit must return 255 to the shell on error, as indicated by 1
I guess?
icke
looks like it was killed
spectre^
http://pastebin.com/m1e803053
buubot
spectre^: The 19 line paste m1e803053 has been copied to http://erxz.com/pb/22638 .
spectre^
Nice bot
I think that's enough to show you what I'm doing
printf("NOTICE gsum returned: %d\n", $?>>8); always shows the value as 255
icke
does it even execute? check $? for -1 before
spectre^
While I can certainly work with that if it's behaving as intended
GumbyPAN
(Action) CPAN Upload: Log-Syslog-Fast-0.26 by ATHOMASON
(Action) CPAN Upload: Text-vCard-2.05 by LLAP
spectre^
Yeah
I get the error
icke
what error?
spectre^
The printed error from the calleee
I didnt bother checking for -1 because I saw the error
Make sense?
DrForr
spectre^: $? may have been set before your operation ran.
icke
hmm? it isn't $!
PerlJam
spectre^: you need to check for -1 to see if it failed to execute, and check $? & 127 to see if it died, and if neither of those things are true, then you can use $?>>8 to find the exit value.
spectre^
As I was saying ... I can work with the return being 255 if that's what's supposed to be happening, but I dont understand why and I dont want to proceed until I do
print ("Invalid begin date specified: " . $options{'b'});
icke
it's supposed to always contain the exit value (as described)
spectre^
I see that printed
er
go|dfish
eval [ 1 - 1.2, 15 - 15.2 ]
spectre^
$? reports the exit status from the last system() command
buubot
go|dfish: ["-0.2","-0.199999999999999"]
spectre^
PerlJam: I'll check
go|dfish
why does that return 2 different results ^^ ?
PerlJam
go|dfish: floating point representation error.
DrForr
go|dfish: Because 1/5 can't be exactly represented in binary. In the first case you just get lucky.
PerlJam
go|dfish: either use fixed point (if you can) or always be sure to specify the precision of your floating point numbers on output
go|dfish: (unless you want more precision than the floating point error, you'll be fine)
spectre^
http://pastebin.com/m27595d
buubot
spectre^: The 25 line paste m27595d has been copied to http://erxz.com/pb/22640 .
spectre^
Still getting a 255
go|dfish
PerlJam: ah
spectre^
With those checks in
go|dfish
DrForr, PerlJam, thanks!
spectre^
And neither of the if statements were true
PerlJam
spectre^: you always see "NOTICE gcum returned 255" just before it dies?
er, s/gcum/gsum/ even
(*NOT* a freudian slip :)
spectre^
Yes, sir
I do
WAIT
LeoNerd
A freudian slip is when you say one thing but mean your mother
spectre^
Let me make sure tehre's not an END defined
In the callee
That changes my exit status
Nope
That's not it
PerlJam
spectre^: have you tried changing "exit(1)" to "exit(42)" or something?
spectre^
I'll try it
icke
spectre^: take the literal code from perldoc -f system to interpret $?. works for me
spectre^
I see what's wrong
PerlJam
It's that exit(255) that you forgot about?
:)
spectre^
Someone else is working on the callee and installed their version of it to /usr/local
Fucker
His version uses die()
No
:)
die() returns 255
And his version uses die()
When I changed it to exit(69) and there was no effect I knew something was wrong :P
Awesome thanks for the help
Now I need help beating that guy down
GumbyPAN
(Action) CPAN Upload: Devel-PartialDump-0.13 by FLORA
(Action) CPAN Upload: Parse-Method-Signatures-1.003013 by FLORA
(Action) CPAN Upload: BerkeleyDB-0.41 by PMQS
Mantususus
hiiiiiiiii
pwrcycle
mst: i remember now, using "ssh -l user example.com" hides the user@ from "ps aux". that was the advantage.
Khisanth
doesn't look terribly useful at least on linux ...
cmihai
cmihai 434268 504020 0 01:56:30 pts/4 0:00 ssh -l cmihai localhost
chee
:)
shadowpaste0
"paull" at 119.10.140.36 pasted "Help! Why this snippet is not working, @_ is a count of traffic in octets passed in. It's bi**hing about $custtraffic not being defined and returns 0" (20 lines) at http://scsys.co.uk:8002/37956
paull
Thanks in advance for any help with my above paste
DrForr
paull: Maybe you're not aware that @_ is a list, not a variable.
paull
I'm only squirting in one value... Would I use $_ instead then?
Khisanth
Number::Bytes::Human
@_ < 1000000000 compares the number of args passed in
if you passed in only one value then @_ == 1
DrForr
sub FormatTraffic { my $count = shift; ... }
paull
Ahhh OK
I'll give that a go.. Thanks so much!
DrForr: happy to help further? Still returns 0!
DrForr
Well, kind of hard to tell what's going on without seeing sample input.
And the rewritten version.
paull
OK
I'll plug away at it
Cheers!
awnstudio
anyone figure out a way to filter rss feed by language?
^^github
f00li5h[HireMe]
well, how do you know which language the posts are in, awnstudio
awnstudio
uh?
Khisanth
ask google to guess :)
awnstudio
me and google arent speaking atm
f00li5h[HireMe]
awnstudio: I mean, are there attributes for the languages
awnstudio
in the regular search yes, try using those params with the feed link, no dice :(
f00li5h[HireMe]
paw at it!
GumbyPAN
(Action) CPAN Upload: Test-BinaryData-0.009 by RJBS
(Action) CPAN Upload: JavaScript-V8x-TestMoreish-0.010 by RKRIMEN
awnstudio
Perl, Python and Ruby comparison apps with similar functionality. Why? Because I can - http://github.com/zoozed/comparisons
kawinija
guys, what is the differences between %yo = (yo => 'yo') and %yo = ('yo' => 'yo)
what are
f00li5h[HireMe]
=> quotes the thing to the left of it... and is a comma.
it is different when the thing to the left is not a "bareword"
pkrumins
tehe
this kit knows the difference
f00li5h[HireMe]
(Action) paws at pkrumins
awnstudio
this is just a fu*king disgrace, http://www.cpantesters.org/distro/W/WWW-Mechanize-Pluggable.html#WWW-Mechanize-Pluggable-1.05
shorten
awnstudio's url is at http://xrl.us/bgscci
kawinija
guys, what are the differences between %yo = (yo => 'yo') and %yo = ('yo' => 'yo)
guys, what are the differences between %yo = (yo => 'yo') and %yo = ('yo' => 'yo')
sorry
icke
already answered
no difference
ew73
Two ' characters.
kawinija
ok
thanks
SpiceMan
kawinija: perldoc -q "semicolons and commas"
dumbtroll
cause i took no exam but i still want to
but i don't know to where i can find it
help please
>
?
you know?
Khisanth
go troll somewhere else
dumbtroll
yeah he said that the other one i was there
but i still felt to so i came here
yo
i saw another one was like more dynamic
but no stupid syntax
you know?
GumbyPAN
(Action) CPAN Upload: Log-Syslog-Fast-0.27 by ATHOMASON
atomiku
surprisingly enough, its dead in here
pkrumins
no it's not. yes it is. no it's not. yes it is.
go|dfish
Perl is dead after all.
f00li5h[HireMe]
paw paw paw
pkrumins
f00li5h[HireMe], kit kit
what are you doing?
f00li5h[HireMe]
going to roleplaing
and getting clawed at va SMS
pkrumins
SMS is so web 1.0
GumbyPAN
(Action) CPAN Upload: Log-Syslog-DangaSocket-1.05 by ATHOMASON
Khisanth
hmm
gather-take would be convenient right now ...
mst
Khisanth: Language::Keyword::Gather
Khisanth
I think you mean Syntax::Keyword::Gather
mst
yes
bennymack
anyone have experience embedding functions into SQLite? I have a list of zip codes in a csv file and I'd like to be able to get a list of other zipcodes in a N mile radius with one round-trip..
Khisanth
this is probably a very silly use of it :)
bennymack
I'm having a look at SQLite::VirtualTable now. Looks promising
there's something like over 500 results for SQLite on CPAN thouhg
Khisanth
my $my_nick = '...'; my $me; @users = gather { for(@users) { if($_->{nick} eq $my_nick) { $me = $_ } else { take $_ } }
bennymack: do you need a virtual table or do you need a function? because DBD::SQLite has a sqlite_create_function method
bennymack
Khisanth: well, I thought the sqlite_create_function stuff happened on the DBI side of things?
waltman
bennymack: I've given a talk at a few yapcs on writing sqlite functions :)
bennymack
i've been to those talks ;)
waltman
yay!
my impression is that there's not really a "round trip", since you're making library calls
I think you can only return a scalar from a function, so I'm not sure how you could return a list. Maybe as a comma-separated string?
bennymack
well, I need to fetch the zip in question, calculate a x and y min and max and select zips that fall within that range.
I have code to do all that. but i'd prefer to just be able to send the zip and distance and get back a list of zip codes.
icke
that's an n-mile square, not radius
bennymack
icke: yes, thanks ;0
waltman
I don't see any way to have an sqlite function return more than one column, let alone multiple rows
I think the best you could do is return a string like "90210,90211,31459" and then have the caller split it
Thuryn
what?
waltman, are you new/
return() *always* returns a list
return('foo', 'bar', 'baz');
returning a single value is just a special case
awnstudio
un huh