Re: what's the error?

2011-11-05 Thread David Christensen
On 11/05/2011 10:49 AM, Uri Guttman wrote: ... you can build a fire and keep a man warm for a night or put him on fire and keep him warm for a lifetime! :) Twisted. You must have played D&D. }:-> David -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mai

Re: what's the error?

2011-11-05 Thread John W. Krahn
Brian Fraser wrote: On Sat, Nov 5, 2011 at 7:25 PM, John W. Krahn wrote: Brian Fraser wrote: On Sat, Nov 5, 2011 at 3:54 PM, Shawn H Corey wrote: On 11-11-05 02:40 PM, Brian Fraser wrote: See `perldoc readline`. $! will be undefined if no error occurs. No. $! will be undefin

Re: what's the error?

2011-11-05 Thread Dr.Ruud
On 2011-11-05 16:15, Ken Peng wrote: > I was just uncomfortable for that unwanted $!. There is no 'unwanted $!'. Read perlvar, it explains where $! is meaningful and meaningless. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...

Re: what's the error?

2011-11-05 Thread Brian Fraser
On Sat, Nov 5, 2011 at 7:25 PM, John W. Krahn wrote: > Brian Fraser wrote: > >> On Sat, Nov 5, 2011 at 3:54 PM, Shawn H Corey >> wrote: >> >> On 11-11-05 02:40 PM, Brian Fraser wrote: >>> >>> See `perldoc readline`. $! will be undefined if no error occurs. No. >>> >>> $! will

Re: Perl threads

2011-11-05 Thread Anneli Cuss
Hi Sharan, Have you considered using asynchronous events instead? You might find it's easier to work out. (See EV, Coro, AnyEvent, etc. in the CPAN) Otherwise, just.. read the manual on threads? - Anneli 2011/11/6 Sharan Basappa > Hello, > > We are in the process of writing a perl program tha

Re: what's the error?

2011-11-05 Thread John W. Krahn
Brian Fraser wrote: On Sat, Nov 5, 2011 at 3:54 PM, Shawn H Corey wrote: On 11-11-05 02:40 PM, Brian Fraser wrote: See `perldoc readline`. $! will be undefined if no error occurs. No. $! will be undefined, not `undef` That's silly. Perl has no spec -- You can't have undefined behavi

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 03:10 PM, Brian Fraser wrote: On Sat, Nov 5, 2011 at 3:54 PM, Shawn H Corey mailto:shawnhco...@gmail.com>> wrote: On 11-11-05 02:40 PM, Brian Fraser wrote: See `perldoc readline`. $! will be undefined if no error occurs. No. $! will be undefined, not

Re: what's the error?

2011-11-05 Thread Brian Fraser
On Sat, Nov 5, 2011 at 3:54 PM, Shawn H Corey wrote: > On 11-11-05 02:40 PM, Brian Fraser wrote: > >>See `perldoc readline`. $! will be undefined if no error occurs. >> >> >> No. >> > > $! will be undefined, not `undef` > > That's silly. Perl has no spec -- You can't have undefined behavior.

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 02:40 PM, Brian Fraser wrote: See `perldoc readline`. $! will be undefined if no error occurs. No. $! will be undefined, not `undef` -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization

Re: what's the error?

2011-11-05 Thread Brian Fraser
On Sat, Nov 5, 2011 at 3:04 PM, Shawn H Corey wrote: > On 11-11-05 01:49 PM, Uri Guttman wrote: > >> readline isn't a system call so it can't set $!. >> >> $! maps to the errno of system calls and has both the text and numeric >> values of the actual error (only if one happens) of the last system

Re: Console Modules for Windows (DOS mode)

