RE: Scientific Number problem again!

2007-07-23 Thread Joseph L. Casale
Right! It can be either, I missed that... Thanks Chas! jlc -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED] Sent: Monday, July 23, 2007 2:18 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Scientific Number problem again! On 7/23/07, Joseph L. Casale <[EMAIL PROT

Re: Scientific Number problem again!

2007-07-23 Thread Chas Owens
On 7/23/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: Sorry, I am still getting the scientific notation in the output instead of standard notation. Thanks! jlc does it look like 1E10 or 1e10. If it looks like the former then you need to change the regex to be return $n unless $n =~ /^(.*)[

RE: Scientific Number problem again!

2007-07-23 Thread Joseph L. Casale
Sorry, I am still getting the scientific notation in the output instead of standard notation. Thanks! jlc -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED] Sent: Monday, July 23, 2007 2:09 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Scientific Number problem ag

Re: Scientific Number problem again!

2007-07-23 Thread Chas Owens
On 7/23/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: Hi guys, I must have been dreaming when I tested this and ran it the first time as I thought it worked! Now it's not :P snip What is your definition of not working? It produces no errors and the output looks right to me. -- To unsubscrib

Re: how do I Append to Perl's @INC array using a variable

2007-07-23 Thread Mr. Shawn H. Corey
Mr. Shawn H. Corey wrote: Is it going to waste so much time that you can't call dirname() twice? If so, try: #!/usr/bin/perl use strict; use warnings; use vars qw( $dir ); use File::Basename; use lib ( $dir = dirname( $0 ) ); print "$dir\n"; print "@INC\n"; __END__ -- Just my 0.0002

Scientific Number problem again!

2007-07-23 Thread Joseph L. Casale
Hi guys, I must have been dreaming when I tested this and ran it the first time as I thought it worked! Now it's not :P Anyone know what's wrong here, can I not leverage the expand sub to convert the scientific notation in the printf statement like I am? sub expand { my $n = shift;

Re: how do I Append to Perl's @INC array using a variable

2007-07-23 Thread Mr. Shawn H. Corey
Adriano Ferreira wrote: On 7/23/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: use File::Basename; use lib dirname( $0 ); Pay attention to the fact that the solution by Shawn does not work also if you try to do something like this: use File::Basename; my $dir = dirname( $0 ); use lib $dir;

Re: how do I Append to Perl's @INC array using a variable

2007-07-23 Thread Chas Owens
On 7/23/07, Adriano Ferreira <[EMAIL PROTECTED]> wrote: On 7/23/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: snip > use File::Basename; > use lib dirname( $0 ); Pay attention to the fact that the solution by Shawn does not work snip Um, yes it does. At least with 5.8.8. I thought I re

Re: array assignement

2007-07-23 Thread Mr. Shawn H. Corey
John W. Krahn wrote: $ perl -le' use Data::Dumper; my %args; @{ $args{ owner } } = qw( hero wierd ); print Dumper \%args; $args{ owner } = q/sachin/; print Dumper \%args; @{ $args{ owner } } = qw( hero wierd ); print Dumper \%args; print Dumper [EMAIL PROTECTED]; Of course, if you `use stri

Re: GetOptions argument given multiple times

2007-07-23 Thread Chas Owens
On 7/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi I'm trying to use multiple options with GetOptions snip Both of the ways specified in the manual work for me: #!/usr/bin/perl use warnings; use strict; use Getopt::Long; @ARGV = qw<--library foo --library bar>; my @libfiles; Get

Re: array assignement

2007-07-23 Thread John W. Krahn
John W. Krahn wrote: jeevs wrote: I just wanted to know what does the following line do @{$args{owner}} = qw(hero wierd); You are assigning a list to the anonymous array in $args{owner}. lets assume $args{owner} = 'sachin'; 'sachin' is a scalar value. Then it would mean @{sachin}

Re: how do I Append to Perl's @INC array using a variable

2007-07-23 Thread Adriano Ferreira
On 7/23/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: Chris Pax wrote: > I know that if i use: use lib "/path/to/dir" works. but when I try to > use a variable it does not work. > here is my code: > @dirs = split /\// , $0; > delete $dirs[-1]; > my $runningDir = join "/",@dirs; > $runningDir.

Re: can i change file content without using a temp file

2007-07-23 Thread Mr. Shawn H. Corey
John W. Krahn wrote: Victor Tsang wrote: if you want to apply this regex to a single file, using the -i option (in place editing) might be the quickest way for you. ie. perl -pe "tr/[a-e]/[1-5]/g" -i $ perl -c -pe "tr/[a-e]/[1-5]/g" Bareword found where operator expected at -e line 1, near

Re: array assignement

2007-07-23 Thread John W. Krahn
jeevs wrote: Hi forum! Hello, I just wanted to know what does the following line do @{$args{owner}} = qw(hero wierd); You are assigning a list to the anonymous array in $args{owner}. lets assume $args{owner} = 'sachin'; 'sachin' is a scalar value. Then it would mean @{sachin} =

Re: can i change file content without using a temp file

2007-07-23 Thread John W. Krahn
Victor Tsang wrote: if you want to apply this regex to a single file, using the -i option (in place editing) might be the quickest way for you. ie. perl -pe "tr/[a-e]/[1-5]/g" -i $ perl -c -pe "tr/[a-e]/[1-5]/g" Bareword found where operator expected at -e line 1, near "tr/[a-e]/[1-5]/g" syn

array assignement

2007-07-23 Thread jeevs
Hi forum! I just wanted to know what does the following line do @{$args{owner}} = qw(hero wierd); lets assume $args{owner} = 'sachin'; Then it would mean @{sachin} = qw(hero wierd); what would {sachin} stand for does it mean an hash refernce or something else. I am lost. Can someone explain

GetOptions argument given multiple times

2007-07-23 Thread fredrik . y . andersson
Hi I'm trying to use multiple options with GetOptions $>perl myprogram.pl --byggvy=abc --byggvy=def How do you write the code for the GetOptions? Best Regards Fredrik Andersson My code: #!/usr/local/bin/perl use warnings; use Getopt::Long; my %Options = (); #Is this the correct way? GetOption

Re: how do I Append to Perl's @INC array using a variable

2007-07-23 Thread Mr. Shawn H. Corey
Chris Pax wrote: I know that if i use: use lib "/path/to/dir" works. but when I try to use a variable it does not work. here is my code: @dirs = split /\// , $0; delete $dirs[-1]; my $runningDir = join "/",@dirs; $runningDir.="/"; use lib $runningDir; use File::Basename; use lib dirname( $0 );

Re: can i change file content without using a temp file

2007-07-23 Thread Victor Tsang
if you want to apply this regex to a single file, using the -i option (in place editing) might be the quickest way for you. ie. perl -pe "tr/[a-e]/[1-5]/g" -i Tor. cute wrote: > Now i create a temp file to store changed content. > is there a simple way to change file content without creating

how do I Append to Perl's @INC array using a variable

2007-07-23 Thread Chris Pax
I know that if i use: use lib "/path/to/dir" works. but when I try to use a variable it does not work. here is my code: @dirs = split /\// , $0; delete $dirs[-1]; my $runningDir = join "/",@dirs; $runningDir.="/"; use lib $runningDir; what I am trying to do with this coded is add the running direc

Re: Simple loop issue

2007-07-23 Thread yaron
Hi, Is you can see the web site is not accessible. I think that you should test the HTTP::Response and get the error: my $res = $mech->get( $url ); unless ($res->is_success) { print STDERR "Error: ",$r->status_line,"\n"; ... } see http://search.cpan.org/~gaas/libwww-perl-5.806/lib/HTTP/Sta

RE: variable in cgi param

2007-07-23 Thread Moon, John
-Original Message- From: ubergoonz [mailto:[EMAIL PROTECTED] Sent: Monday, July 23, 2007 10:06 AM To: Perl Beginners Subject: variable in cgi param Hi, I am trying to parse a param in cgi script. basically how can i make use of a for loop to parse the variables, from the url http://som

Re: variable in cgi param

2007-07-23 Thread thomas polnik
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, > for ($1=1; $i <= $cgi->param('totalkey') ; $i++) { $1 is not $i - If you would use 'use strict', you would find mistakes like this very easy :) > print "$i - $cgi->param('ip$i') cgi->param('hn$i') "; Please try: print "$i - " . $cgi->param('i

Re: variable in cgi param

2007-07-23 Thread jm
i have used this, just to display all param()s and verify the data being passed. i'm thinking someone showed me a newer version for looking at multiple values for checkboxes, etc. but i'm not sure and i don't have more recent code available to verify. hope this helps # foreach my

variable in cgi param

2007-07-23 Thread ubergoonz
Hi, I am trying to parse a param in cgi script. basically how can i make use of a for loop to parse the variables, from the url http://someplace/cgi-bin/script.cgi?ip1=xxx.xxx.xxx.xxx&hn1=blah&ip2=xxx.xxx.xxx.xxx&hn2=blah&ip3=xxx.xxx.xxx.xxx&hn3=blah&totalkey=3 for ($1=1; $i <= $cgi->param('t

Simple loop issue

2007-07-23 Thread Prats, Javier
Hello everyone, I created this simple script as a temporary remedy for IIS. It seems to be going down once a day. We're waiting on new hardware which will be running LAMP instead. In the mean time this Perl script below was created to check the services and bring them up if they are not running

Re: bin2hex

2007-07-23 Thread John W. Krahn
nitesh kumar wrote: Hi All, Hello, I want to convert binary data to hexadecimal. below is the code I used for the conversion. It is converting only for 32 bit. Can anybody suggest me for bit containing more tham 32(it may be 64 or 128). $ perl -le' my %conv = map { sprintf( "%04b", $_ ), s

bin2hex

2007-07-23 Thread nitesh kumar
Hi All, I want to convert binary data to hexadecimal. below is the code I used for the conversion. It is converting only for 32 bit. Can anybody suggest me for bit containing more tham 32(it may be 64 or 128). Thanks and Regards Nitesh $str = "1010101010101010101010101010101010101010"; my $str