Re: Need an explanation

2005-08-26 Thread John W. Krahn
Binish A R wrote: > I've a file, which has entries like the following ... > > IDENTIFIER1=value1; > IDENTIFIER2=value2; > IDENTIFIER3=value3; > > etc > > I've got to parse the above file and am using a hash to do the same ... Have you thought about using one of the many modules on CPAN that doe

Re: System, shell question

2005-08-26 Thread John W. Krahn
steve tran wrote: > Hello Hello, > I am a beginner to perl and I have a question > > if I want to use system or open or backticks to > execute a system command, > like system("$cmd arg1"); ( with system for instance) > > and the $cmd which is a prog takes another program > called in arg1 , a

Re: the time a program runs

2005-08-26 Thread John W. Krahn
Octavian Rasnita wrote: > Hi, Hello, > I have tried to find out the time a perl program runs, and I have used: > > #at the start of the program: > my $begin = (times)[0]; > my $begin_t = time(); > > ... The program follows > > # at the end of the program: > my $end = (times)[0] - $begin; > my

Re: Dot and Dubble Dot directory names

2005-08-26 Thread JupiterHost.Net
In a program such as the following - #!/usr/local/bin/perl -w # always always always use strict and warnings!!! use strict; use warnings; use File::Spec; $windir = "/home/users/tony"; my $windir = '/home/users/tony'; open

Dot and Dubble Dot directory names

2005-08-26 Thread Tony Frasketi
In a program such as the following - #!/usr/local/bin/perl -w $windir = "/home/users/tony"; opendir(NT, $windir) || die "no $windir?: $!"; while ($name = readdir(NT)) { # scalar context, one per loop print "$name\n"; # pr

Re: Directories into arrays, again.

2005-08-26 Thread JupiterHost.Net
Then that would be the code to show :) although I bet strict/warnings/and checking your open's (or die $!;) will show you what is wrong :) <<< I see, however that is still the best practice to be in, especially when asking for assistance since it catches 99.9% of little issues. No, the .

RE: Need a list of files in a dir.

2005-08-26 Thread Daniel Kurtz
From: Bob Showalter [mailto:[EMAIL PROTECTED] >>> OK, you weren't kidding. Since you're new to Perl, you get a free pass :~) <<< I appreciate the indulgence . >>> Seriously, though, not all of us run Perl on Windows. Your approach is Windows-specific. <<< True, I hadn't thought of that. I'm p

Re: Need a list of files in a dir.

2005-08-26 Thread Bob Showalter
Daniel Kurtz wrote: Bob Showalter wrote: Please tell me you're kidding. Why? It works. The question asked how you can do it, not the BEST way to do it. And after a week of Perling, this was the one way I knew. Now I know two ways. OK, you weren't kidding. Since you're new to Perl, you get

RE: Need a list of files in a dir.

