Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Edward WIJAYA
Hi John, I tried your code. But I still cannot remove the whitespace from each line. Suppose I have two files. fileA.txt:fileB.txt: A B A B What I get is: A B A B instead of AB AB I tried to play around with this section of your code but of no avail. # clean up whitespac

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread John W. Krahn
Errin Larsen wrote: Ok ... please forgive my n00b-ness, but can you help me understand a couple of things here. This part: shift (@results) . $line Is it the same as: shift @results . $line I'm thinking "no". But I don't know what the difference is. I also don't understand what exactly tha

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread John W. Krahn
Bee wrote: I would suggest to write in this way : my @res = (); foreach( @ARGV ) { open IN, $_ or die "Couldn't open $_: $!\n"; my @data = ; close IN; s/\s+//g for @data; @res = ( @res, @data ); You are copying the @res array. It would be more efficient using

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread John W. Krahn
Errin Larsen wrote: On Fri, 10 Sep 2004 12:44:51 -0400, David Greenberg <[EMAIL PROTECTED]> wrote: foreach( @ARGV ) { open IN, $_ or die "Couldn't open $_: $!\n"; chomp( my @data = ); close IN; foreach( @data ) { s/\s+//g; } foreach( 0..$#data ) { $results[$_] .= $data[$_]

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread John W. Krahn
Edward WIJAYA wrote: Hi, Hello, I have a simple code that take currently fixed to take 3 input files and append each line of these files together. I wish to know is there anyway I can write the code more flexibly so it can dynamically take the input argument - from minimum 2 files to more. Is there

Fwd: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
I forgot to CC the list with my last post! sorry, won't happen again. --Errin -- Forwarded message -- From: Errin Larsen <[EMAIL PROTECTED]> Date: Fri, 10 Sep 2004 15:46:33 -0500 Subject: Re: How to dynamically taking the multiple input arguments? To: Bee <[EMAIL PROTECTED]> Alr

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Bee
> > Opps, I missed that. Instead of: > > @results = map { my $line = $_; chomp $line; $line =~ s/\s+//g; $line } (@data); > > try: > > my @newresults = map { my $line = $_; chomp $line; $line =~ s/\s+//g; > > shift (@results) . $line } (@data); > > @results = @newresults; > > > > -David This work

Re: Copying files from One PC to another.

2004-09-10 Thread John W. Krahn
[ Please do not top-post. TIA ] [EMAIL PROTECTED] wrote: From: Denham Eva <[EMAIL PROTECTED]> Please I am a beginner. I am making tentative steps to creating a script which will keep my Notebook and Workstation at work in sync. My first attempt is just to copy the files from the one to local. Here

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
I'm not sure if shift (@results) . $line; and shift @results . $line would work differently. It depends on whether the order of operations gives precedence to . or to handing an argument to a function. My guess is that . gets precedence, in which case shift @results . $line; will give you somethi

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Bee
> Ok ... Thanks for helpin' out, HTH! I tried out your suggestions and > now the code looks like this: You are welcome, but my name is Bee, HTH stands for 'Hope This Help' > > #!/usr/bin/perl > use warnings; > use strict; > > unless( @ARGV >= 2 ) { die "Usage: $0 file1 file2 [file3...]\n"; } > >

Re: Copying files from One PC to another.

2004-09-10 Thread John W. Krahn
Denham Eva wrote: Hello Listers. Hello, Please I am a beginner. I am making tentative steps to creating a script which will keep my Notebook and Workstation at work in sync. My first attempt is just to copy the files from the one to local. Here is my script - it works, but I suspect there should be

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
On Fri, 10 Sep 2004 15:01:34 -0400, David Greenberg <[EMAIL PROTECTED]> wrote: > Opps, I missed that. Instead of: > @results = map { my $line = $_; chomp $line; $line =~ s/\s+//g; $line } (@data); > try: > my @newresults = map { my $line = $_; chomp $line; $line =~ s/\s+//g; > shift (@results) . $

Re: Removing a tempdir's on Windows

2004-09-10 Thread Tim Donahue
Mark, you are correct it would help if I had closed the file handles. That is what I get for trusting a friend's code, and not reviewing all it when I add it to my project. Thanks for your help. Tim Donahue On Fri, 2004-09-10 at 15:05, [EMAIL PROTECTED] wrote: > Tim, > You should close your

Re: Removing a tempdir's on Windows

2004-09-10 Thread mgoland
Tim, You should close your file handles in your parsing code, before you unlink hth, Mark G - Original Message - From: Tim Donahue <[EMAIL PROTECTED]> Date: Friday, September 10, 2004 2:58 pm Subject: Removing a tempdir's on Windows > Hello, I am writing a custom log parser for our Sq

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
Opps, I missed that. Instead of: @results = map { my $line = $_; chomp $line; $line =~ s/\s+//g; $line } (@data); try: my @newresults = map { my $line = $_; chomp $line; $line =~ s/\s+//g; shift (@results) . $line } (@data); @results = @newresults; -David On Fri, 10 Sep 2004 13:40:04 -0500, Erri

Re: Copying files from One PC to another.

2004-09-10 Thread mgoland
Denham, As usual with Perl, one can express them self's as they wish. There really is no beter way to do any task, unless you have specific specifications/standards. Here is an alternative, using 'split' function. #!PERL -w use warnings; use strict; use File::Copy; my @files=glob('C:\pie\ba

Removing a tempdir's on Windows

2004-09-10 Thread Tim Donahue
Hello, I am writing a custom log parser for our Squid proxy, and I have run into some problems with trying to use a temporary directory. The script parses all the logs, dumping those that are of interest to us for the various parts of the report to smaller, easier to handle files. I am using the

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
On Sat, 11 Sep 2004 02:20:32 +0800, Bee <[EMAIL PROTECTED]> wrote: > > > > >foreach( @ARGV ) { > > > open IN, $_ or die "Couldn't open $_: $!\n"; > > > chomp( my @data = ); > > > close IN; > > > foreach( @data ) { s/\s+//g; } > > > foreach( 0..$#data ) { $results[$_

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
On Fri, 10 Sep 2004 13:17:40 -0400, David Greenberg <[EMAIL PROTECTED]> wrote: > I'm no expert, but chomp won't give you what you think it will: > my @arr = ('a', "b\n", "c\n"); > print join (",",chomp (@arr)); > > This will print: > 2 > > while this: > my @arr = ('a', "b\n", "c\n"); > chomp (@ar

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Bee
> >foreach( @ARGV ) { > > open IN, $_ or die "Couldn't open $_: $!\n"; > > chomp( my @data = ); > > close IN; > > foreach( @data ) { s/\s+//g; } > > foreach( 0..$#data ) { $results[$_] .= $data[$_]; } > >} > This is a little shorter and saves on iterations: > for m

Reading input and Word completion

2004-09-10 Thread Manish
Hi, I'm new to perl and I'm trying to write a simple program that will take commands from user. I would like to provide command completion. Currently I have: use Term::ReadLine; use Term::Complete; while (true) { $mainTerm = Term::ReadLine->new("Top Level"); $OUT = $mainTerm->OUT ||

Re: Threads Perl On Solaris

2004-09-10 Thread Chris Devers
On Fri, 10 Sep 2004, Eduardo Vazquez Rodriguez wrote: how can I create a thread on Perl (Im using SPARC architecture) so each thread (or child process) can process each function? and therefore increase speed Read this, try it out, then let us know if you have problems:

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
I'm no expert, but chomp won't give you what you think it will: my @arr = ('a', "b\n", "c\n"); print join (",",chomp (@arr)); This will print: 2 while this: my @arr = ('a', "b\n", "c\n"); chomp (@arr); print join (",",@arr); will print: a,b,c Map will run whatever is in the code block (between

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
On Fri, 10 Sep 2004 12:44:51 -0400, David Greenberg <[EMAIL PROTECTED]> wrote: > >foreach( @ARGV ) { > > open IN, $_ or die "Couldn't open $_: $!\n"; > > chomp( my @data = ); > > close IN; > > foreach( @data ) { s/\s+//g; } > > foreach( 0..$#data ) { $results[$_] .= $

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
>foreach( @ARGV ) { > open IN, $_ or die "Couldn't open $_: $!\n"; > chomp( my @data = ); > close IN; > foreach( @data ) { s/\s+//g; } > foreach( 0..$#data ) { $results[$_] .= $data[$_]; } >} This is a little shorter and saves on iterations: for my $file (@ARGV) {

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
Here ya go ... this works for me. I tested it with up to 5 input files and it was still workin'. It does have a bug, though. It doesn't check whether all the input files are the same length. Nor did I test what happens when they AREN'T the same length. Let me know what ya think: #!/usr/bin/pe

RE: CC mit Mailprog funktioniert nicht

2004-09-10 Thread Charles K. Clarkson
From: Chris Devers wrote: : On Fri, 10 Sep 2004, Casey West wrote: : : : Agreed. : : I stand happily overruled :-) I think we should all chip in and get poor Chris a chair. I type better sitting. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread Errin Larsen
Well, I'm kinda new at this stuff myself, but Here's a couple of things I see right away: On Sat, 11 Sep 2004 10:27:44 +0800, Edward WIJAYA <[EMAIL PROTECTED]> wrote: > Hi, <> > #!/usr/bin/perl -w --You don't really need to use the -w flag here AND the 'use warnings' in your subroutine d

Threads Perl On Solaris

2004-09-10 Thread Eduardo Vazquez Rodriguez
Hello everyone out there using Perl. Im doing perl scripts that parses log files of networking devices. In this forum thanks to everyone suggest me to take several lines at time. I can do that already, but I have another problem. If I read 5 lines at time I have to process each once at time, ma

Copying files from One PC to another.

2004-09-10 Thread Denham Eva
Hello Listers. Please I am a beginner. I am making tentative steps to creating a script which will keep my Notebook and Workstation at work in sync. My first attempt is just to copy the files from the one to local. Here is my script - it works, but I suspect there should be a better way to d

How to dynamically taking the multiple input arguments?

2004-09-10 Thread Edward WIJAYA
Hi, I have a simple code that take currently fixed to take 3 input files and append each line of these files together. I wish to know is there anyway I can write the code more flexibly so it can dynamically take the input argument - from minimum 2 files to more. Is there anywhere I can find informa

Re: CC mit Mailprog funktioniert nicht

2004-09-10 Thread Errin Larsen
On Fri, 10 Sep 2004 09:09:43 -0500, Errin Larsen <[EMAIL PROTECTED]> wrote: > Ok ... in the spirit of universal Perl-ing, <> Oops ... I didn't realize he re-posted to the list in English ... Never Mind! --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [E

Re: CC mit Mailprog funktioniert nicht

2004-09-10 Thread Errin Larsen
Ok ... in the spirit of universal Perl-ing, I'll try to translate the below for the rest of us on the list! I put my notes that are in the code inside "--( )--" marks. I'm not really good at this sort of thing, but with the help of some "Google-ing" and what not, here goes ... On Fri, 10 Sep 20

Re: CC mit Mailprog funktioniert nicht

2004-09-10 Thread Chris Devers
On Fri, 10 Sep 2004, Casey West wrote: Agreed. I stand happily overruled :-) -- Chris Devers [EMAIL PROTECTED] http://devers.homeip.net:8080/blog/ np: 'Coin- Operated Boy' by The Dresden Dolls from 'The Dresden Dolls' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman

Re: CC mit Mailprog funktioniert nicht

2004-09-10 Thread Casey West
It was Friday, September 10, 2004 when Paul Johnson took the soap box, saying: : On Thu, Sep 09, 2004 at 07:41:56PM -0400, Chris Devers wrote: : > On Fri, 10 Sep 2004, Reinhold Riedersberger wrote: : > : > >ich habe ein f?r mich seltsames Problem: : : > This is an English language list. : > : >

Re: CC mit Mailprog funktioniert nicht

2004-09-10 Thread Paul Johnson
On Thu, Sep 09, 2004 at 07:41:56PM -0400, Chris Devers wrote: > On Fri, 10 Sep 2004, Reinhold Riedersberger wrote: > > >ich habe ein für mich seltsames Problem: > This is an English language list. > > Please pose your question in English, not German. I don't know about that. Whilst it's true

Re: foreach + shift

2004-09-10 Thread Randal L. Schwartz
> "Fei" == Fei Li <[EMAIL PROTECTED]> writes: Fei> foreach (@test){ Fei> my $n= shift (@test); The foreach loop walks over the array "live". If you modify the array inside the loop, the results are definite, but often unexpected. Maybe you want instead: while (@test) { # do until

foreach + shift

2004-09-10 Thread Fei Li
The source program is: #! /usr/bin/perl -w my @test =qw /test1 test2 test3 test4 test5 test6 test7/; my $count =0; $total = @test; foreach (@test){ my $n= shift (@test); $count++; print "$n $count of $total\n"; print "@test\n"; } print "\n\n==\n\n"; foreach (@test){ $count