Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / Psh / Builtins / Forfile.pm
CommitLineData
86530b38
AT
1package Psh::Builtins::Forfile;
2
3=item * C<forfile globpattern command>
4
5Comparable to the sh-for command:
6
7for i in globpattern; do command $i; done
8
9The current filename will be assigned to $_
10
11Examples:
12
13forfile *.zip unzip $_
14
15=cut
16
17require Psh::Parser;
18require Psh;
19require Psh::Util;
20
21sub bi_forfile {
22 my @words=@{$_[1]};
23 my @files= Psh::OS::glob(Psh::Parser::unquote($words[0]));
24 foreach my $file (@files) {
25 $command= join(' ',@words[1..$#words]);
26 Psh::evl("\$\_=\"$file\"; $command");
27 }
28 return (1,undef);
29}
30
311;