2005-08-26 Thread Ryan Frantz
> -Original Message- > From: Daniel Kurtz [mailto:[EMAIL PROTECTED] > Sent: Friday, August 26, 2005 3:49 PM > To: beginners@perl.org > Subject: RE: Need a list of files in a dir. > > From: Randal L. Schwartz [mailto:[EMAIL PROTECTED] > >>> Daniel> Why? It works. > > Not on Unix it doesn't

Re: map/grep and arrays

2005-08-26 Thread Tom Allison
>print join( ',', map { s/[\r\n]+//g; $_ } @row ), "\n"; bingo! I wasn't doing the ;$_ thingy in map. Putting the $_ at the end of the block isn't very intuitive, but it's "like" a 'return $_' call in a function. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EM

RE: Need a list of files in a dir.

2005-08-26 Thread Daniel Kurtz
From: Randal L. Schwartz [mailto:[EMAIL PROTECTED] >>> Daniel> Why? It works. Not on Unix it doesn't. And there are far more Unix installations of Perl than Windows installations of Perl. <<< Good point. Although... while I'm certain that a higher PERCENTAGE of Unix systems have Perl than Wind

RE: Directories into arrays, again.

2005-08-26 Thread Daniel Kurtz
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] > # Execute a command that backs up every file in the directory # with a > .bak extension. >>> Um, ok so you're wondering why there are no .bak files? Then that would be the code to show :) although I bet strict/warnings/and checking your open's

RE: Directories into arrays, again.

2005-08-26 Thread Daniel Kurtz
Excellent points, all From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] >>> And a reason why using a shell command to copy a file is a bad idea. <<< Well, the 'shell' and 'copy' association in this case is actually something of a red herring. The point of this particular script is not to copy fi

Re: Need a list of files in a dir.

2005-08-26 Thread Randal L. Schwartz
> "Daniel" == Daniel Kurtz <[EMAIL PROTECTED]> writes: Daniel> Why? It works. Not on Unix it doesn't. And there are far more Unix installations of Perl than Windows installations of Perl. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.

Re: Access denied

2005-08-26 Thread Kris Van Bruwaene
On 8/25/05, Karyn Williams <[EMAIL PROTECTED]> wrote: > At 11:29 AM 8/25/05 +0200, you wrote: > >On 8/24/05, Karyn Williams <[EMAIL PROTECTED]> wrote: > Try changing your shell to /bin/sh and then try running the script from the > command line. That won't help, my sh is a symlink to bash. > >> I ca

Re: Directories into arrays, again.

2005-08-26 Thread JupiterHost.Net
Daniel Kurtz wrote: Sorry, obviously the code is supposed to read: Actually it should read: use strict; use warnings; opendir( DIR1, "."); opendir DIR1, '.' or die "Could not open .: $!"; @before = readdir(DIR1); my @before = readdir DIR1; closedir(DIR1); # Execute a command that

Re: odd benchmark result, map vs foreach

2005-08-26 Thread Wiggins d'Anconia
Scott R. Godin wrote: > Wiggins d'Anconia wrote: > >> Your benchmark isn't controlled. In the first instance you are doing a >> ++ on what amounts to a scalar getting autovivified, in the second >> instance you are assigning a pair of values to a list then autovivifying >> it. It isn't necessarily

Re: Directories into arrays, again.

2005-08-26 Thread Wiggins d'Anconia
Daniel Kurtz wrote: > From: Daniel Kurtz [mailto:[EMAIL PROTECTED] > Why does @after end up looking exactly like @before? Is there some > > buffering going on here? And if so, how do I clear it? <<< > > Never mind, I figured it out. The file copying operation is another > shell operation (c

PLEASE HELP

2005-08-26 Thread Angie
I am sorry to bother the list folks with this, but I am trying to get off this list. I have sent SEVERAL unsubscribe from this list to [EMAIL PROTECTED] and every other alias provided in the welcome e-mail. No dice! Nothing! I even wrote an e-mail to the supposed "human" e-mail. Any help would

System, open, SHELL redirect

2005-08-26 Thread steve tran
Hello, I guess I wasnt clear enough in my earlier mail. what I meant was lets say I have 2 programs, exe1 and exe2 exe2 is input to exe1 so I want to call this from my perl wrapper as system ("exe1 exe2"); or `exe1 exe2`; If I want to capture STDOUT from exe1 thats simple if I redirect

Re: Need an explanation

2005-08-26 Thread Binish A R
[EMAIL PROTECTED] wrote: while (<>) {   chomp;   next if /^#/;   next if /^$/;   $CONF{(split/=/)[0]}=(split/=/)[1]; } -Original Message- From: Binish A R <[EMAIL PROTECTED]> To: Perl Beginners Cc: [EMAIL PROTECTED] Sent: Fri,

Re: Need an explanation

2005-08-26 Thread angelflowercn
while (<>) { chomp; next if /^#/; next if /^$/; $CONF{(split/=/)[0]}=(split/=/)[1]; } -Original Message- From: Binish A R <[EMAIL PROTECTED]> To: Perl Beginners Cc: [EMAIL PROTECTED] Sent: Fri, 26 Aug 2005 23:04:58 +0530 Subject: Re: Need an explanation [EMAIL P

RE: Directories into arrays, again.

2005-08-26 Thread Daniel Kurtz
From: Daniel Kurtz [mailto:[EMAIL PROTECTED] >>> Why does @after end up looking exactly like @before? Is there some buffering going on here? And if so, how do I clear it? <<< Never mind, I figured it out. The file copying operation is another shell operation (c'mon, I'm a newby, and I've only rea

Re: Need an explanation

2005-08-26 Thread Binish A R
[EMAIL PROTECTED] wrote: maybe this is brief: while (<>) {    chomp;    next if /^#/;    next if /^$/;    my ($var1,$var2)=split /=/;    $CONF{$var1}=$var2; } -Original Message- From: Binish A R <[EMAIL PROTECTED]> To: Perl Begin

Re: odd benchmark result, map vs foreach

2005-08-26 Thread Scott R. Godin
Wiggins d'Anconia wrote: Your benchmark isn't controlled. In the first instance you are doing a ++ on what amounts to a scalar getting autovivified, in the second instance you are assigning a pair of values to a list then autovivifying it. It isn't necessarily the map vs. foreach that is causing

Re: odd benchmark result, map vs foreach

2005-08-26 Thread Scott R. Godin
John W. Krahn wrote: Scott R. Godin wrote: Interesting .. I would have thought that map would be faster, but it appears that foreach is, in this instance. curious.. :) [snip] To be equivalent the foreach sub should use assignment instead of postincrement (which is also faster.) Interest

RE: Directories into arrays, again.

2005-08-26 Thread Daniel Kurtz
Sorry, obviously the code is supposed to read: opendir( DIR1, "."); @before = readdir(DIR1); closedir(DIR1); # Execute a command that backs up every file in the directory # with a .bak extension. opendir( DIR2, "."); @after = readdir(DIR2); closedir(DIR2); It still doesn't work. daniel -- To

Directories into arrays, again.

2005-08-26 Thread Daniel Kurtz
OK, since everyone's making fun of my suggestion of using the output of a shell command as a means of getting a directory listing into an array , please explain to me what's wrong with this code I'm trying, using opendir and readdir: opendir( DIR1, "."); @before = readdir(DIR); closedir(DIR1); #

Re: Need an explanation

2005-08-26 Thread angelflowercn
maybe this is brief: while (<>) { chomp; next if /^#/; next if /^$/; my ($var1,$var2)=split /=/; $CONF{$var1}=$var2; } -Original Message- From: Binish A R <[EMAIL PROTECTED]> To: Perl Beginners Sent: Fri, 26 Aug 2005 22:28:22 +0530 Subject: Need an expla

Re: System, shell question

2005-08-26 Thread Binish A R
steve tran wrote: Hello I am a beginner to perl and I have a question if I want to use system or open or backticks to execute a system command, like system("$cmd arg1"); ( with system for instance) and the $cmd which is a prog takes another program called in arg1 , and that program(arg

RE: Need a list of files in a dir.

2005-08-26 Thread Daniel Kurtz
Bob Showalter wrote: > Please tell me you're kidding. Why? It works. The question asked how you can do it, not the BEST way to do it. And after a week of Perling, this was the one way I knew. Now I know two ways. daniel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-ma

Need an explanation

2005-08-26 Thread Binish A R
I've a file, which has entries like the following ... IDENTIFIER1=value1; IDENTIFIER2=value2; IDENTIFIER3=value3; etc I've got to parse the above file and am using a hash to do the same ... Here is my code ... while (<>) { chomp; next if /^#/; next if /^$/; %CONF =

RE: Need a list of files in a dir.

2005-08-26 Thread Chance Ervin
-Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Friday, August 26, 2005 9:40 AM To: Daniel Kurtz; beginners@perl.org Subject: Re: Need a list of files in a dir. Daniel Kurtz wrote: > Ooh ooh ooh! One I know! > > open(COMMAND, "dir |"); > @files = ; Please tell m

Re: Need a list of files in a dir.

2005-08-26 Thread Bob Showalter
Daniel Kurtz wrote: Ooh ooh ooh! One I know! open(COMMAND, "dir |"); @files = ; Please tell me you're kidding. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Need a list of files in a dir.

2005-08-26 Thread Luinrandir
Thanks Daniel.. and keep on TOP POSTING! Gawd I hate bottom posting! Lou Hernsen (.. and so my children the war between the topposters and bottomposters began The topposters, light happy and joyous beings ; the bottomposters, smelly and scragly and living below the earth in tunnels and caves in

RE: Need a list of files in a dir.

2005-08-26 Thread Ryan Frantz
> -Original Message- > From: Luinrandir [mailto:[EMAIL PROTECTED] > Sent: Friday, August 26, 2005 2:53 PM > To: Daniel Kurtz > Cc: beginners@perl.org > Subject: Re: Need a list of files in a dir. > > Thanks Daniel.. and keep on TOP POSTING! > Not to start a flame war, but it has been e

System, shell question

2005-08-26 Thread steve tran
Hello I am a beginner to perl and I have a question if I want to use system or open or backticks to execute a system command, like system("$cmd arg1"); ( with system for instance) and the $cmd which is a prog takes another program called in arg1 , and that program(arg1) requires STDIN, and I

RE: Need a list of files in a dir.

2005-08-26 Thread Ryan Frantz
> -Original Message- > From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] > Sent: Friday, August 26, 2005 11:27 AM > To: Daniel Kurtz > Cc: beginners@perl.org > Subject: Re: Need a list of files in a dir. > > Please bottom post... > > Daniel Kurtz wrote: > > Ooh ooh ooh! One I know! > >

the time a program runs

2005-08-26 Thread Octavian Rasnita
Hi, I have tried to find out the time a perl program runs, and I have used: #at the start of the program: my $begin = (times)[0]; my $begin_t = time(); ... The program follows # at the end of the program: my $end = (times)[0] - $begin; my $end_t = time() - $begin_t; print "end: $end\nEnd_t: $en

Re: Need a list of files in a dir.

2005-08-26 Thread Wiggins d'Anconia
Please bottom post... Daniel Kurtz wrote: > Ooh ooh ooh! One I know! > > open(COMMAND, "dir |"); > @files = ; > Sort of, while that *may* work it doesn't have proper error checking, is less secure, less efficient, and less portable than many other ways, especially those already provided. This

RE: Need a list of files in a dir.

2005-08-26 Thread Daniel Kurtz
Ooh ooh ooh! One I know! open(COMMAND, "dir |"); @files = ; Daniel -Original Message- From: Luinrandir [mailto:[EMAIL PROTECTED] Sent: Thursday, August 25, 2005 21:33 To: beginners@perl.org Subject: Need a list of files in a dir. How do I get the list of files in a DIR and put in an a

Re: use Module VERSION; ignoring version???

2005-08-26 Thread JupiterHost.Net
You'll see that the author of this module has incorrectly implemented the VERSION method as: sub VERSION { $VERSION } From perldoc UNIVERSAL: "VERSION ( [ REQUIRE ] )" "VERSION" will return the value of the variable $VERSION in the package the object is blessed in

Cvs.pm

2005-08-26 Thread Chris Knipe
Just a quickie... I'm trying to get to use Cvs.pm... I'm BATTLING. For one, the documentation, indicates that errors is reported by $Cvs::ERROR. $Cvs::ERROR, does not even exist in the module Does anyone have some info on how I could get some DECENT code working with this module?? Afte

Cvs.pm

2005-08-26 Thread Chris Knipe
Just a quickie... I'm trying to get to use Cvs.pm... I'm BATTLING. For one, the documentation, indicates that errors is reported by $Cvs::ERROR. $Cvs::ERROR, does not even exist in the module Does anyone have some info on how I could get some DECENT code working with this module?? After

Re: map/grep and arrays

2005-08-26 Thread Xavier Noria
On Aug 26, 2005, at 13:19, Tom Allison wrote: I keep getting hung up on what I think would be a simple problem. I was to do approximately this: Given an array of "stuff" print them out print join(",", @row),"\n"; works great until your array elements contain dumb characters like \n\r somewh

Re: map/grep and arrays

2005-08-26 Thread John W. Krahn
Tom Allison wrote: > I keep getting hung up on what I think would be a simple problem. > > I was to do approximately this: > > Given an array of "stuff" print them out > print join(",", @row),"\n"; > > works great until your array elements contain dumb characters like \n\r > somewhere in the str

Re: map/grep and arrays

2005-08-26 Thread Manav Mathur
- Original Message - From: "Tom Allison" <[EMAIL PROTECTED]> To: "beginners perl" Sent: Friday, August 26, 2005 4:49 PM Subject: map/grep and arrays > I keep getting hung up on what I think would be a simple problem. > > I was to do approximately this: > > Given an array of "stuff" p

Re: Program is exiting on a failure

2005-08-26 Thread Tom Allison
Wiggins d'Anconia wrote: Chris Lyon wrote: I seem to be erroring out @ the $session->login portion of my program because the module that I am call is saying the password/username is bad. How do I trap the error and exit cleanly without just dumping from the application: login failed: access d

map/grep and arrays

2005-08-26 Thread Tom Allison
I keep getting hung up on what I think would be a simple problem. I was to do approximately this: Given an array of "stuff" print them out print join(",", @row),"\n"; works great until your array elements contain dumb characters like \n\r somewhere in the string (not always at the end!). Ini