in reply to perl script that accepts parameters via STDIN

Welcome to the Monastery, mbravismore!

Normally, I'd skip such a question due to no effort shown whatsoever (please do so in the future), but I thought I'd at least show a basic skeleton that you can at least get started with. See the documentation of Getopt::Long to get an understanding of what is happening. You'll want/need to add in some parameter checking to ensure all required arguments are passed in.

use strict; use warnings; use Getopt::Long; my %args; GetOptions ( 'i|txtpatid=s' => \$args{txtpatid}, 'p|txtpatpw=s' => \$args{txtpatpw}, 's|txtpatserver=s' => \$args{txtpatserver}, ); for (keys %args){ print "$_: $args{$_}\n"; }

Run it:

perl script.pl -i stevieb -p secret -s user

Output:

txtpatid: stevieb txtpatpw: secret txtpatserver: user

Replies are listed 'Best First'.
Re^2: perl script that accepts parameters via STDIN
by LanX (Saint) on Nov 29, 2016 at 13:31 UTC
    I checked Getopt::Long before posting, but couldn't find a mention of parsing STDIN, like the OP wanted.

    How do you fix that?

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Hi LanX,

      Getopt::Long has the functions GetOptionsFromArray and GetOptionsFromString - I only know this because a while back I hacked together a solution to use Getopt::Std on arbitrary strings...

      Regards,
      -- Hauke D

      I think I may have misinterpreted the question ;)