[30211] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1454 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 22 16:08:01 2008

Date: Tue, 22 Apr 2008 13:07:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 22 Apr 2008     Volume: 11 Number: 1454

Today's topics:
        $nntp ->list() <gerry@nowhere.ford>
    Re: $nntp ->list() <1usa@llenroc.ude.invalid>
    Re: $nntp ->list() <gerry@nowhere.ford>
    Re: $nntp ->list() <gerry@nowhere.ford>
        =?KOI8-R?B?8O/p8+sg9+H76egg7+Tu7+vs4fPz7unr7/c=?= <zolotoiklo@mail.ru>
        ANNOUNCE: Text-CSV_XS 0.43 <h.m.brand@xs4all.nl>
        ANNOUNCE: Text::CSV_XS 0.42 <h.m.brand@xs4all.nl>
    Re: Can someone 'splain why this regex won't work both  <ced@blv-sam-01.ca.boeing.com>
    Re: Can someone 'splain why this regex won't work both  <nospam-abuse@ilyaz.org>
        complete perl-package(IDE, IAprompt etc), where? .com o <skanemupp@yahoo.se>
    Re: counting the number of characters that were matched <glennj@ncf.ca>
        counting the number of characters that were matched in  PugetSoundSylvia@gmail.com
    Re: counting the number of characters that were matched PugetSoundSylvia@gmail.com
    Re: counting the number of characters that were matched <jimsgibson@gmail.com>
    Re: counting the number of characters that were matched <someone@example.com>
        Creating necessary configuration files on package insta <david.g.hong@gmail.com>
    Re: Creating necessary configuration files on package i <david.g.hong@gmail.com>
    Re: Creating necessary configuration files on package i <david.g.hong@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 19 Apr 2008 16:11:55 -0500
From: "Gerry Ford" <gerry@nowhere.ford>
Subject: $nntp ->list()
Message-Id: <1208639075_1352@news.newsgroups.com>


[repost from elsewhere]
I've been looking at Mats Peterson's client for the last week.  He has a
perl script and a resource file for things like your server name.

It occurs to me that a person would want to have another resource file of
some type that will hold the list of newsgroups.  With my newsfeed, there's
100,000 of them, and I use a 56K dial-up, so it takes five or ten minutes.
When I fire up OE or binary vortex for the first time, it says "hold on, I'm
downloading the list of newsgroups.  This could take a while, but you
prettymuch only have to do it once."  Consequently it has to be serialized
somehow.

When I've had my minimal clients before, I would hard-code the group I was
looking at, like so:
#!/usr/bin/perl -w

use strict;
use Net::NNTP ();

use constant NUMBER_OF_ARTICLES    => 100;
use constant GROUP_NAME        => 'comp.lang.c';
use constant SERVER_NAME    => 'news.newsgroups.com';
use constant NNTP_DEBUG        => 0;

my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = 'wade196884';
my $PASS = '';

$nntp->authinfo($USER,$PASS) or die $!;


my($article_count, $first_article, $last_article) = $nntp->group(GROUP_NAME)
or die;


# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};

my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
$first_article) {

    # How many articles do we need?  Stop retrieving if we have enough
    my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last
RETRIEVE;


    # Fetch overview information for the articles
    $start_article = $last_article - ($articles_required-1);
    $start_article = $start_article > $first_article ? $start_article :
$first_article;

    my $xover_query = $start_article == $last_article ?
    $start_article :
    [$start_article, $last_article];
    my $xover_ref = $nntp->xover($xover_query) or die;

    # Store headers for the articles we've retrieved
    foreach (sort {$b <=> $a} keys %$xover_ref) {
        push @xover, $xover_ref->{$_};
    }
} continue {
    # Move the pointer forward to fetch previous articles
    $last_article = $start_article - 1;
}

# Disconnect from the NNTP server
$nntp->quit;

print join("\n", map ($_->[$subject_offset].' from '.$_->[$from_offset],
@xover)),"\n";

#  perl mats1.pl 2>text50.txt >text51.txt
__END__

