in reply to Fetch the regex matched values from file and write it to a file in line by line format.(Using HPNA to execute the script)

It looks to me like each "line" ends with either KEY or CERT, and none of the filenames include space characters. Assuming that is true, and that you have/can get the "Garbled Output" into a single string, split could work:
@filenames = split /\s.*?(?:KEY|CERT)/, $garbled_output;
The regex is:
/s whitespace .*? any character (.), unlimited length (*), as few as possible (? +) (?: non-capturing group KEY literal | OR CERT literal ) end group
  • Comment on Re: Fetch the regex matched values from file and write it to a file in line by line format.(Using HPNA to execute the script)
  • Select or Download Code