I have questions on two items. One is syntax related. I know what I want to do, but don't know the syntax to do it in perl. I want to set the variable $plex and $vol for columns two and three in the following output. Summarily, when column one is equal to /^pl/ and column two contains /-02/ then set the plex variable to column two and capture the contents of column three on a line by line basis. Finally, I want to pass those variables to a Unix command (vxplex -g rootdg att $vol $plex). The second question relates to passing the -T option to perl. When I set perl to use taint checking and I ENV={PATH}, perl complains about my using strict.
#!/usr/bin/perl -w use strict; my @vxvols = `/usr/sbin/vxprint -htqg rootdg`; foreach my $type (@vxvols) { if ( $type =~ /pl/ ) { print ($type) ; } } pl Flars-01 Flars ENABLED ACTIVE 20982912 RAID 3/32 + RW pl Flars-02 Flars ENABLED LOG 10176 CONCAT - + RW pl backup-01 backup ENABLED ACTIVE 33560448 CONCAT - + RW pl backup-02 backup ENABLED ACTIVE 33560448 CONCAT - + RW pl backup-03 backup ENABLED ACTIVE LOGONLY CONCAT - + RW pl export_install-01 export_install ENABLED ACTIVE 209727360 RAID 3/32 + RW pl export_install-02 export_install ENABLED LOG 10176 CONCAT - + RW pl rootdisk7vol-01 rootdisk7vol ENABLED ACTIVE 213696 CONCAT - + RW pl rootdisk7vol-02 rootdisk7vol ENABLED ACTIVE 213696 CONCAT - + RW pl rootvol-01 rootvol ENABLED ACTIVE 63427008 CONCAT - + RW pl rootvol-02 rootvol ENABLED ACTIVE 63427008 CONCAT - + RW pl rootvol-03 rootvol ENABLED ACTIVE LOGONLY CONCAT - + RW pl runbook-01 runbook ENABLED ACTIVE 2116608 RAID 3/32 + RW pl runbook-02 runbook ENABLED LOG 10176 CONCAT - + RW pl swapvol-01 swapvol ENABLED ACTIVE 33550272 CONCAT - + RW pl swapvol-02 swapvol ENABLED ACTIVE 33550272 CONCAT - + RW pl var-01 var ENABLED ACTIVE 12587712 CONCAT - + RW pl var-02 var ENABLED ACTIVE 12587712 CONCAT - + RW pl var-03 var ENABLED ACTIVE LOGONLY CONCAT - + RW
ßÖ§†

In reply to Regex matching and setting variables by linebacker

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.