2011-11-05 Thread Shlomi Fish
Hi Steven, On Sat, 05 Nov 2011 11:58:37 -0500 Steven Perry wrote: > Does anybody know of any modules to create console applications for windows? > I don't want a GUI like tk does. I want it to be text based and run in a DOS > window. > > I saw the below example but couldn't get the curses modul

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 01:49 PM, Uri Guttman wrote: readline isn't a system call so it can't set $!. $! maps to the errno of system calls and has both the text and numeric values of the actual error (only if one happens) of the last system call. perl itself can trigger errors in system calls easily but the

Re: what's the error?

2011-11-05 Thread Uri Guttman
On 11/05/2011 01:38 PM, David Christensen wrote: On 11/05/2011 02:00 AM, Uri Guttman wrote: > there was no actual error anywhere in his code. Good. :-) that was a very long post that missed the actual issue. ... he just printed $! which happens to have some value in it (and all $! values are

Re: what's the error?

2011-11-05 Thread David Christensen
On 11/05/2011 02:00 AM, Uri Guttman wrote: > there was no actual error anywhere in his code. Good. :-) that was a very long post that missed the actual issue. ... he just printed $! which happens to have some value in it (and all $! values are some error text/number!). Agreed. I was tryi

Console Modules for Windows (DOS mode)

2011-11-05 Thread Steven Perry
Does anybody know of any modules to create console applications for windows? I don't want a GUI like tk does. I want it to be text based and run in a DOS window. I saw the below example but couldn't get the curses module to work in Windows. This is a good example of what I'd like to do. http://dr

Perl threads

2011-11-05 Thread Sharan Basappa
Hello, We are in the process of writing a perl program that can send network traffic on the native pc network port. Essentially, the perl program emulates as if different traffic type sources are sending the traffic data. For this, our plan is to have a independent thread to emulate each traffic t

Re: what's the error?

2011-11-05 Thread Uri Guttman
On 11/05/2011 08:07 AM, Ken Peng wrote: 于 2011-11-5 16:57, Uri Guttman 写道: it isn't confusing. when a system call error occurs, you get an undef return value which says that. then you check $! to see what was the error. clearing $! on all good calls is a waste of cpu since most calls succeed vs

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 11:17 AM, Ken Peng wrote: Thanks for your explanation. Maybe I should look into some of Perl's source code to find out it. Good luck with that. If you have any questions about Perl's source code, they should be directed at the Perl 5 Porters list: http://lists.perl.org/list/perl5-

Re: what's the error?

2011-11-05 Thread Ken Peng
于 2011-11-5 22:15, Shawn H Corey 写道: It's something the OS does. Ever OS sets a different value. $ perl -le 'print $!;open HD,"/etc/passwd" or die;print $!;;print $!' Inappropriate ioctl for device Inappropriate ioctl for device $ Thanks for your explanation. Maybe I should look into some o

Re: what's the error?

2011-11-05 Thread Ken Peng
ok if I said something rude I just say sorry now. I was just uncomfortable for that unwanted $!. 于 2011-11-5 22:39, Dr.Ruud 写道: On 2011-11-05 15:28, Ken Peng wrote: 于 2011-11-5 22:20, Dr.Ruud 写道: Who cares? You should only use $! *immediately* after an error. Faint, why no one care? I do

Re: what's the error?

2011-11-05 Thread Dr.Ruud
On 2011-11-05 15:28, Ken Peng wrote: 于 2011-11-5 22:20, Dr.Ruud 写道: Who cares? You should only use $! *immediately* after an error. Faint, why no one care? I do care it. Don't troll. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginn

Re: what's the error?

2011-11-05 Thread Ken Peng
于 2011-11-5 22:20, Dr.Ruud 写道: Who cares? You should only use $! *immediately* after an error. Faint, why no one care? I do care it. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: what's the error?

2011-11-05 Thread Dr.Ruud
On 2011-11-05 14:49, Ken Peng wrote: 于 2011-11-5 21:03, Shawn H Corey 写道: You're assuming that perl clears $! at the start of your script. Never assume a variable has a valid value unless you set it yourself. In other words, always initialize your variables. It did clear it, see this: $ per

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 10:07 AM, Ken Peng wrote: 于 2011-11-5 21:59, Shawn H Corey 写道: The open statement: perl -le 'print $!;open HD,"/etc/passwd" or die;print $!;;print $!' So why? Thanks. Ken. It's something the OS does. Ever OS sets a different value. $ perl -le 'print $!;open HD,"/etc/passwd" o

Re: what's the error?

2011-11-05 Thread Ken Peng
于 2011-11-5 21:59, Shawn H Corey 写道: The open statement: perl -le 'print $!;open HD,"/etc/passwd" or die;print $!;;print $!' So why? Thanks. Ken. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 09:45 AM, Ken Peng wrote: It did clear it, see this: $ perl -le 'print $!;open HD,"/etc/passwd" or die;;print $!' Bad file descriptor I don't know where the $! get setted. The open statement: perl -le 'print $!;open HD,"/etc/passwd" or die;print $!;;print $!' -- Just my 0.000

Re: what's the error?

2011-11-05 Thread Ken Peng
于 2011-11-5 21:03, Shawn H Corey 写道: You're assuming that perl clears $! at the start of your script. Never assume a variable has a valid value unless you set it yourself. In other words, always initialize your variables. It did clear it, see this: $ perl -le 'print $!;open HD,"/etc/passwd" o

Re: what's the error?

2011-11-05 Thread Ken Peng
于 2011-11-5 21:03, Shawn H Corey 写道: You're assuming that perl clears $! at the start of your script. Never assume a variable has a valid value unless you set it yourself. In other words, always initialize your variables. It did clear it, see this: $ perl -le 'print $!;open HD,"/etc/passwd" o

Re: what's the error?

2011-11-05 Thread Shawn H Corey
On 11-11-05 08:07 AM, Ken Peng wrote: Then where did it get the error and set up the value of $! in my first post? You're assuming that perl clears $! at the start of your script. Never assume a variable has a valid value unless you set it yourself. In other words, always initialize your vari

Re: what's the error?

2011-11-05 Thread Ken Peng
于 2011-11-5 16:57, Uri Guttman 写道: it isn't confusing. when a system call error occurs, you get an undef return value which says that. then you check $! to see what was the error. clearing $! on all good calls is a waste of cpu since most calls succeed vs the number that fail. the same is true fo

Re: what's the error?

2011-11-05 Thread Uri Guttman
that was a very long post that missed the actual issue. there was no actual error anywhere in his code. he just printed $! which happens to have some value in it (and all $! values are some error text/number!). also posting large chunks of the perldocs isn't too useful. post appropriate sni

Re: what's the error?

2011-11-05 Thread Uri Guttman
On 11/05/2011 12:17 AM, Ken Peng wrote: 于 2011-11-5 11:16, Anneli Cuss 写道: $! is not guaranteed to be cleared if there was no error. This means you probably don't have a "Bad file descriptor" error, it's just the last value of $! (or 'errno'). That's confused. Since there is not such an error,

Re: Perl variable indirection

2011-11-05 Thread Shlomi Fish
Hi Parag, first of all, a few comments on your code. On Sat, 5 Nov 2011 00:16:29 -0700 Parag Kalra wrote: > Hi, > > I have a function which looks something like: > > sub foo_bar { > ${$_[0]} = new foo_bar ( > address => $_[1], >

Re: Perl variable indirection

2011-11-05 Thread Anneli Cuss
Hi Parag, It's probably not a good idea to do this kind of indirection anyway. You're better off using a hash; you don't know what you could be overwriting, depending on the input to foo_bar, and it creates a class of bugs you're better off avoiding worrying about. See this well written article f

Perl variable indirection

2011-11-05 Thread Parag Kalra
Hi, I have a function which looks something like: sub foo_bar { ${$_[0]} = new foo_bar ( address => $_[1], sudo=> $_[3]', id => $_[0] . '_' . $_[2], ); sleep 8;