1Test no feature bareword_filehandles 2 3todo: 4 5print HANDLE 6print HANDLE LIST 7printf HANDLE 8printf HANDLE LIST 9say HANDLE 10say HANDLE LIST 11readline 12<> / <HANDLE> 13<<>> - has an implicit argument 14truncate 15stat 16-X 17lstat 18open 19close 20eof 21fileno 22flock 23getc 24read 25write ? 26seek 27tell 28select 29sysopen 30sysread 31syswrite 32sysseek 33pipe 34 35socket 36connect 37bind 38listen 39recv 40send 41setsockopt 42getsockopt 43shutdown 44socketpair 45accept 46getpeername 47getsockname 48 49binmode 50ioctl 51fcntl 52chmod - doesn't accept bareword handles 53chown - doesn't accept bareword handles 54 55opendir 56closedir 57readdir 58seekdir 59telldir 60rewinddir 61chdir 62 63also check 64 65sort 66map 67grep 68 69aren't modified 70 71 72__END__ 73# NAME defaults and explicitly on 74#!perl -c 75use File::Temp qw(tempfile); 76use Fcntl qw(SEEK_SET); 77use Socket; 78my ($fh, $name) = tempfile; 79open FOO, ">", File::Spec->devnull; 80print FOO; 81print FOO "Hello"; 82printf FOO "Hello"; 83seek FOO, 0, SEEK_SET; 84truncate FOO, 0; 85print FOO "Something read\n"; 86close FOO; 87<FOO>; 88{ 89 local *ARGV; 90 local *ARGVOUT; 91 @ARGV = $name; 92 <<>>; 93 <>; 94} 95pipe FH1, FH2; 96socketpair S1, S2, AF_UNIX, SOCK_STREAM, PF_UNSPEC; 97shutdown S1, 0; 98 99use feature "bareword_filehandles"; 100open FOO, ">", File::Spec->devnull; 101print FOO; 102print FOO "Hello"; 103printf FOO "Hello"; 104seek FOO, 0, SEEK_SET; 105truncate FOO, 0; 106print FOO "Something read\n"; 107close FOO; 108<FOO>; 109{ 110 local *ARGV; 111 local *ARGVOUT; 112 @ARGV = $name; 113 <<>>; 114 <>; 115} 116pipe FH3, FH4; 117socketpair S3, S4, AF_UNIX, SOCK_STREAM, PF_UNSPEC; 118shutdown S3, 0; 119 120EXPECT 121- syntax OK 122######## 123# NAME check atan2() with a handle doesn't trigger bareword filehandle errors 124no feature "bareword_filehandles", "indirect"; 125my $x = atan2(FOO 1, 2); 126# my original approach to this hooked newGVREF(), which the parsing for most LOPs (as with 127# atan2() above) could end up calling newGVREF(), producing an unexpected error message. 128EXPECT 129OPTIONS fatal 130Number found where operator expected at - line 2, near "FOO 1" 131 (Do you need to predeclare FOO?) 132Missing comma after first argument to atan2 function at - line 2, near "2)" 133Execution of - aborted due to compilation errors. 134######## 135# NAME print HANDLE LIST, printf HANDLE LIST, print HANDLE, printf HANDLE 136use File::Spec; 137open FOO, ">", File::Spec->devnull or die $!; 138$_ = "abc"; 139print FOO "test\n"; 140printf FOO "test\n"; 141print FOO; 142printf FOO; 143no feature "bareword_filehandles"; 144print FOO "test2\n"; 145printf FOO "test2\n"; 146print FOO; 147printf FOO; 148print STDERR; 149print STDOUT; 150print ARGV; 151print ARGVOUT; 152print DATA; 153print STDIN; 154EXPECT 155OPTIONS fatal 156Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 157Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 158Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 11. 159Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 12. 160Execution of - aborted due to compilation errors. 161######## 162# NAME say HANDLE LIST, say HANDLE 163use File::Spec; 164use feature "say"; 165open FOO, ">", File::Spec->devnull or die $!; 166$_ = "abc"; 167say FOO "test\n"; 168say FOO; 169no feature "bareword_filehandles"; 170say FOO "test2\n"; 171say FOO; 172EXPECT 173OPTIONS fatal 174Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 175Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 176Execution of - aborted due to compilation errors. 177######## 178# NAME readline FOO, readline, <>, <FOO> 179use File::Spec; 180open FOO, "<", File::Spec->devnull or die $!; 181my $x = readline FOO; 182$x .= readline FOO; # rcatline 183$x = readline(FOO); # parsed a little differently with () 184$x .= readline(FOO); 185$x = <FOO>; 186$x .= <FOO>; 187no feature "bareword_filehandles"; 188$x = readline FOO; 189$x .= readline FOO; # rcatline 190$x = readline(FOO); # parsed a little differently with () 191$x .= readline(FOO); 192$x = <FOO>; 193$x .= <FOO>; 194$x = readline STDIN; 195$x = <STDIN>; 196EXPECT 197OPTIONS fatal 198Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 199Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 11. 200Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 12. 201Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 13. 202Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 14. 203Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 15. 204Execution of - aborted due to compilation errors. 205######## 206# NAME truncate 207use strict; 208use warnings; 209# if all goes well this doesn't run anyway 210my $name = "bare$$.tmp"; 211END { unlink $name if $name; } 212open FOO, ">", $name or die; 213print FOO "Non-zero length data\n"; 214truncate FOO, 2; 215no feature "bareword_filehandles"; 216truncate FOO, 1; 217EXPECT 218OPTIONS fatal 219Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 220Execution of - aborted due to compilation errors. 221######## 222# NAME stat, lstat, -X 223use File::Spec; 224open FOO, "<", File::Spec->devnull; 225my @x = stat FOO; 226@x = lstat FOO; 227my $x = -s FOO; 228no feature "bareword_filehandles"; 229@x = stat FOO; 230@x = lstat FOO; 231$x = -s FOO; 232EXPECT 233OPTIONS fatal 234Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 235Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 236Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 237Execution of - aborted due to compilation errors. 238######## 239# NAME open, close, eof, fileno 240use File::Spec; 241open FOO, "<", File::Spec->devnull; 242my $x = eof FOO; 243$x = fileno FOO; 244close FOO; 245no feature "bareword_filehandles"; 246open FOO, "<", File::Spec->devnull; 247$x = eof FOO; 248$x = fileno FOO; 249close FOO; 250EXPECT 251OPTIONS fatal 252Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 253Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 254Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 255Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 256Execution of - aborted due to compilation errors. 257######## 258# NAME flock 259use Fcntl ":flock"; 260open FOO, "<", $0 or die; 261flock FOO, LOCK_SH; 262no feature "bareword_filehandles"; 263flock FOO, LOCK_UN; 264EXPECT 265OPTIONS fatal 266Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 5. 267Execution of - aborted due to compilation errors. 268######## 269# NAME getc, read, seek, tell 270open FOO, "<", $0 or die; 271my $x = getc FOO; 272read(FOO, $x, 1); 273$x = tell FOO; 274seek FOO, 0, 0; 275no feature "bareword_filehandles"; 276$x = getc FOO; 277read(FOO, $x, 1); 278$x = tell FOO; 279seek FOO, 0, 0; 280EXPECT 281OPTIONS fatal 282Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 283Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 284Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 285Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 286Execution of - aborted due to compilation errors. 287######## 288# NAME select 289open FOO, "<", $0 or die; 290my $old = select FOO; 291no feature "bareword_filehandles"; 292select FOO; 293select $old; 294EXPECT 295OPTIONS fatal 296Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 4. 297Execution of - aborted due to compilation errors. 298######## 299# NAME sysopen, sysread, syswrite, sysseek 300use Fcntl; 301use File::Spec; 302sysopen FOO, File::Spec->devnull, O_RDWR or die; 303sysread FOO, my $x, 10; 304syswrite FOO, "Test"; 305my $y = sysseek FOO, 0, SEEK_CUR; 306close FOO; 307no feature "bareword_filehandles"; 308sysopen FOO, File::Spec->devnull, O_RDWR or die; 309sysread FOO, my $x, 10; 310syswrite FOO, "Test"; 311my $y = sysseek FOO, 0, SEEK_CUR; 312EXPECT 313OPTIONS fatal 314Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 315Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 316Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 11. 317Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 12. 318Execution of - aborted due to compilation errors. 319######## 320# NAME pipe 321my $fh; 322pipe IN, $fh; 323pipe $fh, OUT; 324pipe IN, OUT; 325no feature "bareword_filehandles"; 326pipe IN, $fh; 327pipe $fh, OUT; 328pipe IN, OUT; 329EXPECT 330OPTIONS fatal 331Bareword filehandle "IN" not allowed under 'no feature "bareword_filehandles"' at - line 6. 332Bareword filehandle "OUT" not allowed under 'no feature "bareword_filehandles"' at - line 7. 333Bareword filehandle "IN" not allowed under 'no feature "bareword_filehandles"' at - line 8. 334Bareword filehandle "OUT" not allowed under 'no feature "bareword_filehandles"' at - line 8. 335Execution of - aborted due to compilation errors. 336######## 337# NAME socket, connect, bind, listen 338my $fh; 339# this won't run, just use dummy values for domain, type, protocol 340socket(FOO, 0, 0,0); 341connect(FOO, "abc"); 342bind(FOO, "abc"); 343listen(FOO, 5); 344no feature "bareword_filehandles"; 345socket(FOO, 0, 0,0); 346connect(FOO, "abc"); 347bind(FOO, "abc"); 348listen(FOO, 5); 349EXPECT 350OPTIONS fatal 351Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 352Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 353Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 10. 354Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 11. 355Execution of - aborted due to compilation errors. 356######## 357# NAME accept 358accept(FOO, CHILD); 359accept($fh, CHILD); 360accept(FOO, $fh); 361no feature "bareword_filehandles"; 362accept(FOO, CHILD); 363accept($fh, CHILD); 364accept(FOO, $fh); 365EXPECT 366OPTIONS fatal 367Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 5. 368Bareword filehandle "CHILD" not allowed under 'no feature "bareword_filehandles"' at - line 5. 369Bareword filehandle "CHILD" not allowed under 'no feature "bareword_filehandles"' at - line 6. 370Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 371Execution of - aborted due to compilation errors. 372######## 373# NAME send, recv, setsockopt, getsockopt 374send FOO, "abc", 0; 375recv FOO, my $x, 10, 0; 376setsockopt FOO, 0, 0, 0; 377my $y = getsockopt FOO, 0, 0; 378no feature "bareword_filehandles"; 379send FOO, "abc", 0; 380recv FOO, my $x, 10, 0; 381setsockopt FOO, 0, 0, 0; 382my $y = getsockopt FOO, 0, 0; 383EXPECT 384OPTIONS fatal 385Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 6. 386Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 387Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 388Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 389Execution of - aborted due to compilation errors. 390######## 391# NAME shutdown, getsockname, getpeername 392shutdown FOO, 0; 393my $sockname = getsockname FOO; 394my $peername = getpeername FOO; 395no feature "bareword_filehandles"; 396shutdown FOO, 0; 397$sockname = getsockname FOO; 398$peername = getpeername FOO; 399EXPECT 400OPTIONS fatal 401Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 5. 402Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 6. 403Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 404Execution of - aborted due to compilation errors. 405######## 406# NAME socketpair 407my $fh; 408socketpair IN, $fh, 0, 0, 0; 409socketpair $fh, OUT, 0, 0, 0; 410socketpair IN, OUT, 0, 0, 0; 411no feature "bareword_filehandles"; 412socketpair IN, $fh, 0, 0, 0; 413socketpair $fh, OUT, 0, 0, 0; 414socketpair IN, OUT, 0, 0, 0; 415EXPECT 416OPTIONS fatal 417Bareword filehandle "IN" not allowed under 'no feature "bareword_filehandles"' at - line 6. 418Bareword filehandle "OUT" not allowed under 'no feature "bareword_filehandles"' at - line 7. 419Bareword filehandle "IN" not allowed under 'no feature "bareword_filehandles"' at - line 8. 420Bareword filehandle "OUT" not allowed under 'no feature "bareword_filehandles"' at - line 8. 421Execution of - aborted due to compilation errors. 422######## 423# NAME binmode, ioctl, fcntl 424binmode FOO; 425binmode FOO, ":raw"; 426ioctl FOO, 0, 0; 427fcntl FOO, 0, 0; 428no feature "bareword_filehandles"; 429binmode FOO; 430binmode FOO, ":raw"; 431ioctl FOO, 0, 0; 432fcntl FOO, 0, 0; 433EXPECT 434OPTIONS fatal 435Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 6. 436Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 437Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 438Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 439Execution of - aborted due to compilation errors. 440######## 441# NAME opendir, closedir, readdir 442opendir FOO, "."; 443my @x = readdir FOO; 444chdir FOO; 445closedir FOO; 446no feature "bareword_filehandles"; 447opendir FOO, "."; 448my @x = readdir FOO; 449chdir FOO; 450closedir FOO; 451EXPECT 452OPTIONS fatal 453Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 6. 454Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 455Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 456Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 9. 457Execution of - aborted due to compilation errors. 458######## 459# NAME seekdir, telldir, rewinddir 460use strict; 461my $x = telldir FOO; 462seekdir FOO, $x; 463rewinddir FOO; 464no feature "bareword_filehandles"; 465my $x = telldir FOO; 466seekdir FOO, $x; 467rewinddir FOO; 468EXPECT 469OPTIONS fatal 470Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 6. 471Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 7. 472Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 8. 473Execution of - aborted due to compilation errors. 474######## 475# NAME file tests 476-T FOO; 477-s FOO; 478no feature "bareword_filehandles"; 479-T FOO; 480-s FOO; 481-s _; 482EXPECT 483OPTIONS fatal 484Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 4. 485Bareword filehandle "FOO" not allowed under 'no feature "bareword_filehandles"' at - line 5. 486Execution of - aborted due to compilation errors. 487