I'm not exactly clear whether you want to pass each entire file to your external tool, or whether you want to open each file and then pass it line by line. I guess probably the former. If that's the case, then perhaps this example will help.
Lets say for example your external tool is /bin/cat, and you want to cat each file and capture the output.$ echo 'some text' > 1.pdb $ echo 'some more text' > 2.pdb
$ cat foo.pl #!/usr/bin/perl use strict; use warnings; my $dir = '.'; my $cat = '/bin/cat'; opendir DIR, $dir or die "Cannot open directory $dir:$!\n"; my @pdb_files = grep { -f $_ && $_ =~ /\.pdb$/ } readdir DIR; closedir DIR; for my $file (@pdb_files) { my $content = `$cat "$dir/$file"`; chomp $content; print "Content of $file is $content\n"; }
That should be enough to get you going?$ perl foo.pl Content of 1.pdb is some text Content of 2.pdb is some more text
In reply to Re^3: How to embed a tool in my script
by McDarren
in thread How to embed a tool in my script
by angel_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |