in reply to Re: in file insert character in every row on nth position
in thread in file insert character in every row on nth position

please tell me in format of script...all i am doing is inside a script. Unfortunately i am not much familiar about how to use commands inside perl script.

  • Comment on Re^2: in file insert character in every row on nth position

Replies are listed 'Best First'.
Re^3: in file insert character in every row on nth position
by kcott (Archbishop) on Feb 12, 2016 at 08:52 UTC
    "Unfortunately i am not much familiar about how to use commands inside perl script."

    This would be a good place to start: perlintro: Perl introduction for beginners

    This document will lead you through the creation of a Perl script. It's not particularly lengthy and shouldn't take you long to read. Each section has links to more detailed information: follow as necessary.

    — Ken

Re^3: in file insert character in every row on nth position
by JobC (Acolyte) on Feb 11, 2016 at 20:31 UTC

    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