RE: Directories into arrays, again.



Excellent points, all

From: Wiggins d'Anconia [mailto:wiggins@xxxxxxxxxxxx]
>>> 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 files, it is to illustrate to a non-programmer an easy and dirty
way of executing a program and then capturing some 'results' for
analysis. In this case, the file copying batch program was used simply
because it produces readily verifiable results (either the .bak files
are there, one for each original file specified, or they're not.)

>>>opendir DIR2, '.' or die "Can't open directory for reading a second
time: $!";
my @after = readdir DIR2;
closedir DIR2; <<<

Well, I boiled the script down to essentials before posting it,
including taking out some error handling (not on these particular
commands though.) However, in this particular instance, there were no
errors to trap. The *dirs worked correctly, they just weren't picking up
the changes made to the directory because those changes were not visible
to Perl until after the file handle to the shell was closed or otherwise
reset.

>>> As an aside, if you must use a shell command you are better off
sticking with system, until you need the output which is provided by
backticks, only use the piped open form when you need to communicate
with the command you are running. <<<

I'm certain you're right. As it happens, in this particular instance the
script IS piping additional messages to the shell. Is open() the only
means of doing that?

daniel
.



Relevant Pages

  • Re: How to set /etc/fstab again after system has started
    ... on a Linux desktop somewhere. ... that shell prompt become somewhat more important. ... For me, the big one is "select", which allows any shell command or alias ...
    (comp.os.linux.misc)
  • Re: How to set /etc/fstab again after system has started
    ... on a Linux desktop somewhere. ... that shell prompt become somewhat more important. ... For me, the big one is "select", which allows any shell command or alias ...
    (comp.os.linux.misc)
  • Re: Files launched w/ Followhyperlink open but not visible
    ... It appears that you got a useful answer on using Shell. ... New Window argument. ... it opens an instance of the software registered ... Yes I have considered the Shell command. ...
    (comp.databases.ms-access)
  • Re: [OT] Vim Question
    ... How do you invoke a shell command and pass arguments to said command? ... foo bar foobar barfoo a b c ...
    (comp.lang.ruby)
  • Re: Launch VBS from VBA
    ... "Chip Pearson" wrote: ... To shell and wait for the Shell to end, ... Shall I call the function before the Shell command or within the Shell ... If you need to wait for the script to finish before continuing with your ...
    (microsoft.public.excel.programming)