Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/t/io/iprefix.t

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!./perl

$^I = 'bak*';

# Modified from the original inplace.t to test adding prefixes

print "1..2\n";

@ARGV = ('.a','.b','.c');
if ($^O eq 'MSWin32') {
  $CAT = '.\perl -e "print<>"';
  `.\\perl -le "print 'foo'" > .a`;
  `.\\perl -le "print 'foo'" > .b`;
  `.\\perl -le "print 'foo'" > .c`;
}
elsif ($^O eq 'NetWare') {
  $CAT = 'perl -e "print<>"';
  `perl -le "print 'foo'" > .a`;
  `perl -le "print 'foo'" > .b`;
  `perl -le "print 'foo'" > .c`;
}
elsif ($^O eq 'VMS') {
  $CAT = 'MCR []perl. -e "print<>"';
  `MCR []perl. -le "print 'foo'" > ./.a`;
  `MCR []perl. -le "print 'foo'" > ./.b`;
  `MCR []perl. -le "print 'foo'" > ./.c`;
}
elsif ($^O eq 'MacOS') {
  $CAT = "$^X -e \"print<>\"";
  `$^X -le "print 'foo'" > .a`;
  `$^X -le "print 'foo'" > .b`;
  `$^X -le "print 'foo'" > .c`;
}
else {
  $CAT = 'cat';
  `echo foo | tee .a .b .c`;
}
while (<>) {
    s/foo/bar/;
}
continue {
    print;
}

if (`$CAT .a .b .c` eq "bar\nbar\nbar\n") {print "ok 1\n";} else {print "not ok 1\n";}
if (`$CAT bak.a bak.b bak.c` eq "foo\nfoo\nfoo\n") {print "ok 2\n";} else {print "not ok 2\n";}

unlink '.a', '.b', '.c', 'bak.a', 'bak.b', 'bak.c';

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.