in reply to Re^2: add new lines to output.
in thread add new lines to output.
For data line of: Query = 345, prints:#!/usr/bin/perl -w use strict; open (FILE,"abc345.txt") or die $!; while (<FILE>){ $_ =~ /((^Query = .*)|(^\>.*)|(Length = .*))/i; print $1 // "no match", "\n"; print $2 // "no match", "\n"; print $3 // "no match", "\n"; print $4 // "no match", "\n"; } close (FILE) ;
Update: Had wrong file handle above in "while (<FILE>)". I used <DATA> to test my code and that didn't get corrected in the original post. Anyway the above code does run on my AS Perl 5.10.X machine. I had thought that perhaps something weird was happening with the "=" as that does have significance in a regex, but only in combination with for example "?=". Result is that you do not have to "escape" the = sign. Above code is fine. An escape "\" is required for these characters: {}[]()^$.|*+?\Query = 345 Query = 345 no match no match
|
|---|
| Replies are listed 'Best First'. |
|---|