[28894] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 138 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 15 06:10:22 2007

Date: Thu, 15 Feb 2007 03:09:04 -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           Thu, 15 Feb 2007     Volume: 11 Number: 138

Today's topics:
        Calling 'C' function from Perl <writetoshankar@gmail.com>
    Re: Calling 'C' function from Perl <krotowitz@yahoo.com>
    Re: Calling 'C' function from Perl <paduille.4060.mumia.w+nospam@earthlink.net>
    Re: Calling 'C' function from Perl <sisyphus1@nomail.afraid.com>
    Re: Calling 'C' function from Perl <writetoshankar@gmail.com>
        define a standard exception handler to handle database  <filippo2991@virgilio.it>
    Re: define a standard exception handler to handle datab <tfeserver@gmail.com>
    Re: MIME::Parser filename renaming <dowilly@aolestonia.com>
        new CPAN modules on Thu Feb 15 2007 (Randal Schwartz)
    Re: Perl interaction with Expect <paduille.4060.mumia.w+nospam@earthlink.net>
    Re: problem CGI <john.swilting@wanadoo.fr>
    Re: problem CGI <john.swilting@wanadoo.fr>
    Re: problem CGI <john.swilting@wanadoo.fr>
    Re: problem CGI <john.swilting@wanadoo.fr>
    Re: problem CGI <joe@inwap.com>
    Re: problem CGI <uri@stemsystems.com>
    Re: problem CGI <bik.mido@tiscalinet.it>
    Re: problem CGI <john.swilting@wanadoo.fr>
        regex to convert &#106; to character <le_mo_mo@yahoo.com>
    Re: regex to convert &#106; to character <paduille.4060.mumia.w+nospam@earthlink.net>
    Re: Regexp for email addresses. <john.swilting@wanadoo.fr>
    Re: Wrong Server Port FeelLikeANut@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 14 Feb 2007 21:49:19 -0800
From: "Sankar" <writetoshankar@gmail.com>
Subject: Calling 'C' function from Perl
Message-Id: <1171518559.734735.67170@l53g2000cwa.googlegroups.com>

Dear All,
  I am developing a C application on a linux platform that has many
functions . My requirement is to call those functions from Perl.

I would appreciate if you could give some pointers in this regard.

My requirement is sth like this

C fucntion

int square( int a)
{
 ...
 ...
return(a)

}

in my perl file i should be able to do this.

a = square( 10)


Thanks in advance
Regards
Sankar



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

Date: Thu, 15 Feb 2007 08:52:13 +0100
From: "Marco Neumann" <krotowitz@yahoo.com>
Subject: Re: Calling 'C' function from Perl
Message-Id: <er130b$boq$1@news.uni-kl.de>

Hello, Sankar!

Try this module:

http://search.cpan.org/~ingy/Inline-0.44/C/C.pod
"
use Inline C;
    greet('Ingy');
    greet(42);
    __END__
    __C__
    void greet(char* name) {
      printf("Hello %s!\n", name);
    }
"

Cheers,
Marco.




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

Date: Thu, 15 Feb 2007 07:56:07 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Calling 'C' function from Perl
Message-Id: <rmUAh.1651$_73.990@newsread2.news.pas.earthlink.net>

On 02/14/2007 11:49 PM, Sankar wrote:
> Dear All,
>   I am developing a C application on a linux platform that has many
> functions . My requirement is to call those functions from Perl.
> 
> I would appreciate if you could give some pointers in this regard.
> [...]

perldoc perlxs


-- 
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml


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

Date: Thu, 15 Feb 2007 21:30:25 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.com>
Subject: Re: Calling 'C' function from Perl
Message-Id: <45d435cb$0$16553$afc38c87@news.optusnet.com.au>


"Sankar" <writetoshankar@gmail.com> wrote in message 
news:1171518559.734735.67170@l53g2000cwa.googlegroups.com...
> Dear All,
>  I am developing a C application on a linux platform that has many
> functions . My requirement is to call those functions from Perl.
>
> I would appreciate if you could give some pointers in this regard.
>
> My requirement is sth like this
>
> C fucntion
>
> int square( int a)
> {
> ...
> ...
> return(a)
>
> }
>

Marco has pointed you in the right direction. More specifically:

-----------------
use warnings;
use Inline C => Config =>
    BUILD_NOISY => 1;

use Inline C => <<'EOC';

int square(int a) {
    return a * a;
}

EOC

$a = 173;
$a = square($a);
print $a, "\n";
-----------------

Cheers,
Rob 




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

Date: 15 Feb 2007 03:06:14 -0800
From: "Sankar" <writetoshankar@gmail.com>
Subject: Re: Calling 'C' function from Perl
Message-Id: <1171537573.951567.109020@m58g2000cwm.googlegroups.com>

On Feb 15, 5:30 am, "Sisyphus" <sisyph...@nomail.afraid.com> wrote:
> "Sankar" <writetoshan...@gmail.com> wrote in message
>
> news:1171518559.734735.67170@l53g2000cwa.googlegroups.com...
>
>
>
> > Dear All,
> >  I am developing a C application on a linux platform that has many
> > functions . My requirement is to call those functions from Perl.
>
> > I would appreciate if you could give some pointers in this regard.
>
> > My requirement is sth like this
>
> > C fucntion
>
> > int square( int a)
> > {
> > ...
> > ...
> > return(a)
>
> > }
>
> Marco has pointed you in the right direction. More specifically:
>
> -----------------
> use warnings;
> use Inline C => Config =>
>     BUILD_NOISY => 1;
>
> use Inline C => <<'EOC';
>
> int square(int a) {
>     return a * a;
>
> }
>
> EOC
>
> $a = 173;
> $a = square($a);
> print $a, "\n";
> -----------------
>
> Cheers,
> Rob

Thanks a lot everyone for your response.. Ur help is greatly
appreciated !!

Regards
Sankar



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

Date: 15 Feb 2007 00:15:39 -0800
From: "Filippo" <filippo2991@virgilio.it>
Subject: define a standard exception handler to handle database query faults
Message-Id: <1171527339.814519.275540@h3g2000cwc.googlegroups.com>

hi,

my application is designed this way:

open a database connection at beginning

my $productionDatabase = DBI->connect(
				"DBI:PgPP:dbname=$DATABASE_NAME;host=$DATABASE_SERVER;port=5432",
				"postgres",
				"postgres",
				{
				 RaiseError => 1}
			       ) or die (
					 "failed onnection failed: $DBI::errstr"
					);


then keep open the connection and query database when needeed

  my $sth = $dbh->prepare($sqlQuery);
  $sth->execute;
  my $result = $sth->fetchrow_arrayref;


I want that any database query fails (prepare, execute, fetchrow, do
etc) cause my application to die in case I don't want to manage the
error. As second step I want to cactch some errors in order to recover
from exception (ask the user to check the network connection and retry
the query...).

How can I do?

Thanks,

Filippo



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

Date: 15 Feb 2007 02:19:19 -0800
From: "tfe" <tfeserver@gmail.com>
Subject: Re: define a standard exception handler to handle database query faults
Message-Id: <1171534759.927270.259810@l53g2000cwa.googlegroups.com>

Hi,

Yuo can use the errstr() function like that:
my $sth =3D $dbh->prepare($sqlQuery) or die ("ERROR ON SQL PREPARE ".
$sth->errstr);
$sth->execute or die ("ERROR ON EXECUTE ".$sth->errstr);

--
tfe
http://tfeserver.be


On 15 f=E9v, 09:15, "Filippo" <filippo2...@virgilio.it> wrote:
> hi,
>
> my application is designed this way:
>
> open a database connection at beginning
>
> my $productionDatabase =3D DBI->connect(
>                                 "DBI:PgPP:dbname=3D$DATABASE_NAME;host=3D=
$DATABASE_SERVER;port=3D5432",
>                                 "postgres",
>                                 "postgres",
>                                 {
>                                  RaiseError =3D> 1}
>                                ) or die (
>                                          "failed onnection failed: $DBI::=
errstr"
>                                         );
>
> then keep open the connection and query database when needeed
>
>   my $sth =3D $dbh->prepare($sqlQuery);
>   $sth->execute;
>   my $result =3D $sth->fetchrow_arrayref;
>
> I want that any database query fails (prepare, execute, fetchrow, do
> etc) cause my application to die in case I don't want to manage the
> error. As second step I want to cactch some errors in order to recover
> from exception (ask the user to check the network connection and retry
> the query...).
>
> How can I do?
>
> Thanks,
>
> Filippo




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

Date: Wed, 14 Feb 2007 21:32:50 -0600
From: Dowilly Dummfucc <dowilly@aolestonia.com>
Subject: Re: MIME::Parser filename renaming
Message-Id: <2728485.ilYp4GdcFK@aol.com>

Hey you must be stoopid or something cuz you thot that someone here would
actually respond to your question instead of turning on a robot automaton
to endlessly spit FAQ bits into the ng.  ha ha ha!

Yours,

Dowilly doppelganger


Dowilly Dummfucc wrote:

> I want to be able to rename a parsed mime file by prefixing the received
> data stamp to the filename.  Can anyone point me in the right direction?
> 
> use MIME::Parser;
> my $parser = new MIME::Parser;
> $parser->output_dir("/tmp");
> $parser->output_prefix("msg1");
> my $entity = $parser->parse_open("email-loddyda");



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

Date: Thu, 15 Feb 2007 05:42:08 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Feb 15 2007
Message-Id: <JDHp68.11rx@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

ACME-Require-Require-v0.0.1
http://search.cpan.org/~rlb/ACME-Require-Require-v0.0.1/
Disallow the use of use.
----
Angerwhale-0.03
http://search.cpan.org/~jrockway/Angerwhale-0.03/
filesystem-based blog with integrated cryptography
----
B-Keywords-1.06
http://search.cpan.org/~jjore/B-Keywords-1.06/
Lists of reserved barewords and symbol names
----
Bigtop-0.24
http://search.cpan.org/~philcrow/Bigtop-0.24/
A web application data language processor
----
Config-LotusNotes-0.30
http://search.cpan.org/~albers/Config-LotusNotes-0.30/
Access Lotus Notes/Domino configuration
----
DBIx-Placeholder-Named-0.05
http://search.cpan.org/~izut/DBIx-Placeholder-Named-0.05/
DBI with named placeholders
----
Devel-PPPort-3.11
http://search.cpan.org/~mhx/Devel-PPPort-3.11/
Perl/Pollution/Portability
----
Device-Gsm-1.47
http://search.cpan.org/~cosimo/Device-Gsm-1.47/
Perl extension to interface GSM phones / modems
----
Dispatch-Declare-v0.0.4
http://search.cpan.org/~rlb/Dispatch-Declare-v0.0.4/
Build a hash based dispatch table declaratively
----
Email-LocalDelivery-0.211
http://search.cpan.org/~rjbs/Email-LocalDelivery-0.211/
Deliver a piece of email - simply
----
Email-LocalDelivery-0.212
http://search.cpan.org/~rjbs/Email-LocalDelivery-0.212/
Deliver a piece of email - simply
----
Encode-DoubleEncodedUTF8-0.01
http://search.cpan.org/~miyagawa/Encode-DoubleEncodedUTF8-0.01/
Fix double encoded UTF-8 bytes to the correct one
----
Image-ExifTool-6.75
http://search.cpan.org/~exiftool/Image-ExifTool-6.75/
Read and write meta information
----
Lucene-0.08
http://search.cpan.org/~tbusch/Lucene-0.08/
API to the C++ port of the Lucene search engine
----
Mail-SpamAssassin-3.1.8
http://search.cpan.org/~felicity/Mail-SpamAssassin-3.1.8/
Spam detector and markup engine
----
Net-SIP-0.21
http://search.cpan.org/~sullr/Net-SIP-0.21/
Framework SIP (Voice Over IP, RFC3261)
----
PDF-FromHTML-0.24
http://search.cpan.org/~audreyt/PDF-FromHTML-0.24/
Convert HTML documents to PDF
----
POE-Component-AI-MegaHAL-1.05
http://search.cpan.org/~bingos/POE-Component-AI-MegaHAL-1.05/
A non-blocking wrapper around AI::MegaHAL.
----
POE-Component-Server-SimpleContent-1.05
http://search.cpan.org/~bingos/POE-Component-Server-SimpleContent-1.05/
The easy way to serve web content with POE::Component::Server::SimpleHTTP.
----
POE-Filter-IRCD-2.30
http://search.cpan.org/~bingos/POE-Filter-IRCD-2.30/
A POE-based parser for the IRC protocol.
----
Parse-Syslog-Mail-0.11
http://search.cpan.org/~saper/Parse-Syslog-Mail-0.11/
Parse mailer logs from syslog
----
Perl-Repository-APC-1.240
http://search.cpan.org/~andk/Perl-Repository-APC-1.240/
Class modelling "All Perl Changes" repository
----
SQL-Tokenizer-0.07
http://search.cpan.org/~izut/SQL-Tokenizer-0.07/
A simple SQL tokenizer.
----
Socialtext-Resting-Utils-0.09
http://search.cpan.org/~lukec/Socialtext-Resting-Utils-0.09/
Utilities for Socialtext REST APIs
----
String-IRC-0.01
http://search.cpan.org/~hirose/String-IRC-0.01/
add color codes for mIRC compatible client
----
Test-Device-SerialPort-0.01
http://search.cpan.org/~cosimo/Test-Device-SerialPort-0.01/
Serial port mock object to be used for testing
----
Test-Files-0.13
http://search.cpan.org/~philcrow/Test-Files-0.13/
A Test::Builder based module to ease testing with files and dirs
----
Text-Quoted-1.10
http://search.cpan.org/~jesse/Text-Quoted-1.10/
Extract the structure of a quoted mail message
----
Tk-PerlMethodList-0.02
http://search.cpan.org/~lamprecht/Tk-PerlMethodList-0.02/
query the Symbol-table for methods (subroutines) defined in a class (package) and its parents.
----
Tk-PerlMethodList-0.03
http://search.cpan.org/~lamprecht/Tk-PerlMethodList-0.03/
query the Symbol-table for methods (subroutines) defined in a class (package) and its parents.
----
WWW-Patent-Page-v0.100.0
http://search.cpan.org/~anonwb/WWW-Patent-Page-v0.100.0/
get a patent page or document (e.g. htm, pdf, tif) from selected source (e.g. from United States Patent and Trademark Office (USPTO) website or the European Patent Office (ESPACE_EP). and place into a
----
WWW-Translate-interNOSTRUM-0.09
http://search.cpan.org/~enell/WWW-Translate-interNOSTRUM-0.09/
Catalan < > Spanish machine translation
----
WebService-Images-Nofrag-0.04
http://search.cpan.org/~franckc/WebService-Images-Nofrag-0.04/
upload an image to http://pix.nofrag.com
----
bioperl-1.5.2_102
http://search.cpan.org/~sendu/bioperl-1.5.2_102/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 15 Feb 2007 07:56:08 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Perl interaction with Expect
Message-Id: <smUAh.1652$_73.1091@newsread2.news.pas.earthlink.net>

On 02/14/2007 02:54 PM, Eric wrote:
> Hello,
> 
> I'm not sure if this is a Perl question or an Expect question. But I
> will start here.
> 
> I have written an Expect script that someone else is executing in
> their Perl script. I would like my Expect script to return a string as
> a value to this Perl script, not a boolean (i.e. integer).
> 
> For example, say my Expect script does something like this:
> 
> if (<this>) {
>   return "SUCCESS";
> } else {
>   return "FAILURE";
> }
> 
> The Perl script needs to have the value returned as either a "SUCCESS"
> or "FAILURE".
> 
> I created a short Perl script that executes the Expect script by doing
> the following:
> 
> my $rtnval = `rem.exp`;
> 
> Of course, that's not going to return the value I am looking for; it's
> only going to print the output to stdout. And if I try:
> 
> my $rtnval = system("rem.exp");
> 
> that's only going to tell me if the system call passed or failed (i.e.
> an integer), regardless of whether the Expect script deemed a success
> or fail.
> 
> How can I call an Expect script from a Perl script and return a string
> value? Is there some trick to getting an interaction between Perl and
> Expect? I suppose I could do some kludge, like read the output into a
> file and search the file for the response. But I'd rather avoid that
> if possible.
> 
> Thanks in advance to all that respond.
> 
> Eric
> 

AFAIK, you cannot get a string return value from a separate process. You 
will either have to rewrite the Expect script to send the "SUCCESS" or 
"FAILURE" to STDOUT, or you'll have to use the kludge you mentioned.


-- 
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml


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

Date: Thu, 15 Feb 2007 03:10:32 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: problem CGI
Message-Id: <45d3c10c$0$27389$ba4acef3@news.orange.fr>

Michele Dondi wrote:

> On Wed, 14 Feb 2007 14:48:34 +0100, "john.swilting"
> <john.swilting@wanadoo.fr> wrote:
> 
>>I am afraid to find me with much
>>my $1 = $cgi->param('1');
> 
> Don't! Numbered variables have a special meaning. Try
> 
>   my $one = $cgi->param('1');
> 
> instead.
> 
> 
> Michele
ok



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

Date: Thu, 15 Feb 2007 03:13:13 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: problem CGI
Message-Id: <45d3c1ac$0$27389$ba4acef3@news.orange.fr>

usenet@DavidFilmer.com wrote:

> On Feb 14, 11:44 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
>> On Wed, 14 Feb 2007 15:22:39 +0100, "john.swilting"
> 
>> >that will be a gas works
>>
>> I beg your pardon?!?
> 
> I think the Bablefish French->English translator may have something to
> do with these garbled expressions...
gas works
bablefish translation

