Okay.. This is my final code and its working the way I want it to..but can it be further optimised? Can it be shortened??

my $dt = 'Wed Mar 10 10:10:48 IST 2010'; my (@dtar) = split /[ :]/, $dt; $valar = 'Fri_Jan_29_14:30:22_v09.11-e024_1 Mon_Nov_30_09:20:08_v09.1 +1-e006_1 Tue_Dec_22_14:30:07_v09.11-e015_1 Tue_Nov_24_18:45:00_v08. +13-s001_1 Mon_Dec_07_14:30:09_v09.11-e013_1 Thu_Dec_03_14:30:10_v09.11-e010_1 Tu +e_Feb_02_14:30:06_v09.11-e026_1 Wed_Dec_02_09:20:09_v09.11-e008_1 Mon_Jan_04_14:30:06_v09.11-e017_1 T +hu_Dec_10_14:30:11_v09.11-e014_1 Tue_Feb_09_13:47:51_v09.11-e029_1 +Wed_Jan_06_14:30:08_v09.11-e020_1 Mon_Jan_11_14:30:06_v09.11-e021_1 Thu_Feb_04_09:20:06_v09.11-e027_1 T +ue_Nov_24_09:13:22_v09.10-b072_1 Wed_Jan_27_14:30:11_v09.11-e022_1 Mon_Mar_08_14:30:04_v09.11-s008_1 Thu_Jan_28_14:30:13_v09.11-e023_1 +Tue_Nov_24_15:54:18_v09.11-e005_1 Wed_Mar_03_16:35:18_v09.11-s005_1 Mon_Nov_23_12:36:58_v09.11-e004_1 Tue_Dec_01_14:30:08_v09.10-p002_1 +Tue_Nov_24_17:31:07_v09.10-p001_1 Wed_Nov_25_10:27:43_v09.11-e002_1 '; @valar1 = split(/[\s+\n]/, $valar); foreach (@valar1) { if ($_ =~ /@dtar[1]/) { my ($ver1) = $_ =~ m/(v09.11-[a-z]\d{3})/; print "$ver1\n"; last; } } foreach (@valar1) { if (my ($ver2) = $_ =~ m/(v09.10-[a-z]\d{3})/) { print "$ver2\n"; last; } } foreach (@valar1) { if (my ($ver3) = $_ =~ m/(v08.\d{2}-[a-z]\d{3})/) { print "$ver3\n"; last; } }

I have a feeling I have written waste lines of code but I cant figure out how to do this. Pls help!

Thanks!

BG


In reply to Re^4: missing outputs by blackgoat
in thread missing outputs by blackgoat

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.