In Mats' script I think he gets the group list so:
sub get_all_groups {
    my $groups = $nntp->list() or do {prompt $nntp; return};
    $_ = prompt('File name: '); length or return;
    open(FILE, ">$_") or die "open: $!\n";
    print FILE "$_!\n" foreach (sort keys %$groups);
    close(FILE);
}

The nntp object is already instantiated, and  it looks like the list()
method is the workhorse here.  How would I get all the groups using my
bare-bones script and write them to a FILE?  One answer might be that it's
right in front of my nose, but I have trouble following execution in perl.

-- 
"A belief in a supernatural source of evil is not necessary; men alone
are quite capable of every wickedness."

~~  Joseph Conrad (1857-1924), novelist




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

Date: Sat, 19 Apr 2008 21:45:37 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: $nntp ->list()
Message-Id: <Xns9A85B4AAEA4E8asu1cornelledu@127.0.0.1>

"Gerry Ford" <gerry@nowhere.ford> wrote in
news:1208639075_1352@news.newsgroups.com: 

> 
> When I've had my minimal clients before, I would hard-code the
> group I was looking at, like so:

Sorry, don't have time wade through your script. I don't know much 
about NNTP and the nitty gritty. Besides, it is not relevant to your 
question (unless you wanted us to re-write your script for you).

> In Mats' script I think he gets the group list so:
> sub get_all_groups {
>     my $groups = $nntp->list() or do {prompt $nntp; return};
>     $_ = prompt('File name: '); length or return;
>     open(FILE, ">$_") or die "open: $!\n";
>     print FILE "$_!\n" foreach (sort keys %$groups);
>     close(FILE);
> }
> 
> The nntp object is already instantiated, and  it looks like the
> list() method is the workhorse here.  How would I get all the
> groups using my bare-bones script and write them to a FILE?  One
> answer might be that it's right in front of my nose, but I have
> trouble following execution in perl. 

The answer is literally in front of you. From 
http://search.cpan.org/~gbarr/libnet-1.22/Net/NNTP.pm :

list ()

    Obtain information about all the active newsgroups. The results 
is a reference to a hash where the key is a group name and each 
value is a reference to an array. The elements in this array are:- 
the last article number in the group, the first article number in 
the group and any information flags about the group.

I rewrote it a little bit to make it more pleasing to me. The script 
takes the username and password from command line arguments. I only 
did that so I don't accidentally post my credentials. 

#!/usr/bin/perl -w

use strict;
use warnings;

use Net::NNTP ();

my %settings = (
    SERVER_NAME => '127.0.0.1',
    SERVER_PORT => 563,
    NEWSRC      => 'newsrc.txt',
    DEBUG       => 1,
);

@ARGV == 2
    or die "Provide username and password on the command line\n";

@settings{ qw( USER PASS ) } = @ARGV;

my $nntp = Net::NNTP->new(
    "$settings{SERVER_NAME}:$settings{SERVER_PORT}", 
    'Debug' => $settings{DEBUG},
) or die $@;

$nntp->authinfo(@settings{ qw( USER PASS ) }) or die $@;

my $groups = $nntp->list();

open my $newsrc, '>', $settings{NEWSRC}
    or die "Cannot open '$settings{NEWSRC}': $!";

print $newsrc join( "!\n", sort keys %$groups );

close $newsrc
    or die "Cannot close '$settings{NEWSRC}': $!";

__END__

Here is the debug log:

Net::NNTP>>> Net::NNTP(2.24)
Net::NNTP>>>   Net::Cmd(2.29)
Net::NNTP>>>     Exporter(5.62)
Net::NNTP>>>   IO::Socket::INET(1.31)
Net::NNTP>>>     IO::Socket(1.30_01)
Net::NNTP>>>       IO::Handle(1.27)
Net::NNTP=GLOB(0x1a82274)<<< 200 bgtnsc04 Welcome ...
Net::NNTP=GLOB(0x1a82274)>>> MODE READER
Net::NNTP=GLOB(0x1a82274)<<< 200 bgtnsc04 ...
Net::NNTP=GLOB(0x1a82274)>>> AUTHINFO USER userid
Net::NNTP=GLOB(0x1a82274)<<< 381 More Authentication Required
Net::NNTP=GLOB(0x1a82274)>>> AUTHINFO PASS ....
Net::NNTP=GLOB(0x1a82274)<<< 281 Authentication Accepted
Net::NNTP=GLOB(0x1a82274)>>> LIST
Net::NNTP=GLOB(0x1a82274)<<< 215 NewsGroups Follow
Net::NNTP=GLOB(0x1a82274)>>> QUIT
Net::NNTP=GLOB(0x1a82274)<<< 205 GoodBye

