G'day reqnode,

What you really want may be possible; however, what you describe is illegal syntax.

Consider this example script (see Note below):

#!/usr/bin/env perl

use utf8;

sub smiley {
    print "Smiley\n";
}

sub ☺ {
    print "Smiley\n";
}

Here's what happens when you run this:

$ pm_script_with_utf8.pl Illegal declaration of anonymous subroutine at ./pm_script_with_utf8.p +l line 9.

The documentation for the utf8 pragma even tells you this:

"One can have Unicode in identifier names, but not in package/class or subroutine names."

If you provide a short code example, that might serve to illustrate exactly what you're trying to achieve.

[Note: I've used <pre>, instead of <code>, tags for the code containing Unicode characters. This is to allow the actual characters, instead of character entity references, to be displayed. Please do the same with any such code you post.]

-- Ken


In reply to Re: avoid writing 'use utf8' in every script by kcott
in thread avoid writing 'use utf8' in every script by reqnode

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.