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
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 .
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
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
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
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
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
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
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
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
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
"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
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;
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::
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
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
> 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
17 matches
Mail list logo