usine à gaz en français


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

Date: Thu, 15 Feb 2007 03:16:36 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: problem CGI
Message-Id: <45d3c278$0$5076$ba4acef3@news.orange.fr>

Michele Dondi wrote:

> On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
> <john.swilting@wanadoo.fr> wrote:
> 
>>you cannot help me too a little more perldoc cgi me
> 
> A little more? No I can't. I can help you a little less: try the
> param() function/method.
> 
> 
> HTH,
> Michele
I will find myself with hundreds of -> param(' ');


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

Date: Thu, 15 Feb 2007 03:54:42 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: problem CGI
Message-Id: <45d3cb66$0$25908$ba4acef3@news.orange.fr>

john.swilting wrote:

> Michele Dondi wrote:
> 
>> On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
>> <john.swilting@wanadoo.fr> wrote:
>> 
>>>you cannot help me too a little more perldoc cgi me
>> 
>> A little more? No I can't. I can help you a little less: try the
>> param() function/method.
>> 
>> 
>> HTH,
>> Michele
> I will find myself with hundreds of -> param(' ')
I should not make a loop for on all the data of the form


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

Date: Wed, 14 Feb 2007 23:09:30 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: problem CGI
Message-Id: <KcWdnVvX8aywmknYnZ2dnUVZ_u2mnZ2d@comcast.com>

john.swilting wrote:

> I am afraid to find me with much 
> my $1 = $cgi->param('1');

It is documented in 'perldoc CGI':

        FETCHING THE PARAMETER LIST AS A HASH:

        Many people want to fetch the entire parameter list as a hash in which
        the keys are the names of the CGI parameters, and the values are the
        parameters' values.

Therefore, you can use something like this:

     %params = $cgi->Vars;
     for my $key (sort keys %params) {
       print "The value for $key is '$params{$key}'\n",br;
     }

	-Joe


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

Date: Thu, 15 Feb 2007 03:10:25 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: problem CGI
Message-Id: <x7k5yjkfim.fsf@mail.sysarch.com>

>>>>> "JS" == Joe Smith <joe@inwap.com> writes:

  JS> Therefore, you can use something like this:

  JS>      %params = $cgi->Vars;
  JS>      for my $key (sort keys %params) {
  JS>        print "The value for $key is '$params{$key}'\n",br;
  JS>      }

the problem with that is that multivalued params are not an array but a
string with a separator. so you have to check each param to see if it is
single or multivalued. param() by itself will return a list if the param
is multivalued. i don't know why the Vars method is so broken but i
think it is a backwards compatibility issue. and even if so, why isn't
there a method which does return a proper hash of scalars and arrays. i
had to roll my own by calling param in a loop (map really) over a list
the params.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 15 Feb 2007 09:29:57 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: problem CGI
Message-Id: <3668t2d2mr0d2ak5270o26rshjib4ip2h1@4ax.com>

On Thu, 15 Feb 2007 03:16:36 +0100, "john.swilting"
<john.swilting@wanadoo.fr> wrote:

>> A little more? No I can't. I can help you a little less: try the
>> param() function/method.
>> 
>I will find myself with hundreds of -> param(' ');

If you need to handle hundreds of *different* situations, then that
may well be the only thing to do. If they are not completely different
but have something in common, chances are that the common parts may be
factored away. Hard to say without seeing some code, anyway. Thus try
to concoct a minimal example of the same nature of your program (but
devoid of any irrelevant detail) in which the calls are a tenth
insteads of hundreds. Then someone more knowledgeable than you and me
may well be able to help you.


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: Thu, 15 Feb 2007 09:44:01 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: problem CGI
Message-Id: <45d41d44$0$27386$ba4acef3@news.orange.fr>

Michele Dondi wrote:

> On Thu, 15 Feb 2007 03:16:36 +0100, "john.swilting"
> <john.swilting@wanadoo.fr> wrote:
> 
>>> A little more? No I can't. I can help you a little less: try the
>>> param() function/method.
>>> 
>>I will find myself with hundreds of -> param(' ');
> 
> If you need to handle hundreds of *different* situations, then that
> may well be the only thing to do. If they are not completely different
> but have something in common, chances are that the common parts may be
> factored away. Hard to say without seeing some code, anyway. Thus try
> to concoct a minimal example of the same nature of your program (but
> devoid of any irrelevant detail) in which the calls are a tenth
> insteads of hundreds. Then someone more knowledgeable than you and me
> may well be able to help you.
> 
> 
> Michele
I will try to make a small example this evening 16h pm paris


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

Date: 14 Feb 2007 21:31:00 -0800
From: "Mo" <le_mo_mo@yahoo.com>
Subject: regex to convert &#106; to character
Message-Id: <1171517460.475042.268400@v45g2000cwv.googlegroups.com>

Hi,

Any body knows how the regex convert & # 1 0 6 ; to character "j"?

Thanks,
Mo



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

Date: Thu, 15 Feb 2007 07:56:09 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: regex to convert &#106; to character
Message-Id: <tmUAh.1653$_73.1198@newsread2.news.pas.earthlink.net>

On 02/14/2007 11:31 PM, Mo wrote:
> Hi,
> 
> Any body knows how the regex convert & # 1 0 6 ; to character "j"?
> 
> Thanks,
> Mo
> 

"s/&#(\d+);/chr($1)/eg" will work, but using HTML::Entities is probably 
better.


-- 
Windows Vista and your freedom in conflict:
http://www.badvista.org/


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

Date: Thu, 15 Feb 2007 04:56:27 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: Regexp for email addresses.
Message-Id: <45d3d9df$0$27403$ba4acef3@news.orange.fr>

Abigail wrote:

> 
> use 5.9.5;   # In fact, you need the newest blead.
> 
> 
> my $email_address = qr {
>     (?(DEFINE)
>       (?<addr_spec>       (?&local_part) \@ (?&domain))
>       (?<local_part>      (?&dot_atom) | (?&quoted_string))
>       (?<domain>          (?&dot_atom) | (?&domain_literal))
>       (?<domain_literal>  (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))*
>       (?&FWS)?
>                                     \] (?&CFWS)?)
>       (?<dcontent>        (?&dtext) | (?&quoted_pair))
>       (?<dtext>           (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e])
> 
>       (?<atext>           (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~])
>       (?<atom>            (?&CFWS)? (?&atext)+ (?&CFWS)?)
>       (?<dot_atom>        (?&CFWS)? (?&dot_atom_text) (?&CFWS)?)
>       (?<dot_atom_text>   (?&atext)+ (?: \. (?&atext)+)*)
> 
>       (?<text>            [\x01-\x09\x0b\x0c\x0e-\x7f])
>       (?<quoted_pair>     \\ (?&text))
> 
>       (?<qtext>           (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e])
>       (?<qcontent>        (?&qtext) | (?&quoted_pair))
>       (?<quoted_string>   (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))*
>                            (?&FWS)? (?&DQUOTE) (?&CFWS)?)
> 
>       (?<word>            (?&atom) | (?&quoted_string))
>       (?<phrase>          (?&word)+)
> 
>       # Folding white space
>       (?<FWS>             (?: (?&WSP)* (?&CRLF))? (?&WSP)+)
>       (?<ctext>           (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e])
>       (?<ccontent>        (?&ctext) | (?&quoted_pair) | (?&comment))
>       (?<comment>         \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) )
>       (?<CFWS>            (?: (?&FWS)? (?&comment))*
>                           (?: (?:(?&FWS)? (?&comment)) | (?&FWS)))
> 
>       # No whitespace control
>       (?<NO_WS_CTL>       [\x01-\x08\x0b\x0c\x0e-\x1f\x7f])
> 
>       (?<ALPHA>           [A-Za-z])
>       (?<DIGIT>           [0-9])
>       (?<CRLF>            \x0d \x0a)
>       (?<DQUOTE>          ")
>       (?<WSP>             [\x20\x09])
>     )
> 
>     (?&addr_spec)
> }x;
> 
> 
> 
> 
> Abigail
it is incredible


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

Date: 14 Feb 2007 18:51:20 -0800
From: FeelLikeANut@gmail.com
Subject: Re: Wrong Server Port
Message-Id: <1171507880.807526.63500@p10g2000cwp.googlegroups.com>

On Feb 14, 9:04 pm, "attn.steven....@gmail.com"
<attn.steven....@gmail.com> wrote:
> On Feb 14, 4:53 pm, FeelLikeA...@gmail.com wrote:
>
> > On Feb 14, 6:01 pm, "Mumia W." <paduille.4060.mumia.w
>
> (snipped)
>
> > I don't want to use HTTP_HOST or HTTP_X_FORWARDED_HOST or
> > HTTP_*anything*, because those are set by the browser, not the server,
> > and I'd much rather not rely on them.
>
> > The CGI module uses SERVER_PORT, and the CGI module works. I was
> > hoping people could help inform me why this is. (The CGI module, btw,
> > is a whole lot of Perl code. Just because the code targets another
> > kind of technology does not magically remove all relatedness to Perl.)
>
> Take another look at CGI.pm.  It does check for HTTP_HOST, etc.
> The 'url' method calls the 'http' method and uses
> $ENV{HTTP_HOST} under certain conditions.  In fact it
> seems to prefer HTTP_HOST (if found) over SERVER_PORT:
>
> 'url' => <<'END_OF_FUNC',
> sub url {
>     my($self,@p) = self_or_default(@_);
>     my ($relative,$absolute,$full,$path_info,$query,$base,$rewrite) =
>         rearrange(['RELATIVE','ABSOLUTE','FULL',['PATH','PATH_INFO'],
> ['QUERY','QUERY_STRING'],'BASE','REWRITE'],@p);
>     my $url  = '';
>     $full++      if $base || !($relative || $absolute);
>     $rewrite++   unless defined $rewrite;
>
>     my $path        =  $self->path_info;
>     my $script_name =  $self->script_name;
>     my $request_uri =  unescape($self->request_uri) || '';
>     my $query_str   =  $self->query_string;
>
>     my $rewrite_in_use = $request_uri && $request_uri !~ /^
> $script_name/;     undef $path if $rewrite_in_use && $rewrite;  # path
> not valid when rewriting active
>     my $uri         =  $rewrite && $request_uri ? $request_uri :
> $script_name;
>
>     if ($full) {
>         my $protocol = $self->protocol();
>         $url = "$protocol://";
>         my $vh = http('x_forwarded_host') || http('host');  # <<<<<<<
> LOOK HERE <<<<<<
>         if ($vh) {
>             $url .= $vh;
>         } else {
>             $url .= server_name();
>             my $port = $self->server_port;
>
> # ...
>
> 'http' => <<'END_OF_FUNC',
> sub http {
>     my ($self,$parameter) = self_or_CGI(@_);
>     return $ENV{$parameter} if $parameter=~/^HTTP/;
>     $parameter =~ tr/-/_/;
>     return $ENV{"HTTP_\U$parameter\E"} if $parameter;  # <<<<<<  LOOK
> HERE <<<<<<<
>     my(@p);
>     foreach (keys %ENV) {
>         push(@p,$_) if /^HTTP/;
>     }
>     return @p;}
>
> END_OF_FUNC
>
> --
> Hope this helps,
> Steven

Thanks, Steven. That helps.



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

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 138
**************************************


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