develooper Front page | perl.perl5.porters | Postings from August 2021

Re: PSC #034 2021-08-20 - "Namespaces Special"

Thread Previous | Thread Next
From:
=?UTF-8?B?UmVuw6llIELDpGNrZXI=?=
Date:
August 30, 2021 08:16
Subject:
Re: PSC #034 2021-08-20 - "Namespaces Special"
Message ID:
5aa525af-4e52-2f14-9f11-d14fb113de5c@perl-services.de
Am 30.08.21 um 10:01 schrieb Yuki Kimoto:
>
> Is this really?
>
>   perl -E 'sub substr { print "substr\n" }; substr();'
>
> Output
>
>   Not enough arguments for substr at -e line 1, near "substr()"
>   Execution of -e aborted due to compilation errors.
>
> Imported symbols don't seem to override CORE::substr,
>
> Although the following is OK.
>
>   perl -E 'sub substr { print "substr\n" }; &substr();'
>
> Output
>
>   substr
>

$ cat test_import.pl
#!/usr/bin/perl

use v5.20;

use strict;
use warnings;

use lib '.';
use MYImport;

substr();

$ cat MYImport.pm
package MYImport;

use parent 'Exporter';

our @EXPORT = qw(substr);

sub substr {
    print "substr\n";
}

1;

$ perl test_import.pl
substr


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About