[12833] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 243 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 24 13:07:19 1999

Date: Sat, 24 Jul 1999 10:05:08 -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           Sat, 24 Jul 1999     Volume: 9 Number: 243

Today's topics:
    Re: ARGV validation of command line options (Tad McClellan)
        Extracting plain text from email <rexcell@btinternet.com>
    Re: file manipulation (Tad McClellan)
    Re: file manipulation (Bart Lateur)
        Finding duplicate elements in an array? (Pfash1)
    Re: floating point number format... (Larry Rosler)
    Re: frames (Abigail)
    Re: Geekspeak Programming Contest <cmcurtin@interhack.net>
    Re: Module for e-mail <alex@kawo2.rwth-aachen.de>
    Re: Module for e-mail (Abigail)
    Re: My newbie solution - is this the best? (Tad McClellan)
    Re: My newbie solution - is this the best? mbreslow@my-deja.com
    Re: MySQL or Access? <aperrin@mcmahon.qal.berkeley.edu>
    Re: output of print map ( { unless (/^#/) {} } ("#") ); (Tad McClellan)
    Re: Perl 4 Source Code or Binaries <qwerty@post.utfors.se>
        perl-DBI-mysql <klaus.oberecker@gmx.at>
    Re: Positioning in file? (Tad McClellan)
    Re: regex mathcing (Larry Rosler)
    Re: Regex-ing (Michael Rubenstein)
    Re: Regex-ing (Michael Rubenstein)
    Re: Regex-ing (Larry Rosler)
        some really wierd behavior with POST? <qwerty@post.utfors.se>
    Re: some really wierd behavior with POST? <aperrin@mcmahon.qal.berkeley.edu>
        split([tabulator],$line ); <lehmann@cnm.de>
    Re: the number of fields in a form <swiftkid@bigfoot.com>
    Re: WinNT MD5|SHA Perl <carvdawg@patriot.net>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Sat, 24 Jul 1999 05:47:54 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: ARGV validation of command line options
Message-Id: <a42cn7.rae.ln@magna.metronet.com>

Steve . (syarbrou@nospam.enteract.com) wrote:
: say I have multiple options for a command lines.  They can be used or
: not.  How do I validate if they are there or not?


   There is an example of using the -s command line switch
   in perlrun.pod.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 24 Jul 1999 17:42:51 +0100
From: "Roger" <rexcell@btinternet.com>
Subject: Extracting plain text from email
Message-Id: <7ncqe4$237$1@uranium.btinternet.com>


Hi all

A question with no simple answer i guess

How can you get the plain text version of an email out of all the headers
and if it been sent in html format loose all the formating below the main
body of the message.

Hope that makes sense ?

Also i hope someone has a simple soloution

Thanks for reading and hopefuly helping

Roger

--
 www.btinternet.com/~rexcell








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

Date: Sat, 24 Jul 1999 05:00:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: file manipulation
Message-Id: <9cvbn7.a0e.ln@magna.metronet.com>

Dan Adams (dan@fearsome.net) wrote:

: Following a number of posts to this group, not a single person has been
: willing and able to help me out to the required extent with some code that I
: am stumbling over. 


   Why Questions go Unanswered:

      http://www.plover.com/~mjd/perl/Questions.html


: Since no-one is willing to help me for free, can I induce
: anyone to help me by offering payment? I only need about 10 lines or so of
: code that I am stuck on, but no-one seems willing to help me fix the
: problem.


# UNTESTED
my $infront = 1;
open(FRONT, '>front.out') || die "could not open 'front.out'  $!";
open(BACK, '>back.out') || die "could not open 'back.out'  $!";
while (<>) {
   if ($infront)
      { print FRONT }
   else
      { print BACK }

   $infront = 0 if /<start>/;
}
close(FRONT);
close(BACK);


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 24 Jul 1999 14:56:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: file manipulation
Message-Id: <3799d392.205254@news.skynet.be>

Tad McClellan wrote:

># UNTESTED
>my $infront = 1;
>open(FRONT, '>front.out') || die "could not open 'front.out'  $!";
>open(BACK, '>back.out') || die "could not open 'back.out'  $!";
>while (<>) {
>   if ($infront)
>      { print FRONT }
>   else
>      { print BACK }
>
>   $infront = 0 if /<start>/;
>}
>close(FRONT);
>close(BACK);

Hmm... This looks like a job for... select()! (Tada!)

  open(FRONT, '>front.out') || die "could not open 'front.out'  $!";
  open(BACK, '>back.out') || die "could not open 'back.out'  $!";
  select FRONT;
  while (<>) {
	print; #to the currently selected handle
   	select BACK if /<start>/;
  }
  close(FRONT);
  close(BACK);

	Bart.


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

Date: 24 Jul 1999 16:56:26 GMT
From: pfash1@aol.com (Pfash1)
Subject: Finding duplicate elements in an array?
Message-Id: <19990724125626.22482.00001462@ng-cg1.aol.com>

I have been struggling with a Perl issue that you might have some insight on:
How do I check an array of undetermined size to see if there are duplicate
elements contained in it? In other words:

@arrayone = ('one', 'two', three', 'one')

Let's say this array is initiated by a database search so I don't know the
number of elements in the array or their location.
I want to march thru this array and compare each element to every other one to
find out if there are any duplicates (as is the case with element "one" in the
example above).

Do you have an idea about this? I have sweated over this one and can't find
anything in my books that  works.
(ps. I eventually want to eliminate the duplicates so there is only one of
each.)

Thanks much,
Paul Fortier
pfash@umich.edu


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

Date: Sat, 24 Jul 1999 08:22:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: floating point number format...
Message-Id: <MPG.12037a1fb699f093989d33@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7nbug3$gu4$1@netnews.csie.NCTU.edu.tw> on 24 Jul 1999 
08:45:55 GMT, GEMINI <dennis@info4.csie.nctu.edu.tw> says...
> I wish to ouput floating point numbers in compact format,
> but at most 4 digits decimal, and no exponential (e+04).
> I found that by using sprintf('%g'....
> will get only 1 decimal digit (e.g. 10204.34 will become 10204.3).
> If I use sprintf('%.4g'..., I will get exponential number 
> (e.g. 10203.12 will become 1.02e+04).
> 
> I wouldn't like to use %f instead because there will be too many 
> redundant 0s (i.e., 10.0000).
> 
> So how should I specify the format string for sprintf to
> obtain the needed effect?

my $x = 10203.12;
(my $y = sprintf '%.4f', $x) =~ s/\.?0*$//;
print "$y\n";

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 24 Jul 1999 11:10:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: frames
Message-Id: <slrn7pjp9v.3bc.abigail@alexandra.delanet.com>

JJcoParks4 (jjcoparks4@aol.com) wrote on MMCLIII September MCMXCIII in
<URL:news:19990723215853.20895.00000868@ng-fe1.aol.com>:
|| Hello I am trying to make a perl cgi script and I wan't part of it to be in a
|| frame. Is this posibble? And if so how the heck do I do it?


No. Perl runs on an operating system, not in a frame.


Perhaps you mean something else, but that should be asked somewhere else.



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


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 24 Jul 1999 12:25:20 -0400
From: Matt Curtin <cmcurtin@interhack.net>
Subject: Re: Geekspeak Programming Contest
Message-Id: <xlxu2qunhfz.fsf@gold.cis.ohio-state.edu>

>>>>> On Fri, 23 Jul 1999 14:33:29 -0700, lr@hpl.hp.com (Larry Rosler) said:

>> Jan 1, 2001 = Jan 1, 2000

Larry> I don't get that.

I believe it is a reference to the millennium, which The Masses seem
to think begins with 2000 despite the fact that it won't begin until
2000 has come to an end.

-- 
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/


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

Date: Sat, 24 Jul 1999 18:27:27 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: e-bin <NOSPAMebin111@yahoo.com>
Subject: Re: Module for e-mail
Message-Id: <3799E96F.B773BD10@kawo2.rwth-aachen.de>

e-bin wrote:
> 
> I'm obviously fairly new to learning Perl, and was wondering where I might
> find a module to send e-mail to users without the use of an e-mail program
> such as "sendmail".  

Hi, 

there was an article on it in the summer TPJ - get the source 
from http://www.itknowledge.com/tpj/programs/Issue_14/Sending_Mail/

Regards
Alex

-- 
(java pref) http://simplex.ru/pref.html
(pref news) http://simplex.ru/news.html
(russ.lit.) http://simplex.ru/lit.html


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

Date: 24 Jul 1999 11:29:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Module for e-mail
Message-Id: <slrn7pjq98.3bc.abigail@alexandra.delanet.com>

e-bin (NOSPAMebin111@yahoo.com) wrote on MMCLIII September MCMXCIII in
<URL:news:Xjcm3.934$Fl.39254@typhoon-sf.snfc21.pbi.net>:
,, I'm obviously fairly new to learning Perl, and was wondering where I might
,, find a module to send e-mail to users without the use of an e-mail program
,, such as "sendmail".  Any help would be greatly appreciated.  I've read
,, various documentation on how to do this, but all of them refer to your
,, "e-mail" program to actually complete the task of sending the e-mail/file.

Well, you can use SMTP directly. Of course, you would have to implement
queuing and retrying all yourself, as well as dealing with all the
different return codes from SMTP.

,, Reason for question: My employer wants me to set-up a page that can send
,, e-mail, as well as attachments, much like hotmail, and yahoo's messaging
,, service.

Uh-uh. And we all know that hotmail and yahoo don't have "sendmail" or
an equivalent program....

If you're going to copy hotmails and yahoos service, I wouldn't to it
in Perl if you were new to Perl.

I'd hire a ton of coders that know their tools.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 24 Jul 1999 05:43:21 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: My newbie solution - is this the best?
Message-Id: <pr1cn7.rae.ln@magna.metronet.com>

breslow_marty@tandem.com wrote:
: I found that after the strip of STDIN 


   What does "strip of STDIN" mean?


: the field had a beginning and
: trailing quote so I used substr to remove them.  Then I used
: substitution with the g modifier to substitute "" for " and that
: worked.  I then concatenated the result to get the final product
: i.e., '"' . $newstring . '",'
: Is this best way?  I guess I was hoping for the opposite of tr's
: duplicate removal but that's not automated in the language.


-------------------------------
#!/usr/bin/perl -w
use strict;

$_ = '"this has "internal" and "surrounding" double quotes"';
print "before: '$_'\n";

s/(?<!^)"(?!$)/""/g;    # negative lookahead/lookbehind assertions
print " after: '$_'\n"; #    so that first/last quotes do NOT match
-------------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 24 Jul 1999 16:36:22 GMT
From: mbreslow@my-deja.com
Subject: Re: My newbie solution - is this the best?
Message-Id: <7ncq26$e52$1@nnrp1.deja.com>

Well, do be a little specific.  I am trying a comma separated export of
a MS Access database into Inserts into my Tandem SQL.  The customer's
table has about 250 columns with several long CHAR columns with comments
from a shop floor.  These are comments about sheet metal pieces hence
they have dimensions.  My SQL can take single or double quotes but the
string has any of the same, they must be doubled.
Now, what criteria?  I am learning Perl.  This is my 3rd program that
does anything significant so actually an alternative solutions would be
instructive.  My solution takes things apart and then puts them
together again whereas Larry's seems to tell it to do the substitute op
only on the part between the outer quotes.
   I understand that $1 is the part between the parentheses and the do
is operating on block delimited by the braces but I don't understand
why it has to be assigned to $x and what the $x after the semicolon is
doing.  Anyhow any explanations or alternate solutions are welcome.
   By the way, it occurred to me that an alternate to building Inserts
would be to use pack to build binary records.  SQL has a Load utility
that will let in load from a binary file.  I think I will try that
apporach as a separate learning exercise.
In article <7nb5p2$2i6$1@lublin.zrz.tu-berlin.de>,
  anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> David Cassell  <cassell@mail.cor.epa.gov> wrote in
comp.lang.perl.misc:
> >[courtesy cc emailed to poster]
> >
> >breslow_marty@tandem.com wrote:
> >>
> >> I found that after the strip of STDIN the field had a beginning and
> >> trailing quote so I used substr to remove them.  Then I used
> >> substitution with the g modifier to substitute "" for " and that
> >> worked.  I then concatenated the result to get the final product
> >> i.e., '"' . $newstring . '",'
> >> Is this best way?  I guess I was hoping for the opposite of tr's
> >> duplicate removal but that's not automated in the language.
> >
> >Well, clearly you didn't *really* want unattended duplicate
> >insertion, since you had to strip off delimiting quotes.  So
> >several lines of code seem to be a reasonable way to do this.
> >
> >But an answer about the 'best' way would require more background.
> >Without knowing *why* you want/need to double those quotes
> >and then surround the string with more quotes, it's pretty
> >hard to guess what would be optimal.
>
> With due respect, but what has "why" got to do with anything?  It
> doesn't matter if an external program needs this setup, or his
> boss has told him to do so, or he just likes the sight.  The problem
> is clearly stated (a rare enough occurrence to deserve extra credit).
> What we need to know is what to optimize: cpu time, memory, programmer
> time, maintainability, style, or golf strokes (hi Larry), to name a
few.
> Then optimize away.
>
> Anno
>


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


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

Date: Sat, 24 Jul 1999 08:19:14 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: MySQL or Access?
Message-Id: <3799D972.5C311525@mcmahon.qal.berkeley.edu>

Hmm, well:

MySQL: free, standards-based, OS-portable, easily perl-accessible, and when you
solve customers' problems you actually learn something.

Access: expensive, proprietary (non-standards-based), not OS-portable,
accessible through perl with some difficulty, and when you solve customers'
problems you are left with a sinking feeling, having learned nothing at all of
consequence.

Just my 2c based on a few years' worth of both perl and access development.

That's why I'm quitting the Access side....

Andy

Dan wrote:

> I have got a question..... I would like to choose a db and I have a dilemma
> between MySQL and Microsnot Access. They have both very nice features and
> the decision is not obvious. What do you all think about that?
>
> Also, if I put an Access db file on a unix box can I use ODBC (or something
> else)
> transparently to work with the DB?
>
> Thanks for your suggestions.
> Daniel
> http://thewebcowboy.com



--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting - aperrin@mcmahon.qal.berkeley.edu
            I'M LOOKING FOR ANOTHER EXPERIENCED ACCESS
               DEVELOPER - CONTACT ME IF INTERESTED.
        http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Sat, 24 Jul 1999 06:50:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: output of print map ( { unless (/^#/) {} } ("#") );
Message-Id: <po5cn7.6fe.ln@magna.metronet.com>

Michael Wang (mwang@tech.cicg.ml.com) wrote:
: Tad McClellan <tadmc@metronet.com> wrote:
: >Michael Wang (mwang@tech.cicg.ml.com) wrote:
: >: >Michael Wang (mwang@tech.cicg.ml.com) wrote on MMCLI September MCMXCIII
: >: >in <URL:news:7n7ag7$5re$1@news.ml.com>:
: >: >== What should be the output of the following?
: >: >== 
: >: >== (1) map ( { unless (/^#/) {} } ("#") );


   That doesn't match what you have in the Subject: header.


: >   (1) does not send anything ("produce") to the screen, because
: >       it does not have any output statements.
: >
: >   If you have some code where (1) makes output, then we could
: >   comment on it if you would show it to us.

: OK, please comment on the following, thanks. 


   Since you stealth-Cc'ed me, I will not.

   Stealth Cc'ing makes folks feel mad, not helpful.


   I think I have answered the question on clp.moderated though.

   Have to wait for it to come around...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 23 Jul 1999 18:46:37 +0200
From: "Dr. Who" <qwerty@post.utfors.se>
Subject: Re: Perl 4 Source Code or Binaries
Message-Id: <37989C6D.D18CE9A9@post.utfors.se>

hmm ..in sweden Anno is a female name ..
- are you? :)

Anno Siegel wrote:

> Inge <ingej@mnl.com> wrote in comp.lang.perl.misc:
> >Where can I find source code for Perl 4, or even better, binaries?
> >We're upgrading to Solaris 2.6 and have legacy Perl 4 modules (which
> >we will upgrade to Perl 5 soon, but not right now).
>
> Have you tried cpan (http://theory.uwinnipeg.ca/search/cpan-search.html
> for one)?  I haven't checked but I'd be surprised if they had no
> department of perl archaeology.
>
> Anno



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

Date: Sat, 24 Jul 1999 16:54:22 GMT
From: Klaus Oberecker <klaus.oberecker@gmx.at>
Subject: perl-DBI-mysql
Message-Id: <3799F0B7.32598CA1@gmx.at>

I´m trying to load images with a perl/dbi script into a mySQL-db. - I´ve
wrote a small test-skript:

----
test.pl
----
use DBI;
$dbh=DBI->connect("DBI:mysql:mydb",'xxxxxx','yyyyyy');

local (*FH);
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)=
stat('xxxx.jpg');
open FH, 'xxxx.jpg';
$retval = read FH, $img_str, $size;
$picture=\$img_str;

$my_sql_statement="INSERT INTO tablename (uid,vorname, nachname,
bildtyp, pict) VALUES (0,'Prename','Surename',0,$picture)";
$sth = $dbh->prepare($my_sql_statement);
$rv=$sth->execute($bild);
$dbh->disconnect; 
----

 ... but I always get this error-message:

DBD::mysql::st execute failed: You have an error in your SQL syntax near
'(0x812542c))' at line 1 at test.pl line
12. 



(the "pict-attribute" is "longblob NOT NULL" in the mySQL - db)



Can anyone help me???

klaus oberecker


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

Date: Sat, 24 Jul 1999 05:50:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Positioning in file?
Message-Id: <m92cn7.rae.ln@magna.metronet.com>

Lab User (bogus@razorback.uark.edu) wrote:
:       Ok, I'm trying to write a perl script that'll make log entries in
: a text file in FILO order.  That is, the first entry in the text file
: should be the last entry submitted by the script.

: What do I do?


   Write a temp file in the order you want, then rename() it
   over the original file, as described in Perl FAQ, part 5:

      "How do I change one line in a file/
       delete a line in a file/
       insert a line in the middle of a file/
       append to the beginning of a file?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 24 Jul 1999 08:04:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regex mathcing
Message-Id: <MPG.120375b5cc48a93d989d32@nntp.hpl.hp.com>

In article <7nbqlf$3ba$1@lublin.zrz.tu-berlin.de> on 24 Jul 1999 
07:40:31 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
> Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
> >In article <x3yvhba3hsm.fsf@tigre.matrox.com> on Fri, 23 Jul 1999 
> >22:25:45 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> >> pozman@my-deja.com writes:
> >> > If I have a string and want to know how many occurance there are of
> >> > another particular string within the first one, is there a regular
> >> > expression to  do that.
> >> 
> >> 	$string = 'this is his cat';
> >> 	$search = 'is';
> >> 
> >> 	$count = () = $string =~ /$search/g;
> >> 
> >> If this looks cryptic, then you should have a good look at perlre for
> >> more information of Perl's regexps.
> >
> >We discussed this at length a couple of weeks ago.  
> ><URL:http://x30.deja.com/[ST_rn=ps]/getdoc.xp?AN=498727524&search=thread
> >
> >In addition to being cryptic (which doesn't bother me a bit :-), this 
> 
> It bothers me, because I don't understand how it works.  () provides
> a list context for the pattern match, so it delivers a list of matches,
> that much is clear.  But the result is assigned to the empty list,
> which means nothing is assigned and the result is thrown away.
> So how come the scalar to the left gets to see how many elements
> there used to be?
> 
> I mean, when we replace $count with @list, things work as I would expect.
> Doing away with the pattern match:
> 
> @list = () = ( 1, 2, 3 );
> 
> sets @list to the empty list. Like some politicians, it is blind to
> what happens on the far right.  But $count is more perspicuous:
> 
> $count = () = ( 1, 2, 3 );
> 
> sets $count to 3.  What's going on?

Short answer:  That's the way it's implemented.

Long answer:  And documented.

To save you the trouble of scanning the couple of dozen articles in the 
thread pointed to above, here's a quote from one of my submissions 
<URL:http://x21.deja.com/[ST_rn=ps]/getdoc.xp?AN=499291573>:

<QUOTE>
Well let's see.
 
    $count = () = $str =~ /pattern/g;
 
Assign a list of pattern matches to a null list, and the number of 
elements in that which is assigned comes out the left side, not the 
number of elements in the list assigned to.  How obvious!
 
perldata:  List assignment in a scalar context returns the number of 
elements produced by the expression on the right side of the assignment:  

    $x = (($foo,$bar) = (3,2,1));      # set $x to 3, not 2
    $x = (($foo,$bar) = f());          # set $x to f()'s return count 
 
This is obscure enough to need two examples, AND superfluous sets of 
binding parentheses, yet.
 
To compound the obscurity, the discussion in the Blue Camel under 
Assignment Operators (p. 93) sees fit to point back to this, but the 
discussion in perlop doesn't.  Arcane indeed.
</QUOTE>

Note that the last example is actually mildly useful.  The alternative 
is:

    ($foo, $bar) = my @temp = f();
    $x = @temp;

which has the disadvantage of potentially storing a very long list 
temporarily when all that is wanted is the first two elements and the 
count.

But using that locution for the count only is obscene.  TMTOWTDI, but 
some of the ways should be left under the rocks, not exposed to decent 
people.

I should share my "Certifiable Perl Pornographer" certificate with Ala 
Qumsieh, as his reward for publishing this code again.  Maybe I'll buy 
him one of his own next month in Monterey.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 24 Jul 1999 15:56:24 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Regex-ing
Message-Id: <3799e195.90571765@nntp.ix.netcom.com>

On Fri, 23 Jul 1999 15:01:46 -0700, lr@hpl.hp.com (Larry Rosler)
wrote:

>In article <379bbe40.15991274@nntp.ix.netcom.com> on Fri, 23 Jul 1999 
>19:20:56 GMT, Michael Rubenstein <miker3@ix.netcom.com> says...
>...
>> 	$news =~ s/(?:\r\n?)|(?:\n\r?)/delimiter/g;
>                 ^^^     ^ ^^^     ^
>
>I posted this earlier without all that noise.  Alternation ('|') has the 
>lowest precedence in a regex.

	Along the same lines, just because you CAN omit 
	parentheses in many places doesn't mean that you ought 
	to: 

	        return print reverse sort num values %array;
        	return print(reverse(sort num (values(%array))));

    	When in doubt, parenthesize. At the very least it will 
	let some poor schmuck bounce on the % key in vi. 



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

Date: Sat, 24 Jul 1999 16:11:08 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Regex-ing
Message-Id: <379be298.90831679@nntp.ix.netcom.com>

On Fri, 23 Jul 1999 22:20:50 -0400, Ala Qumsieh
<aqumsieh@matrox.com> wrote:

>
>miker3@ix.netcom.com (Michael Rubenstein) writes:
>
>> Which will translate two of the possible "carriage returns" you
>> list into two delimiters.  Something a little more like
>> 
>> 	$news =~ s/(?:\r\n?)|(?:\n\r?)/delimiter/g;
>> 
>> might work better.
>
>Yeah but you are typing way too many characters:
>
>	$news =~ s/\r\n?|\n\r?/delimiter/g;
>
>The OR ("|") binds very weekly for a good reason. Use it.

Reducing the number of characters I type is way down on my list
of objectives when programming.  It's even lower on my list of
objectives when giving examples to beginners.

	... it's common practice to include alternatives [in a 
	regular expression] in parentheses, to minimize confusion

	about where they start and end. 


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

Date: Sat, 24 Jul 1999 09:57:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex-ing
Message-Id: <MPG.1203903845cbbca9989d34@nntp.hpl.hp.com>

In article <3799e195.90571765@nntp.ix.netcom.com> on Sat, 24 Jul 1999 
15:56:24 GMT, Michael Rubenstein <miker3@ix.netcom.com> says...
> On Fri, 23 Jul 1999 15:01:46 -0700, lr@hpl.hp.com (Larry Rosler)
> wrote:
> >In article <379bbe40.15991274@nntp.ix.netcom.com> on Fri, 23 Jul 1999 
> >19:20:56 GMT, Michael Rubenstein <miker3@ix.netcom.com> says...
> >...
> >> 	$news =~ s/(?:\r\n?)|(?:\n\r?)/delimiter/g;
> >                 ^^^     ^ ^^^     ^
> >
> >I posted this earlier without all that noise.  Alternation ('|') has the 
> >lowest precedence in a regex.
> 
> 	Along the same lines, just because you CAN omit 
> 	parentheses in many places doesn't mean that you ought 
> 	to: 
> 
> 	        return print reverse sort num values %array;
>         	return print(reverse(sort num (values(%array))));

Yuck.  Yes, I know that this is an unattributed quote from Holy Writ, 
but that doesn't require me to buy into it.  The unparenthesized 
statement is totally clear and unambiguous (though why one would choose 
to return 1 is debatable :-).

>     	When in doubt, parenthesize. At the very least it will 
> 	let some poor schmuck bounce on the % key in vi. 

It is a question of relative fluency.  Extra punctuation should convey 
extra semantics, not doubt.

All of us grew up with elementary algebra, so someone who writes

    $x = (3 * $y) + $z;

might rightly be viewed with some suspicion.  But when the operators are 
more obscure -- such as '<<' '>>' '&' '|' -- the relative precedences 
are daunting.  Parenthetization is desirable, even if not required.  
Doubt is acceptable, perhaps is even a social good.

The very low precedence of '|' in a regex is not obscure.  
Parenthesizing around it conveys lack of fluency (i.e., doubt), not 
extra semantics.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 23 Jul 1999 17:21:05 +0200
From: "Dr. Who" <qwerty@post.utfors.se>
Subject: some really wierd behavior with POST?
Message-Id: <37988860.3686800A@post.utfors.se>

The following code is just a fragment of a guestbook .. but it shows a
problem with post?
or perhaps a lame thing I have done myself?
I don't know .. the problem is when I use POST the:
if($ruta[$#name] eq "com" && $name[$#name] eq "write"){
    &skriv;
}
refuses to recognise $#name as the last form element .. ? or even
$length=@name-1
anyway, the fuction &skriv does not execute, only when i use GET, but
then the url looks all
fucked up, and theres a limit to the length of input :)
Any suggestions?

$forminfo=$ENV{'QUERY_STRING'};

#$storlek=$ENV{'CONTENT_LENGTH'};
#read(STDIN, $forminfo, $storlek);
$forminfo=~tr/+/ /;
$forminfo=~s/%(..)/pack("c",hex($1))/ge;

if ($html==0){
$forminfo=~tr/<//;
$forminfo=~tr/>//;
}
# ändrar = tecken i a href för den inte ska splittas

$forminfo=~s/x=/x\#/g;

@par=split(/&/,$forminfo);
$arr=0;

foreach $a (@par){
    ($ruta,$text)=split(/x\#/,$a);
    $INFO{$ruta}=$text;
    if($text eq ""){
 $FORCE{$ruta}="t0mt3";
    }
    else { $FORCE{$ruta}=$text; }
    if($FORCE{$ruta} eq "t0mt3"){
 $name[$arr]="t0mt3";
    }
    else { $name[$arr]=$text; }

    $ruta[$arr]=$ruta;
    $arr++;
}

# here is the evil if
if($ruta[$#name] eq "com" && $name[$#name] eq "write"){
    &skriv;
}



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

Date: Sat, 24 Jul 1999 09:31:06 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: some really wierd behavior with POST?
Message-Id: <3799EA4A.FC2F13F@mcmahon.qal.berkeley.edu>

Dr. Who wrote:

> The following code is just a fragment of a guestbook .. but it shows a
> problem with post?
> or perhaps a lame thing I have done myself?
> ...
> Any suggestions?
>

Sure...use CGI;


--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting -
aperrin@mcmahon.qal.berkeley.edu
            I'M LOOKING FOR ANOTHER EXPERIENCED ACCESS
               DEVELOPER - CONTACT ME IF INTERESTED.
        http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Sat, 24 Jul 1999 18:56:31 +0200
From: Marten Lehmann <lehmann@cnm.de>
Subject: split([tabulator],$line );
Message-Id: <3799F03F.E2E9B491@cnm.de>

Hello,

how can I split a line by the sign of the tabulator?


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

Date: Sat, 24 Jul 1999 19:36:27 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: the number of fields in a form
Message-Id: <7ndmc4$hpb2@news.cyber.net.pk>

: hey,
:
: is the number of fields in the form limited?
: i encountered a situation, where the first 16 values are passed to the
: script, but all the others are ignored. what might be the reason for
: that?

Perhaps they appear after </form>




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

Date: Sat, 24 Jul 1999 11:13:38 -0400
From: HC <carvdawg@patriot.net>
Subject: Re: WinNT MD5|SHA Perl
Message-Id: <3799D822.E9B5A023@patriot.net>

John,

Why are you trying to compile it at all?  If you have ActiveState's
ActivePerl, you
can install the MD5 and SHA modules from their /packages/zips site...

John wrote:

> Hello All,
> I've been trying since the 5 hours to compile the CPAN MD5 Perl
> under WinNT, without success. After preparing the adequate
> environment (vcvars32.bat), perl Makefile.PL, nmake, I get
> the following errors
> ----------
> MD5.c
> MD5.xs(54) : error C2065: 'MD5Init_perl' : undeclared identifier
> MD5.xs(88) : error C2065: 'MD5Update_perl' : undeclared identifier
> MD5.xs(99) : error C2065: 'MD5Final_perl' : undeclared identifier
> NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
> Stop.
> --------
> The problem is that in the MD5.xs, the following symbols are
> used wihout being defined anywhere !
> ------------
> /*
> ** The following macro re-definitions added to work around a problem on
> ** Solaris where the original MD5 routines are already in /lib/libnsl.a.
> **/
> #define MD5Init  MD5Init_perl
> #define MD5Update MD5Update_perl
> #define MD5Final MD5Final_perl
> -----------
> If I remove them, I got other unrecoverable errors ....
>
> Did any body go through this before anf fix it? Or does anyone know
> a MD5 or SHA Perl implementation for WinNT ?
>
> Thanks
>
> John



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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.  

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 V9 Issue 243
*************************************


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