I removed the ^ and $ notations in your regex, and your matching worked perfectly:
#!/usr/bin/perl use Modern::Perl; my @matched = qw {pv_name alt_link pv_status total_pe free_pe autoswitch proactive +_polling}; my $vg_details = ' --- Physical volumes --- PV Name /dev/dsk/c14t3d1 PV Name /dev/dsk/c15t3d1 Alternate Link PV Status available Total PE 15997 Free PE 0 Autoswitch On Proactive Polling On '; $vg_details =~ m/^\s*PV\s+Name\s*(?<pv_name>\S+)\s* (\s*PV\s+Name\s+(?<alt_link>\S+)\s+Alternate\s+Link\s*) # skip t +hem \s*PV\s+Status\s+(?<pv_status>\S+)\s* \s*Total\s+PE\s+(?<total_pe>\S+)\s* \s*Free\s+PE\s+(?<free_pe>\d+)\s* \s*Autoswitch\s+(?<autoswitch>\S+)\s* \s*Proactive\s+Polling\s+(?<proactive_polling>\S+)\s*/gsmx; say $+{$_} for @matched;
Results:
/dev/dsk/c14t3d1 /dev/dsk/c15t3d1 available 15997 0 On On
In reply to Re: Regular expression quantifiers and the /gsmx modifiers
by Kenosis
in thread Regular expression quantifiers and the /gsmx modifiers
by davis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |