implementing getopts when called by functions

Discussion in 'Perl Misc' started by Ironhide, Oct 28, 2008.

  1. Ironhide

    Ironhide Guest

    Hi,

    Is it possible to do this in perl?
    If yes, please let me know how.

    sub A {

    IOWorkload -v .. -a ..

    }

    sub IOWorkload {
    ...
    ...
    }

    _G
    Ironhide, Oct 28, 2008
    #1
    1. Advertising

  2. Ironhide <> wrote:
    >Is it possible to do this in perl?
    >If yes, please let me know how.
    >
    >sub A {


    Yes.

    >IOWorkload -v .. -a ..


    No. The range operator is a binary operator, i.e. there is a missing
    value at the end of that line.
    Also, using two range operators like that most likely won't produce the
    results you may be expecting because one of the lists will be converted
    to a scalar as argument for the second range op.

    >}
    >
    >sub IOWorkload {


    No. IOWorkload must be declared before being used if you want to omit
    the paranthesis in the call.

    jue
    Jürgen Exner, Oct 28, 2008
    #2
    1. Advertising

  3. Ironhide

    smallpond Guest

    On Oct 28, 4:55 am, Ironhide <> wrote:
    > Hi,
    >
    > Is it possible to do this in perl?
    > If yes, please let me know how.
    >
    > sub A {
    >
    > IOWorkload -v .. -a ..
    >
    > }
    >
    > sub IOWorkload {
    > ..
    > ..
    >
    > }
    >
    > _G



    You could try something like:

    use Getopt::Tiny;

    sub IOWorkload($) {
    $_ = shift;
    my @ARGS = split;
    smallpond, Oct 28, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hans van Vooren

    Usage of --help and --version in getopts()

    Hans van Vooren, May 27, 2004, in forum: Perl
    Replies:
    1
    Views:
    545
    Jim Gibson
    May 27, 2004
  2. lnatz

    getopts::std

    lnatz, Jul 27, 2006, in forum: Perl Misc
    Replies:
    7
    Views:
    101
    Uri Guttman
    Jul 28, 2006
  3. vabby
    Replies:
    3
    Views:
    90
    vabby
    Jan 23, 2007
  4. vabby
    Replies:
    0
    Views:
    63
    vabby
    Jan 23, 2007
  5. is this a bug in getopts

    , Feb 7, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    111
    Brian McCauley
    Feb 7, 2007
Loading...

Share This Page