Re: a declaring

2008-04-21 Thread Chas. Owens
On Mon, Apr 21, 2008 at 9:25 PM, J. Peng <[EMAIL PROTECTED]> wrote: > On Tue, Apr 22, 2008 at 1:58 AM, Chas. Owens <[EMAIL PROTECTED]> wrote: > > > Because of a quirk in how the current and past versions of perl parsed > > and handled the statement. It is a mis-feature according to Larry. > >

Re: a declaring

2008-04-21 Thread J. Peng
On Tue, Apr 22, 2008 at 1:58 AM, Chas. Owens <[EMAIL PROTECTED]> wrote: > Because of a quirk in how the current and past versions of perl parsed > and handled the statement. It is a mis-feature according to Larry. Chas, do you mean this is a bad style to declare and assign a variable like belo

Re: a declaring

2008-04-21 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Mon, Apr 21, 2008 at 11:37 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: snip Please read the last para in the "Statement Modifiers" section in "perldoc perlrun". snip I think you mean perlsyn, not perlrun: http://perldoc.perl.org/perlsyn.html#Statement-Modifiers Y

Re: What does "print $cgi->header" do?

2008-04-21 Thread John W. Krahn
Jonathan Mast wrote: There is a line in script we have that I find baffling, it is print $cgi->header; To me this seems to be printing the results of the header method of the CGI module to standard output. Correct. Is something else going on here as well? That depends on what the current

Re: What does "print $cgi->header" do?

2008-04-21 Thread Chas. Owens
On Mon, Apr 21, 2008 at 2:45 PM, Jonathan Mast <[EMAIL PROTECTED]> wrote: > There is a line in script we have that I find baffling, it is > > print $cgi->header; > > To me this seems to be printing the results of the header method of the CGI > module to standard output. > > Is something else go

What does "print $cgi->header" do?

2008-04-21 Thread Jonathan Mast
There is a line in script we have that I find baffling, it is print $cgi->header; To me this seems to be printing the results of the header method of the CGI module to standard output. Is something else going on here as well? Thanks

Re: help in reg. exp.

2008-04-21 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > I have string like OMS.FD.08.03.000.0 Now my req. is that if the string > contains .0 at the end then I want to remove that .0 but if any other > digit is there other than .0 then don't do anything. > > For example: if string is : OMS.FD.08.03.000.0 then regular expre

Re: a declaring

2008-04-21 Thread Chas. Owens
On Mon, Apr 21, 2008 at 10:40 AM, J. Peng <[EMAIL PROTECTED]> wrote: > I'm not sure, but why this can work? > > use strict; > use warnings; > use Data::Dumper; > > my $y=0; > my @x =(1,2,3) if $y; > print Dumper [EMAIL PROTECTED]; > > > Since $y is false, it seems @x shouldn't be declared. >

Re: a declaring

2008-04-21 Thread Chas. Owens
On Mon, Apr 21, 2008 at 11:37 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: snip > Please read the last para in the "Statement Modifiers" section in "perldoc > perlrun". snip I think you mean perlsyn, not perlrun: http://perldoc.perl.org/perlsyn.html#Statement-Modifiers -- Chas. Owens wonkd

Re: opening a big file

2008-04-21 Thread Chas. Owens
On Mon, Apr 21, 2008 at 11:18 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Mr. Shawn H. Corey wrote: > > > The fastest way to do this is to read every line into Perl and disregard > everything not relevant. > > > > Don't think so. > > I did a benchmark on a text file with 100,000 lines, wh

Re: opening a big file

2008-04-21 Thread Gunnar Hjalmarsson
Richard Lee wrote: Gunnar Hjalmarsson wrote: Richard Lee wrote: I don't have root access.. and then compiler which is gcc on sun machine messed up my installation. I tried to install expect and didn't work out. Will gather more information Start here: perldoc -q "own module" thanks..

Re: a declaring

2008-04-21 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: J. Peng wrote: I'm not sure, but why this can work? use strict; use warnings; use Data::Dumper; my $y=0; my @x =(1,2,3) if $y; print Dumper [EMAIL PROTECTED]; Since $y is false, it seems @x shouldn't be declared. Please read the last para in the "Statement Modifier

Re: opening a big file

2008-04-21 Thread Richard Lee
Gunnar Hjalmarsson wrote: Richard Lee wrote: Gunnar Hjalmarsson wrote: Richard Lee wrote: Unfortunately however, the system I am on, I cannot install any modules other than standard modules that already come with the perl. Assuming you have at least FTP access, you are wrong. Which are the

Re: opening a big file

2008-04-21 Thread Gunnar Hjalmarsson
Richard Lee wrote: Gunnar Hjalmarsson wrote: Richard Lee wrote: Unfortunately however, the system I am on, I cannot install any modules other than standard modules that already come with the perl. Assuming you have at least FTP access, you are wrong. Which are the restrictions? I guess ev

Re: a declaring

2008-04-21 Thread Gunnar Hjalmarsson
J. Peng wrote: I'm not sure, but why this can work? use strict; use warnings; use Data::Dumper; my $y=0; my @x =(1,2,3) if $y; print Dumper [EMAIL PROTECTED]; Since $y is false, it seems @x shouldn't be declared. Please read the last para in the "Statement Modifiers" section in "perldoc pe

