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";
204 print FOO "sentence.", "reversed", "a", "is", "This";
205 print "-- ", <FOO>, " --\n";
208 This is a reversed sentence.
209 -- Out of inspiration --
210 and destroyed as well
212 my @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n"
216 @a = ($a, $b, $c, $d) = (5, 6);
218 if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]);
222 print "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000);
226 print "ok\n" if ("\0" lt "\xFF");
230 open(H,'op/misc.t'); # must be in the 't' directory
232 print "ok\n" if (-e _ and -f _ and -r _);
236 sub thing { 0 || return qw(now is the time) }
243 { local $main::{ren} = *stimpy; print $ren, ' ' }
249 { local $main::{ren} = *stimpy; print ${'ren'}, ' ' }
250 print +(defined(${'ren'}) ? 'oops' : 'joy'), "\n";
255 sub func { print 'really ' unless wantarray; 'p' }
256 sub groovy { 'groovy' }
258 print p::func()->groovy(), "\n"
263 @{$h{$k}} = qw(1 2 4);
264 for (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) }
265 print "bogus\n" unless $s == 7;
268 eval q[ my $a = 'inner'; eval q[ print "$a " ] ];
269 eval { my $x = 'peace'; eval q[ print "$x\n" ] }