File: test18-goto2.p

package info (click to toggle)
libdevel-nytprof-perl 6.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,888 kB
  • sloc: perl: 5,497; javascript: 4,033; ansic: 107; makefile: 27
file content (16 lines) | stat: -rw-r--r-- 414 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Test Carp::Heavy's "swap subs out from under you with goto &sub"

use lib 't';

package Test18;

sub longmess  { goto &longmess_jmp }

sub longmess_jmp  {
    # the required file deletes this longmess_jmp sub, while it's executing,
    # and replaces it with longmess_real, which we then goto into!
    require 'test18-goto2.pm'; # has to be require, not eval '...'
    goto &longmess_real;
}

longmess("Oops");