[26034] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8243 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 11 21:05:46 2005

Date: Mon, 11 Jul 2005 18:05:12 -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           Mon, 11 Jul 2005     Volume: 10 Number: 8243

Today's topics:
    Re: Accessing lexical vars in other packages <ra.jones@dpw.clara.co.invalid>
    Re: Book:  Higher-Order Perl: Transforming Programs wit axel@white-eagle.invalid.uk
        Checking If A Function Exists <hal@thresholddigital.com>
    Re: Checking If A Function Exists <tadmc@augustmail.com>
    Re: Checking If A Function Exists <1usa@llenroc.ude.invalid>
    Re: Checking If A Function Exists <sherm@dot-app.org>
    Re: Checking If A Function Exists <pilkowsk@informatik.uni-marburg.de>
    Re: Checking If A Function Exists <noreply@gunnar.cc>
    Re: Custom message formatting callback for Log::Dispatc <jgibson@mail.arc.nasa.gov>
        dat files help jane@rifill.com
    Re: dat files help <jgibson@mail.arc.nasa.gov>
    Re: In basic I say Dim var$(50,50), how to make 2 dimen <abigail@abigail.nl>
        LWP problems <mikee@mikee.ath.cx>
        member callback function <sheam@hb-studios.com>
    Re: member callback function xhoster@gmail.com
    Re: member callback function <1usa@llenroc.ude.invalid>
        Minor correction  July 11, 2005 <edgrsprj@ix.netcom.com>
        OT: Higher Order Perl and Amazon (was: Re: Book:  Highe <stevenv@operamail.com>
        Perl form as a wrapper to a C program. <nospam@nowhere.com>
    Re: Perl form as a wrapper to a C program. <1usa@llenroc.ude.invalid>
    Re: Perl form as a wrapper to a C program. <jgibson@mail.arc.nasa.gov>
        Pool of database connections <spam@couts.org>
    Re: Pool of database connections xhoster@gmail.com
    Re: Problems understanding and implementing process man <tadmc@augustmail.com>
    Re: Why $1 not work in cygwin? <tim@vegeta.ath.cx>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 11 Jul 2005 21:20:04 +0100
From: RA Jones <ra.jones@dpw.clara.co.invalid>
Subject: Re: Accessing lexical vars in other packages
Message-Id: <rr5fAGB0Rt0CFwk7@na326073.eclipse.co.uk>

On Fri, 8 Jul 2005, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> 
wrote:
>You cannot access lexical variables from outside their scope, unless
>code inside the scope allows it.  So, unless the code in CGI::HTMLError
>provides an accessor routine (in the generic sense, not necessarily a
>method) to the variable, you're out of luck.

Of course, you are correct about the irrelevance of which package we are 
trying to access variables from. But it seems a solution may have been 
provided in the other reply.
-- 
ra(dot)jones(at)dpw(dot)clara(dot)co(dot)uk


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

Date: Mon, 11 Jul 2005 13:27:29 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Book:  Higher-Order Perl: Transforming Programs with Programs
Message-Id: <5tuAe.122524$Vo6.54419@fe3.news.blueyonder.co.uk>

David H. Adler <dha@panix.com> wrote:
> On 2005-07-09, axel@white-eagle.invalid.uk <axel@white-eagle.invalid.uk> wrote:
>> Indeed. May I draw attention to the _author's_ site:
>>
>> http://hop.perl.plover.com/#free
>>
>>       "My contract says that after the book is published I can
>>       distribute the complete text from my web site. The content
>>       of my book will be available to everyone everywhere for
>>       free. Watch this space for updates."
 
> That said, if you can, buy the book anyway. It's real good. If we buy
> this one, maybe he'll write more! :-)

I intend to. Acquiring new books is not a problem... now spending time
reading them and, more importantly, finding bookshelf space is!

Axel
 


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

Date: Mon, 11 Jul 2005 17:11:00 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Checking If A Function Exists
Message-Id: <DemdnZdiDIL8fU_fRVn-gg@comcast.com>

I have to filter some data through a number of possible data filters.  The
names of the filters are stored in a database, then loaded into a hash, so
I find the name of the needed filter like this:

        $filter = $filters{$type};
        $filter = \&$filter;
        $data = &$filter($data);

I'd like to be able to do a 2 stage filter, one for incoming, and one for
outgoing.  Most filters don't need 2 stages, but some do.  I'd like to
change it to add an extra step on incoming:

        $filter = $filters{$type};
        $filter = $filter."incoming";
        $filter = \&$filter;
        $data = &$filter($data);

If I do that, is there a way to check if there is a function
"filterincoming()"?  That way I could only add the "incoming" to the end if
an incoming filter actually exists, otherwise, I'd just use the regular
filter.

Is it possible to check and see if a particular functionname is available
without forcing an error?

Thanks!

Hal


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

Date: Mon, 11 Jul 2005 17:14:26 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Checking If A Function Exists
Message-Id: <slrndd5rq2.hc5.tadmc@magna.augustmail.com>

Hal Vaughan <hal@thresholddigital.com> wrote:

> If I do that, is there a way to check if there is a function
> "filterincoming()"?

> Is it possible to check and see if a particular functionname is available
> without forcing an error?


Yes there is.

   if ( *filterincoming{CODE} )
      { print "found a filterincoming() func\n" }


I'd explain the *foo{THING} syntax for you, only I have such poor
people skills that I'm not even going to attempt an explanation...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 11 Jul 2005 22:17:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Checking If A Function Exists
Message-Id: <Xns9690BA0EF10E7asu1cornelledu@127.0.0.1>

Hal Vaughan <hal@thresholddigital.com> wrote in
news:DemdnZdiDIL8fU_fRVn-gg@comcast.com: 

> I have to filter some data through a number of possible data filters. 
> The names of the filters are stored in a database, then loaded into a
> hash, so I find the name of the needed filter like this:
> 
>         $filter = $filters{$type};
>         $filter = \&$filter;
>         $data = &$filter($data);
> 
> I'd like to be able to do a 2 stage filter, one for incoming, and one
> for outgoing.  Most filters don't need 2 stages, but some do.  I'd
> like to change it to add an extra step on incoming:
> 
>         $filter = $filters{$type};
>         $filter = $filter."incoming";
>         $filter = \&$filter;
>         $data = &$filter($data);

All your problems (the ones you know about, and the ones you don't know 
about) would be solved if you used a hash that maps the name of the 
filter to a ref to the sub that is supposed to do the filtering.

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

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: Mon, 11 Jul 2005 18:30:26 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: Checking If A Function Exists
Message-Id: <m23bqlgem5.fsf@Sherm-Pendleys-Computer.local>

Tad McClellan <tadmc@augustmail.com> writes:

> Hal Vaughan <hal@thresholddigital.com> wrote:
>
>> If I do that, is there a way to check if there is a function
>> "filterincoming()"?
>
>> Is it possible to check and see if a particular functionname is available
>> without forcing an error?
>
>
> Yes there is.
>
>    if ( *filterincoming{CODE} )
>       { print "found a filterincoming() func\n" }
>
>
> I'd explain the *foo{THING} syntax for you, only I have such poor
> people skills that I'm not even going to attempt an explanation...

There's a pretty good reference to typeglobs in "perldoc perlmod" - no people
skills required. :-)

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 12 Jul 2005 00:44:10 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: Checking If A Function Exists
Message-Id: <3jgavgFq1a6pU1@individual.net>

* Hal Vaughan schrieb:

> I have to filter some data through a number of possible data filters.  The
> names of the filters are stored in a database, then loaded into a hash, so
> I find the name of the needed filter like this:
> 
>         $filter = $filters{$type};
>         $filter = $filter."incoming";
>         $filter = \&$filter;

I prefer to use different variables for different things. First, $filter
is a string containing the name of your sub -- and later it contains a
coderef to this sub. In my example below I use two vars for that.

>         $data = &$filter($data);
> 
> If I do that, is there a way to check if there is a function
> "filterincoming()"?

Look at the value of

    main->can('filterincoming')

to find out if your package main *can* call a specific function. Btw, on
success can() will return a coderef to that sub.

    my $filtername = 'filterincoming';
    my $filter = main->can( $filtername );
    if ( $filter ) {
        $filter->( $args );
    }

Please read `perldoc UNIVERSAL` for details about can()'s limitations.

> 
> Is it possible to check and see if a particular functionname is available
> without forcing an error?

Another way doing this is to catch that error (exeption handling). That
way you moving around the limitations of can(). Check `perldoc -f eval`
for details on how to catch any kind of runtime errors (such as calling
non-existent subs).

    eval { $filter->( $args ) };
    warn "catched: $@" if $@;

regards,
fabian


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

Date: Tue, 12 Jul 2005 00:51:47 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Checking If A Function Exists
Message-Id: <3jgbg8FpmfttU1@individual.net>

Hal Vaughan wrote:
> Is it possible to check and see if a particular functionname is available
> without forcing an error?

You can use eval() to capture a possible error.

     eval { $data = $filter->($data) };

See "perldoc -f eval".

Or maybe you should consider an alternative approach, for instance:

     sub myfilter {
         my ($data, $incoming) = @_;

         INCOMING: {
             last INCOMING unless $incoming;

             # code for filtering incoming data

             return $data;
         }

         # code for filtering outgoing data

         $data;
     }

     my $filter = \&{ $filters{$type} };
     $data = $filter->($data, 1);

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


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

Date: Mon, 11 Jul 2005 09:00:59 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Custom message formatting callback for Log::Dispatch
Message-Id: <110720050900591123%jgibson@mail.arc.nasa.gov>

In article <89i3d15qvmr975i1hon02qo8n2c6oplbck@4ax.com>, Dan
<Cpp@subclassed.net> wrote:

> I want to set up Log::Dispatch with two outputs... "file" and "email".
> I'd like to use a callback function to do custom formatting of the
> message based on whether the output is going to a logfile or email.

According to the documentation on Log::Dispatch, the callback function
is only called once per message, regardless of the number of
destinations added to the Log::Dispatch object. Therefore, your hope of
using the callback to format the message differently for each
destination will simply not work.

> 
> I.E. a one line entry if sent to logfile and a verbose description,
> possibly including html, hyperlinks, etc if sent by email.
> 
> I figured since the log method supports sending arbitrary named pairs
> to the callback function, all I needed to do was get the name of the
> Dispatch object doing the logging, and have the callback do the
> necessary formatting based on the destination, but getting the name of
> the Dispatch object is proving to be beyond my very measly perl
> programming skills!
> 
> Any help would be greatly appreciated!

You will have to write your own log class, either starting from scratch
or building on the existing Log::Dispatch. You could, for example, have
a log function that calls two different Log::Dispatch objects, one for
file and one for e-mail. Each of those could then have its own
formatting callback. You could use the same callback function and use
the 'type=>xxx' argument to differentiate the destination.

[ program using Log::Dispatch snipped ]

Note: posted code should always include 'use strict;' and 'use
warnings;'. Please see the posting guidelines for this group.

Thanks.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Mon, 11 Jul 2005 20:41:12 GMT
From: jane@rifill.com
Subject: dat files help
Message-Id: <pvl5d112bsamd5998ogahkvq997a80jr1m@4ax.com>

Hi all

Please could you point me in the right direction for a demo or help site for the following


1...I have a Perl/cgi script that collects username, email, password, name, address, town
etc etc

2...This then stores  the information that it gets from a form in dat files in folders like
user    xxxx.dat files. a dat file for each user.    when I look in the dat file for the
above it as stored it in a format like

tom 
fff@ffff.com
dffghh
tom jones
23 smith street

fred town


xxxxxxxx
xxxxx

The other folder is called 1 then there is about another ten folders upto ten with dat files
in each  the dat file contents look like

tom
this is a <br> ffffff <br> fdfsdfsf  <br>    and so on I presume the <br> are returns in the
script form
http://ffffff.com/xxxxxxx.jpg


Want I want to do is this

1...User folder go thro the folder and get all the info out of the dat files then split it
so it would export it to a xls file.


2....The same with the other folder.


Hope I have made my self clear on the above.


Thank you
Jane
  




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

Date: Mon, 11 Jul 2005 14:17:52 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: dat files help
Message-Id: <110720051417523785%jgibson@mail.arc.nasa.gov>

In article <pvl5d112bsamd5998ogahkvq997a80jr1m@4ax.com>,
<jane@rifill.com> wrote:

> Hi all
> 
> Please could you point me in the right direction for a demo or help site for
> the following

You are unlikely to find a demo or website addressing your particular
problem. What have you attempted so far? You are expected to make some
effort at solving your own problem before asking for help here.

See http://learn.perl.org for learning to program in Perl.

> 1...I have a Perl/cgi script that collects username, email, password, name,
> address, town
> etc etc
> 
> 2...This then stores  the information that it gets from a form in dat files
> in folders like
> user    xxxx.dat files. a dat file for each user.    when I look in the dat
> file for the
> above it as stored it in a format like
> 
> tom 
> fff@ffff.com
> dffghh
> tom jones
> 23 smith street
> 
> fred town
> 
> 
> xxxxxxxx
> xxxxx
> 

So you have one field per line and a fixed number of fields per record?
This is in a file called, e.g. 'tom.dat' for user tom in a folder
called 'user'?

> The other folder is called 1 then there is about another ten folders upto ten
> with dat files
> in each  the dat file contents look like
> 
> tom
> this is a <br> ffffff <br> fdfsdfsf  <br>    and so on I presume the <br> are
> returns in the
> script form
> http://ffffff.com/xxxxxxx.jpg
> 
> 

So you have another folder called '1' with up to 10 files ending in
'.dat'? You have not told us what these files are named or what is
their relationship to the file in the user folder, if any.

> Want I want to do is this
> 
> 1...User folder go thro the folder and get all the info out of the dat files
> then split it
> so it would export it to a xls file.

The data already looks split into separate lines. What are you trying
to split?

> 
> 
> 2....The same with the other folder.
> 
> 
> Hope I have made my self clear on the above.

Not entirely. I am afraid your English syntax and punctuation leave
something to be desired and make it difficult to understand your
explanation.

You can find files in specified folders with the glob function or,
better still, with the File::Find module, part of the core perl
distribution.

You can read files with the open function and <> operator, which reads
one line per call in a scalar context.

You can create an Excel spreadsheet file with the
Spreadsheet::WriteExcel module. As this is not in the Perl core
distribution, you may have to install it yourself.

Please see

   perldoc -f open
   perldoc perlop
   perldoc File::Find
   perldoc Spreadsheet::WriteExcel

for more information on these Perl facilities. Please make an attempt
to write a program and ask further questions here if you run into
trouble, but please do read and follow the guidelines for this
newsgroup before doing so:

http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Thanks.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 11 Jul 2005 20:14:09 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: In basic I say Dim var$(50,50), how to make 2 dimensional aray in Perl?
Message-Id: <slrndd5kog.19i.abigail@alexandra.abigail.nl>

max (max@xxxxxxx.xxx) wrote on MMMMCCCXXX September MCMXCIII in
<URL:news:danqkk$p3$1@ss405.t-com.hr>:
:)  In basic language I say
:)  Dim var$(50,50)
:)  or
:)  Dim var$(50,50,50)
:) , how to make 2 or 3 dimensional array in Perl?


You don't "make" multi-dimensional arrays in Perl. Except for objects,
you don't have to "make" any datastructure in Perl. Just use a variable
as a 2 dimensional array - and Perl will create whatever needs to be
created.

    my @power;

    for (my $x = 0; $x < 3; $x ++) {
        for (my $y = 0; $y < 5; $y ++) {
            $power [$x] [$y] = $x ** $y;
        }
    }


See also perldata, perldsc and perlref manual pages.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Mon, 11 Jul 2005 20:04:45 GMT
From: Mike <mikee@mikee.ath.cx>
Subject: LWP problems
Message-Id: <xhAAe.136$rX7.2@fe06.lga>

I'm trying to touch IBM from inside a proxy. My LWP code touches the proxy,
but does not authenticate with the proxy so I can go on to IBM. Does anyone
see my mistake?

Thanks

Mike

Here is the code:


#!/usr/bin/perl

# $Id$
# $Log$

# grab the machine type from 'lsattr -El sys0'
# grab the current microcode version depending on the command for that machine
# grab the latest microcode version for this box from:
#    http://techsupport.services.ibm.com/server/mdownload/download.html
# complain if the microcode is not at the current version

use LWP::UserAgent;
use LWP::Debug qw(+);
use strict;

# globals
my $microcodeurl = 'http://techsupport.services.ibm.com/server/mdownload/download.html';

# get the machine type
my $cmd = 'lsattr -El sys0 | grep modelname';
open(IN, "$cmd |") or die "$0: cannot execute '$cmd': $!";
my $line = <IN>;
close(IN);
chomp($line);

# pull the microcode version from IBM
# and the command to get the currently installed microcode version
my $ua = LWP::UserAgent->new();
$ua->proxy('http', 'http://txisa002.ttiinc.com:8080');
my $req = HTTP::Request->new(GET => $microcodeurl);
my $user = 'domain\user';
my $pass = 'password';
$req->proxy_authorization_basic($user, $pass);
my $page = $ua->request($req)->as_string;
1;



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

Date: Mon, 11 Jul 2005 15:01:05 GMT
From: "Shea Martin" <sheam@hb-studios.com>
Subject: member callback function
Message-Id: <RQvAe.59661$Ph4.1762027@ursa-nb00s0.nbnet.nb.ca>

How to I pass a member function as a callback.

For a normal sub I would do this: \&myFunc,

but what do I do for a member func?
I tried this, but it doesn't work: \&$myClassInstance->myFunc()
I also tried a number of other things.

~S 




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

Date: 11 Jul 2005 15:42:40 GMT
From: xhoster@gmail.com
Subject: Re: member callback function
Message-Id: <20050711114240.507$Wn@newsreader.com>

"Shea Martin" <sheam@hb-studios.com> wrote:
> How to I pass a member function as a callback.
>
> For a normal sub I would do this: \&myFunc,
>
> but what do I do for a member func?
> I tried this, but it doesn't work: \&$myClassInstance->myFunc()
> I also tried a number of other things.
>
> ~S

sub { $myClassInstance->myFunc(@_) }

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 11 Jul 2005 15:45:45 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: member callback function
Message-Id: <Xns969077A70D14Casu1cornelledu@127.0.0.1>

"Shea Martin" <sheam@hb-studios.com> wrote in news:RQvAe.59661
$Ph4.1762027@ursa-nb00s0.nbnet.nb.ca:

> How to I pass a member function as a callback.

Instance methods do not exist independently of a specific instance of 
the class. Just as you cannot cut the arm of a master knitter and send 
it to another location, and expect it to work, you cannot expect an 
instance method to do anything useful without the rest of the object.

> For a normal sub I would do this: \&myFunc,> 
> but what do I do for a member func?
> I tried this, but it doesn't work: \&$myClassInstance->myFunc()
> I also tried a number of other things.

You'll need to use a closure. The code below is untested (as you have 
not provided any code -- see the recommendations in the posting 
guidelines for this group on how you can maximize both the quantity and 
quality of the help you receive by putting some effort into your post).

#!/usr/bin/perl

use strict;
use warnings;

package My::Handler;

sub new {
	my $class = shift;
	bless { }, $class;
}

sub handle {
	my $self = shift;
	print "Go away, I am handling this!\n";
}

package My::Dispatcher;

sub new {
	my $class = shift;
	bless { }, $class;
}

sub register_callback {
	my $self = shift;
	$self->{callback} = shift;
}

sub generate {
	my $self = shift;
	$self->{callback}->();
}

package main;

my $dispatcher = My::Dispatcher->new;
my $handler = My::Handler->new;
$dispatcher->register_callback( sub { $handler->handle } );

$dispatcher->generate;

__END__


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

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: Mon, 11 Jul 2005 21:21:30 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Minor correction  July 11, 2005
Message-Id: <upBAe.1915$oZ.930@newsread2.news.atl.earthlink.net>

"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message
news:D7qAe.21003$eM6.9503@newsread3.news.atl.earthlink.net...
> PROPOSED EARTHQUAKE FORECASTING
> COMPUTER PROGRAM DEVELOPMENT EFFORT

> it jumps strait to the display routine and uses the entered command to
begin

Should be the word "straight" instead of strait.




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

Date: Mon, 11 Jul 2005 15:25:44 -0400
From: Steven Vasilogianis <stevenv@operamail.com>
Subject: OT: Higher Order Perl and Amazon (was: Re: Book:  Higher-Order Perl: Transforming Programs with Programs)
Message-Id: <86pstpxhzb.fsf_-_@bertozzo.ada>

axel@white-eagle.invalid.uk writes:

> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:

[snip URL to Amazon.com with affiliate ID]

>> Take a look at ref=pd_bbs_ur_1. That is someone's Amazon affiliate ID. 
>> If you click on this link, then but something from Amazon a month from 
>> now, that person will make money (if you haven't clicked on someone 
>> else's affiliate link in the mean time).
>  
> Indeed. May I draw attention to the _author's_ site:
>
> http://hop.perl.plover.com/#free
>
> 	"My contract says that after the book is published I can
> 	distribute the complete text from my web site. The content
> 	of my book will be available to everyone everywhere for
> 	free. Watch this space for updates."

I think this portion of an interview with the Mark Jason Dominus (author of
_Higher Order Perl_) is also worth mentioning for those who would still like
to buy it:

  TPR: In the past, you have expressed strong feelings about Amazon.com. Where
  would you like people to buy your book? Do you have an affiliate link?

  MJD: I'm still upset about Amazon's ridiculous "one-click" patent, and I'm
  still boycotting them. Software patents like Amazon's threaten the
  livelihoods of all programmers, including mine, and I don't want to give my
  support to a company that means me ill. They dropped their suit against
  Barnes & Noble, but the terms of the settlement were never disclosed, so we
  don't know what happened, and Amazon could turn around at any moment and sue
  anyone for violating their patent. So the issue is unresolved.

  I'd like people to buy my book from anyone but Amazon. My web site has an
  affiliate link to either to Barnes and Noble or to Powell's Books, depending
  on who isn't out of stock at the moment. I get a small kickback from this,
  but I really don't feel strongly about it. I do feel strongly about not
  supporting Amazon. There are a lot of places to get books online; it's not
  hard to buy books from a company with less abusive business practices than
  Amazon.

http://www.theperlreview.com/Interviews/mjd-hop-20050407.html


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

Date: Mon, 11 Jul 2005 22:46:52 +0100
From: Dave <nospam@nowhere.com>
Subject: Perl form as a wrapper to a C program.
Message-Id: <42d2e8d0@212.67.96.135>

I have a C program (called dipole) that takes 3 command line arguments. 
I want a user to be able to run the program with their choice of 
arguments from a web page.

I wrote a simple form in perl that allows the user to enter the 3 
required parameters. How can I pass them from perl to the C program, 
using perl as a wrapper?

The form is at
http://www.southminster-branch-line.org.uk/cgi-bin/test3-cgi

and the source below of it below.

Is there a way I can call execute

'dipole frequency length diameter'

and return standard output of that C program to the browser?


I think I need to use 'open' rather than exec or system, but I can't get 
any sense from anything. I am new to perl.

#!/usr/bin/perl
use CGI qw(:standard);


print header;
print start_html('Self Impedance of a dipole'),
     h1('Self impedance of a simple dipole (not folded)'),
     start_form,
     "Frequency (MHz)? ",textfield('frequency'),
      p,
     "Length (m) ? ",textfield('length'),
      p,
     "Diameter (mm) ?",textfield('diameter'),
     submit,
     end_form,
     hr;

if (param()) {
     print
         "Frequency is ",em(param('frequency')),
         p,
         "Length is ",em(param('length')),
         p,
         "Diameter is ",em(param('diameter')),
         hr;
}
print end_html;



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

Date: Mon, 11 Jul 2005 22:13:32 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl form as a wrapper to a C program.
Message-Id: <Xns9690B962CCB9asu1cornelledu@127.0.0.1>

Dave <nospam@nowhere.com> wrote in news:42d2e8d0@212.67.96.135:

> Is there a way I can call execute
> 
> 'dipole frequency length diameter'
> 
> and return standard output of that C program to the browser?
> 
> I think I need to use 'open' rather than exec or system, but I can't
> get any sense from anything. I am new to perl.

Have you actually read

perldoc -f system

Sinan

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

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: Mon, 11 Jul 2005 17:20:43 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Perl form as a wrapper to a C program.
Message-Id: <110720051720432839%jgibson@mail.arc.nasa.gov>

In article <42d2e8d0@212.67.96.135>, Dave <nospam@nowhere.com> wrote:

> I have a C program (called dipole) that takes 3 command line arguments. 
> I want a user to be able to run the program with their choice of 
> arguments from a web page.
> 
> I wrote a simple form in perl that allows the user to enter the 3 
> required parameters. How can I pass them from perl to the C program, 
> using perl as a wrapper?
> 
> The form is at
> http://www.southminster-branch-line.org.uk/cgi-bin/test3-cgi
> 
> and the source below of it below.
> 
> Is there a way I can call execute
> 
> 'dipole frequency length diameter'
> 
> and return standard output of that C program to the browser?

Use backticks (reverse apostrophe) or the qx operator to execute an
external command and capture the output. See, for example, 'perldoc
perlop' and search for 'qx'.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Mon, 11 Jul 2005 18:24:46 GMT
From: Aaron Couts <spam@couts.org>
Subject: Pool of database connections
Message-Id: <slrndd5ets.8t1.spam@waimea.local>

I'm working on a network server written entirely in perl, and it's functioning, 
in a way, as a proxy server for an Oracle database.  Right now each new 
socket connection forks off a process, and that new process creates a brand 
new database connection.  This is kind of slow and dumb, so I have a few 
questions.

1. Are there any tools out there that are custom-made for this?  Something 
like Apache::DBI would be great, but I can't run the server under Apache.  
Also I need to use forks rather than threads.

2. I was thinking of using forks::shared to manage a pool of connections, but
it looks like it doesn't work with database handles.  Can anyone confirm this?

Thanks,
Aaron

-- 
To contact me via email, substitute 
'aaronc' for 'spam' in my address.
http://www.towerdata.com


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

Date: 11 Jul 2005 20:46:18 GMT
From: xhoster@gmail.com
Subject: Re: Pool of database connections
Message-Id: <20050711164618.365$UZ@newsreader.com>

Aaron Couts <spam@couts.org> wrote:
> I'm working on a network server written entirely in perl, and it's
> functioning, in a way, as a proxy server for an Oracle database.  Right
> now each new socket connection forks off a process, and that new process
> creates a brand new database connection.  This is kind of slow and dumb,
> so I have a few questions.

Has it's slowness and dumbness been investigated and proven to be an actual
bottleneck in the system, or is merely an abstractly theoretical slowness
and dumbness?

> 1. Are there any tools out there that are custom-made for this?
> Something like Apache::DBI would be great, but I can't run the server
> under Apache. Also I need to use forks rather than threads.

I'm not aware of any meeting those requirements as stated.  Could you make
the server pre-forking?  (And then each pre-forked process would get a dbh
connection at startup and then handle network requests sequentially.)

>
> 2. I was thinking of using forks::shared to manage a pool of connections,
> but it looks like it doesn't work with database handles.  Can anyone
> confirm this?

I can't confirm it specifically with forks::shared, but I think the
underlying mechanism to pass serialized data over a socket, which mechanism
I couldn't make work with oracle connections.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 11 Jul 2005 08:20:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problems understanding and implementing process management
Message-Id: <slrndd4sgg.fqq.tadmc@magna.augustmail.com>

James Calivar <amheiserbush@yahoo.com.au> wrote:
> Tad McClellan wrote:
>> 
>> Glad to join in and oblige.
>> 
>> *plonk*
>> 
>> 
> 
> Christ you people sure are intolerant.  


The code would not compile, you insisted it would compile, we are
intolerant of the possibility of impossible things happening.

Such intolerance is common even outside of this newsgroup.


> Enjoy your limited view of the 
> Perl world, 


Most people would have apologized for the broken code, fixed it,
and gotten some help with it.

It appears you are not such a person.

(and, since the code would not compile, it was NOT a member of the
 set comprising the "Perl world".
)


> fucktard.


I love you too.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 11 Jul 2005 10:07:27 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: Why $1 not work in cygwin?
Message-Id: <slrndd4h3r.f12.tim@vegeta.saiyix>

Bart Lateur <bart.lateur@pandora.be> wrote:
>  niry wrote:
> > perl -e "while(<>) { print $1 if(/^F MEASURE:\s+([0-9\.]+)$/); }"
> > with input:
> > F MEASURE:      0.9343
> >
> > but the output is:
> > F MEASURE:      0.9343
> > not what I expect:
> > 0.9343
> >
> > and this script did well on my windows and linux, except cygwin
> 
> But, what shell are you using? I think you're having a shell escape
> issue.

Doh.  Yeah, the double-quotes would fail to properly escape the $1 in
the shell.  The OP should try using single quotes around the perl code.

$ perl -ne 'print "$1\n" if /^F MEASURE:\s+([\d.]+)$/'
F MEASURE:      0.9343
0.9343
^D
$ 

Tim Hammerquist
-- 
I shall never go back now that I have tasted of sweet, *sweet* invincibility.
It tastes like varnish.  Not many people know that.
    -- Fighter, 8-Bit Theater <http://nuklearpower.com/>


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

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


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