Gossamer Forum
Home : General : Perl Programming :

if $blah contains "blah"

Quote Reply
if $blah contains "blah"
Hi, I'm stuck when it comes to pattern matching!

What I need to do (for this new links mod i'm creating) is have it look through the $blah variable to check if it contains the word (blank category) anywhere.

like this:

Code:
|----- (lets say eq's Contains)
if($blah =~ "Blank_Category"){
$output qq~
<img src="blank_category.gif">
~;

I want to do this for all categories... (I already have everything planend out, worked out..) It's just when it comes to this part. I don't know hoto search the $blah variable to find the current category name.

can Anyone help? Or need more info?

Thanks!
Quote Reply
Re: if $blah contains "blah" In reply to
Oops almost forgot to tell you what the $blah looks like... It's the <title> tag that links automatically creates on the fly for each database page/category.

So it looks somthing like:

Code:
Title : Category : Blah : Blah : Blah

Thanks!
Quote Reply
Re: if $blah contains "blah" In reply to
Ok, I figured it out on my own.. not using pattern matching though Smile which would probably make it a lot easier... I just broke the string down into an array...

All's good Smile
Quote Reply
Re: if $blah contains "blah" In reply to
Hi,

This code will do the trick:

Code:
if ($blah =~ /Blank_Category/) {
$output .= qq~
<img src="blank_category.gif">~;
}

Cheers Smile

Out of topic: I just modified my Links 2.0 copy to look very much like UBB Smile ... you'll be able to see it online in a few days.

------------------
WDresources
www.wdresources.com