Re: installing Text-Balanced module

2008-04-21 Thread Gunnar Hjalmarsson
Sharan Basappa wrote: On Sat, Apr 19, 2008 at 12:35 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: I think it's advisable to follow the recommendation in perldoc -q "own module" and use both the PREFIX and LIB options. Usually I install Perl modules as root, but as a learning exerci

Re: opening a big file

2008-04-21 Thread Richard Lee
Gunnar Hjalmarsson wrote: Richard Lee wrote: Unfortunately however, the system I am on, I cannot install any modules other than standard modules that already come with the perl. Assuming you have at least FTP access, you are wrong. Which are the restrictions? I guess even that, I should lo

Re: opening a big file

2008-04-21 Thread Gunnar Hjalmarsson
Mr. Shawn H. Corey wrote: The fastest way to do this is to read every line into Perl and disregard everything not relevant. Don't think so. I did a benchmark on a text file with 100,000 lines, where I'm actually only interested in the 5 last lines. Except for Tie::File, which proved to be aw

Re: opening a big file

2008-04-21 Thread Richard Lee
beyhan wrote: The key is : use Tie::File "Tie::File" represents a regular text file as a Perl array. Each ele‐ ment in the array corresponds to a record in the file. The first line of the file is element 0 of the array; the second line is element 1, and so on. The

Re: opening a big file

2008-04-21 Thread Gunnar Hjalmarsson
Richard Lee wrote: Unfortunately however, the system I am on, I cannot install any modules other than standard modules that already come with the perl. Assuming you have at least FTP access, you are wrong. Which are the restrictions? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/

a declaring

2008-04-21 Thread J. Peng
I'm not sure, but why this can work? use strict; use warnings; use Data::Dumper; my $y=0; my @x =(1,2,3) if $y; print Dumper [EMAIL PROTECTED]; Since $y is false, it seems @x shouldn't be declared. But why the last print can work? -- J. Peng - QQMail Operation Team eMail: [EMAIL PROTECTED] A

Re: installing Text-Balanced module

2008-04-21 Thread Sharan Basappa
On Sat, Apr 19, 2008 at 12:35 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Sharan Basappa wrote: > > > I downloaded version and installed it. That went smoothly. When I go back > to text-balanced installation, it still does not seem to locate version.pm > > > > I think it's advisable to fol

Re: help in reg. exp.

2008-04-21 Thread J. Peng
On Mon, Apr 21, 2008 at 7:17 PM, <[EMAIL PROTECTED]> wrote: > Hi All, > > > > I have string like OMS.FD.08.03.000.0 Now my req. is that if the string > contains .0 at the end then I want to remove that .0 but if any other > digit is there other than .0 then don't do anything. > > > > For examp

Re: help in reg. exp.

2008-04-21 Thread Chas. Owens
On Mon, Apr 21, 2008 at 7:17 AM, <[EMAIL PROTECTED]> wrote: snip > I have string like OMS.FD.08.03.000.0 Now my req. is that if the string > contains .0 at the end then I want to remove that .0 but if any other > digit is there other than .0 then don't do anything. snip What have you tried so

help in reg. exp.

2008-04-21 Thread Irfan.Sayed
Hi All, I have string like OMS.FD.08.03.000.0 Now my req. is that if the string contains .0 at the end then I want to remove that .0 but if any other digit is there other than .0 then don't do anything. For example: if string is : OMS.FD.08.03.000.0 then regular expression should give OMS.F

Re: opening a big file

2008-04-21 Thread beyhan
The key is : use Tie::File "Tie::File" represents a regular text file as a Perl array. Each ele‐ ment in the array corresponds to a record in the file. The first line of the file is element 0 of the array; the second line is element 1, and so on. The file is not loa

Re: opening a big file

2008-04-21 Thread Mr. Shawn H. Corey
On Sun, 2008-04-20 at 20:22 -0400, Chas. Owens wrote: > No, you obviously don't know how it is implemented. It seeks to the > end of the file and reads it into a buffer where it searches for line > endings. It does not read the entire file until you reach the first > line. > That's not the poin

Re: opening a big file

2008-04-21 Thread Mr. Shawn H. Corey
On Sun, 2008-04-20 at 18:10 -0400, Richard Lee wrote: > There is no way to read say last 10 MB of the file or something? It's > very surprising why no such thing exists.. > No, it's not. It is a text file, not a fixed-sized record fix. There is no way to compute where the lines of text start.

Re: opening a big file

2008-04-21 Thread Mr. Shawn H. Corey
On Sun, 2008-04-20 at 17:02 -0400, Richard Lee wrote: > Chas. Owens wrote: > > On Sun, Apr 20, 2008 at 1:49 PM, Richard Lee <[EMAIL PROTECTED]> wrote: > > snip > > > >> can this be optimized in anyway? > >> open (my $source, '-|', "tail -10 /server/server.log") > >> > >> is this the best

Re: opening a big file

2008-04-21 Thread Jenda Krynicky
From: Richard Lee <[EMAIL PROTECTED]> > Mr. Shawn H. Corey wrote: > > It still has to go through the entire file and mark the offsets to the > > start of every line. > > > > The best way to do this is just to bite the bullet and do it. > > There is no way to read say last 10 MB of the file or some