What kind of action do you have in mind, and what is the format of the file? If you have one shell command per line, why not run it in the shell? I'll assume that's not the case. To read a file into an array is elementary:

open FOO, '<', '/path/to/bar.data' or die $!; my @actions = <FOO>; close FOO or die $!;

I'll suppose the actions are keys to a "dispatch table", a hash of coderefs, followed by some arguments, space delimited. Call the hash %action_code.

for (@actions) { my @act = split " "; $action_code{$act[0]}->(@act[1..$#act]); }

If &$action_code{foo} returns a value, you may prefer map to what I have shown.

You made this easy, but maybe pointless, by leaving out all the details.

After Compline,
Zaxo


In reply to Re: Creating an array from a text file by Zaxo
in thread Creating an array from a text file by mikevanhoff

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, details, 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, summary, 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.