I’m trying to work out a bug in my script. I need to accommodate for longer Snapshot names but longer names cause the date:time to wrap to a new line. My script is only properly grepping off the date and and smaller snapshot name. I need to accommodate longer snapshot names. In the first example output, the snapshot names are 1, 2, 3... In the second sample, the names begin with Snapxxxx.

#Source array @sourceResult = $sourceTelnet->cmd("$sourceGetsnapshots"); print @sourceResult; @sourceGrepsnaps = grep(/20(13|14)/, @sourceResult); print "This is sourceGrepsnaps\n"; print @sourceGrepsnaps; print "\n";

This is the output from @sourceResult, sample 1

Vdisk Serial Number Name Creation Date/Time + Status Status-Reason Source Volume Snap-pool Name Snap Data Uniq +ue Data Shared Data Priority User Priority Type ---------------------------------------------------------------------- +--------- vd02 00c0ff10f4370000be62415201000000 1 2013-09-24 10:00:30 + Available N/A rep_pri_vol sprep_pri_vol 0B 0B + 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd02 00c0ff10f4370000bf63415201000000 2 2013-09-24 10:04:47 + Available N/A rep_pri_vol sprep_pri_vol 0B 0B + 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd02 00c0ff10f4370000c76e415201000000 3 2013-09-24 10:51:51 + Available N/A rep_pri_vol sprep_pri_vol 0B 0B + 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd02 00c0ff10f4370000d87c415201000000 4 2013-09-24 11:51:52 + Available N/A rep_pri_vol sprep_pri_vol 0B 0B + 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd02 00c0ff10f4370000e68a415201000000 5 2013-09-24 12:51:50 + Available N/A rep_pri_vol sprep_pri_vol 0B 0B + 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd02 00c0ff10f4370000f698415201000000 6 2013-09-24 13:51:50 + Available N/A rep_pri_vol sprep_pri_vol 0B 0B + 0B 0x8000 0x0000 Replication snapshot(Current sync point)(Common sync point) ---------------------------------------------------------------------- +--------- Success: Command completed successfully. (2013-09-24 14:04:47)

This is the output from @sourceResult, sample 2

Vdisk Serial Number Name Creation Date/Time Status Status-Reason Source Volume Snap-pool Name Snap Data Unique Data Shared Data Priority User Priority Type + ---------------------------------------------------------------------- +-------- vd01 00c0ff10e1e50000eac6415201000000 Snap13800424740 2013-09-24 17:07:54 Available N/A rrep_pri_vol sprrep_pri_vol 0B 0B 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd01 00c0ff10e1e50000efc6415201000000 Snap13800424790 2013-09-24 17:07:59 Available N/A rrep_pri_vol sprrep_pri_vol 0B 0B 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd01 00c0ff10e1e50000f4c6415201000000 Snap13800424840 2013-09-24 17:08:04 Available N/A rrep_pri_vol sprrep_pri_vol 0B 0B 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd01 00c0ff10e1e50000f8c6415201000000 Snap13800424880 2013-09-24 17:08:08 Available N/A rrep_pri_vol sprrep_pri_vol 0B 0B 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd01 00c0ff10e1e50000ead1415201000000 Snap13800452900 2013-09-24 17:54:50 Available N/A rrep_pri_vol sprrep_pri_vol 0B 0B 0B 0x4000 0x0000 Replication snapshot(Old Common sync point) vd01 00c0ff10e1e50000fbdf415201000000 Snap13800488910 2013-09-24 18:54:51 Available N/A rrep_pri_vol sprrep_pri_vol 0B 0B 0B 0x8000 0x0000 Replication snapshot(Current sync point)(Common sync + point)
The output can be below or vice versa. Date:Time Snapshotname Date:Time Snapshotname Date:Time Snapshotname Date:Time Snapshotname

How would you go about exacting that information? Thanks


In reply to Bug in script when users use long names by Sparky

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.