Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm fighting syntax issues and losing when trying to match a constant's value within a regular expression. Searching the archives yielded http://www.perlmonks.com/index.pl?node_id=293323, but I'm still getting syntax errors. A simplified test case is:
Can you help me over these syntax issues? Thanks.#!/usr/bin/perl use strict; use warnings; use constant { ATTRIBUTE_0 => 'foo', ATTRIBUTE_1 => 'bar' }; open IN, 'input.xml' or die 'unable to open input XML file'; while (<IN>) { print "attribute 0=\t$1\n" if m/@{ATTRIBUTE_0}='(.*)'/e; print "attribute 1=\t$1\n" if m/@{ATTRIBUTE_1}='(.*)'/e; } close IN;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: matching constants within a regular expression?
by Paladin (Vicar) on Mar 10, 2004 at 23:00 UTC | |
Re: matching constants within a regular expression?
by elusion (Curate) on Mar 10, 2004 at 23:15 UTC | |
Re: matching constants within a regular expression?
by thelenm (Vicar) on Mar 10, 2004 at 23:00 UTC | |
Re: matching constants within a regular expression?
by BrowserUk (Patriarch) on Mar 10, 2004 at 23:12 UTC | |
Re: matching constants within a regular expression?
by matija (Priest) on Mar 10, 2004 at 23:07 UTC |
Back to
Seekers of Perl Wisdom