5 $ENV{PERL5LIB} = "../lib";
10 @prgs = split "\n########\n", <DATA>;
11 print "1..", scalar @prgs, "\n";
13 $tmpfile = "misctmp000";
14 1 while -f ++$tmpfile;
15 END { unlink $tmpfile if $tmpfile; }
22 my($prog,$expected) = split(/\nEXPECT\n/, $_);
23 open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
24 print TEST $prog, "\n";
27 $results = `cat $tmpfile`;
29 $expected =~ s/\n+$//;
30 if ( $results ne $expected){
31 print STDERR "PROG: $switch\n$prog\n";
32 print STDERR "EXPECTED:\n$expected\n";
33 print STDERR "GOT:\n$results\n";
36 print "ok ", ++$i, "\n";
42 $a = ":="; split /($a)/o, "a:=b:=c"; print "@_"
46 $cusp = ~0 ^ (~0 >> 1);
48 print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, ($cusp + 1) % 8, "!\n";
54 Can't call method "go" without a package or object reference at - line 1.
63 $x=0x0eabcd; print $x->ref;
65 Can't call method "ref" without a package or object reference at - line 1.
67 chop ($str .= <STDIN>);
71 $x=2;$y=3;$x<$y ? $x : $y += 23;print $x;
75 eval {sub bar {print "In bar";}}
77 system "./perl -ne 'print if eof' /dev/null"
82 sub new {my ($obj,$n)=@_; bless \$n}
91 Can't coerce HASH to string in repeat at - line 1.
94 printf(STDOUT "%s\n", $_);
106 sub sub {local($_) = @_;
109 Modification of a read-only value attempted at - line 3.
111 package FOO;sub new {bless {FOO => BAR}};
125 print scalar ("foo","bar")
129 sub by_number { $a <=> $b; };# inline function for sort below
131 @ordered_array=sort by_number keys(%as_ary);
136 my($m2) = $#Shells++;
137 $Shells[$m2]{HOST} = $Host;
146 &ShowShell(&NewShell(beach,Work,"+0+0"));
147 &ShowShell(&NewShell(beach,Work,"+0+0"));
148 &ShowShell(&NewShell(beach,Work,"+0+0"));
154 { print "TIEARRAY @_\n";
155 die "bomb out\n" unless $count ++ ;
158 sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] }
159 sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] }
160 sub DESTROY { print "DESTROY \n"; undef @{$_[0]}; }
163 eval 'tie @h, FAKEARRAY, fred' ;
164 tie @h, FAKEARRAY, fred ;
166 TIEARRAY FAKEARRAY fred
167 TIEARRAY FAKEARRAY fred
170 BEGIN { die "phooey\n" }
173 BEGIN failed--compilation aborted at - line 1.
177 Illegal division by zero at - line 1.
178 BEGIN failed--compilation aborted at - line 1.
182 Modification of a read-only value attempted at - line 1.
183 BEGIN failed--compilation aborted at - line 1.
189 print join(' ', reverse @_)."\n";
195 "Out of inspiration";
198 print "and destroyed as well\n";
202 print STDOUT "foo->can(READ)(@_)\n";
207 print STDOUT "Don't GETC, Get Perl\n";
214 print FOO "sentence.", "reversed", "a", "is", "This";
215 print "-- ", <FOO>, " --\n";
216 my($buf,$len,$offset);
218 $len = 10; $offset = 1;
219 read(FOO, $buf, $len, $offset) == 100 or die "foo->READ failed";
220 getc(FOO) eq "a" or die "foo->GETC failed";
223 This is a reversed sentence.
224 -- Out of inspiration --
225 foo->can(READ)(string 10 1)
227 and destroyed as well
229 my @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n"
233 @a = ($a, $b, $c, $d) = (5, 6);
235 if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]);
239 print "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000);
243 print "ok\n" if ("\0" lt "\xFF");
247 open(H,'op/misc.t'); # must be in the 't' directory
249 print "ok\n" if (-e _ and -f _ and -r _);
253 sub thing { 0 || return qw(now is the time) }
260 { local $main::{ren} = *stimpy; print $ren, ' ' }
266 { local $main::{ren} = *stimpy; print ${'ren'}, ' ' }
267 print +(defined(${'ren'}) ? 'oops' : 'joy'), "\n";
272 sub func { print 'really ' unless wantarray; 'p' }
273 sub groovy { 'groovy' }
275 print p::func()->groovy(), "\n"
279 @list = ([ 'one', 1 ], [ 'two', 2 ]);
280 sub func { $num = shift; (grep $_->[1] == $num, @list)[0] }
281 print scalar(map &func($_), 1 .. 3), " ",
282 scalar(map scalar &func($_), 1 .. 3), "\n";
287 @{$h{$k}} = qw(1 2 4);
288 for (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) }
289 print "bogus\n" unless $s == 7;
292 eval q[ my $a = 'inner'; eval q[ print "$a " ] ];
293 eval { my $x = 'peace'; eval q[ print "$x\n" ] }
301 eval 'sub foo { print "In foo2\n" }';
302 print "Exiting foo1\n";
308 Subroutine foo redefined at (eval 1) line 1.
313 map {#this newline here tickles the bug
315 print "eat flaming death\n" unless ($s == 7);
317 sub foo { local $_ = shift; split; @_ }
319 print "you die joe!\n" unless "@x" eq 'x y z';
321 sub foo { local(@_) = ('p', 'q', 'r'); }
322 sub bar { unshift @_, 'D'; @_ }
323 sub baz { push @_, 'E'; return @_ }
324 for (1..3) { print foo('a', 'b', 'c'), bar('d'), baz('e'), "\n" }