Re: Q: cannot use 'use base' without quote ?

2007-07-18 Thread Mumia W.
On 07/18/2007 12:13 AM, Jack Minoshima wrote: [...] Please tell my why I need quote after use base while using strict subs. Thank you very much in advance ! -- jackm The first explanation is that the module's documentation suggests that the quotes are required. The second quick explanation

Optimize my script

2007-07-18 Thread JeeBee
Dear Perl experts, Some time ago I wrote a Perl script that combines the output values of a lot of simulation runs. Because there are so many, I could some quite some time if the script would run a bit faster. (I have the feeling it is quite slow like it is). Perhaps somebody has a tip to make

Re: Q: cannot use base while Exporting ?

2007-07-18 Thread Paul Johnson
On Wed, Jul 18, 2007 at 02:20:15PM +0900, Jack Minoshima wrote: Hi. Please allow me to ask another silly question. I wrote the program and it works fine. Animal.pm package Animal; use Exporter; @ISA = qw(Exporter);

Re: Optimize my script

2007-07-18 Thread JeeBee
Because I'm trying to match this regular expression a lot of times, that could very well be the point to improve. I can imagine this is the slowest part of the script: my $exp = nan|-?inf|[0-9\.e\+\-]+; my $stat_pat = (?:\\s+($exp))(?:\\s+($exp)) . # $1 number of samples, $2 minimum

Re: Optimize my script

2007-07-18 Thread Paul Johnson
On Wed, Jul 18, 2007 at 09:49:24AM +, JeeBee wrote: Because I'm trying to match this regular expression a lot of times, that could very well be the point to improve. I can imagine this is the slowest part of the script: Don't imagine. Profile. Then you'll know which parts of your

Re: Optimize my script

2007-07-18 Thread JeeBee
Thanks Paul, I should profile of course, should have thought about that. I tried the below, but it's not quite clear what this means to me. When I run with ./analyze.pl foo bar the execution time is fast, so the problem is not starting up/exiting of Perl, and I conclude it must be inside the

Re: connect a database in remote server (can connect to the server via SSH)

2007-07-18 Thread Ken Foskey
On Tue, 2007-07-17 at 16:40 +, [EMAIL PROTECTED] wrote: Hi, All: I am a new to perl. My perl code need to connect to the database in the remote server, and I can login that server via SSH. Can anyone give me a hint about how can I do that? Many thanks. There is a proxy module that you can

Re: Executing commands through Perl

2007-07-18 Thread Teresa Thomas
Exactly, I actually wish to run 'yum' through Perl, but I want to give (even) a non-sudoer the opportunity to authenticate for root and go ahead with the install. Tom Phoenix wrote: On 7/17/07, Teresa Thomas [EMAIL PROTECTED] wrote: But when I try to execute commands that require user input

Re: Optimize my script

2007-07-18 Thread Paul Johnson
On Wed, Jul 18, 2007 at 10:17:00AM +, JeeBee wrote: Thanks Paul, I should profile of course, should have thought about that. I tried the below, but it's not quite clear what this means to me. When I run with ./analyze.pl foo bar the execution time is fast, so the problem is not

Re: Optimize my script

2007-07-18 Thread Paul Johnson
On Wed, Jul 18, 2007 at 03:29:51PM +0200, Paul Johnson wrote: - post your code so that other people can guess too Sorry, I notice that you have already done this. When I first tried to follow the link I had no success, but it works fine for me now. I see I was right about no subroutines, so

Re: Optimize my script

2007-07-18 Thread yaron
Hi, Perhaps you can use the /\G.../gc idiom and develop lex like engine. see: http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlfaq6.pod#What_good_is_\G_in_a_regular_expression?_ and: http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlop.pod#Regexp_Quote-Like_Operators From my experience

Re: Optimize my script

2007-07-18 Thread Chas Owens
On 7/18/07, Paul Johnson [EMAIL PROTECTED] wrote: snip I see the following options: - split your code into subroutines to gain a better understanding of what is taking how much time - install Devel::Cover and run $ perl -MDevel::Cover ./analyze.pl traplas-example output $ cover

Apache ate my hard drive! (and questions)

2007-07-18 Thread Inventor
While enthusiastically writing my new program, I was having so much fun coding and reading www.perl.com articles that I didn't notice a slow, creeping horror that was gradually building up on my machine. Luckily I was reading about Apache and the log files when I remembered that someone here

