Problem using Getopts package

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Problem using Getopts package

    I am getting errors when I try to get command line
    parameters.
    For example this small code doesn't work on my
    machine.
    #########################################
    #!/usr/bin/perl -w
    use 'Getopt::Std';

    getopt('de');
    print "U have used d ", if $opt_d;
    print "U have used e ", if $opt_e;
    #########################################


    The interpreter points out an error on the line "use
    'Getopt::Std'"

    __________________________________________________ ______________________
    Yahoo! India Education Special: Study in the UK now.
    Go to [url]http://in.specials.yahoo.com/index1.html[/url]
    Harshal borade Guest

  2. Similar Questions and Discussions

    1. Getopts::std
      I am using various switches in my script. I have the Getopts::std module and I wrote the following line: getopts('F:S:D:T:I:plen', \%OPTS); How...
    2. Again package problem!!!
      I tried to package my publication but think CS has some problems with font copying! In ID 2.0 CE there wern't any problems with fonts. I noticed that...
    3. GetOpts: boolean and argument value combos
      Hey Perl Peps, I am stuck in the mudd and hoping someone can give me a few clues that will help get me back on track. I want to submit some...
    4. Adobe picture package problem
      When I try to print using picture package I get a pop up saying Could not complete picture package because of a command error or disc error. I think...
    5. Picture Package Problem!
      Does anyone know how to reset the background defaults when you make a picture package in Photoshop 7.0? Mine was fine until recently and somehow I...
  3. #2

    Default Re: Problem using Getopts package

    On 02/11/04 06:33, Harshal Borade wrote:
    > I am getting errors when I try to get command line
    > parameters.
    > For example this small code doesn't work on my
    > machine.
    > #########################################
    > #!/usr/bin/perl -w
    > use 'Getopt::Std';
    >
    > getopt('de');
    > print "U have used d ", if $opt_d;
    > print "U have used e ", if $opt_e;
    > #########################################
    >
    >
    > The interpreter points out an error on the line "use
    > 'Getopt::Std'"
    You do not need to quote the module name in a use statement:

    use Getopt::Std;

    Regards,
    Randy.
    Randy W. Sims Guest

  4. #3

    Default Re: Problem using Getopts package

    On 2/11/2004 9:23 AM, Wiggins d Anconia wrote:
    > Actually we can emphasize that 'need' a bit to a 'cannot'. 'use' *must*
    > take a bareword.
    unless it's in an eval ;-)

    perl -Mstrict -we "my $m='Cwd';eval qq(use $m);print cwd();"
    > perldoc -f use
    >
    > [url]http://danconia.org[/url]
    >

    Randy W. Sims Guest

  5. #4

    Default Re: Problem using Getopts package

    "Randy W. Sims" wrote:
    > On 2/11/2004 9:23 AM, Wiggins d Anconia wrote:
    >
    > > Actually we can emphasize that 'need' a bit to a 'cannot'. 'use' *must*
    > > take a bareword.
    >
    > unless it's in an eval ;-)
    >
    > perl -Mstrict -we "my $m='Cwd';eval qq(use $m);print cwd();"
    Not really. In the example above, the module name is not quoted. The string
    constant to be substituted into the eval'ed expression is quoted:
    my $m='Cwd'
    as is necessay for a string assignment to a scalar.
    The expression as a whole is double-quoted, as is required for nterpolated
    strings offered for evaluation.
    eval qq(use $m);
    The module name, though, is not separately quoted. This is actually a simple
    misuse of eval in void context for its side effects .The actual use statement
    that gets processed is not quoted in any way.

    Joseph

    R. Joseph Newton Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139