On Saturday 27 October 2007 11:39:26 Matisse Enzer wrote:

> What am i doing wrong:
>
>
> #############################################
> # test.pl
> use strict;
> use warnings;
> use Test::More tests => 2;
>
> my $test_string = 'overrode function';
>
> {
>      no warnings qw(once);
>      *CORE::GLOBAL::glob = sub {
>          $test_string;
>      };
>
>      *CORE::GLOBAL::print = sub {
>          $test_string;
>      };
> }
>
> is( glob, $test_string, 'overrode glob' );
> is( print, $test_string, 'overrode print' );
>
> #############################################
>
> % perl test.pl
> 1..2
> Subroutine CORE::GLOBAL::glob redefined at test.pl line 11.
> ok 1 - overrode glob
> Use of uninitialized value in print at test.pl line 19.
> not ok 2 - overrode print
> #   Failed test 'overrode print'
> #   at test.pl line 19.
> #          got: '1'
> #     expected: 'overrode function'
> # Looks like you failed 1 test of 2.

I don't think you can override print.

        my $p = prototype 'CORE::print';
        print defined $p ? $p : 'unoverrideable';

-- c

Reply via email to