Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

chr() function

by catfish1116 (Beadle)
on Nov 13, 2018 at 21:51 UTC ( #1225755=perlquestion: print w/replies, xml ) Need Help??

catfish1116 has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to figure out the chr() function, and have written a few lines of code:

#!/usr/bin/perl use v5.12; use warnings; $alpha = chr(65); say "This is what Alpha looks like $alpha". "\n";

And I'm getting this error

Global symbol "$alpha" requires explicit package name at ./Page_34 li +ne 5. Global symbol "$alpha" requires explicit package name at ./Page_34 lin +e 6.

What package is it looking for? TIA catfish

Replies are listed 'Best First'.
Re: chr() function
by LanX (Cardinal) on Nov 13, 2018 at 21:53 UTC
    You have strict activated when using 5.12.

    Write my $alpha = ...

    Perl can't tell if it's a private (my) or global package (our) variable.

    So it takes a guess and asks you to make it clear by prepending a name space.

    our $var is basically an alias of the fully qualified $Pkg::var with the current package at declaration time.

    And yes this error message is confusing because nowadays most declarations are done with my , which doesn't have a name space.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Thank you sir !
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1225755]
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2021-05-15 15:16 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (150 votes). Check out past polls.