Dear Monks,

i've been doing the following for years in KSH with something like the below but need to do it in Perl now. i have been trawling your site and the web for days now and am totally lost on how to do it in a perl.pl script.

Tried numerous while and foreach (<MYFILE>) examples and using split on ":" etc etc.. They all seem to either print the below every time for every line multiple times (like a cartesian join) of grabled mess. I have so many hacks that have failed i dont want to bother you with them. basically we need to do the following in PERL that we are currently doing in KSH.

Any assistance would be most greatly appreciated.

br&thnx, karl

Here's the KSH with for loop, cut, grep:

#!/bin/ksh for t in $(cat $MYFILE) do job_name=`echo $t | grep job_name | cut -d: -f2` days_of_week=`echo $t | grep days_of_week | cut -d: -f2` start_times=`echo $t | grep start_times | cut -d: -f2` printf "$job_name:$days_of_week:$start_times" done

----- Example (Target Output) ------

myservername001.dlog.xyz:su,mo,tu,we,th,fr,sa:"12:00" myservername001.osaudit.xyz:su,mo,tu,we,th,fr,sa:"12:00" myservername001.expdb.xyz:su,mo,tu,we,th,fr,sa:"12:00"
----- MYFILE (Source DATA) --------- /*----- myservername001.dblogs.xyz -----*/ job_name:myservername001.dlog.xyz days_of_week: su,mo,tu,we,th,fr,sa start_times: "12:00" /*----- myservername001.osaudit.xyz -----*/ job_name:myservername001.osaudit.xyz days_of_week: su,mo,tu,we,th,fr,sa start_times: "12:00" /*----- myservername001.expdb.xyz -----*/ job_name:myservername001.expdb.xyz days_of_week: su,mo,tu,we,th,fr,sa start_times: "12:00"

In reply to [KSH convert to PERL] Rollup multi line values to single row outputs. by captainK

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.