Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Using system (); with Strawberry Perl by bliako
in thread Using system (); with Strawberry Perl by hadrons

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-26 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found