Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

How do I enter parameters from the Command Line?

by sinan (Sexton)
on Aug 27, 2000 at 12:22 UTC ( #29875=categorized question: print w/replies, xml ) Need Help??
Contributed by sinan on Aug 27, 2000 at 12:22 UTC
Q&A  > CGI programming


When I use in the perl program and run it, I get a line that asks me for name=value pairs on standart input. How do I enter these?

Answer: How do I enter parameters from the Command Line?
contributed by merlyn

Well, a quick typing of perldoc CGI reveals a pretty direct answer without waiting for a fellow monk to go fetch the book and read it to you...

DEBUGGING If you are running the script from the command line or in the perl debugger, you can pass the script a list of key- words or parameter=value pairs on the command line or from standard input (you don't have to worry about tricking your script into reading from environment variables). You can pass keywords like this: keyword1 keyword2 keyword3 or this: keyword1+keyword2+keyword3 or this: name1=value1 name2=value2 or this: name1=value1&name2=value2 To turn off this feature, use the -no_debug pragma. To test the POST method, you may enable full debugging with the -debug pragma. This will allow you to feed new- line-delimited name=value pairs to the script on standard input. When debugging, you can use quotes and backslashes to escape characters in the familiar shell manner, letting you place spaces and other funny characters in your param- eter=value pairs: "name1='I am a long value'" "name2=two\ words +"
Answer: How do I enter parameters from the Command Line?
contributed by athomason

Do just that: enter name=value pairs. For example, if you want the variable node_id to be set to 29875, enter node_id=29875 on a line by itself. Rinse and repeat for each parameter you want to set. When you're finished (or if you don't want to set any at all), enter your EOF control character, which is CTRL-D on most Unix systems and CTRL-Z on Windows.

Please (register and) log in if you wish to add an answer

  • 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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Corion]: marioroy: Oh, that's always cool, having API-compatible modules. This makes testing and comparing things much easier
    [marioroy]: IPC in MCE::Shared can handle 400k (sends) per second. That's seems a lot for being a pure-Perl module. After making the release, will come back and post a solution for a node by a fellow wanting faster logging.
    [Corion]: While working on WWW::Mechanize:: Chrome, I had the suspicion that AnyEvent was doing something wrong, but I was able to swap it out for Mojolicious and the error persisted.
    [Corion]: Of course, the error was in my own code ;)
    [marioroy]: Corion, start and start_child in MCE::Hobo::Manager return a MCE::Hobo object, whereas P::FM returns the PID. I can have it return the PID though. I tried Hobo::Manager with several P::FM modules, just changed P::FM to MCE::Hobo::Manager and it works.
    [marioroy]: I also have a Hobo driver for Forklift allowing folks to use in multiple classes, no conflicts with one another. That's not possible for P::FM.
    [Discipulus]: congrats marioroy!
    [marioroy]: CORE::wait works well eventhough multiple instances or classes using Hobo::Manager.
    [Corion]: marioroy: I'm not sure what the normal use for the PID is in P:FM, but I guess that most programs just ignore or log it

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (6)
    As of 2017-05-26 08:40 GMT
    Find Nodes?
      Voting Booth?