[25102] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7352 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 2 21:06:02 2004

Date: Tue, 2 Nov 2004 18:05:07 -0800 (PST)
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, 2 Nov 2004     Volume: 10 Number: 7352

Today's topics:
        24-hrs sex hotline live from China <yuan-feng@yfco.com>
        Check POP3 E-mail <tihana@verso.co.izbaciovo>
    Re: Check POP3 E-mail <ioneabu@yahoo.com>
    Re: Check POP3 E-mail <1usa@llenroc.ude.invalid>
    Re: Check POP3 E-mail <matthew.garrish@sympatico.ca>
    Re: Extracting Directories and Sub Directories and Coun <bik.mido@tiscalinet.it>
    Re: FAQ 4.35: How do I find the soundex value of a stri <comdog@panix.com>
    Re: FAQ 4.35: How do I find the soundex value of a stri <usenet_05_08_2004@stuartmoore.org.uk>
        FAQ 8.34: I {changed directory, modified my environment <comdog@panix.com>
    Re: Global @INC <william@wilbur.25thandClement.com>
    Re: List all Printer-Driver on a Mashine <matthew.garrish@sympatico.ca>
        Partly OT: name suggestion <bik.mido@tiscalinet.it>
        Perl CGI project ideas bharat.shetty@gmail.com
    Re: Perl is awsome! <bik.mido@tiscalinet.it>
        Q: re Inline and Benchmark <bik.mido@tiscalinet.it>
    Re: Q: re Inline and Benchmark <abigail@abigail.nl>
        replace pattern including newline : perl version 5.8 (Prince Kumar)
    Re: replace pattern including newline : perl version 5. <abigail@abigail.nl>
    Re: replace pattern including newline : perl version 5. <someone@example.com>
        using different copies of same module <ioneabu@yahoo.com>
    Re: using different copies of same module <mritty@gmail.com>
    Re: using different copies of same module <noreply@gunnar.cc>
        writing a function like map, sort, grep <john@mailinator.com>
    Re: writing a function like map, sort, grep <john@mailinator.com>
    Re: writing a function like map, sort, grep <noreply@gunnar.cc>
    Re: writing a function like map, sort, grep <perl@my-header.org>
    Re: writing a function like map, sort, grep <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 31 Oct 2004 15:49:45 GMT
From: " livesex" <yuan-feng@yfco.com>
Subject: 24-hrs sex hotline live from China
Message-Id: <cm31ip$4t51734@imsp212.netvigator.com>

Free trial +86 13180152666



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

Date: Tue, 2 Nov 2004 23:23:21 +0100
From: "Tihana" <tihana@verso.co.izbaciovo>
Subject: Check POP3 E-mail
Message-Id: <418808d9$1@news.s5.net>

How to check E-mail in POP3 mailbox,
if there have world "Congratulation" in subject.

TNX




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

Date: Tue, 02 Nov 2004 18:46:28 -0500
From: wana <ioneabu@yahoo.com>
Subject: Re: Check POP3 E-mail
Message-Id: <10og3oan8mlj02e@news.supernews.com>

Tihana wrote:

> How to check E-mail in POP3 mailbox,
> if there have world "Congratulation" in subject.
> 
> TNX

This might work.  I modified the example from Mail::POP3Client docs.  I did
not test so it may be wrong.

#! /usr/bin/perl

use strict;
use warnings;
my @message = ();
my $flag = 0;
  use Mail::POP3Client;
 my $pop = new Mail::POP3Client( USER     => "username",
                               PASSWORD => "password",
                               HOST     => "pop3.yourserver.net" );
        for(my $i = 1; $i <= $pop->Count(); $i++ )
        {
                $flag = 0;
                @message = ();
                foreach( $pop->Head( $i ) )
                {
                        /^(From|Subject|Date):\s+/i
                                && push @message, "$_\n";
                        if (/^Subject:.*Congratulation.*/i)
                        {
                                flag = 1;
                        }
                }
                foreach( $pop->Body( $i ) )
                {
                        push @message, "$_\n";
                }
                if (flag)
                {
                        foreach(@message)
                        {
                                print;
                        }
                }
                #$pop->Delete($i);
        }
$pop->Close();





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

Date: 2 Nov 2004 23:32:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Check POP3 E-mail
Message-Id: <Xns9595BC995A87asu1cornelledu@132.236.56.8>

wana <ioneabu@yahoo.com> wrote in
news:10og3oan8mlj02e@news.supernews.com: 

> Tihana wrote:
> 
>> How to check E-mail in POP3 mailbox,
>> if there have world "Congratulation" in subject.
>> 
>> TNX
> 
> This might work.  I modified the example from Mail::POP3Client docs. 
> I did not test so it may be wrong.

Why post it then?

> #! /usr/bin/perl
> 
> use strict;
> use warnings;
> my @message = ();

There is no need to explictly initialize my variables.

> my $flag = 0;

Ditto.

>   use Mail::POP3Client;
>  my $pop = new Mail::POP3Client( USER     => "username",
>                                PASSWORD => "password",
>                                HOST     => "pop3.yourserver.net" );
>         for(my $i = 1; $i <= $pop->Count(); $i++ )
>         {
>                 $flag = 0;
>                 @message = ();

The fact that you keep reinitializing this variable means you have declared 
it in the wrong scope.

Rest of the script snipped.

Basically, you haven't thought hard enough about the task. What you want to 
do is check if the subject line of the message contains the required 
phrase, and if it does, print the whole message. There is no need for all 
the flag setting etc.

However, your main sin is responding to a poster who is asking for a canned 
script without showing that he has put any effort into this by trying to do 
the work he should have done. Now that the cat is out of the bag, however:

#! perl

use strict;
use warnings;

use Mail::POP3Client;

my $pop = Mail::POP3Client->new(
    USER     => 'xxxxxxx',
    PASSWORD => 'xxxxxxx',
    HOST     => 'xxxxxxx',
);

my $count = $pop->Count;
$count >= 0 or die "Cannot get messge count.\n";
$count > 0 or die "No messages in mailbox.\n";

for my $i (1 .. $count) {
    my @headers = $pop->Head( $i );
    for my $h ( @headers ) {
        if( $h =~ /^Subject:\s+Congratulation/ ) {
            print print "$h\n", join "\n", $pop->Body( $i );
            last;
        }
    }
}

$pop->Close;
__END__

D:\Home> perl chk.pl
Subject:   Congratulation

This is a test



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

Date: Tue, 2 Nov 2004 18:24:44 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Check POP3 E-mail
Message-Id: <%GUhd.12861$dj2.637909@news20.bellglobal.com>


"wana" <ioneabu@yahoo.com> wrote in message 
news:10og3oan8mlj02e@news.supernews.com...
> Tihana wrote:
>
>> How to check E-mail in POP3 mailbox,
>> if there have world "Congratulation" in subject.
>>
>> TNX
>
> This might work.  I modified the example from Mail::POP3Client docs.  I 
> did
> not test so it may be wrong.
>
> #! /usr/bin/perl
>
> use strict;
> use warnings;
> my @message = ();
> my $flag = 0;
>  use Mail::POP3Client;
> my $pop = new Mail::POP3Client( USER     => "username",
>                               PASSWORD => "password",
>                               HOST     => "pop3.yourserver.net" );
>        for(my $i = 1; $i <= $pop->Count(); $i++ )
>        {
>                $flag = 0;
>                @message = ();
>                foreach( $pop->Head( $i ) )
>                {
>                        /^(From|Subject|Date):\s+/i
>                                && push @message, "$_\n";

Why did you change from "and" to the higher precedence "&&"?

>                        if (/^Subject:.*Congratulation.*/i)
>                        {
>                                flag = 1;

Hmm.. $flag = 1?

>                        }
>                }
>                foreach( $pop->Body( $i ) )
>                {
>                        push @message, "$_\n";
>                }
>                if (flag)

Oops, you did it again!

The script could certainly be cleaned up, but I suppose it's otherwise 
functional. From the OP's posting, however, I would tend to infer that he 
wants to delete messages with that word (i.e., a spam filter), so he can 
probably just check the subject line and determine what to do at that point 
instead of collecting the entire message into an array.

Matt 




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

Date: Wed, 03 Nov 2004 00:23:12 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Extracting Directories and Sub Directories and Counting
Message-Id: <ae0go09brhqnk37g5c22j203kvbtqapal8@4ax.com>

On Tue, 02 Nov 2004 18:08:26 +0000, Brian McCauley <nobull@mail.com>
wrote:

>I have found that File::Find can be slow on Win32 (because, IIRC, stat() 
>is rediculously slow[1]). For most things this is not enough to stop me 
>using File::Find but occasionally for really big trees I've resorted to 

Well, in my personal experience it is fast enough that I don't notice
it to be slow. But then I carry on most of my file management
activities under Linux, even on Win* FS's.

For the record I've tried this both under Windows98 (sorry, i.e.
happy: no XP yet!) and Linux (kernel 2.6.9):


  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  use Time::HiRes 'time';
  
  my ($n,$t)=(250_000,time);
  stat $ARGV[0] while $n--;
  print time - $t;
  
  __END__


As a rough indication I get these figures (no claim of real accuracy):

  (*) Windows98

      32s both with files in CWD and with absolute paths,

  (*) Linux

      vfat[1] -> 0.34s with files in CWD (relative path),
                 0.43s with files "involving two dirs"[2],
     
      ReiserFS & tmpfs -> 0.26s with files in CWD (relative path),
                          0.38s with files "involving two dirs".

>parsing the output of 'dir /b /s'.

OTOH *on my system* (and I do not doubt that it is a quirk of it)
starting a shell by whichever means (no matter if via C<qx/.../>,
'-|'-open()s or whatever) involves some "mysterious" and annoying
floppy disk activity. This is not by any means limited to perl and
happens also, e.g. with my text editor in shell interaction mode[3].


[1] To be precise, exactly the same file(s) also tested under Windows.
[2] I mean: whose full path is of the kind of /mnt/winc/test.txt.
[3] Irritatingly enough, this behaviour is intermittent.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 02 Nov 2004 15:18:33 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: FAQ 4.35: How do I find the soundex value of a string?
Message-Id: <021120041518333959%comdog@panix.com>

In article <cm8ie8$d48$2@sun3.bham.ac.uk>, Brian McCauley
<nobull@mail.com> wrote:

> PerlFAQ Server wrote:
> 
> > 4.35: How do I find the soundex value of a string?

> The are an very large class of questions "how do I do foo?" for which 
> the answer is "get a module that does foo from CPAN".

That's still a helpful answer, and I'm amazed at how many people
don't think to look at CPAN first.

I don't know how fraquent a FAQ it is though.

-- 
brian d foy, comdog@panix.com
Subscribe to The Perl Review: http://www.theperlreview.com


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

Date: Tue, 02 Nov 2004 23:45:58 +0000
From: Stuart Moore <usenet_05_08_2004@stuartmoore.org.uk>
Subject: Re: FAQ 4.35: How do I find the soundex value of a string?
Message-Id: <cm967e$166$2@gemini.csx.cam.ac.uk>

brian d foy wrote:

> In article <cm8ie8$d48$2@sun3.bham.ac.uk>, Brian McCauley
> <nobull@mail.com> wrote:
> 
> 
>>PerlFAQ Server wrote:
>>
>>
>>>4.35: How do I find the soundex value of a string?
> 
> 
>>The are an very large class of questions "how do I do foo?" for which 
>>the answer is "get a module that does foo from CPAN".
> 
> 
> That's still a helpful answer, and I'm amazed at how many people
> don't think to look at CPAN first.
> 
> I don't know how fraquent a FAQ it is though.

I found it useful because it mentioned String::Approx, which otherwise 
I'd never have found. Although that wasn't the question I was asking...


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

Date: Tue, 2 Nov 2004 23:03:02 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 8.34: I {changed directory, modified my environment} in a perl script.  How come the change disappeared when I exited the script?  How do I get my changes to be visible?
Message-Id: <cm93n6$1vp$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

8.34: I {changed directory, modified my environment} in a perl script.  How come the change disappeared when I exited the script?  How do I get my changes to be visible?

    Unix
        In the strictest sense, it can't be done--the script executes as a
        different process from the shell it was started from. Changes to a
        process are not reflected in its parent--only in any children
        created after the change. There is shell magic that may allow you to
        fake it by eval()ing the script's output in your shell; check out
        the comp.unix.questions FAQ for details.



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Tue, 2 Nov 2004 12:26:50 -0800
From: William Ahern <william@wilbur.25thandClement.com>
Subject: Re: Global @INC
Message-Id: <a57l52-nu3.ln1@wilbur.25thandClement.com>

Ben Morrow <usenet@morrow.me.uk> wrote:

> Quoth William Ahern <william@wilbur.25thandClement.com>:
> > How can I globally specify additional @INC paths. Is there a module I can
> > edit amongst any Perl library modules--written in perl?

> No, you have to rebuild perl. This is on the TODO list :)...

> > I've tried setting PERL5LIB in the the global shell startup files in /etc,
> > but that doesn't work for perl code started from init.

> Errr.... *why* are you starting perl from init? Sounds like a Bad Idea
> to me... In any case, you can use -I.

Well, not directly from init. But, daemons written in Perl executed at
startup. Maybe I should look deeper into editing that environment.

The problem I'm trying to solve is more-or-less a practical one here at
work. We have lots of code I'd like to break apart into sensible modules so
we can reuse out collective efforts. And I'd like to keep the barrier low
for the rest of the team, so that I can simply say: `use Foo::Bar`, instead
of, `First, edit your @INC path to include /some/long/obscure/path....'.
Also, including the path in the code is a pain because then it's difficult
to do automatic regression testing using modules in another alternate
location.

For various reasons, these modules cannot be installed in the default system
paths. So, I need some way to easily bootstrap our local (unfortuantely not
literally /usr/local) execution environment.

Ah well. Thanx!


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

Date: Tue, 2 Nov 2004 18:09:39 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: List all Printer-Driver on a Mashine
Message-Id: <SsUhd.12428$dj2.630728@news20.bellglobal.com>


"Laura" <lwt0301@bellsouth.net> wrote in message 
news:10of1uqre7suhc0@news.supernews.com...
> Ronny Kluge wrote:
>
>> i want to get a List of all Printer Drivers, wich are installed on a
>> Mashine.
>>
>> Do you know how to do this with Perl?
>
> I do it like this:
>
> @drivers = MashineDrivers('printers');
> print for @drivers;
>
> I have written the implementation for this function in the margins of my
> 'Perl Cookbook' which I have unfortunately misplaced.

Much like your brain, I expect...

Matt 




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

Date: Wed, 03 Nov 2004 00:23:14 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Partly OT: name suggestion
Message-Id: <725go0po1nr1svsp6dqq9cn4r8jrvn8s15@4ax.com>

I would like to write some articles on Perl techniques[1] (mostly
inspired by threads from this ng) and upload them to a web page. Now,
I'd like to call the "project" something like 'Perl-Justu'[2], but as
far as the exact name goes I can't make up my mind: here are some
possibilities:

  PerlJutsu
  perljutsu
  Perl-Jutsu
  Perl::Jutsu  # because of Perl-ishness!
  etc.

Any suggestion? Preferences?


[1]  Please note that I'm not attempting at writing yet another
(awful) tutorial nor a cookbook: these will constitute more a kind of
blog, if you want to give it a name.

[2] Be ready to expect puns on 'Perl-Do' too! ;-)


TIA,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 2 Nov 2004 18:01:52 -0800
From: bharat.shetty@gmail.com
Subject: Perl CGI project ideas
Message-Id: <1099447312.300707.292650@f14g2000cwb.googlegroups.com>

Hi all,

We have a project to develop a simple application on Linux using Perl
and CGI. I have been totally devoid of ideas for my project becuase
whatever I thought is being done . Could anyone provide me with gist of
ideas for my project. I would appreciate if someone points me to a
necessary application that doesnt exist on Linux but on windoze. Since
I dont have too much time left , really K I S S ideas are requested.
Also which books should i read as i am relatively a Perl / CGI newbie
 .......

T I A

~cryptonewbie



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

Date: Wed, 03 Nov 2004 00:23:10 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl is awsome!
Message-Id: <pnpfo0pvo30p17sf3kiahon4tgbo6i6824@4ax.com>

On 2 Nov 2004 09:15:01 -0800, bjarne@gmail.com (Bjarne Stroustrup)
wrote:

>That message is a fake. It did not come from me

Somehow we realized! ;-)

Still I can't figure out what kind of troll is that: one imagines the
average one popping out in clpmisc saying we're all idiots. What the
hell could be the point, in *his* logic, of impersonating Bjarne
Stroustrup making positive cmts about Perl?!? I don't see any
"suspect" Followup-To header nor anything similar...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 03 Nov 2004 00:23:13 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Q: re Inline and Benchmark
Message-Id: <622go0t6h7eubof6htn31jn2lmoqll9gji@4ax.com>

While revising the benchmarks I had done for the fast random string
generation thread of a few weeks ago I wanted to include Abigail's
Inline::C solution too. Now, in the original ones I gave cmpthese() a
second param of the form:

  {
     ...  
     Solution => \&Solution,
     ...
  };

But this *doesn't* work[1] with the Inline::C solution, even if I
predeclare the sub. I've succeeded with

     Inline => sub { Inline() },

and BTW it still largely outperforms all the other ones, but I'm
bothered by the fact that it involves one extra sub call which IMHO is
not elegant at all and, even if only marginally relevant, not fair for
comparison purposes. So, do you have any suggestion on what I should
do instead?

Also, the previous question was not terribly specific of Benchmark.pm
(but only of the kind of parameters one of its functions wants), so
more on-topic: is there any caveat with benchmarks carried on
Inline::C subs? I don't think so, but just to be sure...

As a side note, since I want to simply cmpthese() a bunch of (named)
subs giving as labels their respective names, I don't want to write
things twice as above and so was thinking of using a map() instead.
Now I'm unsure which of these would be better:

  { map { $_ => "$_()" } qw/sol1 sol2 .../ };
  
  { map {
      no strict 'refs';
      $_ => \&{$_};
  } qw/sol1 sol2 .../ };

Generally speaking, I don't particularly like the 'code' version, and
I suspect it to be less efficient too[2]. (Well, I just tried: it is!)
Well, any advice?

[1] For some IMHO sensible acceptation of "doesn't work", in the sense
that I've tried some quite obvious variations, but then I'd be happy
to know that I was just too dumb and missed somethins obvious.

[2] Not that this is terribly relevant, but since we're speaking of
something that must be repeated *many* times, anyway...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 03 Nov 2004 00:22:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Q: re Inline and Benchmark
Message-Id: <slrncog96u.d9i.abigail@alexandra.abigail.nl>

Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMLXXXI September
MCMXCIII in <URL:news:622go0t6h7eubof6htn31jn2lmoqll9gji@4ax.com>:
||  While revising the benchmarks I had done for the fast random string
||  generation thread of a few weeks ago I wanted to include Abigail's
||  Inline::C solution too. Now, in the original ones I gave cmpthese() a
||  second param of the form:
||  
||    {
||       ...  
||       Solution => \&Solution,
||       ...
||    };
||  
||  But this *doesn't* work[1] with the Inline::C solution, even if I
||  predeclare the sub. I've succeeded with
||  
||       Inline => sub { Inline() },
||  
||  and BTW it still largely outperforms all the other ones, but I'm
||  bothered by the fact that it involves one extra sub call which IMHO is
||  not elegant at all and, even if only marginally relevant, not fair for
||  comparison purposes. So, do you have any suggestion on what I should
||  do instead?

    use Inline C => <<'--';
        char * r_string () {
            char * str;
            int    i;
            int    l;

            l = 20000;
            srand (time ((time_t) NULL));
            if ((str = (char *) malloc (l * sizeof (char))) == (char *) NULL) {
                perror (malloc);
                exit (-1);
            }
            for (i = 0; i < l; i ++) {
                str [i] = rand () % 255;
            }
            return (str);
        }
    --

    cmpthese 500 => {
        C     =>  'r_string',
        Loop1 => \&Loop1,
        Loop2 => \&Loop2,
        ...
    }



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: 2 Nov 2004 13:51:10 -0800
From: gspk@yahoo.com (Prince Kumar)
Subject: replace pattern including newline : perl version 5.8
Message-Id: <629275ba.0411021351.721f541f@posting.google.com>

I have a file with the following contents.

drop table tabl1;

create table tabl1 (
col1
col2
col3);

drop table tabl2;

create table tabl2 (
col1
col2);

 ..

I want to replace "create table * );" with 
"create table * ) IN TBSP1;" 

I tried the following, but I am not getting the desired result.

perl -p -e 'undef $/; s/^CREATE TABLE (.*?)\);$/CREATE TABLE $1 \) IN
TBSP/s' my_input_file.

Your help is appreciated.

Thank You!


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

Date: 02 Nov 2004 22:20:00 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: replace pattern including newline : perl version 5.8
Message-Id: <slrncog20g.d9i.abigail@alexandra.abigail.nl>

Prince Kumar (gspk@yahoo.com) wrote on MMMMLXXXI September MCMXCIII in
<URL:news:629275ba.0411021351.721f541f@posting.google.com>:
$$  I have a file with the following contents.
$$  
$$  drop table tabl1;
$$  
$$  create table tabl1 (
$$  col1
$$  col2
$$  col3);
$$  
$$  drop table tabl2;
$$  
$$  create table tabl2 (
$$  col1
$$  col2);
$$  
$$  ..
$$  
$$  I want to replace "create table * );" with 
$$  "create table * ) IN TBSP1;" 
$$  
$$  I tried the following, but I am not getting the desired result.
$$  
$$  perl -p -e 'undef $/; s/^CREATE TABLE (.*?)\);$/CREATE TABLE $1 \) IN
$$  TBSP/s' my_input_file.
$$  
$$  Your help is appreciated.


If you want to change "create table * );", then why do you write
"CREATE TABLE" in the s///? Upper case isn't the same as lower
case in te absence of /i.


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Tue, 02 Nov 2004 22:25:07 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: replace pattern including newline : perl version 5.8
Message-Id: <7PThd.85034$9b.53687@edtnps84>

Prince Kumar wrote:
> I have a file with the following contents.
> 
> drop table tabl1;
> 
> create table tabl1 (
> col1
> col2
> col3);
> 
> drop table tabl2;
> 
> create table tabl2 (
> col1
> col2);
> 
> ..
> 
> I want to replace "create table * );" with 
> "create table * ) IN TBSP1;" 
> 
> I tried the following, but I am not getting the desired result.
> 
> perl -p -e 'undef $/; s/^CREATE TABLE (.*?)\);$/CREATE TABLE $1 \) IN
> TBSP/s' my_input_file.


perl -073pe's/^(\s*create\s+table\s+(\S+)\s+\((?s:.+?)\));/$1 IN \U$2;/i' 
my_input_file



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 02 Nov 2004 15:38:33 -0500
From: wana <ioneabu@yahoo.com>
Subject: using different copies of same module
Message-Id: <10ofonurnnc0eda@news.supernews.com>

Suppose you have a module installed and you want to test an updated version
but you need to be certain of which copy on your system you are using.

For example MYMODULE is installed in /usr/lib/perl/ but I want to put a
slightly modified version with the same name in the directory with my
program and I want to be certain that that is the one that will be used. 
How can I be sure that the one in /usr/lib/perl isn't looked at first?

Thanks!

wana


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

Date: Tue, 02 Nov 2004 19:59:33 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: using different copies of same module
Message-Id: <FGRhd.6222$o52.3495@trndny03>

"wana" <ioneabu@yahoo.com> wrote in message
news:10ofonurnnc0eda@news.supernews.com...
> Suppose you have a module installed and you want to test an updated
version
> but you need to be certain of which copy on your system you are using.
>
> For example MYMODULE is installed in /usr/lib/perl/ but I want to put
a
> slightly modified version with the same name in the directory with my
> program and I want to be certain that that is the one that will be
used.
> How can I be sure that the one in /usr/lib/perl isn't looked at first?

use lib 'foo';

The above line will add 'foo' to the *beginning* of @INC.  Therefore,
any module found in foo/ will be used in favor of any same-named module
in a different directory elsewhere in @INC.

For the truly paranoid, you could
no lib '/usr/lib/perl';
to remove that directory from @INC, but I can't imagine that's a
particularly good idea.

Paul Lalli




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

Date: Tue, 02 Nov 2004 21:20:39 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: using different copies of same module
Message-Id: <2uq8gpF2ddmteU1@uni-berlin.de>

Paul Lalli wrote:
> "wana" wrote:
>> How can I be sure that the one in /usr/lib/perl isn't looked at
>> first?
> 
> use lib 'foo';
> 
> The above line will add 'foo' to the *beginning* of @INC.  Therefore,
> any module found in foo/ will be used in favor of any same-named
> module in a different directory elsewhere in @INC.

One way to confirm that it worked is to check the %INC hash:

     print "$INC{'MYMODULE.pm'}\n";

That prints the path to the module that was actually loaded.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 02 Nov 2004 15:06:02 -0600
From: John <john@mailinator.com>
Subject: writing a function like map, sort, grep
Message-Id: <BJShd.3$J62.2@fe25.usenetserver.com>

Is there a way to write a function that ban be run like the 
aforementioned ones, i.e.

	Foo BLOCK LIST

I want to do this because I sometimes want LIST to be a real list, and 
sometimes a function. I know there are other ways to do it, I was just 
curious if something like this can be implemented easily.

TIA, John




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

Date: Tue, 02 Nov 2004 15:28:48 -0600
From: John <john@mailinator.com>
Subject: Re: writing a function like map, sort, grep
Message-Id: <Y2Thd.8$J62.7@fe25.usenetserver.com>

John wrote:
> Is there a way to write a function that ban be run like the 
> aforementioned ones, i.e.
> 
>     Foo BLOCK LIST
> 
> I want to do this because I sometimes want LIST to be a real list, and 
> sometimes a function. I know there are other ways to do it, I was just 
> curious if something like this can be implemented easily.
> 
> TIA, John
> 
> 

I don't mean a function, I mean a CODE reference, which I could 
determine inside Foo (hopefully).




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

Date: Tue, 02 Nov 2004 22:45:48 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: writing a function like map, sort, grep
Message-Id: <2uqdggF2ea1i5U1@uni-berlin.de>

John wrote:
> Is there a way to write a function that ban be run like the 
> aforementioned ones, i.e.
> 
>     Foo BLOCK LIST

You can use prototypes

     sub Foo(&@)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 02 Nov 2004 22:46:53 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: writing a function like map, sort, grep
Message-Id: <1mvfo05gj7ejpafqbcr1etdt3t6u29qunb@4ax.com>

X-Ftn-To: John 

John <john@mailinator.com> wrote:
>Is there a way to write a function that ban be run like the 
>aforementioned ones, i.e.
>
>	Foo BLOCK LIST
>
>I want to do this because I sometimes want LIST to be a real list, and 
>sometimes a function. I know there are other ways to do it, I was just 
>curious if something like this can be implemented easily.

It seems that it can, I saw some example using prototypes,

sub apply (&@) {
  my $sub = shift;
  $sub->() for my @ret = @_;
  @ret;
}

print
$str = join "", apply {tr/abc/def/; s/d/123/g} qw/jen dva/;



-- 
Matija


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

Date: Tue, 2 Nov 2004 23:17:58 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: writing a function like map, sort, grep
Message-Id: <66hl52-s88.ln1@osiris.mauzo.dyndns.org>


Quoth Gunnar Hjalmarsson <noreply@gunnar.cc>:
> John wrote:
> > Is there a way to write a function that ban be run like the 
> > aforementioned ones, i.e.
> > 
> >     Foo BLOCK LIST
> 
> You can use prototypes
> 
>      sub Foo(&@)

Note that this will *not* allow the foo EXPR, LIST usage of map, grep,
nor the named or missing sub of sort (as is reflected by the fact that 
prototype returns undef for all of these).

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


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

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 V10 Issue 7352
***************************************


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