www.webdeveloper.com
Results 1 to 2 of 2

Thread: array population only works w/o Strict

  1. #1
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887

    array population only works w/o Strict

    Full source of my file test123.pl:
    Code:
    #!/usr/bin/perl -w
    # use strict;
    use CGI qw(:standard);
    use warnings FATAL => 'all';
    use CGI::Carp qw(fatalsToBrowser);
    print header;
    
    our @markings;my $marking;
    $body='
    <body>
    ...
    <!-- Start marking -->
    &lt;data1&gt;
    <!-- End marking -->
    ...
    <!-- Start marking -->
    &lt;data2&gt;
    <!-- End marking -->
    ...
    </body>
    ';
    
    $marking=$body;
    $marking =~ s/<\!--\s*Start\s+marking\s*-->(.*?)<\!--\s*End\s+marking\s*-->/buildMarkingsArray($1)/iegs;
    print $markings[0];
    
    
    sub buildMarkingsArray{
    push(@markings, $_[0]);return "";
    }
    When not using the Strict module, the above prints:
    Code:
    <data1>
    like it should and as intended.

    When using the Strict module, I get an error:
    Code:
    Software error:
    
    Global symbol "$body" requires explicit package name at /cgi-bin/test123.pl line 9.
    Global symbol "$body" requires explicit package name at /cgi-bin/test123.pl line 23.
    Execution of cgi-bin/test123.pl aborted due to compilation errors.
    My question is how do I revise the above code to work with the Strict module?

  2. #2
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Oh wait nevermind, I found the error myself, silly me
    Code:
    my $body;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles