This it the code:
if ($line[0]=~ /^c/) { $line =~/(0x[A-Fa-f0-9]+).*(0x[A-Fa-f0-9]+).*((unit=([ +0-9]+)))/i; my @error = ($1, $2); my $value1= hex $error[0]; my $value2= hex $error[1]; my $unit= $5; $line =~/(port=([0-9]+))/i; my $port= $2; print "Value1: $value1,Value2: $value2, Unit: $unit,P +ort1: $port,Stat: $line[6]\n"; } ----data------ Ctl Date Severity Alarm Message ---------------------------------------------------------------------- +-------- c0 [Mon Apr 10 15:12:42 2006] INFO (0x04:0x000B): Rebuild star +ted: unit=0 c0 [Mon Apr 10 15:12:09 2006] INFO (0x04:0x003B): Rebuild paus +ed: unit=0 c0 [Mon Apr 10 15:08:28 2006] INFO (0x04:0x000B): Rebuild star +ted: unit=0 c0 [Mon Apr 10 15:06:31 2006] ERROR (0x04:0x0002): Degraded uni +t: unit=0, port=1 c0 [Mon Apr 10 15:06:31 2006] WARNING (0x04:0x0019): Drive was re +moved from a bay: port=1
The prob:

The $2 value is wrong in the print out when there is no port... so I would need to delete it but $2 is read-only :-)

Any idea??

Thanks for the help

2006-04-11 Retitled by g0n, as per Monastery guidelines
Original title: 'matching pattens'


In reply to matching patterns by theroninwins

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.