So, if you are switching from DOS "batch" scripts to Perl scripts, then:
- everywhere the batch file has "%PARAM%", the perl file will have $param
- everywhere the batch file does "cd some\path" the perl file will do chdir "some/path";
- if the batch file does a lot of "pushd" (especially if it does two or more of these before doing a "popd"), the perl file should have use Cwd; and my @dirstack; near the top. Then everywhere the batch file does "pushd %SOMEDIR%", the perl file will do push @dirstack, getcwd(); chdir $somedir; and everywhere the batch file has "popd", the perl file will have chdir pop @dirstack;
- where the batch file is putting literal strings on a command line, and presenting literal quotation marks as a string of three double-quotes ("""in quotes"""), the perl file will assign a quoted string to a variable or array element, and use a backslash to escape a quotation mark that should be part of the string: $arg = "opt=x(foo,[bar=\"in-quotes\"])";
As indicated above, do
system( @cmd ); or
system( $cmdname, @args ); to actually run some other program from the perl script.
There might be ways to refactor or rethink the design of the batch files, to make better (shorter, easier to maintain) perl scripts, but if you're not a programmer, I don't know how far you'd be able or willing to go in that direction.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.