6 require './test.pl'; # for run_perl()
10 my $test = 'bytecode.pl';
11 END { 1 while unlink $test }
14 my @tests = split /\n###+\n/, <DATA>;
16 print "1..".($#tests+1)."\n";
22 my ($script, $expect) = split />>>+\n/;
24 open T, ">$test"; print T $script; close T;
25 $got = run_perl(switches => [ "-MO=Bytecode,-H,-o$test" ],
29 $got = run_perl(progfile => $test);
31 if ($got =~ /^$expect$/) {
64 ############################################################
65 for (1,2,3) { print if /\d/ }
68 ############################################################
69 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/ge; print $_
72 ############################################################
73 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/g; print $_
76 ############################################################
77 split /a/,"bananarama"; print @_
80 ############################################################
81 { package P; sub x { print 'ya' } x }
84 ############################################################
85 @z = split /:/,"b:r:n:f:g"; print @z
88 ############################################################
89 sub AUTOLOAD { print 1 } &{"a"}()
92 ############################################################
93 my $l = 3; $x = sub { print $l }; &$x
96 ############################################################
98 my $foo = sub {$i = shift if @_};
100 ############################################################
101 $_="\xff\xff"; use utf8; utf8::encode $_; print $_
104 ############################################################
105 $x="Cannot use"; print index $x, "Can"
108 ############################################################
109 my $i=6; eval "print \$i\n"
112 ############################################################
113 BEGIN { %h=(1=>2,3=>4) } print $h{3}
116 ############################################################
118 ############################################################
126 ############################################################
127 BEGIN { tie @a, __PACKAGE__; sub TIEARRAY { bless{} } sub FETCH { 1 } }
131 ############################################################
132 my $i=3; print 1 .. $i
135 ############################################################
136 my $h = { a=>3, b=>1 }; print sort {$h->{$a} <=> $h->{$b}} keys %$h
139 ############################################################
140 print sort { my $p; $b <=> $a } 1,4,3