C:\Temp\nntp> grep comp.lang.perl newsrc.txt
comp.lang.perl.announce!
comp.lang.perl.misc!
comp.lang.perl.moderated!
comp.lang.perl.modules!
comp.lang.perl.tk!
de.comp.lang.perl.cgi!
de.comp.lang.perl.misc!
fj.comp.lang.perl!
fr.comp.lang.perl!
han.comp.lang.perl!
pl.comp.lang.perl!

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Sun, 20 Apr 2008 00:02:28 -0500
From: "Gerry Ford" <gerry@nowhere.ford>
Subject: Re: $nntp ->list()
Message-Id: <1208667309_2050@news.newsgroups.com>


"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
news:Xns9A85B4AAEA4E8asu1cornelledu@127.0.0.1...
> "Gerry Ford" <gerry@nowhere.ford> wrote in
> news:1208639075_1352@news.newsgroups.com:
>
>>
>> When I've had my minimal clients before, I would hard-code the
>> group I was looking at, like so:
>
> Sorry, don't have time wade through your script. I don't know much
> about NNTP and the nitty gritty. Besides, it is not relevant to your
> question (unless you wanted us to re-write your script for you).
>
>> In Mats' script I think he gets the group list so:
>> sub get_all_groups {
>>     my $groups = $nntp->list() or do {prompt $nntp; return};
>>     $_ = prompt('File name: '); length or return;
>>     open(FILE, ">$_") or die "open: $!\n";
>>     print FILE "$_!\n" foreach (sort keys %$groups);
>>     close(FILE);
>> }
>>
>> The nntp object is already instantiated, and  it looks like the
>> list() method is the workhorse here.  How would I get all the
>> groups using my bare-bones script and write them to a FILE?  One
>> answer might be that it's right in front of my nose, but I have
>> trouble following execution in perl.
>
> The answer is literally in front of you. From
> http://search.cpan.org/~gbarr/libnet-1.22/Net/NNTP.pm :
>
> list ()
>
>    Obtain information about all the active newsgroups. The results
> is a reference to a hash where the key is a group name and each
> value is a reference to an array. The elements in this array are:-
> the last article number in the group, the first article number in
> the group and any information flags about the group.
>
> I rewrote it a little bit to make it more pleasing to me. The script
> takes the username and password from command line arguments. I only
> did that so I don't accidentally post my credentials.
>
> #!/usr/bin/perl -w
>
> use strict;
> use warnings;
>
> use Net::NNTP ();
>
> my %settings = (
>    SERVER_NAME => '127.0.0.1',
>    SERVER_PORT => 563,
>    NEWSRC      => 'newsrc.txt',
>    DEBUG       => 1,
> );
>
> @ARGV == 2
>    or die "Provide username and password on the command line\n";
>
> @settings{ qw( USER PASS ) } = @ARGV;
>
> my $nntp = Net::NNTP->new(
>    "$settings{SERVER_NAME}:$settings{SERVER_PORT}",
>    'Debug' => $settings{DEBUG},
> ) or die $@;
>
> $nntp->authinfo(@settings{ qw( USER PASS ) }) or die $@;
>
> my $groups = $nntp->list();
>
> open my $newsrc, '>', $settings{NEWSRC}
>    or die "Cannot open '$settings{NEWSRC}': $!";
>
> print $newsrc join( "!\n", sort keys %$groups );
>
> close $newsrc
>    or die "Cannot close '$settings{NEWSRC}': $!";
>
> __END__
>
> Here is the debug log:
>
> Net::NNTP>>> Net::NNTP(2.24)
> Net::NNTP>>>   Net::Cmd(2.29)
> Net::NNTP>>>     Exporter(5.62)
> Net::NNTP>>>   IO::Socket::INET(1.31)
> Net::NNTP>>>     IO::Socket(1.30_01)
> Net::NNTP>>>       IO::Handle(1.27)
> Net::NNTP=GLOB(0x1a82274)<<< 200 bgtnsc04 Welcome ...
> Net::NNTP=GLOB(0x1a82274)>>> MODE READER
> Net::NNTP=GLOB(0x1a82274)<<< 200 bgtnsc04 ...
> Net::NNTP=GLOB(0x1a82274)>>> AUTHINFO USER userid
> Net::NNTP=GLOB(0x1a82274)<<< 381 More Authentication Required
> Net::NNTP=GLOB(0x1a82274)>>> AUTHINFO PASS ....
> Net::NNTP=GLOB(0x1a82274)<<< 281 Authentication Accepted
> Net::NNTP=GLOB(0x1a82274)>>> LIST
> Net::NNTP=GLOB(0x1a82274)<<< 215 NewsGroups Follow
> Net::NNTP=GLOB(0x1a82274)>>> QUIT
> Net::NNTP=GLOB(0x1a82274)<<< 205 GoodBye
>
> C:\Temp\nntp> grep comp.lang.perl newsrc.txt
> comp.lang.perl.announce!
> comp.lang.perl.misc!
> comp.lang.perl.moderated!
> comp.lang.perl.modules!
> comp.lang.perl.tk!
> de.comp.lang.perl.cgi!
> de.comp.lang.perl.misc!
> fj.comp.lang.perl!
> fr.comp.lang.perl!
> han.comp.lang.perl!
> pl.comp.lang.perl!
I think I married the two here, yet I get no new file called 'newsrc2.txt' 
in my scripts folder.

I get 3 arts and print subject and from from clc.  Why doesn't this then 
create the file with the whole thing?  Would it maybe not  create the file 
until the whole thing were downloaded?
#!/usr/bin/perl -w

use strict;
use Net::NNTP ();

use constant NUMBER_OF_ARTICLES    => 3;
use constant GROUP_NAME        => 'comp.lang.c';
use constant SERVER_NAME    => 'news.newsgroups.com';
use constant NNTP_DEBUG        => 0;

my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = '';
my $PASS = '';

my %settings = (
    SERVER_NAME => '127.0.0.1',
    SERVER_PORT => 563,
    NEWSRC      => 'newsrc2.txt',
    DEBUG       => 1,
);

$nntp->authinfo($USER,$PASS) or die $!;


my($article_count, $first_article, $last_article) =

$nntp->group(GROUP_NAME) or die;


# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};

my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=

$first_article) {

    # How many articles do we need?  Stop retrieving if we have enough
    my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last

RETRIEVE;


    # Fetch overview information for the articles
    $start_article = $last_article - ($articles_required-1);
    $start_article = $start_article > $first_article ? $start_article :

$first_article;

    my $xover_query = $start_article == $last_article ?
    $start_article :
    [$start_article, $last_article];
    my $xover_ref = $nntp->xover($xover_query) or die;

    # Store headers for the articles we've retrieved
    foreach (sort {$b <=> $a} keys %$xover_ref) {
        push @xover, $xover_ref->{$_};
    }
} continue {
    # Move the pointer forward to fetch previous articles
    $last_article = $start_article - 1;
}

print join("\n", map ($_->[$subject_offset].' from '.$_->[$from_offset],

@xover)),"\n";
# end script that prints 3 arts from clc



my $groups = $nntp->list();

open my $newsrc, '>', $settings{NEWSRC}
    or die "Cannot open '$settings{NEWSRC}': $!";

print $newsrc join( "!\n", sort keys %$groups );

close $newsrc
    or die "Cannot close '$settings{NEWSRC}': $!";
# Disconnect from the NNTP server
$nntp->quit;


#  perl mats3.pl 2>text50.txt >text51.txt
__END__

-- 
"A belief in a supernatural source of evil is not necessary; men alone
are quite capable of every wickedness."

~~  Joseph Conrad (1857-1924), novelist 




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

Date: Sun, 20 Apr 2008 00:46:36 -0500
From: "Gerry Ford" <gerry@nowhere.ford>
Subject: Re: $nntp ->list()
Message-Id: <1208669957_2205@news.newsgroups.com>


