Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: coloring patterns of an array

by chargrill (Parson)
on Feb 05, 2007 at 05:43 UTC ( #598256=note: print w/replies, xml ) Need Help??

in reply to coloring patterns of an array

First, that looks like a scalar to me, not an array. An array looks like this in perl:

@array = ( 'M', 'A', 'S', 'K', ...);

Second, what have you tried?

I immediately think to use a regular expression, wherein I would match 3 or more repeating 'S' characters, capture that match, and surround the match by your font tags in the right hand side of said regular expression.

Look into s/// in "Regexp quote-like operators" at perlop. In particular, pay attention to the use of capturing parenthesis (), the special $1 backreference variable, the {} quantifiers (specifically look for "Match at least n times"), and the /g global modifier.

After you've given it an effort, and if you're still having trouble, let us know - we'll be happy to help.

Update: Taking a second look, you'll also need to decide if you want to add spaces, as you have in your example, or whether that was a typo.

s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://598256]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2019-10-18 03:33 GMT
Find Nodes?
    Voting Booth?