Hi,
This little thing has been bugging me for a while now <G>
Basically, if you use;
$_ =~ m/regex-string/ and do_something();
|regex-string| and do_something();
m|regex-string| and do_something();
/regex-string/ and do_something();
m/regex-string/ and do_something();
These work fine (although the m isn't really needed).
However, something like this;
if ($_ =~ m/regex-string/) { do_something(); }WORKS
if (|regex-string|) { do_something(); }DOESN'T WORK
if (m|regex-string|) { do_something(); } DOESN'T WORK
if (/regex-string/) { do_something(); } WORKS
if (m/regex-string/) { do_something(); } WORKS
I get a syntax error. Basically, anything that uses the format of if (|regex|) (i.e using || as the delimiter, mainly for automatic escaping of / , which would get messed up if using m//).
Is there a reason/workaround for this?
Today, for example.. I wanted to do;
.. but ended up having to use the 'm';
.. as it kept coming up with synax errors
TIA for any comments= )
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
This little thing has been bugging me for a while now <G>
Basically, if you use;
Code:
$_ =~ /regex-string/ and do_something(); $_ =~ m/regex-string/ and do_something();
|regex-string| and do_something();
m|regex-string| and do_something();
/regex-string/ and do_something();
m/regex-string/ and do_something();
These work fine (although the m isn't really needed).
However, something like this;
Code:
if ($_ =~ /regex-string/) { do_something(); }WORKS if ($_ =~ m/regex-string/) { do_something(); }WORKS
if (|regex-string|) { do_something(); }DOESN'T WORK
if (m|regex-string|) { do_something(); } DOESN'T WORK
if (/regex-string/) { do_something(); } WORKS
if (m/regex-string/) { do_something(); } WORKS
I get a syntax error. Basically, anything that uses the format of if (|regex|) (i.e using || as the delimiter, mainly for automatic escaping of / , which would get messed up if using m//).
Is there a reason/workaround for this?
Today, for example.. I wanted to do;
Code:
if ($_ !~ |\Q<Topic r:id="Top/$cat/\E(.*?)\Q">\E| && $flag && $_ =~ |\Q<Topic r:id="Top/|i) { $stop = 1; }.. but ended up having to use the 'm';
Code:
if ($_ !~ m|\Q<Topic r:id="Top/$cat/\E(.*?)\Q">\E| && $flag && $_ =~ m|\Q<Topic r:id="Top/|i) { $stop = 1; }.. as it kept coming up with synax errors
TIA for any comments= )
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

