Dear monks, I am a noob in Perl. I am also not a programmer.... From a file i have to extract 2 emailaddresses. I know they end with @dh.nl. So i wrote this little (ugly) script.
#finding @dh.nl #!/usr/bin/perl -w my $file="logs1"; chomp $file; open (FILE, $file) || die "Can't open logs file: $!\n"; my @line =(<FILE>); chomp (@line); foreach (@line){ if (/(\D+)(@)(dh.nl)/) { $a=$1; $b=$2; $c=$3; } } print "$a"."$b"."$c"."\n"; close FILE;
The result is: JT; qwerty@dh.nl,abcde@dh.nl I just need: qwerty@dh.nl,abcde@dh.nl The (part of) file is:
193.10.168.23 - - [07/Jan/2013:00:07:48 +0000] "GET /UserFiles/File/Ra +dio%203rd%20Newsletter%20for%20web.pdf HTTP/1.0" 304 - "-" "gsa-crawl +er (Enterprise; M2-N7RQ5RABCA2JT; qwerty@dh.nl,abcde@dh.nl)"
What am I doing wrong? Please advice me. Thanks in advance. fritsimeel.

In reply to using regular expressions showing just the hits. by fritsimeel

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.