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",
28 $got = run_perl(progfile => $test);
30 if ($got =~ /^$expect$/) {
63 ############################################################
64 for (1,2,3) { print if /\d/ }
67 ############################################################
68 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/ge; print $_
71 ############################################################
72 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/g; print $_
75 ############################################################
76 split /a/,"bananarama"; print @_
79 ############################################################
80 { package P; sub x { print 'ya' } x }
83 ############################################################
84 @z = split /:/,"b:r:n:f:g"; print @z
87 ############################################################
88 sub AUTOLOAD { print 1 } &{"a"}()
91 ############################################################
92 my $l = 3; $x = sub { print $l }; &$x
95 ############################################################
97 my $foo = sub {$i = shift if @_};
99 ############################################################
100 $_="\xff\xff"; use utf8; utf8::encode $_; print $_
103 ############################################################
104 $x="Cannot use"; print index $x, "Can"
107 ############################################################
108 my $i=6; eval "print \$i\n"
111 ############################################################
112 BEGIN { %h=(1=>2,3=>4) } print $h{3}
115 ############################################################
117 ############################################################
125 ############################################################
126 BEGIN { tie @a, __PACKAGE__; sub TIEARRAY { bless{} } sub FETCH { 1 } }
130 ############################################################
131 my $i=3; print 1 .. $i
134 ############################################################
135 my $h = { a=>3, b=>1 }; print sort {$h->{$a} <=> $h->{$b}} keys %$h
138 ############################################################
139 print sort { my $p; $b <=> $a } 1,4,3