On Sun, Jun 11, 2006 at 04:33:52PM +0200, Adriano Allora wrote:

> i need to extract from a list  of words (in a single column) anotherl 
> list containing only the words of 5 or less chars.
> 
> I wrote this script, but it doesn't work:
> 
> #!/usr/bin/perl -w
> 
> while (<>)
>       {
>       print "$_" if /^\w{,5}/;
>       }
> 
> someone can tell me why it does not work?

You don't tell us in which way it doesn't work, but the {,5} construct
isn't doing what you think it is.  The first parameter doesn't have a
default, so you probably want to write {1,5}.

But even then it won't work.  Think about the regular expression you
have written.  It says "match the start of the string, followed by one
to five word characters".  Can you see why that would match a string
such as "terminate" for example?

> Thanks all,
> 
> alladr
> 
> 
> |^|_|^|_|^|                              |^|_|^|_|^|  
>  |            |                                 |            |
>  |            |                                 |            |
>  |            |*\_/*\_/*\_/*\_/*\_/* |            |
>  |                                                           |
>  |                                                           |
>  |                                                           |
>  |       http://www.e-allora.net        |
>  |                                                           |
>  |                                                           |
> **************************************

Hmmm.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to