Re: Can't print to file

2005-12-06 Thread John W. Krahn
David Sudjiman wrote: > This is my script. > > === > #!/usr/bin/perl > # ex9-2b.pl > > use strict; > use warnings; > > my ($filename) = @ARGV; > > open FILE, $filename or die "Can't open $filename : $!"; > > $^I = ".out"; > while () { >s/Fred/Larry/i; >print; > } > === > > I execut

Re: OOP inheritance question (simple)

2005-12-06 Thread Xavier Noria
On Dec 7, 2005, at 4:36, Ken Farmer wrote: I have tried this question in a couple of other places but the answers are far above my current level of understanding of oop - which is the level of very interested newbie - real newbie. So here goes again. I make an empty (of data) perl objec

Can't print to file

2005-12-06 Thread David Sudjiman
This is my script. === #!/usr/bin/perl # ex9-2b.pl use strict; use warnings; my ($filename) = @ARGV; open FILE, $filename or die "Can't open $filename : $!"; $^I = ".out"; while () { s/Fred/Larry/i; print; } === I executed using: $ perl ex9-2b.pl fred_larry.txt AlLarry Larrydy Larryd

OOP inheritance question (simple)

2005-12-06 Thread Ken Farmer
I have tried this question in a couple of other places but the answers are far above my current level of understanding of oop - which is the level of very interested newbie - real newbie. So here goes again. I make an empty (of data) perl object1 with an included method which can be called t

Re: A Strange Syntax

2005-12-06 Thread Jennifer Garner
Thanks for Adriano Ferreira.Your explaination is good for me.I have known that. On 12/7/05, Adriano Ferreira <[EMAIL PROTECTED]> wrote: > > On 12/5/05, Jennifer Garner <[EMAIL PROTECTED]> wrote: > > As we know, $::{sym} == *main::sym, it's a typeglob. > > but what is **main::sym? and the same,what

Re: Can't open file.

2005-12-06 Thread David Sudjiman
On Tue, 6 Dec 2005, John W. Krahn wrote: > An array in scalar context returns the number of elements in the array so if > @ARGV contains one file name then $filename will be assigned the number 1. > You want to do either: > > my $filename = shift @ARGV; > > Or: > > my ( $filename ) = @ARGV; I

Re: Can't open file.

2005-12-06 Thread Mohammed Shameer
> my $filename = @ARGV; you are assigning an array ( list ) to a scalar. so the rvalue will be calculated in scalar context which will be the number elements in @ARRAY which will be 1 if you give one argument (my $filename) = @ARGV; On Wednesday 07 December 2005 05:40, David Sudjiman wrote:

Re: Can't open file.

2005-12-06 Thread John W. Krahn
David Sudjiman wrote: > Hi All, Hello, > I try this script: > > #!/usr/bin/perl > > use strict; > use warnings; > > my $filename = @ARGV; An array in scalar context returns the number of elements in the array so if @ARGV contains one file name then $filename will be assigned the number 1. You

Can't open file.

2005-12-06 Thread David Sudjiman
Hi All, I try this script: #!/usr/bin/perl use strict; use warnings; my $filename = @ARGV; my $lines; #open FILE, "fred.txt" or die "Can't open foobar.txt : $!"; open FILE, $filename or die "Can't open $filename : $!"; $lines = join '', ; print "$lines\n\n\n\n"; $lines =~ s/^/fred.txt: /mg;

Re: when do vars go out of scope in this case?

2005-12-06 Thread Wiggins d'Anconia
Dr.Ruud wrote: > Wiggins d'Anconia: > > >>the memory will still be available to the same process, >>so it will not be available to other programs for instance until the >>program has ended. > > > And even that is not entirely true, because the memory manager of your > OS can decide to swap stal

Re: when do vars go out of scope in this case?

2005-12-06 Thread Dr.Ruud
Wiggins d'Anconia: > the memory will still be available to the same process, > so it will not be available to other programs for instance until the > program has ended. And even that is not entirely true, because the memory manager of your OS can decide to swap stale stuff from precious RAM to di

Re: when do vars go out of scope in this case?

2005-12-06 Thread JupiterHost.Net
Wiggins d'Anconia wrote: JupiterHost.Net wrote: I just had a discussion about variables going out of scope (for memory considerations) The idea was presented that variables go out of scope as soon they're last referenced in a block, I always thought it was when the block ended. When a v

Re: when do vars go out of scope in this case?

2005-12-06 Thread JupiterHost.Net
Paul Johnson wrote: On Tue, Dec 06, 2005 at 11:58:16AM -0600, JupiterHost.Net wrote: Shawn Corey wrote: JupiterHost.Net wrote: { my $foo = load_100M_of_data(); print $foo; # $foo is using 100M of memeory ± } # memory for $foo has been released Good idea Shawn :) the act

Re: when do vars go out of scope in this case?

2005-12-06 Thread Paul Johnson
On Tue, Dec 06, 2005 at 11:58:16AM -0600, JupiterHost.Net wrote: > Shawn Corey wrote: > > >JupiterHost.Net wrote: > > > >{ > > > >>my $foo = load_100M_of_data(); > >> > >>print $foo; # $foo is using 100M of memeory ± > >> > > > >} # memory for $foo has been released > > Good idea

Re: when do vars go out of scope in this case?

2005-12-06 Thread Shawn Corey
JupiterHost.Net wrote: Good idea Shawn :) the actual project is one thing, I'm really mostly curious if that is true or not, that its out of scope when its last referenced in a block instead of the end of a block. I still think at the end of the block. Going out-of-scope when last used woul

Re: which is more effective between map and foreach?

2005-12-06 Thread Randal L. Schwartz
> "Shawn" == Shawn Corey <[EMAIL PROTECTED]> writes: Shawn> Write the code like you are going to lose your memory in six Shawn> months. Most people would say I write code like I've already lost my mind. Is that the same thing? :-) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc

Re: which is more effective between map and foreach?

2005-12-06 Thread Randal L. Schwartz
> "Jennifer" == Jennifer Garner <[EMAIL PROTECTED]> writes: Jennifer> map { print RESULT $_,":",$ips{$_},"\n" } Jennifer> sort { $ips{$b} <=> $ips{$a} } keys %ips; Map is generally used when you want to collect the results. Since you aren't using the results, but merely using it for

Re: which is more effective between map and foreach?

2005-12-06 Thread Todd W
"Bob Showalter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jennifer Garner wrote: > > Hi,lists, > > > > I have a small script,when it run,it generate much more lines and put > > them > > into a file. > > The code for printing I writed: > > > > map { print RESULT $_,":",$ips{$_}

Re: when do vars go out of scope in this case?

2005-12-06 Thread Wiggins d'Anconia
JupiterHost.Net wrote: > I just had a discussion about variables going out of scope (for memory > considerations) > > The idea was presented that variables go out of scope as soon they're > last referenced in a block, I always thought it was when the block ended. > When a var goes out of scope an

Re: when do vars go out of scope in this case?

2005-12-06 Thread JupiterHost.Net
Shawn Corey wrote: JupiterHost.Net wrote: I'm thinking its B and and the best way to reclaim the memory in this case is to undef()ine $foo when its no longer used in the block. I always thought B too. But don't forget you can use a block anywhere you can use a statement. { {

Re: when do vars go out of scope in this case?

2005-12-06 Thread Shawn Corey
JupiterHost.Net wrote: I'm thinking its B and and the best way to reclaim the memory in this case is to undef()ine $foo when its no longer used in the block. I always thought B too. But don't forget you can use a block anywhere you can use a statement. { { my $foo = load_100M_of

when do vars go out of scope in this case?

2005-12-06 Thread JupiterHost.Net
I just had a discussion about variables going out of scope (for memory considerations) The idea was presented that variables go out of scope as soon they're last referenced in a block, I always thought it was when the block ended. I was just about to search for this and thought I'd ask to see

Set HELO/EHLO from Mail::Send

2005-12-06 Thread Ryan Frantz
Perlers, Can the HELO string be set using Mail::Send? I've done it for Net::SMTP but cannot locate anything in the Mail::Send documentation (or online) that demonstrates as much. I have an internal host (host.privatedomain.com) that needs to email my phone but my provider blocks email comi

Re: A Strange Syntax

2005-12-06 Thread Adriano Ferreira
On 12/5/05, Jennifer Garner <[EMAIL PROTECTED]> wrote: > As we know, $::{sym} == *main::sym, it's a typeglob. > but what is **main::sym? and the same,what is *{$glob}?thanks. **main::sym is a syntax error, but *{*main::sym}==*main::sym. But don't be fooled by the equality $::{sym} == *main::sym.

Re: Help with eval (WAS: which is more effective between map and foreach?)

2005-12-06 Thread Shawn Corey
Jennifer Garner wrote: And, I have another syntax question here. I can't know clearly the difference between eval "" and eval {}. I have run "perldoc -f eval" and read it,but still can't know clearly.Can you help me on this? eval {} or eval BLOCK is parsed only once at compile time. This means

Re: which is more effective between map and foreach?

2005-12-06 Thread Shawn Corey
Xavier Noria wrote: This is kind of a holy war. Some people have that point of view, some don't. All depends on the way you read map. The disagreement is such that recently map was optimized in void context to avoid the generation of the list. As always, Benchmark.pm is your friend for spe

Re: which is more effective between map and foreach?

2005-12-06 Thread Jennifer Garner
Thanks for all.maybe I would use Benchmark.pm to find out a good choice. And, I have another syntax question here. I can't know clearly the difference between eval "" and eval {}. I have run "perldoc -f eval" and read it,but still can't know clearly.Can you help me on this?

Re: which is more effective between map and foreach?

2005-12-06 Thread Bob Showalter
Jennifer Garner wrote: Hi,lists, I have a small script,when it run,it generate much more lines and put them into a file. The code for printing I writed: map { print RESULT $_,":",$ips{$_},"\n" } sort { $ips{$b} <=> $ips{$a} } keys %ips; I would write it like this: print RESULT "$

RE: how to sleep 100 miliseconds?

2005-12-06 Thread Thomas Bätzler
TOKO <[EMAIL PROTECTED]> asked: > hi. I'm new at perl and am looking for solution of let script > sleep for few miliseconds. I tried sleep(0.1); but it does > not work :) as I thought. than I found this solution: select > undef, undef, undef, .01; but it freezes script and it does > not conti

Re: how to sleep 100 miliseconds?

2005-12-06 Thread Elie De Brauwer
TOKO wrote: hi. I'm new at perl and am looking for solution of let script sleep for few miliseconds. I tried sleep(0.1); but it does not work :) as I thought. than I found this solution: select undef, undef, undef, .01; but it freezes script and it does not continue. Thanks for any ideas. TOKO

Re: which is more effective between map and foreach?

2005-12-06 Thread Xavier Noria
On Dec 6, 2005, at 14:50, Frank Bax wrote: At 06:06 AM 12/6/05, Jennifer Garner wrote: I have a small script,when it run,it generate much more lines and put them into a file. The code for printing I writed: map { print RESULT $_,":",$ips{$_},"\n" } sort { $ips{$b} <=> $ips{$a} } key

Re: how to sleep 100 miliseconds?

2005-12-06 Thread Bob Showalter
TOKO wrote: hi. I'm new at perl and am looking for solution of let script sleep for few miliseconds. I tried sleep(0.1); but it does not work :) as I thought. Easist way IMO is to use Time::HiRes: use Time::HiRes qw(sleep); sleep(0.1); > than I found this solution: select undef, unde

how to sleep 100 miliseconds?

2005-12-06 Thread TOKO
hi. I'm new at perl and am looking for solution of let script sleep for few miliseconds. I tried sleep(0.1); but it does not work :) as I thought. than I found this solution: select undef, undef, undef, .01; but it freezes script and it does not continue. Thanks for any ideas. TOKO -- To unsub

Re: which is more effective between map and foreach?

2005-12-06 Thread Frank Bax
At 06:06 AM 12/6/05, Jennifer Garner wrote: I have a small script,when it run,it generate much more lines and put them into a file. The code for printing I writed: map { print RESULT $_,":",$ips{$_},"\n" } sort { $ips{$b} <=> $ips{$a} } keys %ips; Certainly, I can write that code with

Re: Can't hadle error

2005-12-06 Thread John Doe
Lorenzo Caggioni am Dienstag, 6. Dezember 2005 10.19: > Hi! > I write a big program in perl that open some file, and copy them to an > other directory. > To do move files I use this command: > > system("mv","in_file/i","in_file/o") == 0 >or die "Cannot reject input file: $! \n"; The F

RE: which is more effective between map and foreach?

2005-12-06 Thread Thomas Bätzler
Hi, Jennifer Garner <[EMAIL PROTECTED]> asked: > I have a small script,when it run,it generate much more lines > and put them into a file. > The code for printing I writed: > > map { print RESULT $_,":",$ips{$_},"\n" } > sort { $ips{$b} <=> $ips{$a} } keys %ips; > > Certainly, I can w

which is more effective between map and foreach?

2005-12-06 Thread Jennifer Garner
Hi,lists, I have a small script,when it run,it generate much more lines and put them into a file. The code for printing I writed: map { print RESULT $_,":",$ips{$_},"\n" } sort { $ips{$b} <=> $ips{$a} } keys %ips; Certainly, I can write that code with foreach style. I want to know which

RE: Filering a file

2005-12-06 Thread Dermot Paikkos
On 6 Dec 2005 at 8:14, Adedayo Adeyeye wrote: > Hello David, > > I'm able to open the file, read the contents and output the results of > my initial filtering to a new file. > > The problem is that my new file has duplicate entries, and cleaning up > duplicates is where I'm stuck. > > Kind rega

Can't hadle error

2005-12-06 Thread Lorenzo Caggioni
Hi! I write a big program in perl that open some file, and copy them to an other directory. To do move files I use this command: system("mv","in_file/i","in_file/o") == 0 or die "Cannot reject input file: $! \n"; At the beginning, when the program aws little, it worked fine: If it can