Insomniak wrote:
>
> Hi All,
Hello,
> Please please please ....can someone save me from further headaches.
> Bascially the regex will match the header (lines with hashes) to the
> </VirtualHost>
> giving me what I need into %virtual_host.
>
> However if there is a blank line as shown for server 1
> the regex wont match.
> Can any regex gurus help me with this????
>
> Oh and please feel free to point out any cockups ive made :)
>
> The code
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> sub open_httpd {
> open(FH, "<". @_[0]) or die print "Cannot read @_[0]";
> local $/ = '';
> while (<FH>) {
> while (/^([#]{50}\n## [Ss]erver
>+?([0-9]+).*^(<VirtualHost(.*)>(.*)^<\/VirtualHost>)\n$)$/smg) {
| | | | | | | | |
|
| +- $2 -+ | +$4+ +$5+ |
|
| +---------------- $3 -----------------+
|
+--------------------------------------- $1
----------------------------------+
It isn't clear what you are trying to match and why you are using 5 backreferences.
while ( /^(#{50}\n## [Ss]erver +?([0-9]+).*?^<VirtualHost.*?>.*?^<\/VirtualHost>)$/smg
) {
> if (!exists $virtual_host{$2}){
> $virtual_host{$2}=$1;
> }else {
> warn "Duplicate Virtual Host ID $2 found at $.\n";
> }
> }
> }
> }
>
> Sample Data
>
> [snip]
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]