Re: reading files c vs perl

2009-04-15 Thread John W. Krahn
Emen Zhao wrote: This is off topic. But I'm just curious about why "4096" is picked here. Is there any particular reason behind it? I guess you can even calc the lines like this - perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename Except that it's slower than using tr///: $ time perl -ln077

Re: reading files c vs perl

2009-04-15 Thread Chas. Owens
On Thu, Apr 16, 2009 at 00:58, Emen Zhao wrote: > This is off topic. But I'm just curious about why "4096" is picked here. Is > there any particular reason behind it? I guess you can even calc the lines > like this - > perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename > > Thanks, > Emen > 409

Re: reading files c vs perl

2009-04-15 Thread Emen Zhao
This is off topic. But I'm just curious about why "4096" is picked here. Is there any particular reason behind it? I guess you can even calc the lines like this - perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename Thanks, Emen

Re: calc page's downloading time

2009-04-15 Thread practicalperl
Thanks Jay, Chas and all others.Will try WWW:Mechanzie. 2009/4/15 Jay Savage : > MWWW::Mechanzie > (http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm) was > designed to do just this. There's no need to reinvent the wheel by > trying to cobble something out of LWP::Simple and HTML::Pa

Re: if statement being ignored

2009-04-15 Thread Robert Citek
On Wed, Apr 15, 2009 at 6:33 AM, John W. Krahn wrote: > Robert Citek wrote: >> >> You probably want ($Lang == "fr") > > Probably not. You are using a numerical comparison on a string which will > convert the string to a number so that is the same as saying: ($Lang == 0) You are correct. Serves

Re: Syntax query

2009-04-15 Thread asmith9983
I'd suggest placing your pipeline of commands into a bash shell script and running it manually from the command line and carefully observing it running. That way you are then dealing with a known quantity outwith any Perl issues. As someone else replied, consider using the "qx" command rather th

Re: Syntax query

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 10:41, John W. Krahn wrote: > Chas. Owens wrote: >> >> On Wed, Apr 15, 2009 at 09:20, Rajini Naidu wrote: >>> >>>  I am trying to execute the below line in the perl program and returns a >>> value 0. >>> >>> my $test2 = ""; >>> my $include =  "file"; >>> >>> $test2 = syste

Re: Syntax query

