Hello, I need to search for a certain string in a file. It has to be the first character in the line (if it is 2nd or later - don't get it). If the string is found, I have to get the value after the delimiter - (= equal). eg: Generated filename=a_b_c.xml Search for 'Generated filename' and return the value a_b_c.xml.Also G has to be the 1st character in the line. I have a basic code snippet:
my $logFile = "someFile.log"; my $stringToFind = "Generated filename"; open logFile, $logFile or die $!; my @list = grep /\b$stringToFind\b/, <logFile>; chomp @list; print "$_\n" foreach @list;
However, I am clueless how to ensure that G is the first character and to return the value after the equal sign. Thanks

In reply to Need to search for a string in a file by akrrs7

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.