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

  1. #1

    Default Use Strict Error

    When I use the following portion of Perl code:
    __________________________________________________

    #!/usr/bin/perl
    # use with:
    # perl IfThenElse tfcfam (Use all of this at the command line!)

    use strict;
    use warnings;

    print "Search by name: ";

    my $name = <STDIN>;
    'egrep $name testing.txt'

    #my(@col1, @col2, @col3);
    my @col1;
    my @col2;
    my @col3;
    my $col = 1;
    my ($find);

    __________________________________________________

    I get the following error:

    syntax error at trashthistest2 line 17, near "my "
    Global symbol "@col1" requires explicit package name at trashthistest2 line 17.
    Global symbol"@col1" requires explicit package name at trashthistest2 line 40.
    Global symbol "@col1" requires explicit package name at trashthistest2 line 53.
    Global symbol "@col1" requires explicit package name at trashthistest2 line 59.
    Global symbol "@col1" requires explicit package name at trashthistest2 line 81.
    Execution of trashthistest2 aborted due to compilation errors.

    __________________________________________________

    If I have declared my @col1 at line 17, why am I getting these errors?

    Thanks for any assitance you can offer.

    Bill J.

    Bill Jastram Guest

  2. Similar Questions and Discussions

    1. how to strict the movement?
      i got this behavior from a tutorial on web. i drag and drop it to my 3d member, and it works great. i can move the model i clicked anywhere on the...
    2. Use strict with plperl
      In 8.0 how does one have a plperl function use strict? If I add "use strict" within the function body I receive an error message: "creation of...
    3. use strict and filehandles
      Hi All, I'm having trouble understanding what use strict is trying to tell me. If I have run this program ...
    4. Using strict references
      Hi, I am trying to write all of my code using strict to improve my code. However, the correct use of references for the following problem...
    5. Does Option Strict On add overhead?
      By turning Option Strict on, is there extra overhead? For example w/o it on the following doesnt get flagged: validxhtml.Attributes.Add("height",...
  3. #2

    Default Re: Use Strict Error

    Bill Jastram wrote:
    >
    > When I use the following portion of Perl code:
    > __________________________________________________
    >
    > #!/usr/bin/perl
    > # use with:
    > # perl IfThenElse tfcfam (Use all of this at the command line!)
    >
    > use strict;
    > use warnings;
    >
    > print "Search by name: ";
    >
    > my $name = <STDIN>;
    > 'egrep $name testing.txt'
    >
    > #my(@col1, @col2, @col3);
    > my @col1;
    > my @col2;
    > my @col3;
    > my $col = 1;
    > my ($find);
    >
    > __________________________________________________
    >
    > I get the following error:
    >
    > syntax error at trashthistest2 line 17, near "my "
    > Global symbol "@col1" requires explicit package name at trashthistest2 line 17.
    > Global symbol"@col1" requires explicit package name at trashthistest2 line 40.
    > Global symbol "@col1" requires explicit package name at trashthistest2 line 53.
    > Global symbol "@col1" requires explicit package name at trashthistest2 line 59.
    > Global symbol "@col1" requires explicit package name at trashthistest2 line 81.
    > Execution of trashthistest2 aborted due to compilation errors.
    >
    > __________________________________________________
    >
    > If I have declared my @col1 at line 17, why am I getting these errors?
    Hi Bill.

    Your code isn't the most maintainable I've seen (your line 17 is the 14th in
    the code you showed) but what's the stray string
    > 'egrep $name testing.txt'
    doing at 'line 14'? Slap a semicolon after it and it will compile, but then
    you've just shelled out, run 'egrep' and thrown the results away.

    May I also make a preemptive strike and say that you seem to be writing a
    shell script in Perl. Almost all backticks or 'system' calls are a bad idea:
    Perl usually knows how to do it better than you do, so code it in Perl.

    Rob


    Rob Dixon Guest

  4. #3

    Default RE: Use Strict Error

    Please bottom post.
    > 1. You are missing ";"
    > Type
    > `egrep $name testing.txt`;
    > And not
    > 'egrep $name testing.txt'
    >
    > Not the backticks and not quotes ...
    >
    There's also no reason to use backticks in void context.

    perldoc -f system

    Please use full paths, error check, etc. if you are going to shell out,
    which brings me to the next point, why shell out to 'egrep' in the first
    place, you should either do it in Perl using open, while, a regex, etc.
    or use a shell script....

    [url]http://danconia.org[/url]
    Wiggins D Anconia 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