Extreme beginner question on reading lines from a file.

2007-07-18 Thread Ayesha
Hi all I got started on Perl only today! I have a text file in which I need to read a line and the line after that. Like line1 and line2 line2 and line3 line3 and line4 when I use while($line1 = MYFILE){ $line = MYFILE; } I get output line1 and

Query

2007-07-18 Thread kapil.V
Hi, su-2.05b# df -h . Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1e 136G 102G 23G 82% /home From my script I do: my $du = qx#df -h \.#; ($total,$used) = $du =~ /([0-9]+(\.[ 0-9]+)?)[ M|G]/sg; print Total:$total\nUsed:$used\ n;

Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread country
I have multiple CSV files (3 for this example) with identical record layouts except that each Server Name may not be in all of the files. Also the CSV files might not be sorted by Server Name. File A Server Name,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util WSOMQAVPRA05,93.75,95.87,66.67,68.13

Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Gary Stainburn
On Wednesday 18 July 2007 06:16, Ayesha wrote: Hi all I got started on Perl only today! I have a text file in which I need to read a line and the line after that. Like line1 and line2 line2 and line3 line3 and line4 when I use while($line1 = MYFILE){ $line =

Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Jeff Pang
--- Ayesha [EMAIL PROTECTED] wrote: Hi all I got started on Perl only today! I have a text file in which I need to read a line and the line after that. Like line1 and line2 line2 and line3 line3 and line4 when I use while($line1 = MYFILE){ $line =

Re: Optimize my script

2007-07-18 Thread kapil.V
JeeBee wrote: Because I'm trying to match this regular expression a lot of times, that could very well be the point to improve. I can imagine this is the slowest part of the script: my $exp = nan|-?inf|[0-9\.e\+\-]+; my $stat_pat = (?:\\s+($exp))(?:\\s+($exp)) . # $1 number of samples, $2

Re: Apache ate my hard drive! (and questions)

2007-07-18 Thread Rob Dixon
Inventor wrote: [snip Apache tragedy] My program accesses small text configuration files, allowing the user to change them with a CGI interface before writing them out and doing its compute thing. The problem is that each user needs to have their own set of configuration files so that the

RE: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Joseph L. Casale
Hrm, I am confused then:) I have this as a file I am using right now! while (FILEIN) { my @data = split; next unless @data == 3; next if grep (/[^0-9.-]/, @data); printf FILEOUT X%s Y%s\n, $data[0], $data[1]; printf FILEOUT G01 Z[%s+DPad] F[PFRate]\n,

Re: Apache ate my hard drive! (and questions)

2007-07-18 Thread Jeff Pang
--- Inventor [EMAIL PROTECTED] wrote: While enthusiastically writing my new program, I was having so much fun coding and reading www.perl.com articles that I didn't notice a slow, creeping horror that was gradually building up on my machine. Luckily I was reading about Apache and the log

RE: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
-Original Message- From: country [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 18, 2007 06:00 To: beginners@perl.org Cc: [EMAIL PROTECTED] Subject: Combining Records From Multiple Files based on Common Key Values I have multiple CSV files (3 for this example) with identical

Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Gary Stainburn
On Wednesday 18 July 2007 17:08, Joseph L. Casale wrote: Is that true? I use while loops and they cycle through each line without me keeping track? jlc Yeah, it's true. Why would you want to keep track? (you can BTW, look at perldoc perlvar for $.) in my code, the 1st line is written into

Re: Apache ate my hard drive! (and questions)

2007-07-18 Thread Mr. Shawn H. Corey
Inventor wrote: While enthusiastically writing my new program, I was having so much fun coding and reading www.perl.com articles that I didn't notice a slow, creeping horror that was gradually building up on my machine. Luckily I was reading about Apache and the log files when I remembered that

Re: Query

2007-07-18 Thread Jeff Pang
--- kapil.V [EMAIL PROTECTED] wrote: Hi, su-2.05b# df -h . Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1e 136G 102G 23G 82% /home From my script I do: my $du = qx#df -h \.#; ($total,$used) = $du =~ /([0-9]+(\.[ 0-9]+)?)[ M|G]/sg;

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Rob Dixon
country wrote: I have multiple CSV files (3 for this example) with identical record layouts except that each Server Name may not be in all of the files. Also the CSV files might not be sorted by Server Name. File A Server Name,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util

Re: Query

2007-07-18 Thread Mr. Shawn H. Corey
kapil.V wrote: Hi, su-2.05b# df -h . Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1e 136G 102G 23G 82% /home From my script I do: my $du = qx#df -h \.#; ($total,$used) = $du =~ /([0-9]+(\.[ 0-9]+)?)[ M|G]/sg; ^^ looks

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Mr. Shawn H. Corey
country wrote: #!/usr/bin/perl use strict; use warnings; ### # Create File with Average CPU Numbers ### my %resultacpu; my @files = qw( FileA FileB FileC ); for my $file (FileA,FileB,FileC) { for my $i ( 0 ..

Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Chas Owens
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote: Hrm, I am confused then:) I have this as a file I am using right now! while (FILEIN) { my @data = split; next unless @data == 3; next if grep (/[^0-9.-]/, @data); printf FILEOUT X%s Y%s\n, $data[0], $data[1];

heredoc issure

2007-07-18 Thread lnatz
Hi, I'm having an issue with here docs, and I'm sure it's something simple that I'm overlooking but it's annoying me. Here is a snippet from my script. sub usageAndDie { printEOF; The following single-character otions are accepted: wih arguments: -T -S without

Re: heredoc issure

2007-07-18 Thread Chas Owens
On 7/18/07, lnatz [EMAIL PROTECTED] wrote: Hi, I'm having an issue with here docs, and I'm sure it's something simple that I'm overlooking but it's annoying me. Here is a snippet from my script. snip Its failing with the error: Can't find string terminator EOF anywhere before EOF at

Re: heredoc issure

2007-07-18 Thread Rob Dixon
lnatz wrote: Hi, I'm having an issue with here docs, and I'm sure it's something simple that I'm overlooking but it's annoying me. Here is a snippet from my script. sub usageAndDie { printEOF; The following single-character otions are accepted: wih arguments: -T -S

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread John W. Krahn
country wrote: I have multiple CSV files (3 for this example) with identical record layouts except that each Server Name may not be in all of the files. Also the CSV files might not be sorted by Server Name. File A Server Name,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util

Re: heredoc issure

2007-07-18 Thread John W. Krahn
lnatz wrote: Hi, I'm having an issue with here docs, and I'm sure it's something simple that I'm overlooking but it's annoying me. perldoc -q HERE documents John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Rob Dixon
Rob Dixon wrote: country wrote: I have multiple CSV files (3 for this example) with identical record layouts except that each Server Name may not be in all of the files. Also the CSV files might not be sorted by Server Name. File A Server Name,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Rob Dixon
John W. Krahn wrote: country wrote: [snip] Notice in File OUT for Server Name (wsompapgtw05), since wsompapgtw05 does not appear in File A, the value is replaced with '0'. How can I get perl to place a '0' in the output file when a particular server name appears in at least 1 of the input

Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Rob Dixon
Chas Owens wrote: On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote: Hrm, I am confused then:) I have this as a file I am using right now! while (FILEIN) { my @data = split; next unless @data == 3; next if grep (/[^0-9.-]/, @data); printf FILEOUT X%s Y%s\n,

The role of listen()

2007-07-18 Thread Monty
In studying network programming (and I'm just beginning at it), I see where listen() is called to set up a socket that waits for incoming connection requests. The next step appears to be a call to accept() where the request is granted and the connection made on a new socket, as in this code

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread John W. Krahn
Rob Dixon wrote: John W. Krahn wrote: country wrote: [snip] Notice in File OUT for Server Name (wsompapgtw05), since wsompapgtw05 does not appear in File A, the value is replaced with '0'. How can I get perl to place a '0' in the output file when a particular server name appears in at

renaming a file while using copy using regex

2007-07-18 Thread Paul
I have a line that is reading files from and array and copying to a different directory. Is there a way to rename the file with regex at the same time? I'm wanting to remove spaces only in the filenames with: s/\ //g My copy line reads: copy( $dir/$file, $newdir/$file ); If I need to work with

Re: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Chas Owens
On 7/18/07, Rob Dixon [EMAIL PROTECTED] wrote: snip Your solution has the same problem that made my final one frustratingly ugly: if a server name is missing from the last file in the list there will be no corresponding trailing zero in the output file for that server. snip The answer is to

Re: The role of listen()

2007-07-18 Thread Tom Phoenix
On 7/18/07, Monty [EMAIL PROTECTED] wrote: In studying network programming (and I'm just beginning at it), I see where listen() is called to set up a socket that waits for incoming connection requests. The next step appears to be a call to accept() Unless you really need to work at this low

Re: Query

2007-07-18 Thread John W. Krahn
kapil.V wrote: Hi, Hello, su-2.05b# df -h . Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1e 136G 102G 23G 82% /home From my script I do: my $du = qx#df -h \.#; ($total,$used) = $du =~ /([0-9]+(\.[ 0-9]+)?)[ M|G]/sg; ^

Re: renaming a file while using copy using regex

2007-07-18 Thread John W. Krahn
Paul wrote: I have a line that is reading files from and array and copying to a different directory. Is there a way to rename the file with regex at the same time? No, you have to store the modified file name in a different variable. I'm wanting to remove spaces only in the filenames with:

Re: renaming a file while using copy using regex

2007-07-18 Thread Chas Owens
On 7/18/07, Paul [EMAIL PROTECTED] wrote: I have a line that is reading files from and array and copying to a different directory. Is there a way to rename the file with regex at the same time? I'm wanting to remove spaces only in the filenames with: s/\ //g My copy line reads: copy(

Re: renaming a file while using copy using regex

2007-07-18 Thread Paul
On Wed, July 18, 2007 3:58 pm, John W. Krahn wrote: Paul wrote: I have a line that is reading files from and array and copying to a different directory. Is there a way to rename the file with regex at the same time? No, you have to store the modified file name in a different variable.

Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Joseph L. Casale
How can I detect this, I have been running some code for a few days to develop some files and ran into the situation where I am getting the following data for input: 14.95313 14.45312 0 14.95313 1.570813E-015 0 14.95313 -14.45313 0 -14.95313 -28.90625 0 -14.95313 -14.45313 0 -14.95313

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Chas Owens
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote: How can I detect this, I have been running some code for a few days to develop some files and ran into the situation where I am getting the following data for input: 14.95313 14.45312 0 14.95313 1.570813E-015 0 14.95313 -14.45313 0 -14.95313

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread John W. Krahn
Joseph L. Casale wrote: How can I detect this, I have been running some code for a few days to develop some files and ran into the situation where I am getting the following data for input: 14.95313 14.45312 0 14.95313 1.570813E-015 0 14.95313 -14.45313 0 -14.95313 -28.90625 0 -14.95313

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Xavier Noria
El Jul 18, 2007, a las 11:19 PM, Joseph L. Casale escribió: How can I detect this, I have been running some code for a few days to develop some files and ran into the situation where I am getting the following data for input: 14.95313 14.45312 0 14.95313 1.570813E-015 0 14.95313 -14.45313

RE: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Joseph L. Casale
Interesting, I see from your regexp you use a \A and \z, from Perldoc this means: \A Match only at beginning of string \z Match only at end of string I am not sure I understand this requirement? In my case, I am checking an array of 3 scalars. Does this make sense: next unless @data =~

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Chas Owens
On 7/18/07, Chas Owens [EMAIL PROTECTED] wrote: On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote: How can I detect this, I have been running some code for a few days to develop some files and ran into the situation where I am getting the following data for input: 14.95313 14.45312 0

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Chas Owens
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote: Interesting, I see from your regexp you use a \A and \z, from Perldoc this means: \A Match only at beginning of string \z Match only at end of string Is foo10bar valid? /^$RE{num}{real}$/ says no, but /$RE{num}{real}/ says yes.

RE: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Joseph L. Casale
Chas, Sorry but I am not clear on what you mean by reduce? Do you mean remove all non numbers from the array? Thanks! jlc -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 18, 2007 4:31 PM To: Joseph L. Casale Cc: Xavier Noria; beginners@perl.org

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Chas Owens
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote: Chas, Sorry but I am not clear on what you mean by reduce? Do you mean remove all non numbers from the array? snip Sort of, the code doesn't modify the original array, it creates a new array with only the values that are numbers. -- To

hex conversion

2007-07-18 Thread venkateshwar
hello all, i have a hex value which needs to be checked if a particular bit is set in that string. for example, i need to check if 12th bit is set. i tried doing mask(0x1000) with my input value i receive, so that only if 12th bit is 1, will the answer be onebut can i do a direct comparison

Re: hex conversion

2007-07-18 Thread Tom Phoenix
On 7/18/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: i have a hex value which needs to be checked if a particular bit is set in that string. You probably want to start with the hex() function, which turns a string like '01AF' into a number. But there are other ways; if it's an