"Gerry Ford" <gerry@nowhere.ford> wrote in message 
news:1208667309_2050@news.newsgroups.com...
>
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message

> my $groups = $nntp->list();
>
> open my $newsrc, '>', $settings{NEWSRC}
>    or die "Cannot open '$settings{NEWSRC}': $!";
>
> print $newsrc join( "!\n", sort keys %$groups );
>
> close $newsrc
>    or die "Cannot close '$settings{NEWSRC}': $!";
> # Disconnect from the NNTP server
> $nntp->quit;
>
>
> #  perl mats3.pl 2>text50.txt >text51.txt
> __END__
Dr. Unur,

We did get it; I simply didn't wait enough.  There were a lot of finer 
points in the comparison of the two scripts.  One was debug info.  I 
switched my debug info from 0 to 1 and was on my way: 
http://zaxfuuq.net/perl153.jpg .

From newssrc2.txt:
zer.t-netz.modem!
zer.t-netz.modem.usr!
zer.t-netz.modem.zyxel!
zer.t-netz.netzwesen!
zer.t-netz.newsbrothers!
zer.t-netz.partnerwahl!

Mit freundlichem Gruss,
-- 
"A belief in a supernatural source of evil is not necessary; men alone
are quite capable of every wickedness."

~~  Joseph Conrad (1857-1924), novelist 




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

Date: Wed, 16 Apr 2008 02:18:54 -0700 (PDT)
From: =?KOI8-R?B?+s/Mz9TPyiDrzM/O?= <zolotoiklo@mail.ru>
Subject: =?KOI8-R?B?8O/p8+sg9+H76egg7+Tu7+vs4fPz7unr7/c=?=
Message-Id: <aff6370b-88d5-47cc-af99-1ff871b882d1@a70g2000hsh.googlegroups.com>

8O/p8+sg9+H76egg7+Tu7+vs4fPz7unr7/cNCmh0dHA6Ly9vZG5va2xhc3NuaWtpLmttLnJ1Lz9p
bnZpdGVpZD0yODc3NjYyDQoNCvLFx8nT1NLBw8nRLg0K99nCxdLJ1MUg0sXHyc/OLCDXIMvP1M/S
z80g19kg1d7JzMnT2CDXINvLz8zF


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

Date: Tue, 22 Apr 2008 16:01:57 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: ANNOUNCE: Text-CSV_XS 0.43
Message-Id: <JzqI10.pwD@zorch.sf-bay.org>

On popular demand ...

  file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.43.tgz
  size: 87473 bytes
   md5: 47f9a2011dd0afba7cb0ee967a592aa3

2008-04-21  0.43 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * parse errors try to remember failing position
        * used valgrind to test for leaks (devel-only)
        * used Test::Valgrind as alternative leak check (devel-only)
        * improve documentation for error 2023
        * nailed the loose quotes in quoted fields

2008-04-16  0.42 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * Generate META.yml myself. I won't use Build.PL
        * Array-refs now accept scalars with magic:
          $csv->print (*STDOUT, $sth->{NAME_lc});
        * More/better examples
        * Added t/76_magic.t

