When posting a question please take the time to make sure it says what it should, and that the data examples show up like you excpect them to. Its a little tough to grok what the actual string you are working with is, but I'll give it a shot

# lets assume we are starting after the split in your sub # so the contents of @fields would be @fields = ( '463694', 'BROOKS JR', 'JAMES', 'ArnoldMarkoe', '1/17/03', 'MD Wkly Note', '17\00004DA5.005' ); # # So with that assumption you are attempting to join 0 .. 5 # and the last field's file extension? # here im not sure if you want the actual file name, or # simply the extension of the file, as you are going to # glob all files in that sub dir with that file extension # I will assume its the last case. # $line = join('|', @fields[0 .. 5]) . '|H:\\' . ( split(/\\/, $fields[-1]) )[0] . '\\.' . ( split(/\./, $fields[-1]) )[1]; print "$line\n"; # # which will produce # 463694|BROOKS JR|JAMES|ArnoldMarkoe|1/17/03|MD Wkly Note|H:\17\.005

Im not sure if that is what you actually want or not. If you could refine the exact data you are trying to get, it might make it easier to help you.

BTW, what I am doing with the splits is working with the last element of fields ( ala $fields-1 ), and split returns an array of elements that were successfully split. So I take the entire split expression, slap it in parenthases, and treat it like a normal array slice, and only return the elements I want. In the first case, I split on \, and return elem 0 which should be the sub dir if Im reading your data correctly. In the second case I split on . and return the second element, which should be the file extension. I am assuming that there is only one . in the string, which may be false, but I cant tell without more data.



/* And the Creator, against his better judgement, wrote man.c */

In reply to Re: File Parsing and String Formatting by l2kashe
in thread File Parsing and String Formatting by skyler

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.