Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7780903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:03:17+00:00 2026-06-01T19:03:17+00:00

This is usex.pl: #use strict; require ‘x.pl’; print $x; Here is x.pl: #use strict;

  • 0

This is usex.pl:

#use strict;
require 'x.pl';
print $x;

Here is x.pl:

#use strict;
our $x = 99;
1;

It runs fine as shown. If I uncomment the line to use strict in usesx.pl, I get

Global symbol "$x" requires explicit package name

The use or not of strict in x.pl seems not to matter (unless I drop the ‘our’ keyword, but I’m not interested in that.)

I’m fairly new to Perl. Why does strict make $x not visible in the main script, and what is the normal solution to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:03:19+00:00Added an answer on June 1, 2026 at 7:03 pm

    Hehe, our is not easy to grok as it mixes the concepts of global and lexical scope. What it does is exempting a global variable from the strict 'vars' pragma and allowing unqualified access to it within its scope, which is the enclosing block, or the end of the current file, whatever comes first. Read the full (but brief) story in the manual, which is also accessible by saying perldoc -f our on the command line.

    As for your script, you can verify the truthfulness of the words in the manual by modifying the variable accessor to use a package-qualified name:

    use strict;
    require 'x.pl';
    print $main::x;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, x is static in class's definition. I should use x in this
I try to use grep to match a case like this: I have a
This is beyond both making sense and my control. That being said here is
This is essentially what I want to do: public abstract class Uniform<T> { public
This more of a style question, rather than a how to. So I've got
This problem has been bugging me since forever. I have an array and in
This is a weired problem, I have implemented simple quick sort as follows.. static
This has been implemented in many websites lets say odesk or so.What I am
This code fails when I try to debug it using VC2010: char frd[32]=word-list.txt; FILE
This is my bitmap object Bitmap b = new Bitmap(columns, rows, PixelFormat.Format8bppIndexed); BitmapData bmd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.