[Wolves] Pay-for music download sites

Barbie barbie at missbarbell.co.uk
Tue Jun 15 16:00:58 BST 2004


On 15 June 2004 14:41 David Goodwin wrote:

> <joke type='obligatory' class='perl'>
> It's legible perl code....
> </joke>

It could be worse, it could have been python .... cue holy wars ;)

> On the subject of perl :
> 
> If I have a string with ".... cs:Connected st: ..." in it,
> why doesn't
> the following catch the word after cs: ?
> 
> if($tmp =~ /cs:\b st:/) {
>     # should $1 == Connected ?
> }

Nope, you've not captured anything. '\b' marks a word boundary, but the regex will not match the string you want. Try:

if($tmp =~ /cs:(.*?) st:/) {

The capture '()' will do a non-greedy match '.*?', although in most cases you can just do a greedy match '.*'.

Barbie.




More information about the Wolves mailing list