Gossamer Forum
Home : General : Perl Programming :

/ / => | |

Quote Reply
/ / => | |
<mentalblock>

I'm doing a string match using =~ /string/; but it's getting ugly. How can I use something besides // as my 'thingies' - (for the lack of a better word). How can I do =~ |string|;

Thanks!

- wil

Last edited by:

Wil: Mar 19, 2002, 6:41 AM
Quote Reply
Re: [Wil] / / => | | In reply to
Not definate, but dont you put it like;

=~ m|||;

Unimpressed

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Wil] / / => | | In reply to
Use m.

=~ m|bla|;
Quote Reply
Re: [Paul] / / => | | In reply to
What a guess Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [A.J.] / / => | | In reply to
Hmm after I submitted my post yours wasn't even there....mine was below Wils.

I didn't even know you'd posted...weird.

>>What a guess <<

Close but wasn't quite right :)

Last edited by:

Paul: Mar 19, 2002, 6:36 AM
Quote Reply
Re: / / => | | In reply to
Ah yeah. I needed the m modifier.

Thanks, all!

</mentalblock>

- wil
Quote Reply
Re: [Paul] / / => | | In reply to
Ah well, we did post at exactly the same time Wink It was almost right, I just accidently put in the extra |, otherwise it was right...lol

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

A.J.: Mar 19, 2002, 6:46 AM
Quote Reply
Re: [A.J.] / / => | | In reply to
Close again. It was a | lol
Quote Reply
Re: [Paul] / / => | | In reply to
Indeed, typo...fixed now ;)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [A.J.] / / => | | In reply to
Hm. Why will the following not work under use strict?

Code:
my $referrer = $ENV{HTTP_REFERER};
my $goto = $referrer;

if ($referrer =~ m|/en/|g) {
$goto =~ ms|/en/|/ws/|g;
}
elsif ($referrer =~ m|/ws/|g) {
$goto =~ ms|/ws/|/en/|g;
}
else {
die("Can't understand what to translate to.");
}

print $query->redirect($goto);

It tells me that:

Code:
Bareword "g" not allowed while "strict subs" in use at translate line 29.

:-\

I can't globally match something under use strict then? This seems a bit silly?

- wil
Quote Reply
Re: [Wil] / / => | | In reply to
um, what exactly is

$goto =~ ms|/en/|/ws/|g;

there's no such thing as ms.

Are you matching or substituting? You appear to be substituting, so remove the m. You can use alternate delimiters with s

Smile

--mark

Last edited by:

Mark Badolato: Mar 19, 2002, 6:57 AM
Quote Reply
Re: [Mark Badolato] / / => | | In reply to
Aha. Bingo.

Thanks a lot.

- wil
Quote Reply
Re: [Wil] / / => | | In reply to
The g isn't needed for if/elsif lines. You are only trying to find a match so whether you use g or not makes no difference as the regex will be true after the first match.

Last edited by:

Paul: Mar 19, 2002, 7:29 AM
Post deleted by Paul In reply to

Last edited by:

Paul: Mar 19, 2002, 7:31 AM