in reply to Using system (); with Strawberry Perl
A quick hack if you have cygwin installed in your computer: run each shell command (grep, mv, etc.) through cygwin's shell, like system("c:/cygwin/bin/bash.exe -c 'rm data2.txt'"); Of course you may be able to call mv.exe, rm.exe by using their fullpath, with something like this: system("c:/cygwin/bin/rm.exe data2.txt");. I am not familiar with cygwin to know if that's possible. If the above works then you can create your own system() to prepend the fullpath to any system command.
sub mysystem { my ($cmd, $args) = @_; my $finalcmd = 'c:/cygwin/bin/'.$cmd.'.exe'.' '.$args; # or ... 'c:/cygwin/bin/bash.exe -c "'.$cmd.' '.$args.'"'; return system($finalcmd); } mysystem("ls", "-al data2.txt > abc")==0 or die "system command failed +";
Thankfully I do not have any windows computer available within the borders of my estate and so all the above are untested. Therefore it is best to avoid use of rm during testing!
EDIT: check also a more elegant rewrite of the above: https://stackoverflow.com/a/55010946 . And also for the bit below, this is an informative post: The problem of "the" default shell
BUT! the advice of other Monks is much more sound than using the hack above: rewrite everything in Perl. Actually jwkrahn++ has done the work for you! Apropos File::Grep being slow, show us the codez.
bw, bliako
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using system (); with Strawberry Perl
by hadrons (Novice) on Nov 25, 2021 at 18:02 UTC | |
|
Re^2: Using system (); with Strawberry Perl
by hadrons (Novice) on Nov 25, 2021 at 19:16 UTC |