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 6587319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:54:07+00:00 2026-05-25T16:54:07+00:00

I am stuck on chapter 4 exercise 4 page 78 of Learning Perl 6th

  • 0

I am stuck on chapter 4 exercise 4 page 78 of Learning Perl 6th Edition. I copied the code example for the problem from page 301. I am using Perl version 5.10.1 on Ubuntu 11.04. I get errors that I cannot figure out could someone please help? I will list the code and the error message below.

#!/usr/bin/perl -w
use strict;

greet( 'Fred' );
greet( 'Barney' );

sub greet {
  state $last_person;

  my $name = shift;

  print "Hi $name! ";

  if( defined $last_person ) {
      print "$last_person is also here!\n";
 }
  else {
      print "You are the first one here!\n";
}
  $last_person = $name;
}


Global symbol "$last_person" requires explicit package name at ./ex4-4 line 8.
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 14.
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 15.
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 20.
Execution of ./ex4-4 aborted due to compilation errors.
  • 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-05-25T16:54:08+00:00Added an answer on May 25, 2026 at 4:54 pm

    From the manual:

    Beginning with perl 5.9.4, you can declare variables with the state
    keyword in place of my. For that to work, though, you must have
    enabled that feature beforehand, either by using the feature pragma,
    or by using -E on one-liners. (see feature)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm presently stuck on a question from IFPH chapter 7. It's Exercise 7.1.2 which
I am working on SportsStore example on chapter 4 from the following book and
Reading through Thinking in Java i stuck in ex:6 of Inner Classes chapter. Exercise
This question was from Thinking in C++ Vol-1, Chapter 5's exercise No.14: Create a
Been stuck on this for ages. Currently learning Django and done some bits on
I stuck with problem of mail application , i am developing a website for
Im stuck with this little project in C# but basically my problem is this:
im stuck with a problem im basically trying to create a function where I
I stuck while trying to compile qpid c++ with boost 1_47_0 using Visual Studio
I'm going through the Beginning iPhone Development book & stuck in chapter 9. I've

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.