Re: Capturing an external program return code

2007-05-01 Thread Mumia W.
On 05/01/2007 07:09 PM, Vladimir Lemberg wrote: [...] system ( "$program -f $program.cfg" ); if ($? == -3) { [...] You're facing two problems: the return value for system() needs to be shifted right by eight bits; and that value is provided in "unsigned" form, so you have to massage it: m

Re: Capturing an external program return code

2007-05-01 Thread Vladimir Lemberg
Hi Tom, That was very helpful. Thanks a lot, Vladimir - Original Message - From: "Tom Phoenix" <[EMAIL PROTECTED]> To: "Vladimir Lemberg" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, May 01, 2007 5:36 PM Subject: Re: Capturing an external program return code On 5/1/07, Vladimir Lemberg <

Re: Capturing an external program return code

2007-05-01 Thread Tom Phoenix
On 5/1/07, Vladimir Lemberg <[EMAIL PROTECTED]> wrote: My script is executing external program, which returns code i.e 0, -1, -2, -3 etc if ($? == -3) { This is not working. Nothing is printing to the log file when I'm simulating -3 code. If I print $?, it shown 65280. The value in $? i

Re: Capturing an external program return code

2007-05-01 Thread Chas Owens
On 5/1/07, Vladimir Lemberg <[EMAIL PROTECTED]> wrote: snip This is not working. Nothing is printing to the log file when I'm simulating -3 code. If I print $?, it shown 65280. snip from perldoc -f system: if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) {

Re: Illegal use of undefined subroutine..

2007-05-01 Thread Chas Owens
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: Actually, that was just an example to explain my problem. I am facing this problem when i use Tk. Any subroutine associated with the -command option of a button widget. use Tk; my $mw = MainWindow->new; my $b = $mw->Button(-text=>'hello',-command=>su

Capturing an external program return code

2007-05-01 Thread Vladimir Lemberg
Hi All, My script is executing external program, which returns code i.e 0, -1, -2, -3 etc In case of error, I need to create log file according to error code. For example code -3 means missing input file use strict; use warnings; use Win32; system ( "$program -f $program.cfg" ); if ($? ==

Re: Regexp problem

2007-05-01 Thread Tom Phoenix
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: my $input = 'loqr'; if ( $input =~ m!lor!i ) {print 'match'} how will that match? i want them to match. Thats what i want to do. You can add the 'q' to the pattern. Is this what you want? if ( $input =~ /loqr/i ) { print 'match' } Or you can

Re: Illegal use of undefined subroutine..

2007-05-01 Thread John W. Krahn
Somu wrote: > Actually, that was just an example to explain my problem. I am facing > this problem when i use Tk. Any subroutine associated with the > -command option of a button widget. > > use Tk; > my $mw = MainWindow->new; > my $b = $mw->Button(-text=>'hello',-command=>sub { &welcome })->pack;

Re: perl and postgres

2007-05-01 Thread Francisco Valladolid H.
Hi, I'm using NetBSD in both, test and production enviroment. there are many resources for setup perl, and PgPP, DBI, DBD::Pg and Pg module. This is a OT, but if you sendme a private mail, maybe can help you. the http://wiki.netbsd.se have many tutorials for setting a NAPP(NetBSD+Apache+PostgreSQ

Re: Regexp problem

2007-05-01 Thread Somu
Thats where the problem arises my $input = 'loqr'; if ( $input =~ m!lor!i ) {print 'match'} how will that match? i want them to match. Thats what i want to do. by the way, can i get some url where i can get lots of problems and solutions on regexp. I'm very weak in it.. -- To unsubscribe, e-ma

Re: Illegal use of undefined subroutine..

2007-05-01 Thread Somu
Because if define it, it says 'Global variable "$l" needs...' what do i do? Actually, i am not happy nor sad that the subroutine needed a declaration before use.. I'm using ActivePerl 5.8.8 on Windows XP -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTE

Re: Illegal use of undefined subroutine..

2007-05-01 Thread Somu
Actually, that was just an example to explain my problem. I am facing this problem when i use Tk. Any subroutine associated with the -command option of a button widget. use Tk; my $mw = MainWindow->new; my $b = $mw->Button(-text=>'hello',-command=>sub { &welcome })->pack; my $l = $mw->Label(-text

Re: Illegal use of undefined subroutine..

2007-05-01 Thread Chas Owens
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: my $s = <>; my $t = <>; conc ( $s , $t ); sub conc { my $str = $_[0].$_[1]; print $str; } Why? It works allright only after add an extra line at the top, that is sub conc; its become just like C Your code works just fine for me (no errors)

Re: Illegal use of undefined subroutine..

2007-05-01 Thread Chas Owens
On 5/1/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: > my $s = <>; > my $t = <>; > conc ( $s , $t ); > sub conc { > my $str = $_[0].$_[1]; > print $str; > } > > > Why? It works allright only after add an extra line at the top, that is > sub conc; >

Re: Regexp problem

2007-05-01 Thread Howard Sherman
#!/usr/bin/perl use strict; my @Strings = qw(lmn lpt lor mps npr nqt opq rst); chomp(my $Input = ); my $SortedChars = join "", sort (split //, $Input); foreach (@Strings) { if ($SortedChars =~ /$_/) { print "Got a match for $Input with $_\n";

Re: Illegal use of undefined subroutine..

2007-05-01 Thread Tom Phoenix
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: my $s = <>; my $t = <>; conc ( $s , $t ); sub conc { my $str = $_[0].$_[1]; print $str; } Why? Why not? It works allright only after add an extra line at the top, that is sub conc; its become just like C Are you asking a question? Per

Illegal use of undefined subroutine..

2007-05-01 Thread Somu
my $s = <>; my $t = <>; conc ( $s , $t ); sub conc { my $str = $_[0].$_[1]; print $str; } Why? It works allright only after add an extra line at the top, that is sub conc; its become just like C -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] htt

Re: Regexp problem

2007-05-01 Thread Tom Phoenix
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: Hi, i have a matching problem. I get input from the user as a 3-5 character long string consisting of characters from 'l' to 't', and the chars are always sorted for example, the user enters: 'lrqo'. It becomes: 'loqr'. But i have to match the modified

Re: Regexp problem

2007-05-01 Thread Jeff Pang
2007/5/2, Somu <[EMAIL PROTECTED]>: Hi, i have a matching problem. I get input from the user as a 3-5 character long string consisting of characters from 'l' to 't', and the chars are always sorted for example, the user enters: 'lrqo'. It becomes: 'loqr'. But i have to match the modified string

Regexp problem

2007-05-01 Thread Somu
Hi, i have a matching problem. I get input from the user as a 3-5 character long string consisting of characters from 'l' to 't', and the chars are always sorted for example, the user enters: 'lrqo'. It becomes: 'loqr'. But i have to match the modified string to any of the following: lmn, lpt, lo

Re: unit messages

2007-05-01 Thread oryann9
> > Why are you creating these regexes so far from > where > > they are used? > > If you are going to do this at least give them > > meaningful names. I dont have a good reason Chas other than I like the ability to easily change the variable in one spot in case of future use. If this is not a goo

Re: perl and postgres

2007-05-01 Thread Rodrick Brown
On 5/1/07, Maphin Philip <[EMAIL PROTECTED]> wrote: I am using postgres8.2 in netbsd OS 1.How to install perl here? Look at your netbsd ports collection documentation on how to install software on your system using the facility. 2.Can we use perl programs for manipulating data in postg

Re: perl and postgres

2007-05-01 Thread Francisco Valladolid H.
Hi, I'm a NetBSD user. Maphin Philip <[EMAIL PROTECTED]> wrote: > I am using postgres8.2 in netbsd OS > > > > > > > > 1.How to install perl here? > Maybe it be a OT but it ca do here: You can ask in private mail ok and can mail all info need for run perl wit postgresql. > 2.Can we use

Re: unit messages

2007-05-01 Thread Chas Owens
On 5/1/07, oryann9 <[EMAIL PROTECTED]> wrote: snip my $regexp = qr/(host:\w+)/is; my $regexp1 = qr/(onlinejfs.*)/is; my $regexp2 = qr/(jfs\sversion.*)/is; snip Why are you creating these regexes so far from where they are used? If you are going to do this at least give them meaningful names.

Re: unit messages

2007-05-01 Thread oryann9
> #!/usr/bin/perl > > use strict; > use warnings; > > my @a = qw(abc def ghi); > > for my $s (@a) { > $s =~ /(b)|(e)|(h)/; > print "1 => [$1] 2 => [$2] 3 => [$3]\n"; > } > Thank you for the kind replies. I understand now and have modified the code to: use strict; use warnings

Re: perl and postgres

2007-05-01 Thread Jeff Pang
2007/5/1, Maphin Philip <[EMAIL PROTECTED]>: 1.How to install perl here? 2.Can we use perl programs for manipulating data in postgres database Hello, 1. Google it with keyword "how to install perl on netbsd". 2. Surely you can.Please check the modules on CPAN like DBI. -- Chinese Practical

perl and postgres

2007-05-01 Thread Maphin Philip
I am using postgres8.2 in netbsd OS 1.How to install perl here? 2.Can we use perl programs for manipulating data in postgres database Thanks

Re: Binary search

2007-05-01 Thread Jeff Pang
2007/5/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: Hi all, Is there a perl built in function that search a value in sorted array? Although I found such an algorithm in the cpan (Search::Binary), I wonder if there is an efficient solution within the core perl. For large array which was sorted a

Binary search

2007-05-01 Thread yaron
Hi all, Is there a perl built in function that search a value in sorted array? Although I found such an algorithm in the cpan (Search::Binary), I wonder if there is an efficient solution within the core perl. Thanks in advanced, Yaron Kahanovitch -- To unsubscribe, e-mail: [EMAIL PROTECTED] F