[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 |