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; }
17 $CAT = (($^O eq 'MSWin32') ? '.\perl -e "print <>"' : 'cat');
24 my($prog,$expected) = split(/\nEXPECT\n/, $_);
25 if ($^O eq 'MSWin32') {
26 open TEST, "| .\\perl -I../lib $switch >$tmpfile 2>&1";
29 open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
31 print TEST $prog, "\n";
34 $results = `$CAT $tmpfile`;
36 $expected =~ s/\n+$//;
37 if ( $results ne $expected){
38 print STDERR "PROG: $switch\n$prog\n";
39 print STDERR "EXPECTED:\n$expected\n";
40 print STDERR "GOT:\n$results\n";
43 print "ok ", ++$i, "\n";
49 $a = ":="; split /($a)/o, "a:=b:=c"; print "@_"
53 $cusp = ~0 ^ (~0 >> 1);
55 print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, ($cusp + 1) % 8, "!\n";
61 Can't call method "go" without a package or object reference at - line 1.
70 $x=0x0eabcd; print $x->ref;
72 Can't call method "ref" without a package or object reference at - line 1.
74 chop ($str .= <STDIN>);
78 $x=2;$y=3;$x<$y ? $x : $y += 23;print $x;
82 eval {sub bar {print "In bar";}}
84 system './perl -ne "print if eof" /dev/null'
89 sub new {my ($obj,$n)=@_; bless \$n}
98 Can't modify hash deref in repeat at - line 1, near "0;"
99 Execution of - aborted due to compilation errors.
102 printf(STDOUT "%s\n", $_);
114 sub sub {local($_) = @_;
117 Modification of a read-only value attempted at - line 3.
119 package FOO;sub new {bless {FOO => BAR}};
133 print scalar ("foo","bar")
137 sub by_number { $a <=> $b; };# inline function for sort below
139 @ordered_array=sort by_number keys(%as_ary);
144 my($m2) = $#Shells++;
145 $Shells[$m2]{HOST} = $Host;
154 &ShowShell(&NewShell(beach,Work,"+0+0"));
155 &ShowShell(&NewShell(beach,Work,"+0+0"));
156 &ShowShell(&NewShell(beach,Work,"+0+0"));
162 { print "TIEARRAY @_\n";
163 die "bomb out\n" unless $count ++ ;
166 sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] }
167 sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] }
168 sub DESTROY { print "DESTROY \n"; undef @{$_[0]}; }
171 eval 'tie @h, FAKEARRAY, fred' ;
172 tie @h, FAKEARRAY, fred ;
174 TIEARRAY FAKEARRAY fred
175 TIEARRAY FAKEARRAY fred
178 BEGIN { die "phooey\n" }
181 BEGIN failed--compilation aborted at - line 1.
185 Illegal division by zero at - line 1.
186 BEGIN failed--compilation aborted at - line 1.
190 Modification of a read-only value attempted at - line 1.
191 BEGIN failed--compilation aborted at - line 1.
197 print join(' ', reverse @_)."\n";
202 print sprintf($fmt, @_)."\n";
208 "Out of inspiration";
211 print "and destroyed as well\n";
215 print STDOUT "foo->can(READ)(@_)\n";
220 print STDOUT "Don't GETC, Get Perl\n";
227 print FOO "sentence.", "reversed", "a", "is", "This";
228 print "-- ", <FOO>, " --\n";
229 my($buf,$len,$offset);
231 $len = 10; $offset = 1;
232 read(FOO, $buf, $len, $offset) == 100 or die "foo->READ failed";
233 getc(FOO) eq "a" or die "foo->GETC failed";
234 printf "%s is number %d\n", "Perl", 1;
237 This is a reversed sentence.
238 -- Out of inspiration --
239 foo->can(READ)(string 10 1)
242 and destroyed as well
244 my @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n"
248 @a = ($a, $b, $c, $d) = (5, 6);
250 if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]);
254 print "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000);
258 print "ok\n" if ("\0" lt "\xFF");
262 open(H,'op/misc.t'); # must be in the 't' directory
264 print "ok\n" if (-e _ and -f _ and -r _);
268 sub thing { 0 || return qw(now is the time) }
275 { local $main::{ren} = *stimpy; print $ren, ' ' }
281 { local $main::{ren} = *stimpy; print ${'ren'}, ' ' }
282 print +(defined(${'ren'}) ? 'oops' : 'joy'), "\n";
287 sub func { print 'really ' unless wantarray; 'p' }
288 sub groovy { 'groovy' }
290 print p::func()->groovy(), "\n"
294 @list = ([ 'one', 1 ], [ 'two', 2 ]);
295 sub func { $num = shift; (grep $_->[1] == $num, @list)[0] }
296 print scalar(map &func($_), 1 .. 3), " ",
297 scalar(map scalar &func($_), 1 .. 3), "\n";
302 @{$h{$k}} = qw(1 2 4);
303 for (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) }
304 print "bogus\n" unless $s == 7;
307 eval q[ my $a = 'inner'; eval q[ print "$a " ] ];
308 eval { my $x = 'peace'; eval q[ print "$x\n" ] }
316 eval 'sub foo { print "In foo2\n" }';
317 print "Exiting foo1\n";
323 Subroutine foo redefined at (eval 1) line 1.
328 map {#this newline here tickles the bug
330 print "eat flaming death\n" unless ($s == 7);
332 sub foo { local $_ = shift; split; @_ }
334 print "you die joe!\n" unless "@x" eq 'x y z';
336 sub foo { local(@_) = ('p', 'q', 'r'); }
337 sub bar { unshift @_, 'D'; @_ }
338 sub baz { push @_, 'E'; return @_ }
339 for (1..3) { print foo('a', 'b', 'c'), bar('d'), baz('e'), "\n" }