I am pretty new and I was wondering about this too. I asked the question on the chatterbox and this is the result.

[JobC] I occasionally read the questions and answers posted on SOPW +. Often I will see answers that show how to do something from a comma +nd line. How can this then be converted to a script? [shmem] essentially you put the quoted text after -e into a file [MidLifeXis] Which platform? [JobC] Like this one: in file insert character in every row on nth +position [JobC] i am using strawberry perl on windows [MidLifeXis] There may be some nuances based on Windows/Unix(sh,ksh +,csh,zsh)/VMS, and so on. [MidLifeXis] Is your environment set up to run .pl scripts on click +? [JobC] I have never tried that. I am using cmd shell [MidLifeXis] If you do SET PATHEXT, is .pl in the provided list? [shmem] then you add a line # *perl * at the top and add switches a +fter perl [MidLifeXis] perl -Mlib1 -Mlib2 -e 'foo(bar())' [JobC] nope .pl is not there.\ [shmem] shmem fades out [MidLifeXis] Then just do as shmem is saying, and execute: perl scr +iptname.pl [MidLifeXis] My example above would go into foo.pl as "use lib1;\nu +se lib2\nfoo(bar());\n" (replace '\n' with a newline) [JobC] Ok, Thanks! [MidLifeXis] Recommendation: always (or at least until you know why + you shouldn't) use use strict; use warnings at the top of your scrip +t. [MidLifeXis] Helps to catch very comment typos and mistakes. [MidLifeXis] *common, not comment

hopefully this helps you as much as it helped me


In reply to Re^3: in file insert character in every row on nth position by JobC
in thread in file insert character in every row on nth position by ukhare

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.