2009-04-15 Thread John W. Krahn
Chas. Owens wrote: On Wed, Apr 15, 2009 at 09:20, Rajini Naidu wrote: I am trying to execute the below line in the perl program and returns a value 0. my $test2 = ""; my $include = "file"; $test2 = system("/usr/atria/bin/cleartool desc \$include | grep created | awk -F\" \" \'{print \$2}\'

Re: calc page's downloading time

2009-04-15 Thread Jay Savage
On Wed, Apr 15, 2009 at 10:02 AM, Chas. Owens wrote: > On Wed, Apr 15, 2009 at 09:38,   wrote: >> Greetings, >> >> >> What's the easy way to calculate a webpage's downloading time? >> (not only the page, but all the elements in this page, like images, >> JS, css etc). >> For example, I want to get

Re: reading files c vs perl

2009-04-15 Thread Jerry Rocteur
On 15 Apr 2009, at 13:01, John W. Krahn wrote: Dermot wrote: 2009/4/14 Chas. Owens : On Tue, Apr 14, 2009 at 11:49, Rick wrote: is it true that perl will be just as fast as c for reading files ? for example cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl my $count = 0; $/ =

Re: Syntax query

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 09:20, Rajini Naidu wrote: snip > $test2 = system("/usr/atria/bin/cleartool desc \$include | grep created | > awk -F\" \" \'{print \$2}\' | cut -b 1-9 "); snip You might also want to look on CPAN[1] for interfaces to cleartool[2]. Many people use Perl with ClearCase, so th

Re: calc page's downloading time

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 09:38, wrote: > Greetings, > > > What's the easy way to calculate a webpage's downloading time? > (not only the page, but all the elements in this page, like images, > JS, css etc). > For example, I want to get a function: > > my $dl_time = fetch_a_page("www.yahoo.com"); s

Re: calc page's downloading time

2009-04-15 Thread Jayesh Thakrar
Just a thought - A web page (say www.yahoo.com) may contain several links, some of which could be non-traditional html (e.g. media files, Flash files, etc). Do you want "fetch_a_page" to just read the URI of the hyperlink or even "consume" (parse, read, etc.) the URI? Also, since reading the

Re: Syntax query

2009-04-15 Thread Jayesh Thakrar
Just a thought, maybe you can simplify the "whole thing" using shell and Perl as follows - include=file /usr/atria/bin/cleartool desc $include | grep created | awk -F " " '{print $2}' | cut -b 1-9 | perl -w -e 'print ' -- Jayesh - Original Message From: Owen To: Rajini Naidu Cc

Re: Syntax query

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 09:39, Owen wrote: snip > You will probably need to specify the full path of grep and awk. > (usr/bin/grep etc) snip Whereas that is not a bad thing to do, it is not his/her current problem. The system function is returning 0 which means that it was successful. The probl

Re: Syntax query

2009-04-15 Thread Owen
> Hi, > > I am trying to execute the below line in the perl program and returns > a > value 0. > > my $test2 = ""; > my $include = "file"; > > $test2 = system("/usr/atria/bin/cleartool desc \$include | grep > created | > awk -F\" \" \'{print \$2}\' | cut -b 1-9 "); > > The value returned by $tes

calc page's downloading time

2009-04-15 Thread practicalperl
Greetings, What's the easy way to calculate a webpage's downloading time? (not only the page, but all the elements in this page, like images, JS, css etc). For example, I want to get a function: my $dl_time = fetch_a_page("www.yahoo.com"); Thanks in advance. Regards. -- To unsubscribe, e-ma

Re: Syntax query

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 09:20, Rajini Naidu wrote: > Hi, > >  I am trying to execute the below line in the perl program and returns a > value 0. > > my $test2 = ""; > my $include =  "file"; > > $test2 = system("/usr/atria/bin/cleartool desc \$include | grep created | > awk -F\" \" \'{print \$2}\'

Syntax query

2009-04-15 Thread Rajini Naidu
Hi, I am trying to execute the below line in the perl program and returns a value 0. my $test2 = ""; my $include = "file"; $test2 = system("/usr/atria/bin/cleartool desc \$include | grep created | awk -F\" \" \'{print \$2}\' | cut -b 1-9 "); The value returned by $test2 is 0. I suspect grep a

Re: Several packages in one file, no Export possible?

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 03:24, Patrick Kirsch wrote: snip > In one file: > > package Util; > use base 'Exporter'; > our @EXPORT = ('foo', 'bar'); > > sub foo { >    print "foo!"; > } > > package Amy; > use Util;  # imports symbols in @EXPORT > foo(); > > On execution it gives the error: >  Can't l

Re: Match and split on array help with output

2009-04-15 Thread Chas. Owens
On Tue, Apr 14, 2009 at 13:58, Dr.Ruud wrote: > p...@highdeck.com wrote: > >> /:\/\// > > Alternative: > >  m~://~ snip What drove your choice of tildas here? Normally I would go for once of the matched delimiters (i.e. (), {}, [], or <>). -- Chas. Owens wonkden.net The most important skill a

Re: if statement being ignored

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 07:33, John W. Krahn wrote: > Robert Citek wrote: >> >> On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: >>> >>> could someone please help me with this little problem? >>> I am trying to include an if statement part way through printing. >>> When the program reaches the line

Re: Compiling Error Perl

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 03:15, Tecno-World wrote: > I read a lot of messages and faqs, but nothing helps really. > > > > I tried to attach the messages during the ./Configure and the make, but the > mailing list accepts only 50kB. You might want to ask this question on the Perl5 Porters list[1].

Re: if statement being ignored

2009-04-15 Thread John W. Krahn
Robert Citek wrote: On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: could someone please help me with this little problem? I am trying to include an if statement part way through printing. When the program reaches the line if ($Lang = fr ) { print " that line gets ignored and the cgi keeps g

Re: if statement being ignored

2009-04-15 Thread Robert Citek
You probably want ($Lang == "fr") Regards, - Robert On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: > could someone please help me with this little problem? > I am trying to include an if statement part way through printing. > When the program reaches the line if ($Lang = fr ) { print " > that

Re: reading files c vs perl

2009-04-15 Thread John W. Krahn
Dermot wrote: 2009/4/14 Chas. Owens : On Tue, Apr 14, 2009 at 11:49, Rick wrote: is it true that perl will be just as fast as c for reading files ? for example cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl my $count = 0; $/ = \4096; while (<>) { $count += tr/\n//;

Re: Match and split on array help with output

2009-04-15 Thread Dr.Ruud
p...@highdeck.com wrote: /:\/\// Alternative: m~://~ > print( ( split /\// )[ 2 ] ); print +( split m~/~ )[ 2 ]; -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: reading files c vs perl

2009-04-15 Thread Dermot
2009/4/14 Chas. Owens : > On Tue, Apr 14, 2009 at 11:49, Rick wrote: >> is it true that perl will be just as fast as c for reading files ? >> >> for example >> > cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl > my $count = 0; > > $/ = \4096; > while (<>) { >        $count += tr/\n//

RE: Reg:Regular expression

2009-04-15 Thread Owen
> > > > -Original Message- > From: Owen [mailto:rc...@pcug.org.au] > Sent: Wednesday, April 15, 2009 3:16 PM > To: Gowri Chandra Sekhar Barla, TLS, Chennai > Subject: RE: Reg:Regular expression > >> >> >> >> -Original Message- >> From: Owen [mailto:rc...@pcug.org.au] >> Sent: Wedne

RE: Reg:Regular expression

2009-04-15 Thread Gowri Chandra Sekhar Barla, TLS, Chennai
Hi owen, Please find the test.txt in theattachments. Thanks and regards, Gowri -Original Message- From: Owen [mailto:rc...@pcug.org.au] Sent: Wednesday, April 15, 2009 2:19 PM To: Gowri Chandra Sekhar Barla, TLS, Chennai Cc: Perl Beginners Subject: RE: Reg:Regular expression > > Hi o

RE: Reg:Regular expression

2009-04-15 Thread Owen
> > Hi owen, > > Please help me in resolving errors in the following script > > open(INPUT," open(OUTPUT,">new.txt"); > $temp = \/user\/gowri\/remote2; > while ( ) { > $_ =~ s{\\/user\\/cce\\/g_tool}{$temp}; > print OUTPUT $_; > } Well, I can try. But why don't you help me by sending a few l

RE: Reg:Regular expression

2009-04-15 Thread Gowri Chandra Sekhar Barla, TLS, Chennai
Hi owen, Please help me in resolving errors in the following script open(INPUT,"new.txt"); $temp = \/user\/gowri\/remote2; while ( ) { $_ =~ s{\\/user\\/cce\\/g_tool}{$temp}; print OUTPUT $_; } Error: Bareword found where operator expected at example1.pl line 5, near "$_ =~ s{\\/user" (Migh

RE: Reg:Regular expression

2009-04-15 Thread Owen
> > Hi . > > > > Please help me in resolving errors in the following script > > > > 1.open(INPUT," > 2.open(OUTPUT,">new.txt"); > > 3.$temp = \/user\/gowri\/rem2; > > 4.while ( ) { > > 5.$_ =~ s{\\/user\\/cce\\/dbg_tool}{$temp}; > > 6.print OUTPUT $_; > > 7.} > > > > Errors: > > Bareword found wh

Re: Several packages in one file, no Export possible?

2009-04-15 Thread Gunnar Hjalmarsson
Patrick Kirsch wrote: Hey list, I'm sure you can direct me: I have several packages together in one file and now I would like "use" the packages. Now my problem is that Perl's "use" wants to have a file and does not search in the executed file, see example: In one file: package Util; use base

RE: Reg:Regular expression

2009-04-15 Thread Gowri Chandra Sekhar Barla, TLS, Chennai
Hi . Please help me in resolving errors in the following script 1.open(INPUT,"new.txt"); 3.$temp = \/user\/gowri\/rem2; 4.while ( ) { 5.$_ =~ s{\\/user\\/cce\\/dbg_tool}{$temp}; 6.print OUTPUT $_; 7.} Errors: Bareword found where operator expected at example1.pl line 5, near "$

Several packages in one file, no Export possible?

2009-04-15 Thread Patrick Kirsch
Hey list, I'm sure you can direct me: I have several packages together in one file and now I would like "use" the packages. Now my problem is that Perl's "use" wants to have a file and does not search in the executed file, see example: In one file: package Util; use base 'Exporter'; our @EXPORT

Re: AW: if statement being ignored

2009-04-15 Thread Brian
Thomas Bätzler wrote: Brian wrote: could someone please help me with this little problem? I am trying to include an if statement part way through printing. When the program reaches the line if ($Lang = fr ) { print " that line gets ignored and the cgi keeps going to the end. thanks Brian

Compiling Error Perl

2009-04-15 Thread Tecno-World
I read a lot of messages and faqs, but nothing helps really. I tried to attach the messages during the ./Configure and the make, but the mailing list accepts only 50kB. I filtered the messages a little bit… Where is the error, what goes wrong? The System is a at91 ARM CPU from Atmel, i use