Hello 1nickt,

Maybe you missed understand what I was writing / asking. I am asking what was his target in total. It looks like XY Problem

I never used it they way that you are using it, I would use it like this:

#!/usr/bin/perl use strict; use warnings; use feature 'say'; sub print_timestamp { local *_get_formatted_time = sub { return $_[0] . uc scalar localtime; }; return _get_formatted_time(@_); } say print_timestamp('The time was: '); __END__ $ perl test.pl The time was: FRI AUG 25 15:18:08 2017

Instead of:

#!/usr/bin/perl use strict; use warnings; use feature 'say'; print_timestamp('nigh'); print_timestamp( get_formatted_time() ); sub print_timestamp { say 'The time was ' . shift() } sub get_formatted_time { return uc scalar localtime } __END__ $ perl test.pl The time was nigh The time was FRI AUG 25 15:20:10 2017

Update: When you are calling a subroutine withing another subroutine like this:

sub a { sub b{ } }

It is basically the same as:

sub a { } sub b{ }

End of Update: So since he is try to test if a subroutine is safe (foo(bar()); # no errors reported - not expected behavior and foo(); # Undefined subroutine reported as expected). Why not simply calling it one by one, since it is the same thing if they are not defined locally?

But I suppose it depends the case. Thanks for sharing other ideas, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^3: Safe module and undefined subroutines by thanos1983
in thread Safe module and undefined subroutines by bovlb

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.