Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Well, no. Probably not.

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.

$ echo 'some text' > 1.pdb $ echo 'some more text' > 2.pdb
Lets say for example your external tool is /bin/cat, and you want to cat each file and capture the output.
$ 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"; }
$ perl foo.pl Content of 1.pdb is some text Content of 2.pdb is some more text
That should be enough to get you going?

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Corion]: I heard a good analogy to the GDPR, which likely only works for Germans. GDPR is the new "separating your thrash", which is common in Germany. I equate "sharing" data with littering - and likely the fight will also take 30+ years for data sharing to ...
    [Corion]: ... become as socially inacceptable as littering is today
    [Corion]: Has anybody worked with Template::Liquid and Template::Liquid:: Include? I must be doing something stupid because Template::Liquid:: Include won't interpolate variables in the include files for me...
    [Corion]: Template::LiquidX ::Include I meant...
    [Corion]: Doh - 3rd time's the charm, maybe? Tempalte::LiquidX ::Tag::Include :D
    [Corion]: Ah well, you know what it should be ;) hard, copied link

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (11)
    As of 2018-05-25 12:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?