Re: Most dependable way to run system commands

2007-12-12 Thread Rob Dixon
Steve Bertrand wrote: [snipped due to excessive content] ... [snip] Tom was probably thinking of Unix, but same principles apply to other platforms. It's also worth noting that whatever application you're using to update the database may well output something useful to STDOUT and it may be a

Re: array modification

2007-12-12 Thread Chas. Owens
On Dec 13, 2007 1:02 AM, Steve Bertrand <[EMAIL PROTECTED]> wrote: > Rob Dixon wrote: > > Chas. Owens wrote: > >> > >> Only use the default variable with functions and operators that use > >> it by default like chomp and regexes. > > > > What's this? The Gospel according to Chas?! > > Hey now... >

Re: array modification

2007-12-12 Thread Steve Bertrand
Rob Dixon wrote: > Chas. Owens wrote: >> >> Only use the default variable with functions and operators that use >> it by default like chomp and regexes. > > What's this? The Gospel according to Chas?! Hey now... Take into consideration that this is not everyone's point of view. Just because you

Re: Most dependable way to run system commands

2007-12-12 Thread Steve Bertrand
[snipped due to excessive content] ... > [snip] > > Tom was probably thinking of Unix, but same principles apply to other > platforms. > > It's also worth noting that whatever application you're using to update > the database may well output something useful to STDOUT and it may be a > simple st

Re: Most dependable way to run system commands

2007-12-12 Thread Rob Dixon
Steve Bertrand wrote: > Tom Phoenix wrote: >> [snip] >> I think you're looking for the program's exit status. Traditionally on Unix and many similar systems, the exit status is an integer, with 0 meaning "normal exit" and anything else meaning that something went wrong. That's the value that's

Re: Most dependable way to run system commands

2007-12-12 Thread Steve Bertrand
>> I am heavily modifying (re-writing) some Perl scripts that are bundled >> within the dialup_admin web interface for FreeRADIUS. >> >> Eventually I'd like to bring the execution of a few system commands >> (executing mysql binary and importing an SQL file into it) into Perl, >> however, for now I

Re: array modification

2007-12-12 Thread Rob Dixon
Chas. Owens wrote: > Only use the default variable with functions and operators that use > it by default like chomp and regexes. What's this? The Gospel according to Chas?! Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.or

Re: array modification

2007-12-12 Thread Rob Dixon
Chas. Owens wrote: > On Dec 12, 2007 1:00 AM, jeff pang <[EMAIL PROTECTED]> wrote: snip You can add a "\n" (or "\r\n" on windows,etc) at the end of each element in the array,like, snip In Perl, "\n" is not linefeed, it is the newline character. It translates to the proper sequence of characte

Re: Calculating Average from a file

2007-12-12 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > I used the script Rob posted a few days with the list::util option and it works. Thanks Rob! However we also use systems we earlier versions of perl it seems. When using the same script I find that it moans about Arrays being present rather than an operator within the

Re: Most dependable way to run system commands

2007-12-12 Thread Tom Phoenix
On 12/12/07, Steve Bertrand <[EMAIL PROTECTED]> wrote: > I am heavily modifying (re-writing) some Perl scripts that are bundled > within the dialup_admin web interface for FreeRADIUS. > > Eventually I'd like to bring the execution of a few system commands > (executing mysql binary and importing an

install non-current version module from cpan shell

2007-12-12 Thread jeff pang
I want to install Apache::Scoreboard v0.15 (b/c I'm using mp1) from cpan shell. But the current version is 2.08. How can I install the specified version of a module from cpan shell? thanks. Best Regards, Jeff (joy) Peng _

Re: Use of uninitialized value in numeric eq (==)

2007-12-12 Thread Dr.Ruud
protoplasm schreef: > foreach (keys %opts_hash) > { > if ( !defined $opts_hash{$_} ) > { > next; > } > elsif ( $opts_hash{$_} == 1 ) > { > print "$_ = $opts_hash{$_}\n"; > } > } An alternative way to write that: for (sort keys %opts_hash) { next unless defined $opts_hash

Re: Effective search of text file

2007-12-12 Thread Dr.Ruud
John W . Krahn schreef: > Dr.Ruud: >> my $filename = "test.db"; >> open my $fd, "<", $filename >> or die "'$filename': $!"; >> >> (yes, I prefer Texan quotes nowadays :) > > Is that Dutch slang? I have never heard that expression before. I paraphrased on a recent discussion in p6lang.

Most dependable way to run system commands

2007-12-12 Thread Steve Bertrand
I am heavily modifying (re-writing) some Perl scripts that are bundled within the dialup_admin web interface for FreeRADIUS. Eventually I'd like to bring the execution of a few system commands (executing mysql binary and importing an SQL file into it) into Perl, however, for now I just need it to

Re: Timestamp sub

2007-12-12 Thread Gunnar Hjalmarsson
yitzle wrote: sub timestamp { my $t = localtime; return \$t; } This function stores the localtime (seconds since epoch?) in a variable $t No, seconds since epoch is not what localtime() returns and what's stored in $t. perldoc -f localtime -- Gunnar Hjalmarsson Email: http://www.gunnar

Re: Regex password length

2007-12-12 Thread Tom Phoenix
On 12/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm trying to create a regex to ensure a minimum password length. It would seem that you should use the length function. (Also, why should it matter that the string in question is a password?) > I'm trying this: > > $regex= '^.{4,}$' M

Re: Timestamp sub

2007-12-12 Thread Tom Phoenix
On 12/12/07, Henrik Nielsen <[EMAIL PROTECTED]> wrote: > Whats with the \$t in this sub? > sub timestamp { my $t = localtime; \$t } > > And what does this do? > sub timestamp { my $t = localtime; } The localtime function is documented in the perlfunc manpage. It's being used here in a scalar cont

Re: Timestamp sub

2007-12-12 Thread yitzle
In perl, the last variable in a function is returned. sub timestamp { my $t = localtime; \$t } is the same as sub timestamp { my $t = localtime; return \$t; } This function stores the localtime (seconds since epoch?) in a variable $t, then returns a reference to $t. -- To unsubscribe, e-mail

Timestamp sub

2007-12-12 Thread Henrik Nielsen
Hi Whats with the \$t in this sub? sub timestamp { my $t = localtime; \$t } And what does this do? sub timestamp { my $t = localtime; } Henrik -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Use of uninitialized value in numeric eq (==)

2007-12-12 Thread protoplasm
Thanks for the advice. After I posted I tried this and it worked too: foreach (keys %opts_hash) { # This next line of code eliminates the "Use of uninitialized value in # numeric eq (==)" error when 'use warnings;' is enabled. if ( !defined $opts_hash{$_} ) {

Re: Regex password length

2007-12-12 Thread yitzle
You just want the length of a string? $size = length $input; or if ( length $input > $minSize ) { ... } else { ... } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Regex password length

2007-12-12 Thread alfonso . marinmarin
Hi all, I'm trying to create a regex to ensure a minimum password length. I'm trying this: $regex= '^.{4,}$' That work fine exept for, at least, the equal signal (=) For example, if i try 'my=test", it returns false. If i try 'myte=st', that works. If i change 4 for 2 in regex, then the first

Re: Identify source of warning

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 12:52 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Dec 12, 2007 12:26 PM, <[EMAIL PROTECTED]> wrote: > > Paul Johnson <[EMAIL PROTECTED]> writes: > snip > > > It certainly would. And if you find any which don't, and the reason > > > can't be tracked back to a problem in your co

Re: Identify source of warning

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 12:26 PM, <[EMAIL PROTECTED]> wrote: > Paul Johnson <[EMAIL PROTECTED]> writes: snip > > It certainly would. And if you find any which don't, and the reason > > can't be tracked back to a problem in your code (or perhaps even if it > > can), please use the perlbug utility to repor

Re: Identify source of warning

2007-12-12 Thread reader
Paul Johnson <[EMAIL PROTECTED]> writes: [...] > This would be absolutely wonderful test material for the new release! > >> It will be interesting to see if they all still work. > > It certainly would. And if you find any which don't, and the reason > can't be tracked back to a problem in your

Re: array modification

2007-12-12 Thread John W . Krahn
On Wednesday 12 December 2007 07:15, Jenda Krynicky wrote: > From: jeff pang <[EMAIL PROTECTED]> > > > --- "Sayed, Irfan (Irfan)" <[EMAIL PROTECTED]> wrote: > > > My query is that can i store the output of this for loop in > > > variable or > > > list. so that if i print the content of that variabl

Re: Use of uninitialized value in numeric eq (==)

2007-12-12 Thread John W . Krahn
On Tuesday 11 December 2007 16:53, protoplasm wrote: > > I'm messing around with Getopt and have a set of arguments that can > be passed to the program. I am new to perl and am unaware of how to > resolve the error while keeping 'use warnings;' enabled. Any help > would be greatly appreciated. > >

Re: Data::Compare module help

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 10:11 AM, Roman Daszczyszak <[EMAIL PROTECTED]> wrote: > Oops.. I made one mistake in my explanation. The structure in > question is a hash of usernames each containing another hash of the > user attributes. I'm trying to use the code to ignore an attribute in > the second-level h

Re: array modification

2007-12-12 Thread Jenda Krynicky
From: jeff pang <[EMAIL PROTECTED]> > --- "Sayed, Irfan (Irfan)" <[EMAIL PROTECTED]> wrote: > > > > My query is that can i store the output of this for loop in > > variable or > > list. so that if i print the content of that variable or array then > > it > > should print as > > > > dadsad > > as

Re: Data::Compare module help

2007-12-12 Thread Roman Daszczyszak
Oops.. I made one mistake in my explanation. The structure in question is a hash of usernames each containing another hash of the user attributes. I'm trying to use the code to ignore an attribute in the second-level hash. Will that work? On Dec 12, 2007 3:49 PM, Roman Daszczyszak <[EMAIL PROTE

Re: Data::Compare module help

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 9:49 AM, Roman Daszczyszak <[EMAIL PROTECTED]> wrote: > Hi all, > > I am trying to utilize Data::Compare to compare two data structures > containing user names and account attributes from Windows XP systems. > Using Win32API::Net, it returns an array of usernames, which can be > loo

Re: Use of uninitialized value in numeric eq (==)

2007-12-12 Thread Chas. Owens
On Dec 11, 2007 7:53 PM, protoplasm <[EMAIL PROTECTED]> wrote: snip > my $opts_hash; > my %opts_hash = (); snip You don't need $opts_hash (you aren't using it). You can get rid of the undef warnings by making sure that the keys in %opts_hash are used like this: #default values for the options my

Data::Compare module help

2007-12-12 Thread Roman Daszczyszak
Hi all, I am trying to utilize Data::Compare to compare two data structures containing user names and account attributes from Windows XP systems. Using Win32API::Net, it returns an array of usernames, which can be looped through to pull a hash of each users' attributes. However, comparing these h

Use of uninitialized value in numeric eq (==)

2007-12-12 Thread protoplasm
I'm messing around with Getopt and have a set of arguments that can be passed to the program. I am new to perl and am unaware of how to resolve the error while keeping 'use warnings;' enabled. Any help would be greatly appreciated. Code: == #!/opt/local

Re: Effective search of text file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 8:46 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: > On Wednesday 12 December 2007 04:03, Dr.Ruud wrote: snip > > or die "'$filename': $!"; > > > > (yes, I prefer Texan quotes nowadays :) > > Is that Dutch slang? I have never heard that expression before. > snip Some people c

Re: Effective search of text file

2007-12-12 Thread John W . Krahn
On Wednesday 12 December 2007 04:03, Dr.Ruud wrote: > jeff pang schreef: > > open FD,"test.db" or die $!; > > Jeff, could you please start using lexical filehandles, more > whitespace, and 3-argument opens, when publishing example code on > this list? > > my $filename = "test.db"; > open my $fd

Re: Effective search of text file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 8:12 AM, jeff pang <[EMAIL PROTECTED]> wrote: > > --- "Chas. Owens" <[EMAIL PROTECTED]> wrote: > > The only reason to use any version earlier than 5.6.3 > > is > > that your sysadmins won't upgrade an ancient box (and even then it > > is > > time to quit that job because if they are

poll

2007-12-12 Thread Octavian Rasnita
Hello, I have searched on cpan.org but I couldn't find what I need. Do you know if there is a perl module that can create questionnaires for polls? I would like to use a module that could create questionnaires with more questions, that can split them in more pages (like a wizard) as I specify

Re: Effective search of text file

2007-12-12 Thread jeff pang
--- "Chas. Owens" <[EMAIL PROTECTED]> wrote: > The only reason to use any version earlier than 5.6.3 > is > that your sysadmins won't upgrade an ancient box (and even then it > is > time to quit that job because if they are that stupid then there > are > probably other issues as well). > mhh? if

Re: Effective search of text file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 7:30 AM, jeff pang <[EMAIL PROTECTED]> wrote: snip > I'd like. But I learned perl from 2002 year, I even don't know what's > perl 4. snip Some features you would have to stop using: * lexical variables (i.e. my) * multidimensional arrays and nested hashes * real (vs symbolic) refer

Re: Calculating Average from a file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 5:42 AM, <[EMAIL PROTECTED]> wrote: > All, > > Thanks for your assistance in helping me with my issues. > > The script posted by Rob on the 7th works fantastic. > > However I've discovered that we have a lot of systems out there > running a previous version of perl, so much so that

Re: Effective search of text file

2007-12-12 Thread jeff pang
--- "Chas. Owens" <[EMAIL PROTECTED]> wrote: > Failing backwards > compatibility > with an ancient version of Perl is not a bad thing. Or do you also > support Perl 4? > I'd like. But I learned perl from 2002 year, I even don't know what's perl 4. Best Regards, Jeff (joy) Peng __

Re: Effective search of text file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 7:09 AM, jeff pang <[EMAIL PROTECTED]> wrote: > > --- "Dr.Ruud" <[EMAIL PROTECTED]> wrote: > > > jeff pang schreef: > > > > > open FD,"test.db" or die $!; > > > > Jeff, could you please start using lexical filehandles, more > > whitespace, > > and 3-argument opens, > > Ok I can but

Re: Write the output to a file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 7:08 AM, Dr.Ruud <[EMAIL PROTECTED]> wrote: > "Chas. Owens" schreef: snip > > } #unless a reference was made to $fh it will close here snip > Your last comment line ("it will close here") I would put inside the > block, or I would say "is closed with the block". > (I am all for lexi

Re: Calculating Average from a file

2007-12-12 Thread jase . critchley
All, Thanks for your assistance in helping me with my issues. The script posted by Rob on the 7th works fantastic. However I've discovered that we have a lot of systems out there running a previous version of perl, so much so that I am getting errors within the util.pm. "Array found where opera

Re: Calculating Average from a file

2007-12-12 Thread jase . critchley
I used the script Rob posted a few days with the list::util option and it works. Thanks Rob! However we also use systems we earlier versions of perl it seems. When using the same script I find that it moans about Arrays being present rather than an operator within the util.pm script. Do we use th

Re: Effective search of text file

2007-12-12 Thread jeff pang
--- "Dr.Ruud" <[EMAIL PROTECTED]> wrote: > jeff pang schreef: > > > open FD,"test.db" or die $!; > > Jeff, could you please start using lexical filehandles, more > whitespace, > and 3-argument opens, Ok I can but I don't like. When I uploaded my cpan module with a lexical FH and 3 args open,

Re: Write the output to a file

2007-12-12 Thread Dr.Ruud
"Chas. Owens" schreef: > Dr.Ruud: >> Chas. Owens: >>> (you should close file handles once you >>> stop using them because they are a limited resource). >> >> I often start a new block at opening a file. > > If you are using the new scalar based file handles this is a good > practice since they aut

Re: Question about escaped characters

2007-12-12 Thread Chas. Owens
On Dec 11, 2007 7:33 PM, Why Tea <[EMAIL PROTECTED]> wrote: > my $s = "This is a string\nThis is line 2\n"; > print $s; > > The "\n" is interpreted as newline in the code above. But if the > string (i.e. $s) is in a file, it will be printed literally as "\n" - > how do I get Perl to treat it as new

Re: Effective search of text file

2007-12-12 Thread Dr.Ruud
jeff pang schreef: > open FD,"test.db" or die $!; Jeff, could you please start using lexical filehandles, more whitespace, and 3-argument opens, when publishing example code on this list? my $filename = "test.db"; open my $fd, "<", $filename or die "'$filename': $!"; (yes, I prefer Te

Question about escaped characters

2007-12-12 Thread Why Tea
my $s = "This is a string\nThis is line 2\n"; print $s; The "\n" is interpreted as newline in the code above. But if the string (i.e. $s) is in a file, it will be printed literally as "\n" - how do I get Perl to treat it as newline? /Why Tea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For add

Re: Write the output to a file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 4:46 AM, Dr.Ruud <[EMAIL PROTECTED]> wrote: > "Chas. Owens" schreef: > > > (you should close file handles once you > > stop using them because they are a limited resource). > > I often start a new block at opening a file. snip If you are using the new scalar based file handles this

Re: Effective search of text file

2007-12-12 Thread Chas. Owens
On Dec 11, 2007 6:26 PM, Why Tea <[EMAIL PROTECTED]> wrote: > I have a text file of acronyms of about 2MB, I would like to write a > cgi script to allow users to query for any acronym in the text file. > What is the best way of implementing it (i.e. taking the acronym as a > key to search for the e

Re: array modification

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 12:04 AM, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote: > Hi All, > > I have some string stored in array as follows. > > @array=(dadsad,assasd) Now if i print this array then it is printing as > dadsad,assasd I certainly hope you are not using barewords like this. This will work

Re: Effective search of text file

2007-12-12 Thread jeff pang
--- Why Tea <[EMAIL PROTECTED]> wrote: > I have a text file of acronyms of about 2MB, I would like to write > a > cgi script to allow users to query for any acronym in the text > file. > What is the best way of implementing it (i.e. taking the acronym as > a > key to search for the expanded text)

Re: array modification

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 1:00 AM, jeff pang <[EMAIL PROTECTED]> wrote: snip > You can add a "\n" (or "\r\n" on windows,etc) at the end of each > element in the array,like, snip In Perl, "\n" is not linefeed, it is the newline character. It translates to the proper sequence of characters on each operating

Re: array modification

2007-12-12 Thread protoplasm
Irfan, this will work: #!/opt/local/bin/perl use warnings; use strict; my @output = ("dadsad", "assasd"); foreach (@output) { print "$_\n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Effective search of text file

2007-12-12 Thread Why Tea
I have a text file of acronyms of about 2MB, I would like to write a cgi script to allow users to query for any acronym in the text file. What is the best way of implementing it (i.e. taking the acronym as a key to search for the expanded text)? /Why Tea -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: Write the output to a file

2007-12-12 Thread Dr.Ruud
"Chas. Owens" schreef: > (you should close file handles once you > stop using them because they are a limited resource). I often start a new block at opening a file. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: seek/tell usage

2007-12-12 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: *PLONK* -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Perl Code

2007-12-12 Thread Dermot
On 12/12/2007, Auxence Sima <[EMAIL PROTECTED]> wrote: > > Hi everyone. > I d like to have u guys input about my code. Im writing a perl script > that would generate some primers. my input file calles " output.txt ) was > generated from primer3. > if u guys can take a look at my script and tell