comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
January 2008
motuwethfrsasuw
 123456 1
78910111213 2
14151617181920 3
21222324252627 4
28293031    5
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Question about "?" character in Perl Regular Expression         


Author: Ahmad
Date: Jan 1, 2008 23:58

When running the following example:

$str="aaaaaa bbbb";
($a,$b)= $str=~/(\w+)\s?(\w+)/;
print $a,"\n",$b;

The result is:

aaaaa
a

Why do we get this result??? Can anybody explain it?
thanks and regards,
Ahmad
6 Comments
  FAQ 6.15 How can I do approximate matching?         


Author: PerlFAQ Server
Date: Jan 1, 2008 12:03

This is an excerpt from the latest version perlfaq6.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

6.15: How can I do approximate matching?

See the module String::Approx available from CPAN.

--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
no comments
  Strip equal portion of strings / version comparison         


Author: Stefan
Date: Jan 1, 2008 10:02

Starting with:

$a = '1.1.2';
$b = '1.1.10';

Is there an elegant, one-liner way -- possibly using RE -- to yield:

$a = '2';
$b = '10';

In other words, strip out the beginning equal portion of 2 strings?

Moreover, how could you compare the original $a and $b such that $b >
$a (as in version comparisons)?

Thanks!
Stefan
3 Comments
  FAQ 6.7 How can I match a locale-smart version of "/[a-zA-Z]/"?         


Author: PerlFAQ Server
Date: Jan 1, 2008 06:03

This is an excerpt from the latest version perlfaq6.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

6.7: How can I match a locale-smart version of "/[a-zA-Z]/"?

You can use the POSIX character class syntax "/[[:alpha:]]/" documented
in perlre.

No matter which locale you are in, the alphabetic characters are the
characters in \w without the digits and the underscore. As a regex, that
looks like "/[^\W\d_]/". Its complement, the non-alphabetics, is then
everything in \W along with the digits and the underscore, or
"/[\W\d_]/".

--------------------------------------------------------------------
Show full article (1.43Kb)
no comments
  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)         


Author: tadmc
Date: Jan 1, 2008 00:12

Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information ...
Show full article (16.63Kb)
no comments
  FAQ 6.8 How can I quote a variable to use in a regex?         


Author: PerlFAQ Server
Date: Jan 1, 2008 00:03

This is an excerpt from the latest version perlfaq6.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

6.8: How can I quote a variable to use in a regex?

The Perl parser will expand $variable and @variable references in
regular expressions unless the delimiter is a single quote. Remember,
too, that the right-hand side of a "s///" substitution is considered a
double-quoted string (see perlop for more details). Remember also that
any regex special characters will be acted on unless you precede the
substitution with \Q. Here's an example:

$string = "Placido P. Octopus";
$regex = "P.";

$string =~ s/$regex/Polyp/;
# $string is now "Polypacido P. Octopus"
Show full article (2.13Kb)
no comments