develooper Front page | perl.perl5.porters | Postings from June 2009

RE: Greetings and...

Thread Previous | Thread Next
From:
Jim Ferguson
Date:
June 11, 2009 01:24
Subject:
RE: Greetings and...
Message ID:
FF2AEE6C5317AE498BB138A768DE08000C7E8B18@excpap02.smh.com
Merijn et al.

My sincere apologies for not providing an explicit report.  I am
referring to the section that describes:

% cat > keymatch
    #!/usr/bin/perl
    $kwds = 'copy compare list print';
    while( $command = <> ){
        $command =~ s/^\s+|\s+$//g;  # trim leading and trailing spaces
        if( ( @matches = $kwds =~ /\b$command\w*/g ) == 1 ){
            print "command: '$matches'\n";
        } elsif( @matches == 0 ){
            print "no such command: '$command'\n";
        } else {
            print "not unique: '$command' (could be one of:
@matches)\n";
        }
    }
    ^D

    % keymatch
    li
    command: 'list'
    co
    not unique: 'co' (could be one of: copy compare)
    printer
    no such command: 'printer'


> Line-6 reads:
>
> print "command: '$matches'\n";
> 
> ...whereas it should be:
> 
> print "command: '@matches'\n";


...JRF...
 
James R. Ferguson
Systems  Architect
Information Systems
Sarasota Memorial Healthcare System
941-917-2188
jim-ferguson@smh.com
 

-----Original Message-----
From: H.Merijn Brand [mailto:h.m.brand@xs4all.nl] 
Sent: Wednesday, June 10, 2009 2:19 PM
To: Jim Ferguson
Cc: Perl5 Porters
Subject: Re: Greetings and...

On Wed, 10 Jun 2009 13:21:47 -0400, "Jim Ferguson"
<Jim-Ferguson@smh.com> wrote:

> Hello Merijn!

You can either mail
  Perl5 Porters <perl5-porters@perl.org>
which is the developer ML, or you can file a RT ticket using 'perlbug'

For maint (perl-5.10.x), the procedure is to fetch from devel
(perl-5.11.x => perl-5.12.0). Non of the developers patches against
maint. Only DaveM does, and he's steaming up to a 5.10.1 release

> I attempted to email listmast@lists.perl.org with the below but met
with
> a timeout failure (quite possibly an internal issue here).
> 
> That said, I thought perhaps I could report this minor correction to
the
> 5.10.0 'perlretut' documentation to your attention.  After all, it was
> originally _you_ who sparked my Perl passion :-)
> 
> If there is a more appropriate target, please let me know.
> 
>
http://perldoc.perl.org/perlretut.html#Composing-regular-expressions-at-
runtime
> 
> Line-6 reads:
> 
> print "command: '$matches'\n";
> 
> ...whereas it should be:
> 
> print "command: '@matches'\n";

It currently looks like this, so I guess it has changed

=head2 Composing regular expressions at runtime

Backtracking is more efficient than repeated tries with different
regular
expressions.  If there are several regular expressions and a match with
any of them is acceptable, then it is possible to combine them into a
set
of alternatives.  If the individual expressions are input data, this
can be done by programming a join operation.  We'll exploit this idea in
an improved version of the C<simple_grep> program: a program that
matches
multiple patterns:

    % cat > multi_grep
    #!/usr/bin/perl
    # multi_grep - match any of <number> regexps
    # usage: multi_grep <number> regexp1 regexp2 ... file1 file2 ...

    $number = shift;
    $regexp[$_] = shift foreach (0..$number-1);
    $pattern = join '|', @regexp;

    while ($line = <>) {
        print $line if $line =~ /$pattern/o;
    }
    ^D

    % multi_grep 2 shift for multi_grep
    $number = shift;
    $regexp[$_] = shift foreach (0..$number-1);

> Thanks again for everything you do for the ITRC and Perl community.
> Please feel free to drop me a line anytime.  I look forward to your
> pointers.
> 
> Warmest regards...
> ...JRF...
> James R. Ferguson
> Systems  Architect
> Information Systems
> Sarasota Memorial Healthcare System
> 941-917-2188
> jim-ferguson@smh.com

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About