Some highlights ...

       allow_loose_quotes
           By default, parsing fields that have "quote_char" characters  inside
           an unquoted field, like

            1,foo "bar" baz,42

           would result in a parse error. Though it is still bad practice  to
           allow this format, we cannot help there are some vendors that  make
           their applications spit out lines styled like this.

           In case there is really bad CSV data, like

            1,"foo "bar" baz",42

           or

            1,""foo bar baz"",42

           there is a way to get that parsed, and leave the quotes inside  the
           quoted field as$,1rp(Bis. This can be achieved by setting
           "allow_loose_quotes" AND making sure that the "escape_char" is  not
           equal to "quote_char".

       error_diag

        Text::CSV_XS$,1x2(B>error_diag ();
        $csv$,1x2(B>error_diag ();
        $error_code   = 0  + $csv$,1x2(B>error_diag ();
        $error_str    = "" . $csv$,1x2(B>error_diag ();
        ($cde, $str, $pos) = $csv$,1x2(B>error_diag ();

       If (and only if) an error occured, this function returns the
       diagnostics of that error.

       If called in void context, it will print the internal error code and
       the associated error message to STDERR.

       If called in list context, it will return the error code and the  error
       message in that order. If the last error was from parsing, the third
       value returned is the best guess at the location within the line  that
       was being parsed. It$,1ry(Bs value is 1$,1x2(Bbased.

       If called in scalar context, it will return the diagnostics in a  single
       scalar, a$,1x2(Bla $!. It will contain the error code in numeric context,  and
       the diagnostics message in string context.

       When called as a class method or a direct function call, the error  diag
       is that of the last "new ()" call.

       SetDiag

        $csv$,1x2(B>SetDiag (0);

       Use to reset the diagnosticts if you are dealing with errors.




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

Date: Wed, 16 Apr 2008 13:49:54 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: ANNOUNCE: Text::CSV_XS 0.42
Message-Id: <JzFAo8.1t8t@zorch.sf-bay.org>

  file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.42.tgz
  size: 86136 bytes
   md5: 1cf4491f48965793f1e31fc74159f20f

We can do MAGIC now!

Dumping the content of a database ($dbh) table ($tbl) to CSV:

  my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
  open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";
  my $sth = $dbh->prepare ("select * from $tbl");
  $sth->execute;
  $csv->print ($fh, $sth->{NAME_lc});
  while (my $row = $sth->fetch) {
      $csv->print ($fh, $row);
      }
  close $fh;

2008-04-16  0.42 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * Generate META.yml myself. I won't use Build.PL
        * Array-refs now accept scalars with magic:
          $csv->print (*STDOUT, $sth->{NAME_lc});
        * More/better examples
        * Added t/76_magic.t

2008-04-11  0.41 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * error_diag () subclassable
        * typo in bind_columns () docs
        * examples/csv2xls now uses getline ()
        * better test for getline in t/75_hashref.t (makamata)
        * document return value of getline () with bind_columns ()
        * add perl version prereq to META.yml




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

Date: Wed, 16 Apr 2008 15:54:39 -0700 (PDT)
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Can someone 'splain why this regex won't work both ways?
Message-Id: <bdf7607b-2ed2-42cc-92e2-44dcbb07130b@59g2000hsb.googlegroups.com>

On Apr 14, 4:28 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> ...
>
> It is, however, possible to get \1 to match when it appears earlier in
> the expression than the first brackets (which is why it's not a syntax
> error); you just have to make sure it gets set first. For instance,
>
>     "abac" =~ /^(?:\1c|(a)b)+$/
>
> matches. The first time through the +, $1 is undef so the \1c part fails;
> but the (a)b part succeeds so $1 gets set. Then it goes round the + loop
> again, and this time $1 is 'a' so the first branch can succeed.
>

Slightly different example sans alternation could work too if $N is
optional:

 "abab" =~ /(?:(\2)?(b))+/

I'd have the same enthusiasm for a root canal though...

--
Charles DeRykus



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

Date: Thu, 17 Apr 2008 03:06:23 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Can someone 'splain why this regex won't work both ways?
Message-Id: <fu6erf$vml$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
comp.llang.perl.moderated
<ced@blv-sam-01.ca.boeing.com>], who wrote in article <bdf7607b-2ed2-42cc-92e2-44dcbb07130b@59g2000hsb.googlegroups.com>:
> Slightly different example sans alternation could work too if $N is
> optional:
> 
>  "abab" =~ /(?:(\2)?(b))+/
> 
> I'd have the same enthusiasm for a root canal though...

Extra parens are considered harmfull:

  perl -wle "q(abab) =~ /(?: \1? (b) )+/x or die"

(not much beauty gained or lost, of course...).

Yours,
Ilya


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

Date: Tue, 22 Apr 2008 08:49:25 -0700 (PDT)
From: globalrev <skanemupp@yahoo.se>
Subject: complete perl-package(IDE, IAprompt etc), where? .com or .org?
Message-Id: <149a7885-fd7c-4400-8849-bc25220772d1@d45g2000hsc.googlegroups.com>

is there a complete IDE with an interactive prompt that i can
download?
what si the diffrence between perl.com and perl.org? is it the same
language?

do they include IDEs etc?


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

Date: 16 Apr 2008 19:42:43 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: counting the number of characters that were matched in a regular  expression
Message-Id: <slrng0cllk.kta.glennj@smeagol.ncf.ca>

At 2008-04-16 03:08PM, "PugetSoundSylvia@gmail.com" wrote:
>  In a string, I need to replace all instances of 15 or 16 number
>  characters with the 11 or 12 "x" characters, then the last 4 digits of
>  the 15 or 16 number characters.  The chunk of number characters may
>  appear numerous times in the string.

You want  s/(\d{11,12})(\d{4})/"x" x length($1) . $2/eg

Note the 'e' modifier


-- 
Glenn Jackman
  "If there is anything the nonconformist hates worse than a conformist, 
   it's another nonconformist who doesn't conform to the prevailing 
   standard of nonconformity." -- Bill Vaughan 


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

Date: Wed, 16 Apr 2008 12:08:05 -0700 (PDT)
From: PugetSoundSylvia@gmail.com
Subject: counting the number of characters that were matched in a regular  expression
Message-Id: <9a1eeadf-ff25-4bba-93a5-050076008996@b9g2000prh.googlegroups.com>



Hello all,

Can anyone give me a pointer on this?  I'm pretty sure this can be
done, just not sure how.

In a string, I need to replace all instances of 15 or 16 number
characters with the 11 or 12 "x" characters, then the last 4 digits of
the 15 or 16 number characters.  The chunk of number characters may
appear numerous times in the string.

For instance, if I have this:

$PotentialCreditCardData = "bac1984938193829382 099824  3s ";

 ... I want to have this
$PotentialCreditCardData = "bacxxxxxxxxxxxx9382 099824  3s ";

Here's what I have so far that doesn't work:

use strict;
use warnings;

my($PotentialCreditCardData);

$PotentialCreditCardData = "bac1984938193829382 099824  3s ";
# $PotentialCreditCardData = "junk 198493819382938 22 ";
# $PotentialCreditCardData = "02m5k2 198493819382938 gg24
198493819382938";

$PotentialCreditCardData =~ s/(\d{11,12})(\d{4})/$1$2/g;
print $PotentialCreditCardData;

thanks for any hints!
Sylvia


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

Date: Wed, 16 Apr 2008 12:20:13 -0700 (PDT)
From: PugetSoundSylvia@gmail.com
Subject: Re: counting the number of characters that were matched in a regular  expression
Message-Id: <a8f59971-5979-497a-be0a-b024d6b9de50@a23g2000hsc.googlegroups.com>

Actually, this was what I was trying, that doesn't work...

$PotentialCreditCardData =~ s/(\d{11,12})(\d{4})/"X"length($1)$2/g;


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

Date: Wed, 16 Apr 2008 12:52:51 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: counting the number of characters that were matched in a regular expression
Message-Id: <160420081252512351%jimsgibson@gmail.com>

In article
<a8f59971-5979-497a-be0a-b024d6b9de50@a23g2000hsc.googlegroups.com>,
<PugetSoundSylvia@gmail.com> wrote:

> Actually, this was what I was trying, that doesn't work...
> 
> $PotentialCreditCardData =~ s/(\d{11,12})(\d{4})/"X"length($1)$2/g;

This is close, but you need to add the 'x' operator, the 'e' modifier,
and rewrite your replacement string as a valid Perl expression:

$PotentialCreditCardData =~ 
  s/(\d{11,12})(\d{4})/"X" x length($1) . $2/eg;

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------     
                http://www.usenet.com


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

Date: Wed, 16 Apr 2008 20:18:52 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: counting the number of characters that were matched in a regular expression
Message-Id: <MatNj.17$og.1@edtnps91>

PugetSoundSylvia@gmail.com wrote:
> 
> Hello all,
> 
> Can anyone give me a pointer on this?  I'm pretty sure this can be
> done, just not sure how.
> 
> In a string, I need to replace all instances of 15 or 16 number
> characters with the 11 or 12 "x" characters, then the last 4 digits of
> the 15 or 16 number characters.  The chunk of number characters may
> appear numerous times in the string.
> 
> For instance, if I have this:
> 
> $PotentialCreditCardData = "bac1984938193829382 099824  3s ";
> 
> ... I want to have this
> $PotentialCreditCardData = "bacxxxxxxxxxxxx9382 099824  3s ";
> 
> Here's what I have so far that doesn't work:
> 
> use strict;
> use warnings;
> 
> my($PotentialCreditCardData);
> 
> $PotentialCreditCardData = "bac1984938193829382 099824  3s ";
> # $PotentialCreditCardData = "junk 198493819382938 22 ";
> # $PotentialCreditCardData = "02m5k2 198493819382938 gg24
> 198493819382938";
> 
> $PotentialCreditCardData =~ s/(\d{11,12})(\d{4})/$1$2/g;
> print $PotentialCreditCardData;

$ perl -le'
my @PotentialCreditCardData = (
     "bac1984938193829382 099824  3s ",
     "junk 198493819382938 22 ",
     "02m5k2 198493819382938 gg24 198493819382938",
     );

for my $data ( @PotentialCreditCardData ) {
     print $data;
     $data =~ s/ (?: (?<=\D) | ^ ) ( [0-9]{11,12} ) (?= [0-9]{4} (?: \D 
| $ ) ) / "X" x length( $1 ) /xeg;
     print $data;
     }
'
bac1984938193829382 099824  3s
bacXXXXXXXXXXXX9382 099824  3s
junk 198493819382938 22
junk XXXXXXXXXXX2938 22
02m5k2 198493819382938 gg24 198493819382938
02m5k2 XXXXXXXXXXX2938 gg24 XXXXXXXXXXX2938



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Sun, 20 Apr 2008 17:39:44 -0700 (PDT)
From: "David G. Hong" <david.g.hong@gmail.com>
Subject: Creating necessary configuration files on package installation
Message-Id: <0927b618-34bd-4f16-a738-ca0bf989556f@l25g2000prd.googlegroups.com>

Hi,

I am writing a fairly customised piece of software. And some parts of
the software are configurable - meaning that there exists some sort of
configuration file like httpd.conf (for Apache 2). Now, I want to be
able to set this up upon package installation.

Is there a procedure I can use to do this?


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

Date: Sun, 20 Apr 2008 18:12:32 -0700 (PDT)
From: "David G. Hong" <david.g.hong@gmail.com>
Subject: Re: Creating necessary configuration files on package installation
Message-Id: <0eb0986f-4085-469f-ab9c-8c10408f3217@b9g2000prh.googlegroups.com>

On Apr 21, 10:39 am, "David G. Hong" <david.g.h...@gmail.com> wrote:
> Hi,
>
> I am writing a fairly customised piece of software. And some parts of
> the software are configurable - meaning that there exists some sort of
> configuration file like httpd.conf (for Apache 2). Now, I want to be
> able to set this up upon package installation.
>
> Is there a procedure I can use to do this?

May be I should clarify a little more.

Ultimately, I want to setup somethings like:

  $PREFIX/conf/prog.conf

And have prog.conf contain some generic default configuration
settings. And this should be created upon:

  perl Makefile.pl
  make
  make test
  make install


Thanks,
David


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

Date: Sun, 20 Apr 2008 18:12:52 -0700 (PDT)
From: "David G. Hong" <david.g.hong@gmail.com>
Subject: Re: Creating necessary configuration files on package installation
Message-Id: <d7ca797b-7541-472a-8cee-cdefddc23b81@z24g2000prf.googlegroups.com>

On Apr 21, 10:39 am, "David G. Hong" <david.g.h...@gmail.com> wrote:
> Hi,
>
> I am writing a fairly customised piece of software. And some parts of
> the software are configurable - meaning that there exists some sort of
> configuration file like httpd.conf (for Apache 2). Now, I want to be
> able to set this up upon package installation.
>
> Is there a procedure I can use to do this?

May be I should clarify a little more.

Ultimately, I want to setup somethings like:

  $PREFIX/conf/prog.conf

And have prog.conf contain some generic default configuration
settings. And this should be created upon:

  perl Makefile.pl
  make
  make test
  make install


Thanks,
David


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1454
***************************************


home help back first fref pref prev next nref lref last post