RE: Directories into arrays, again.

2005-08-29 Thread Daniel Kurtz
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] > Or weren't. >>> So its working now then? What changed? <<< Changes to the file system wrought in the shell are not visible to the calling Perl program until the shell's file handle is closed or otherwise reset. Simply had to close() the file h

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: 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: 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: 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

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: 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

Re: directories

2001-11-21 Thread Jenda Krynicky
From: Dave Rankin <[EMAIL PROTECTED]> > You can use the -d operator to test for a directory. > > print "Found directory!\n" if (-d "/path/to/directory"); > > (Just make sure you use the c:\\path\\to\\directory format on Windows.) Perl doesn't care whether you use forward or

Re: directories

2001-11-21 Thread Dave Storrs
Any of the following should work for you: if ( -e $dirpath && -d $dirpath ) { ...stuff...} if ( -e $dirpath && -d _ ) { ...stuff...} if ( -d $dirpath ) { ...stuff...} You can always substitute $dirpath for a literal string path in the above as well...e.g.: if ( -d '/usr/bin/home' ) { ... stuff

Re: directories

2001-11-21 Thread Dave Rankin
You can use the -d operator to test for a directory. print "Found directory!\n" if (-d "/path/to/directory"); (Just make sure you use the c:\\path\\to\\directory format on Windows.) HTH. -Dave On Wednesday 21 November 2001 10:41 am, [EMAIL PROTECTED] wrote: > what is the best way to check f

Re: Directories, Arrays

2001-10-26 Thread Andrea Holstein
"Beau E. Cox" wrote: > >>3. How do I do a pattern search that looks for capital > >>words only? > > Try this: > > my $test = "Test: HELLO my name is BEAU Cox"; > $_ = $test; > my @cap_words = /\s*([A-Z0-9\.@_]+?)\s+/g; > print "@cap_words\n"; > > NOTE: the search

RE: Directories, Arrays

2001-10-26 Thread Beau E. Cox
Hi Ben, I am _not_ an expert, but... >>1. How can I get a directory listing ONLY? Try File::Find (search www.CPAN.org for the package documentation - It should be in your Perl distribution by default. #!/usr/bin/perl # # File:Find recursive directory search example example # use strict;

Re: Directories

2001-07-20 Thread Michael Fowler
On Fri, Jul 20, 2001 at 05:56:43AM -0400, Porter, Chris wrote: > Could I please have an example of the rmtree function. Everytime I try to > run this function my script dies on me. I'm sure I'm just missing a small > part of it. Can you give us an example of how you're using it? perldoc File::

RE: Directories

2001-07-20 Thread Porter, Chris
quot;} -Original Message- From: Craig Moynes/Markham/IBM [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 10, 2001 9:02 AM To: Porter, Chris Cc: '[EMAIL PROTECTED]' Subject: Re: Directories > Calling perl gurus, > Hello, help please!!! Looking

Re: Directories

2001-07-10 Thread Michael Fowler
On Tue, Jul 10, 2001 at 09:02:21AM -0400, Craig Moynes/Markham/IBM wrote: > I am having some difficulty understanding your question. > If you just want to modify this script so that it does not die if the > directory contains files change the following: > > [snip] > >if ((-d $Name) and ($Name

Re: Directories

2001-07-10 Thread Craig Moynes/Markham/IBM
> Calling perl gurus, > Hello, help please!!! Looking to delete empty directories, I have a script > for that but if the directories have files in them, it dies. Either can I > add some type of script to delete them also or can I just avoid them all > together and just delete the empty ones. A