Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl regex matching multiple multiline groups
    primarykey
    data
    text
    <p>I have bunch of text and I am trying to match a group of pattern, the regex which I am using is able to match the pattern but the problem is that it matches only the second group not the first group.</p> <pre><code>open(FILE, "match.txt") || die("Could not open file "); my $text = do { local $/; &lt;FILE&gt; }; while( $text =~ m/FibreChannel SCSI Interface.*World Wide Port Number\.*(.*?)\n.*Driver\.+(.*?)\n.*Vendor Name\.+(.*?)\n/sgmp ) { print "$1\n$2\n$3\n"; } </code></pre> <hr> <p>Prints</p> <p> 0x1b201<br/> lpfc_740<br> Test Corporation<br> </p> <p>The above code works but it displays only the text from the second group not the first group. What am I missing here? Is there a better way to do this?</p> <p>I thought it would print</p> <p>0x1a101<br> lpfc_740<br> Test Corporation<br> 0x1b201<br> lpfc_740<br> Test Corporation</p> <p>------------------------ match.txt contains</p> <pre><code>\==+FibreChannel SCSI Interface : |----Link State.........................................Down |----World Wide Port Number.............................0x1a101 \==+SCSI Interface : |----Driver..........................................lpfc_740 |----Queue Depth.....................................2038 \==+PCI Device : |----Bus..........................................0x06 |----Vendor Name..................................Test Corporation |----Slot Description............................. \==+FibreChannel SCSI Interface : |----Link State.........................................Down |----World Wide Port Number.............................0x1b201 \==+SCSI Interface : |----Driver..........................................lpfc_740 |----Queue Depth.....................................2038 \==+PCI Device : |----Bus..........................................0x0a |----Vendor Name..................................Test Corporation |----Slot Description............................. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload