[12268] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5868 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 3 07:07:25 1999

Date: Thu, 3 Jun 99 04:00:33 -0700
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, 3 Jun 1999     Volume: 8 Number: 5868

Today's topics:
        [?] Where do Mail Robot warnings go? <sergei_klimov@sierra.auriga.ru>
        A Problem with NULLs quanlay@yahoo.com
        Auto de/increments help jknoll@my-deja.com
    Re: beginner (Sitaram Chamarty)
    Re: Can Perl call C functions? sbeaulieu@my-deja.com
        CGI parameter passing with GET question toddyip@my-deja.com
    Re: comparing 3 numeric values (I.J. Garlick)
        Determining height and with of uploaded Graphic files mraffin@cisclub.acad.emich.edu
        displaying adodb errors. slamda@hotmail.com
        Fields without values (Re: FAQ 4.29: How can I split a  kgentes@gentek.net
    Re: Find all files regardless of extension <gellyfish@gellyfish.com>
        funky STDOUT under Win32? orock@my-deja.com
        Getting around the refresh button motyk@my-deja.com
        Getting rid of blank lines themuppet@my-deja.com
        Help for a newbie reddogg1471@my-deja.com
        Help for a newbie reddogg1471@my-deja.com
        Help on process data in a file tvn007@my-deja.com
        HELP: Regular Expressions <dgmdan@md-sites.com>
        How to call from HTML ? (Moxel23)
    Re: How to call from HTML ? <office@asc.nl>
    Re: How to call from HTML ? <gellyfish@gellyfish.com>
    Re: Is split (surprisingly, amazingly) slow? <jdporter@min.net>
    Re: Is split (surprisingly, amazingly) slow? <jdporter@min.net>
    Re: Loading modules at run time - Solution <jan.van.rensburg@epiuse.com>
    Re: Loading modules at run time <jan.van.rensburg@epiuse.com>
        lvalue subroutine returns in perl <B.A.McCauley@bham.ac.uk>
    Re: micro$~1 perl <garethr@cre.canon.co.uk>
        PERL Newbie Question andrewvignes@hotmail.com
    Re: PERL Newbie Question <bill@fccj.org>
        Perl script keeps terminating (kevin)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 31 May 1999 14:31:02 GMT
From: Sergei Klimov <sergei_klimov@sierra.auriga.ru>
Subject: [?] Where do Mail Robot warnings go?
Message-Id: <7iu6f7$ftj$1@nnrp1.deja.com>

Hi All;

Could you please teach me where to find warnings from e-mail robot?
I wrote a script for processing incoming mail, and put
"!/usr/bin/perl -w
in its first line. Now I would like to see those warnings but do not
know where to find them. Please help. I found answer neither in FAQ,
nor in Camel and Llama books.

Thank you!

Sergei


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 05:45:42 GMT
From: quanlay@yahoo.com
Subject: A Problem with NULLs
Message-Id: <7ivs27$ubm$1@nnrp1.deja.com>

I've run into a rode block.  Maybe someone can shed a little light on
this for me.

I would like to use a standard routine to write to a database using a
module but I can seem to write NULLs to a variable and write it to the
database.

The database can accept nulls and in some instances, other programs
accessing the database expect them.

Currently, an example of my code looks like this:

package testnull;

sub new {
  my $test = shift;
  my $class = ref($test) || $test;
  my $self = {
    String => '',
    Integer => 0,
    Nothing => null
  };
  bless($self, $class);
  return $self;
}

sub Write {
  my $self = shift;
  my $sql = "
    INSERT INTO testtable (
    String, Integer, Nothing
    ) VALUE (
    $self->{String},
    $self->{Integer},
    $self->{Nothing}
    )
  ";
  return $sql;
}

 ...

Anyhow the return SQL statement is written to the database but the
problem is that it chokes.  Nothing could be an Integer or a Null.  I
want to avoid if thening the $self->Nothing for an undef or null to
build a sql statement of
 ... $self->(Integer), null) ...
because I want the full sql in one statement quote if possible...

Any Suggestions?

Thanks in advance,
Quan


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 18:14:01 GMT
From: jknoll@my-deja.com
Subject: Auto de/increments help
Message-Id: <7j17tu$r5p$1@nnrp2.deja.com>

I am testing auto de-in crements and I keep getting hung up on this
little script.

Im trying to get this;
Two $nums are 10 * 2 and adding one to $var makes Perl++
Two $nums are 20 and adding to $var makes Perm

and I get this:
Two $nums are 10 * 2 and adding one to $var makes Perl++
Two $nums are 20 and adding to $var makes Perl

why doesn't the Perl change to Perm ??

tia
Jesse

here's the code:

$var="Perl";
$num=10;
print "Two \$nums are $num * 2 and adding one to \$var makes $var++\n";
print "Two \$nums are ", $num * 2," and adding one to \$var makes ",
$var++,"\n";

--
JESSE KNOLL
--Senior - Ball State University - INDIANA --
jrknoll@cwix.com

Majors:				Minor:
Sport Administration		Computer Science
Business Finance

 ...Either you have the force...or you don't.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 03 Jun 1999 10:38:17 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: beginner
Message-Id: <slrn7lapb5.gk.sitaram@diac.com>

On Tue, 01 Jun 1999 19:46:45 -0400, Emily Brock Latham
<eblatham@unity.ncsu.edu> wrote:
>
>I have just been getting my feet wet with perl.  And I am writing a
>script that is executing the following line:
>
>   exec 'more','avail.dat';
>
>and another line:
>
>   exec ("grep $username all.dat");
>
>but each of these clears the screen before outputting the data.  Is
>there any way to keep it from doing this? 

The first one I would have said is a problem with "more".  But the
second one leads me to think that there may be something in your
$ENV that's doing this.

In other words, this doesnt sound like a perl problem.


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

Date: Tue, 01 Jun 1999 21:17:07 GMT
From: sbeaulieu@my-deja.com
Subject: Re: Can Perl call C functions?
Message-Id: <7j1ikj$v88$1@nnrp2.deja.com>



> Yes .. by reading the proper docs. Here are the most relevant docs in
> random order:
>
> perldoc perlembed
> perldoc perlcall
> perldoc perlxs
>

The perlxs example 4 does exactly what I want but I can't seem to get
it to work with Windows NT which is what I need it to work in.  Any
comments?

Stephen


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 08:45:03 GMT
From: toddyip@my-deja.com
Subject: CGI parameter passing with GET question
Message-Id: <7j06ig$10t$1@nnrp1.deja.com>

I am a newbie in writing Perl and now I have a problem a writing a
simple CGI.

I want to pass a string to a CGI program with GET method and then test
the string with following lines.  As I am using ActivePerl in Win95,
there is no need to type something like #!c:/perl/bin/perl.exe

----
print "Content-type:text/html\n\n";

print $ENV{'QUERY_STRING'};
----

When I type "http://home/cgi-bin/test_input.cgi?a=1" in the command
line of browser, it just works fine.

However, when I use

----
print <form action=\"http://home/cgi-bin/test_input.cgi?a=1\"\"
method=\"GET\">";
print "<input type=\"submit\" name=\"Submit\" value=\"Confirm\">";
print "</form>";
----

It just give me submit="Confirm" but not a="1".

Could anyone help me solve this?

Thanks a lot!!

Todd ^.^



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 3 Jun 1999 09:36:24 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: comparing 3 numeric values
Message-Id: <FCqw0o.Jy3@csc.liv.ac.uk>

In article <%hd53.407$cb5.38316@ord-read.news.verio.net>,
elvis@NOTGRACELANDclark.net writes:
> 
> I have 3 values:
> $start = "6/15/1999" ;
> $end = "6/30/1999" ;
> $current = "6/16/1999" ; 
> 
> Ok, so that is easy to get the numeric values off those dates
> (month/day/year)
> 
> I want to find out if $current lies between (or on) $start and $end
> dates.
> 
> Is there an easy way to do this.
> 
> I am thinking...seconds from January, 1970 but I forget how to do that.

<TONGUE POSITION=inCheek HOW=firmly>

Pity you daft Americans can't right dates properly. You wouldn't need to
use the epoch start date if you wrote dates the way we English do.

For instance I write 6/15/1999 as 15/06/1999.

Now split that out into an array, reverse the array and join it together
with no separator. Actually it's probably better to use sprintf as single
figure months and days would need a 0 prefixing.

This gives 19990615, 19990630, and 19990616 for the 3 dates above.
They are numerical and you have to agree easy to work out
relationships between them now.

See it's even Y2K compliant 20000101, :-) :) ROFL

</TONGUE>

Seriously it's probably better to stick to the localtime and
Time::Local::timelocal functions to convert between them as they will only
allow valid dates I think. The above "tongue firmly in cheek" scenario
doesnt have any checking and would allow 19990645 quite easly.

see man Time::Local and perldoc -f localtime for the correct sytax for use.

-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

We are Pentium III of Borg. Prepare to be identified.
Deactivation is futile.



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

Date: Tue, 01 Jun 1999 15:20:16 GMT
From: mraffin@cisclub.acad.emich.edu
Subject: Determining height and with of uploaded Graphic files
Message-Id: <7j0tnc$7ko$1@nnrp1.deja.com>

I need to determine the height and width of graphic files that users
upload (via browser) to my site.  Is this possible?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 11:29:48 GMT
From: slamda@hotmail.com
Subject: displaying adodb errors.
Message-Id: <7j0g7c$36e$1@nnrp1.deja.com>

Hi,  I'm using an adodb connection to query a MS SQLserver database. I'm
trying to use the folloing code to diplay errors when i get a null recordset,
but it fails to print any of the error messages....the errors can be printed
by:  print $lbdb->errors(1); etc, but I'd rather get an array of the error
message (as the code below is supposed to do!)


#### START OF CODE SNIPPET ####

# Open the database
 $lbdb = $Server->CreateObject("ADODB.Connection");
 $lbdb->Open("DSN=listbroker;UID=listbroker;PWD=lbuser");
 if(!$lbdb) {Print "\nUnable to connect to database\n"; die; }

$RS=$lbdb->Execute("select distinct catname from ccat");}
if (!$RS) {
  print "unable to execute sql statement<br>";print "Errors:<br>";
  $Errors=$lbdb->Errors();
  foreach $error (keys %$Errors) {
    printf("%s\n", $error->{Description});
  };
 $lbdb->Close();die;}

#### END OF CODE SNIPPET ####

Any suggestions?

Thanks in advance

  Ian Dash


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 22:10:23 GMT
From: kgentes@gentek.net
Subject: Fields without values (Re: FAQ 4.29: How can I split a [character] delimited string except when inside [character]? (Comma-separated files) )
Message-Id: <7j1lof$2nq$1@nnrp1.deja.com>

This is precisely the information I was looking for,
EXCEPT, I also need the routines below to return a
placeholder empty value for fields which contain
no values in a CSV record.  It is very common
for records to contain fields that are
simply be blank
(ie. "123,,47,The Person,,123 address Ave,87990,,")

In that example, once parsed, I can't rely on the
results of "quotewords" because it does not return
a value for missing fields.  Which method do I
use to extracting CSV so that I can guarantee the
returning array includes empty fields as well as
ones with values?

thanks
Kim Gentes

In article <373d7d91@cs.colorado.edu>,
  perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> (This excerpt from perlfaq4 - Data Manipulation
>     ($Revision: 1.46 $, $Date: 1999/04/20 18:59:53 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq4.html
> if your negligent system adminstrator has been remiss in his duties.)
>
>   How can I split a [character] delimited string except when inside
> [character]? (Comma-separated files)
>
>     Take the example case of trying to split a string that is comma-
>     separated into its different fields. (We'll pretend you said
comma-
>     separated, not comma-delimited, which is different and almost
never
>     what you mean.) You can't use `split(/,/)' because you shouldn't
>     split if the comma is inside quotes. For example, take a data line
>     like this:
>
>         SAR001,"","Cimetrix, Inc","Bob Smith","CAM",N,8,1,0,7,"Error,
Core Dumped"
>
>     Due to the restriction of the quotes, this is a fairly complex
>     problem. Thankfully, we have Jeffrey Friedl, author of a highly
>     recommended book on regular expressions, to handle these for us.
He
>     suggests (assuming your string is contained in $text):
>
>          @new = ();
>          push(@new, $+) while $text =~ m{
>              "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase
inside the quotes
>            | ([^,]+),?
>            | ,
>          }gx;
>          push(@new, undef) if substr($text,-1,1) eq ',';
>
>     If you want to represent quotation marks inside a quotation-mark-
>     delimited field, escape them with backslashes (eg, `"like
>     \"this\""'. Unescaping them is a task addressed earlier in this
>     section.
>
>     Alternatively, the Text::ParseWords module (part of the standard
>     perl distribution) lets you say:
>
>         use Text::ParseWords;
>         @new = quotewords(",", 0, $text);
>
>     There's also a Text::CSV module on CPAN.
>
> --
>     "That which does not kill me makes me stranger." --Larry Wall
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 3 Jun 1999 10:53:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Find all files regardless of extension
Message-Id: <37565090@newsread3.dircon.co.uk>

Abigail <abigail@delanet.com> wrote:
> Bart Lateur (bart.lateur@skynet.be) wrote on MMLXXVI September MCMXCIII
> in <URL:news:373551e7.3001816@news.skynet.be>:
> && Jonathan Stowe wrote:
> && 
> && >One usually would do something like:
> && >
> && >   @files = grep !/^\.{1,2}$/,readdir(DIR);
> && 
> && That's a complex regex for such a simple test.
> && 
> && How about 
> && 
> && 	/[^.]/
> 
> ... is a normal file, but it doesn't match /[^.]/.
> 
> 

Except on a PC woth Novell Client Software installed where 'cd ...' will
take you up two directories - most strange.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 01 Jun 1999 21:00:25 GMT
From: orock@my-deja.com
Subject: funky STDOUT under Win32?
Message-Id: <7j1hl9$s52$1@nnrp2.deja.com>

I am checking some application logs for errors with perl.
While building a simple test suite I discovered a problem
with STDOUT and a .pl script.

[NT 4.0 sp4, perl 5.005_03 Active State build 516]

simple test script to exhibit problem -- junk.pl...

for (1 .. 3) {
    print scalar localtime,"\n";
    sleep 1;
}

the output is obvious..
> junk.pl
Tue Jun  1 16:29:11 1999
Tue Jun  1 16:29:12 1999
Tue Jun  1 16:29:13 1999

>
here is the problem.

> junk.pl > junk.log
> type junk.log

>
log file has been created but is empty
then I discovered the following.

> perl.exe junk.pl > junk.log
> type junk.log
Tue Jun  1 16:32:04 1999
Tue Jun  1 16:32:05 1999
Tue Jun  1 16:32:06 1999

>
it works fine if I run it through perl explicitly.

Has anyone seen something like this before?  Is this an NT
OS problem or a perl.exe problem?  It seems to me that
perl.exe is not passing STDOUT on properly when run
implicitly with a .pl script.

The work arounds are obvious; I was just surprised that such
a simple test for monitoring a growing log file revealed such
an unexpected result.

Does anyone feel that this is a bug and worth reporting?

Thanks,

Oliver Rockwell


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 17:01:24 GMT
From: motyk@my-deja.com
Subject: Getting around the refresh button
Message-Id: <7j13kp$9rs$1@nnrp1.deja.com>

Hello!

I am in the process of developing a site, and came across the following
issue, and was wondering if someone can give me some direction/help.
Here is the scenario:

The browser loads an html document - the user enters data which updates
this html document in the server - the user gets a confirmation that his
data has been accepted.

 Is there a way to redirect the user to the UPDATED html document
without having to tell the user to reload the page?  i.e., is there a
way to tell a browser "don't read this doc from cache but read it from
the server again"?

Thanks in advance!

Moty


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 23:44:16 GMT
From: themuppet@my-deja.com
Subject: Getting rid of blank lines
Message-Id: <7j1r8d$4le$1@nnrp1.deja.com>

Hello,

I'm trying to get rid of all the blank lines in a file that I'm parsing
through.  What kind of regexp would I use to delete a blank line?  I'm
looping through a file, and am concatenating the text together kind of
like this:

while (<>) {

if !(???????) {
   $finalstring = $finalstring . $_;
}

}

The question marks are where I'm looking for the regexp that will return
true if $_ is a blank line.

Thanks in advance!

~themuppet


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 31 May 1999 22:53:56 GMT
From: reddogg1471@my-deja.com
Subject: Help for a newbie
Message-Id: <7iv3u4$o3h$1@nnrp1.deja.com>

I am currently writing a script that will allow me to give out free
webspace on my website. I'm almost finished with it and have one
problem. I need to insert a header and footer from a text file and am
unsure how to go about it. I need to first check the html file and see
if the header and footer is already there, and if not, I need to add
it. This needs to be done for all html files in the directory.

If anyone can point me in the right direction, or if you have any
snippets of code laying around for me use or just to look at for ideas
it would be much appreciated.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 31 May 1999 22:49:51 GMT
From: reddogg1471@my-deja.com
Subject: Help for a newbie
Message-Id: <7iv3mf$o1a$1@nnrp1.deja.com>

I am currently writing a script that will allow
me to give out free webspace on my website. I'm
almost finished with it and have one problem. I
need to insert a header and footer from a text
file and am unsure how to go about it. I need to
first check the html file and see if the header
and footer is already there, and if not, I need
to add it. This needs to be done for all html
files in the directory.

If anyone can point me in the right direction, or
if you have any snippets of code laying around
for me use or just to look at for ideas it would
be much appreciated.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 02 Jun 1999 00:31:17 GMT
From: tvn007@my-deja.com
Subject: Help on process data in a file
Message-Id: <7j1u0l$5h3$1@nnrp1.deja.com>

Hi,

Would someone help me with the following problem ?

I already came up with a solution but it's to lenghthy
and not robust, I think I need a better solution.

Here is the problem:

I am reading line by line from a file with the input as follow:

SETR P:=T'LLLH';
SETR P:=T'HXH0';
SETR P:=T'0101';
RUNP FOR 2;
SETR P:=T'HLH0';
SETR P:=T'HHHH';
RUNP FOR 30;

The output should be: (you need to repeat the previous line x time
if you see RUNP FOR x command).

R1  ddc1 LLLH;
R1  ddc1 HXH0;
R2  ddc1 0101;
R1  ddc1 HLH0;
R30 ddc1 HHHH;


######################################

Thanks in advance for your help,


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 02 Jun 1999 00:05:35 GMT
From: dgmdan <dgmdan@md-sites.com>
Subject: HELP: Regular Expressions
Message-Id: <7j1sg9$530$1@nnrp1.deja.com>

I'm trying to create a script that takes $newnick and checks to see if
it meets the requirements:
a. the first character can be *only* a letter
b. other than the first character, it can contain letters, numbers,
dashes, periods, and underscores

If $newnick doesn't meet the requirements, I want the script to run the
sub "error".  This is what I have:

if ($newnick !~ /[a-zA-Z][\w-.]+/) { &error; }

However, it appears as though when $newnick has a letter next to any of
the other characters, it doesn't run newnick.  For example, if $newnick
is "a1!" it would see "a1" and it would not run the sub, even though the
"!" is there.

How do I make it require that the entire string meet the requirements,
not just any segment of it?

- dgmdan | www.md-sites.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 03 Jun 1999 09:18:34 GMT
From: moxel23@hotmail.com (Moxel23)
Subject: How to call from HTML ?
Message-Id: <7j5h90$b57$1@news.dpc.net>

I know this is a dummy question, but
please...
Thank You...
Moxel


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

Date: Thu, 3 Jun 1999 11:34:33 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: Re: How to call from HTML ?
Message-Id: <7j5i9s$f2j$1@zonnetje.NL.net>

either link to a .cgi file directly
or figure out if your isp supports ssi , an then you could use something
like :
<!--#include virtual="/cgi-localbin/ax.cgi" -->

Moxel23 heeft geschreven in bericht <7j5h90$b57$1@news.dpc.net>...
>I know this is a dummy question, but
>please...
>Thank You...
>Moxel




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

Date: 3 Jun 1999 10:51:00 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to call from HTML ?
Message-Id: <37565004@newsread3.dircon.co.uk>

Moxel23 <moxel23@hotmail.com> wrote:
> I know this is a dummy question, but
> please...

Er.  I believe you have the wrong group:

   comp.infosystems.www.authoring.cgi

   comp.infosystems.www.authoring.html

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 01 Jun 1999 14:18:50 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Is split (surprisingly, amazingly) slow?
Message-Id: <7j0q49$68j$1@nnrp1.deja.com>



Considering that Lear's purpose for writing the programs as he did
was simply to be a framework for benchmarking the relative speed of
splitting a string, it seems to me that the overhead of his framework
can (and will) obscure the value he's really after.
So I took the perl and python programs and made versions which are
identical but which do not perform the split; then subtracted the
timings of these, in order to find the time for just doing the splits.
Here are user times (i.e. not including sys and io times), and the
differences, which shows the performance of the split.  Interestingly,
the perl code was faster than the python code in every observed respect.


27.0    RSP.pl  (Perl)
 3.4    RSP-nonsplitting.pl
----
23.6

41.7    RSP.py  (Python)
12.1    RSP-nonsplitting.py
----
29.6

My input data was one million lines of 9 fields; field lengths
randomly distributed uniformly from 0 to 9.

perl 5.005_02
python 1.5.1
Sun Solaris 2.6, sparc Ultra-60, 640Mb ram,


--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 01 Jun 1999 16:55:19 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Is split (surprisingly, amazingly) slow?
Message-Id: <7j139e$9md$1@nnrp1.deja.com>



I have to follow up to my own post, to point out that my perl program
which seemed to run faster than python was doing an implicit split
to @_.  Here are some revised run times:

43.6    RSP.pl
27.0    RSP-implicit.pl
 3.5    RSP-nonsplitting.pl

41.5    RSP.py
41.2    RSP-discard.py
12.1    RSP-nonsplitting.py

In RSP-discard.py, the result of split is being ignored. I assume it
is actually being discarded, which is not the case in perl.
So, taking the version in each language which splits to an explicit
variable:
Perl:   43.6 -  3.5 = 40.1 seconds
Python: 41.5 - 12.1 = 29.4 seconds to do one million splits.
I wonder why Python's while input loop seems to be so much less
efficient than Perl's...

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 03 Jun 1999 12:36:13 +0200
From: Jan van Rensburg <jan.van.rensburg@epiuse.com>
Subject: Re: Loading modules at run time - Solution
Message-Id: <37565A9D.E55BC373@epiuse.com>

a solution at last, thanks to a java programmer:

instead of:

	use $somemodule;

i did a:

	eval("use $somemodule;");  

why didn't i think of this before... is this bad style though?

thanks,
jan van rensburg


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

Date: Thu, 03 Jun 1999 11:24:18 +0200
From: Jan van Rensburg <jan.van.rensburg@epiuse.com>
Subject: Re: Loading modules at run time
Message-Id: <375649C2.969C438B@epiuse.com>

tom,

by "roll your own" do you mean do a: 

	{require $somename;
		 import $somename qw(function);
	}

if i do that instead of using "use $somename" directly i get the

	Can't locate Pingtime in @INC <somepath>.. error.

*but* my module is located in the <somepath> part! i did a:

	use lib "somepath";

and it works fine if i say

	use ModuleName;

instead of 

	{require $somename;
		 import $somename qw(function);
	}

oh, i'm so tired of being stuck at this technicality.

thanks,
jan van rensburg



Tom Phoenix wrote:

> > is there any way to load modules at run time?
> 
> Sure; just "roll your own" use directive. See the entry on use in
> perlfunc. Cheers!
> 
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: 3 Jun 1999 08:48:24 +0100
From: Brian McCauley <B.A.McCauley@bham.ac.uk>
To: Brett.Diamond@lmco.com
Subject: lvalue subroutine returns in perl
Message-Id: <u9wvxlvctg.fsf@wcl-l.bham.ac.uk>

If you remember in January we discussed the possibility of creating
functions in perl that return lvalues.  I spouted some rubbish about
using prototypes. 

Well this has been fermenting at the back of my mind and now I have a
very alpha patch (against 5.005_57) to support it.

If you want to play it's at:

ftp://ftp.wcl.bham.ac.uk/pub/bam/patches/perl/perl5.005_57-lvalue.diff

The code fragment at the end of this post illustrates it's use.

The initial idea is to have a "use lvalue" pragma that modifies the
behaviour of "return" (and the "leavesub" the implicit return at the
end of a subroutine block) so that they don't copy mortalize the
return list.  

Another possibility would be to introduce a new list opertor that
could be used in place of "return".  Since I hate to extend the set of
reserved words how about "tied return" for this?

Example:

package MySubstr;

sub TIESCALAR { 
   bless [ \$_[1], @_[ 2 .. $#_ ] ], $_[0];
}

sub STORE { 
    my ($self, $rval ) = @_;
    substr ( ${$self->[0]}, $self->[1], $self->[2] ) =  $rval;
};

sub FETCH {
    my ( $self ) = @_;
    substr ( ${$self->[0]}, $self->[1], $self->[2] );
}

package main;

# This could be done by lvalue::import called as "use lvalue"
# but until I write lvalue.pl just do it...

BEGIN { $^H |= 0x00800000 };

sub mysubstr {
  tie my $lval, 'MySubstr', @_;
  $kludge = \$lval; # Not quite got the ref counting right yet!
  $lval;
}

$foo = 'abc';

mysubstr($foo,1,1) = 'x';

print "$foo\n";

-- 
     \\   ( )  No male bovine  | Email: B.A.McCauley@bham.ac.uk
  .  _\\__[oo   faeces from    | Phones: +44 121 471 3789 (home)
 .__/  \\ /\@  /~)  /~[   /\/[ |   +44 121 627 2173 (voice) 2175 (fax)
 .  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
  # ll  l\\  ~~~~ ~   ~ ~    ~ | http://www.wcl.bham.ac.uk/~bam/
 ###LL  LL\\ (Brian McCauley)  |


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

Date: Thu, 3 Jun 1999 09:43:23 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: micro$~1 perl
Message-Id: <sir9nty5z8.fsf@cre.canon.co.uk>

Cameron Dorey <camerond@mail.uca.edu> wrote:
> Might you copy/summarize what's taking place there for those of us
> without access to p5p?

The relevant articles are archived at Deja.com:

http://www.deja.com/=dnc/%5BST_rn=ps%5D/qs.xp?ST=PS&defaultOp=AND&DBS=1&format=terse&showsort=date&maxhits=100&LNG=english&OP=dnquery.xp&QRY=microsoft&authors=&groups=perl.porters-gw

The list is also archived at:

http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/

-- 
Gareth Rees


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

Date: Tue, 01 Jun 1999 17:52:22 GMT
From: andrewvignes@hotmail.com
Subject: PERL Newbie Question
Message-Id: <7j16la$o3l$1@nnrp2.deja.com>

Hi all,

I was just wondering how we can update the information that we typed on
a webpage to the server.Can i do this using PERL?.

The users fill out the application form on our home page and currently
we get the information by mail and we MANUALLY update the http server.
Now this process needs to be automated. i.e., instead of getting a mail
and manually changing, it should automatically write into the server. I
guess i need to use PERL to extract the information and then i may have
to open a socket connection and write it into the http port number 80.
Have anyone here done anything similar to this?. If so, it would be a
great help if you could pass me some sample code!

Thanks a lot!
Andrew


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 03 Jun 1999 06:23:27 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: PERL Newbie Question
Message-Id: <375657b8.0@usenet.fccj.cc.fl.us>

In article <7j16la$o3l$1@nnrp2.deja.com>, andrewvignes@hotmail.com wrote:


> Hi all,
>
> I was just wondering how we can update the information that we typed on
> a webpage to the server.Can i do this using PERL?.
>
> The users fill out the application form on our home page and currently
> we get the information by mail and we MANUALLY update the http server.
> Now this process needs to be automated. i.e., instead of getting a mail
> and manually changing, it should automatically write into the server. I
> guess i need to use PERL to extract the information and then i may have
> to open a socket connection and write it into the http port number 80.
> Have anyone here done anything similar to this?. If so, it would be a
> great help if you could pass me some sample code!
>
> Thanks a lot!
> Andrew


You guess correctly (or you could use C, but that's a
different newsgroup.)  As this group deals with perl, I
would like to point you to MySQL.

We have an on-line Job Application, which the results are
stored in MySQL database, the application data is
feed into a postscript template and feed to a 'watched'
Adobe Exchange directory where it is changed into a
PDF and then sent to H/R...

Not real hard, but some worthwhile work.  Your question
is along these lines.  Research your local CPAN, then
as new questions come up, look at 'perldoc' included
with your distribution.

Oh, sent you're on DejaNews, you have a wealth of
research there as well, check it out sometime :]

HTH,
-Sneex-  :]
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss

         Jacksonville Perl Mongers
         http://jacksonville.pm.org
         jax@jacksonville.pm.org

         Running LinuxPPC RedHat 5.0 (Hurricane)
       __ _                     http://www.linuxppc.org
      / /(_)_ __  _   ___  __   http://www.apache.org
     / / | | '_ \| | | \ \/ /   http://www.redhat.com
    / /__| | | | | |_| |>  <    http://www.perl.com
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org


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

Date: Thu, 03 Jun 1999 10:41:18 GMT
From: kevin@nospam.co.uk (kevin)
Subject: Perl script keeps terminating
Message-Id: <37565b16.13709257@news.free-online.net>

My perl script has been running fine
until recently when it appears
to auto-terminate within 2-5
mins of of commencing.

Any know if this is likely to be
a code/server problem?

I suspect because it was previously
OK it must be the server?

Kevin


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5868
**************************************

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