Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-03-28 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found