[11887] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5487 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 26 14:07:30 1999

Date: Mon, 26 Apr 99 11:00:18 -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           Mon, 26 Apr 1999     Volume: 8 Number: 5487

Today's topics:
    Re: "learning perl" does not seem to be written well (Larry Rosler)
    Re: "learning perl" does not seem to be written well (Tad McClellan)
    Re: "learning perl" does not seem to be written well (I R A Aggie)
    Re: "learning perl" does not seem to be written well (Andrew Johnson)
    Re: Country of a visitor <cassell@mail.cor.epa.gov>
    Re: Decimal to fraction <droby@copyright.com>
    Re: Decimal to fraction <dfan@harmonixmusic.com>
        Delete line cryptoman@my-dejanews.com
    Re: Free Web Hosting with CGI <CoolCyberDude@abigfoot.com>
    Re: Help! Error message when using C-comment stripper f (James R. Goodfriend)
    Re: Help:How to find Pixel size of an uploaded image us <cassell@mail.cor.epa.gov>
        How to ftp in perl? mr_potato_head@my-dejanews.com
    Re: pearl sdf spf <grant_erwinREMOVETHIS@halcyon.com>
    Re: Perl and Oracle.. <gh@fh-sw.de>
    Re: question about guestbook <cassell@mail.cor.epa.gov>
    Re: QUESTION:Perl Regular Expression Subtring Matches?  <cassell@mail.cor.epa.gov>
        Recompile perl dist w/ O/S upgrade? dirkse@my-dejanews.com
    Re: regex: I see THAT it works, but I don't see WHY <uri@sysarch.com>
    Re: regex: I see THAT it works, but I don't see WHY <uri@sysarch.com>
    Re: serial port <cassell@mail.cor.epa.gov>
    Re: STDOUT ?? (Lee)
        Very long strings <max.vilen@home.se>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 26 Apr 1999 10:05:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <MPG.118e3c9654ad1c47989943@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7g21tk$ijg$1@nnrp1.dejanews.com> on Mon, 26 Apr 1999 
15:49:10 GMT, ralawrence@my-dejanews.com <ralawrence@my-dejanews.com> 
says...
 ...
> I've been learning from the very same book and came to the conclusion that it
> was fantastic (hi Randall). But onwards.

That's 'Randal'.

 ...
 
> Here is how I see it (and I *am* a newbie so bear with me). s/\W.*// matches
> any words (\W) followed by any character (.) any number of times (*). Since \W
> is greedy (ie. it takes as many character as it can) then this is basically
> saying replace any characters with nothing.

No.  Sorry.  \W matches a *single* character, which is *not* a 'word 
character' (usually a letter of either case, a digit, or an underscore).  
So s/\W.*// means 'delete everything beginning with the first non-word 
character' up to but not including the first newline character, if any 
(which is a more subtle understanding of what '.*' really means in this 
regex).

Your intentions are well-meant, but you should verify your 
interpretations against real data before publishing them (just as you 
would -- presumably -- test your programs before exposing others to 
them).

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


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

Date: Mon, 26 Apr 1999 08:02:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <0lk1g7.t73.ln@magna.metronet.com>

ralawrence@my-dejanews.com wrote:

: Here is how I see it (and I *am* a newbie so bear with me).


   But you don't have it quite right.


: s/\W.*// matches
: any words (\W) followed by any character (.) any number of times (*). 


   s/\W.*// matches any *single non-word character* followed by any 
   character (.) any number of times (*).

   It matches a *non-word* character, not a word character 
   ( \w is for a word character).


: Since \W
: is greedy (ie. it takes as many character as it can) 


   \W is not "greedy".

   There is no indeterminism in how many characters match \W.

   It _always_ matches a single character (one character).


   It is the _quantifier_ (*) that is greedy, or not greedy (*?).


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


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

Date: 26 Apr 1999 17:14:15 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <slrn7i97s5.6j7.fl_aggie@stat.fsu.edu>

[several posters, actually]

+ Randall

One 'l'. Randal.

HTH.

James


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

Date: Mon, 26 Apr 1999 17:25:56 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <Ek1V2.3148$mR1.47232@news1.rdc1.on.wave.home.com>

In article <37248A9C.444BE8D1@vpservices.com>,
 Jeff Zucker <jeff@vpservices.com> wrote:
 mikecard@my-dejanews.com wrote:
 
! >  uhm if you take the contents of this scalar and replace them with
! >  nothing, where does it go, ascii purgatory? 
! >  
! 
! That's an interesting question, hold it in the back of your mind and
! revisit it from time to time.  I don't know if you (or I) will ever know
! its full answer

rumour has it that all zapped characters are secretly sent to a vast
used-character-pool maintained by Larry --- when we eventually run
out of ascii characters (and in this throw-away society it is only a
question of when, not if) and Bill G. attempts to bind the world into
some new character technology (built into his OS of course), Larry
will save the day by flooding the market with free, previously used
ascii characters.

regards
andrew


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

Date: Mon, 26 Apr 1999 10:08:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Country of a visitor
Message-Id: <37249DA6.F0DE6944@mail.cor.epa.gov>

Philip 'Yes, that's my address' Newton wrote:
> 
> Michael Stillwell wrote:
> >
> > In your opinion, what proportion of hosts misrepresent their location?
> > Is this proportion worth worrying about?
> 
> What do you mean, location? Most hosts don't say anything about their
> location. Domains are not necessarily connected with geography. Just
> because I'm in Germany doesn't mean I have to use a .de address; .com
> .org .net and even .si .to .tv etc. work just fine.

That may be, but I'm going to side with Michael on this one.

If my server 'sees' an address that ends in .au , I think it is a
fair assumption [not an iron-clad guarantee of course] that the poster
is transmitting from an English prison^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
Australia.

If I see .edu in the address, I think it is reasonable that the 
transmitter is using a university account.  If the post/email
ends in .com or .net or .org, then there is no obvious country
info, but that doesn't invalidate Michael's point.

Clearly, these can be spoofed by Seymour Scriptkiddie or anyone with
a clue [these are disjoint sets of course].  But how often does that
happen?  I've seen you post from a .de address more than once, and so
I have assumed that you work in Germany.  Similarly, I assume Mike
guy is in the UK, and Michael Stillwell is in Australia.

A deeper question is: "What does one do with that information?"
Since it is not safe to deduce the preferred language from one's
country of posting [e.g., my cousin in Israel prefers English], 
locale issues remain sticky.  I still think one's best option is
asking your visitors what language/customs they prefer.  If 
someone says 'Mandarin' as a joke, when they only speak English
[or American], then they get what they deserve - a screen full of
ideographs.

David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Mon, 26 Apr 1999 17:22:19 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Decimal to fraction
Message-Id: <7g27c5$nuo$1@nnrp1.dejanews.com>

In article <7g0tma$mdf$1@monet.op.net>,
  mjd@op.net (Mark-Jason Dominus) wrote:
> In article <Y1OU2.2726$94.1233838@news1.usit.net>,
> JJ <webdude@mcminn.net> wrote:
> >is it possible to convert decimal values to fractions in a script?
>
> Sure, that sounds like fun.  Here's a package you can use either as a
> standalone program, or as a module.  (Install it as `Fraction.pm' and
> say `use Fraction').  It contains four functions, of which the
> simplest is `decimal_to_fraction'.

Except you sort of lost the decimal_to_fraction function in editing your
module to also act as a program.

<snip>

>     The program guarantees to find the simplest possible fraction
> that is within the specified error.  The default error is 2**(-12)
> which is .000244140625.
>

I'd contest that guarantee.  It might be guaranteed on a machine with
infinite memory, but I suspect the errors implicit in floating point
representation might then just lead to inaccuracy instead of deep recursion.

0.11 has a nice short representation as a continued fraction in reality, but
leads this program on a wild goose chase ending in "out of memory".

Other than this minor reality check, it's a lovely module.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 26 Apr 1999 12:51:07 -0400
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: Decimal to fraction
Message-Id: <wkiuaje35w.fsf@turangalila.harmonixmusic.com>

mjd@op.net (Mark-Jason Dominus) writes:

| [description of his fraction-finding module]
| 
| 	convergents(3.14159);
| 
| returns a list ([3,1], [22,7], [333,106], ...) which represents this
| list of fractions:
| 
| 	3/1		(too low  by 1/7)
| 	22/7		(too high by 1/789)
| 	333/106		(too low  by 1/12412)
| 	355/113		(too high by 1/342424)
| 	9208/2931	(etc.)
| 	9563/3044
| 	76149/24239
| 	314159/100000	(exact)
| 
| It stops there because obviously 314159/100000 is exact.  Again,
| there's an optional second parameter that tells it how close it should
| get before it stops.  
| 
| The other two functions in the package are only of interest to
| mathematicians.  If you are not a mathematician, you may ignore
| them.  If you are a mathematician, you will find them
| self-documenting, and, in fact, you probably already know what they
| are without my having to tell you.

I'm not a mathematician, so I don't know if Mark-Jason's algorithm
is really the same as mine.  I read it in Concrete Mathematics by
Knuth, Graham and Patashnik, which unfortunately is at home.  The
idea is that if r is between n0/d0 and n1/d1, then a good next guess
for r is (n0+n1)/(d0+d1).  This method is guaranteed to find the best
approximation with denominator < d for any given d.  (It produces all
of Mark-Jason's approximations, and some other ones as well; you can
throw out the extra ones by collapsing runs in which you're always
moving the same side of the span.)

I didn't have any time to work it up so it's not as usable as mjd's,
but here it is anyway.  In the worst UI decision of my life, I made
the second argument be either the number of fractions to produce or
the desired precision, using advanced DWIM technology.

  $num = shift;

  if ($num =~ /(\d*)\.(\d+)/) {
    @frac1 = ($1, 1);
    @frac2 = ($1 + 1, 1);
  } else {
    die "Give me a decimal number to approximate, please.";
  }

  $arg = shift || 20;
  if ($arg >= 1) {
    $iters = $arg;
    $precision = 0;
  } else {
    $precision = $arg;
    $iters = 100000000;
  }

  $mindiff = 10;

  while ($iters) {
    @newfrac = ($frac1[0] + $frac2[0], $frac1[1] + $frac2[1]);
    $val = $newfrac[0]/$newfrac[1];
    $diff = abs($val - $num);
    if ($val > $num) {
      @frac2 = @newfrac;
    } else {
      @frac1 = @newfrac;
    }
    if ($diff < $mindiff) {
      $mindiff = $diff;
      --$iters;
      print "$newfrac[0]/$newfrac[1] = $val\n";
      exit if ($diff <= $precision);
    }
  }

-- 
                 Dan Schmidt -> dfan@harmonixmusic.com, dfan@alum.mit.edu
Honest Bob & the                http://www2.thecia.net/users/dfan/
Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/
          Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/


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

Date: Mon, 26 Apr 1999 17:40:16 GMT
From: cryptoman@my-dejanews.com
Subject: Delete line
Message-Id: <7g28e0$p1k$1@nnrp1.dejanews.com>

Hi,

There is anyone can tell me which function should I use to delete a line in a
text's file. I looked at CPAN and in the Perl CookBook but it doesn't help.

Thank you!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 26 Apr 1999 19:13:26 +0200
From: "ccd" <CoolCyberDude@abigfoot.com>
Subject: Re: Free Web Hosting with CGI
Message-Id: <7g26rk$5s4$1@news.casema.net>

http://www.virtualave.net has full Perl support

Paul A. Fortin heeft geschreven in bericht <37240137.B7135A0E@i-1.net>...
>Is there a site out there that allows CGI hosting and that is free.
>I've tried "webjump" but they severely limit what you can do in a script
>and it has become an irritant?
>
>Thanks for the help in advance.
>
>Paul A. Fortin
>




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

Date: 26 Apr 1999 17:46:58 GMT
From: GoodfriB@jntf.osd.mil (James R. Goodfriend)
Subject: Re: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <7g28qi$nr0$1@news1.rmi.net>

In article <7g0fom$7gg$1@nnrp1.dejanews.com>, ebatutis@my-dejanews.com 
says...
>
>In article <7flli5$5k2$1@news1.rmi.net>,
>  GoodfriB@jntf.osd.mil (James R. Goodfriend) wrote:
>> Greetings,
>>
>>       I'm using the massive regular expression listed in perlfaq6 
to strip
>> out the comments from a C file.  (I won't repeat my code here since 
mine
>> exactly the same).  When I run this using -w I get the following 
error
>message:
>>
>> Use of uninitialized value at (program) line 19, <CFILE> chunk 1.
>>
>
>I found a work-around.
>
>Instead of just having $2 in the REPLACEMENT part of the expression
>
>s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|\n+|.
[^/"'\\]*)#
>$2#g;
>
>I used the expression
>
>if (defined $2) { $2; } else { ""; }
>
>with the "e" modifier. So the whole thing now looks like this:
>
>s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|\n+|.
[^/"'\\]*)#
>if (defined $2) { $2; } else { ""; }#ge;
>
	I found a similar solution (I didn't think of doing it inline 
and hackingly called a subroutine) on friday afternoon; thanks to 
Larry Rosler for dropping the (unrelated except through a lateral 
leap) hint that put me on the right path.
	I did go ahead and forward my inelegant solution to the FAQ 
changes address; hopefully others won't hit this problem in the 
future.

				-Bob



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

Date: Mon, 26 Apr 1999 10:29:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help:How to find Pixel size of an uploaded image using CGI?
Message-Id: <3724A265.8FCD50DC@mail.cor.epa.gov>

Philip 'Yes, that's my address' Newton wrote:
> 
> Jonathan Stowe wrote:
> >
> > On Sat, 24 Apr 1999 18:14:57 GMT ltif@my-dejanews.com wrote:
> > > When user is uploading an image (.gif or .jpeg) into
> > > our LINUX/APACHE server using his/her
> > > browser, how can we find out the pixel size of the image
> > > using CGI (of course we can do it offline using paintshoppro)?
> >
> > I figure that the module Image::Size available from CPAN does that -
> > though I have never had cause to use it myself not being a pornographer.
> 
> No, Jonathan; Image::Size requires Perl. ltif wanted to find out the size
> of a picture using only the Common Gateway Interface.

<gasp>  Surely that couldn't be true, Philip.  I can't conceive
of someone asking a pure CGI or webserver question in this newsgroup!
Tell me it isn't so!

Signed,
Shocked
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Mon, 26 Apr 1999 17:18:32 GMT
From: mr_potato_head@my-dejanews.com
Subject: How to ftp in perl?
Message-Id: <7g2753$npq$1@nnrp1.dejanews.com>

Hi,	I need to ftp a file on a daily basis from one unix server to a
novell server and I would like to do this ftp in perl.	Does anyone have a
short hack to show me how to do this???  Thanks in advance...

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 26 Apr 1999 10:29:59 -0700
From: Grant Erwin <grant_erwinREMOVETHIS@halcyon.com>
Subject: Re: pearl sdf spf
Message-Id: <3724A297.AB942A11@halcyon.com>

The name "Pearl" predated "Perl" coming into common usage. It was
named at a university. Cadence bought the tool and hired its
development team. I'm sure they considered changing the name but
the name already had become known, and brand name familiarity
costs money ..

When someone stepped out of the way to let Pearl Bailey through a
door, saying, "Age before beauty", she walked through, retorting,
"Pearls before swine" ..

Grant Erwin
Seattle, Washington

-- 


Thomas Arneberg wrote:
 
> Wow...I thought "surely, this newbie must be mistaken.  There's no way a
> CAD company would name a product 'Pearl'!  Must be a typo."
> 
> But I've been out of the loop on Cadence stuff for a couple years now,
> so I checked their web page...and sure enough:
> 
>   http://www.cadence.com/software/DeepSubmicron/pearl.html
> 
> Amazing.
> 
> I wonder if there was any discussion within Cadence about this name.
> Do users write Perl scripts to parse output from Pearl?  Would they be
> Pearl Perl scripts?
> 
> Maybe Cadence should name their next program "Younicks" or "Said"
> or "Tickle" to help alleviate the confusion...  :-/
> 
>   - Tom A. (crossposting to comp.lang.perl.misc)
> --------------------------------------------+---------------------
> ;-) I'd rather be ____  Thomas R. Arneberg  | Only 384 more days
> :-) singing in a |____| toma@arneberg.com   |   until my sabbatical!
> :-) Barbershop  _|   _| sqi/Cray IC Design  | http://arneberg.com
> :-) Quartet!   (_)  (_) Chippewa Falls, WI  | We're the colon in http:
> --------------------------------------------+---------------------


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

Date: Mon, 26 Apr 1999 19:23:40 +0200
From: Gerd huessner <gh@fh-sw.de>
To: pdean@pcmars.cs.ndsu.nodak.edu
Subject: Re: Perl and Oracle..
Message-Id: <3724A11C.4873C574@topmail.de>

Take a look at the DBD-module at
     http://www.perl.com/CPAN-local/authors/id/TIMB/DBD-ODBC-0.20.tar.gz
inside this tar file there is a script:  test.pl
with a build-in ENV-check, where the requested ENV vars are listed.

wfr ben
 ------------------------------



pdean@pcmars.cs.ndsu.nodak.edu schrieb:

> Hi...
>
> I'm trying to write a CGI script which has to access the Database that is
> running on the different machine.I'm using DBD-Oracle to connect to the
> database do i have to set up any ENV variable or do i have to meddle with any
> tnsnames.ora file.If so pls let me what i have to do ....Any help is
> requested.
>
> Regards,
> Pradeep.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: Mon, 26 Apr 1999 10:48:45 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: question about guestbook
Message-Id: <3724A6FD.3741D915@mail.cor.epa.gov>

S.L. de Vries wrote:
> 
> I'm from The Netherlands, so I hope you can understand this message.
> Hello,
> 
> I've download a guestbook and changed the settings to  the settings of
> my page.
> But when I fill it in I get an error that I did not fill in my name, but
> 
> I did it.
> When I first let the script check for the comments then I get an error
> that I did not fill in my comments.
> Does anyone know what the problem is?

Sjoerd, your English is just fine.  Better than some of the American
posters I have seen recently.  That is not the problem.  The
problem is that you did not give us enough information to answer
your question.  And since the PSI::ESP module is still in alpha, we
cannot divine the solution.

There are lots of `guestbook' scripts around.  Some are well-written,
and some are horrendous pieces of pseudo-Perl garbage.

Can you cut down your script to something under 40 lines, and still
have it illustrate the problem?  If so, post it and tell us what
it does, what it should do, and exactly what error you got.  Don't
re-type it.  Make sure it runs and then cut-and-paste into your
newsreader.  And follow the great suggestions found in the e-mail
from gnat which you should have received by now.

HTH,
David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Mon, 26 Apr 1999 10:21:49 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: QUESTION:Perl Regular Expression Subtring Matches? Strange   Behaviour...
Message-Id: <3724A0AD.11B680F6@mail.cor.epa.gov>

Craig Graham wrote:
> 
> [mucho snippo]
>
> That's not in fact true, as the final match for that pattern will in
> fact
> have (a.b)+ matching 6 characters (see my example) but only 3
> of them appearing as a substring (the first substring is only returned
> as a component of the last matched $&).

Oops.  "Whut we hav heeyah is a failyah ta communicate!"
That was the point I was trying to make.
 
> >So it's not an inconsistency in the syntax.  But it may be different
> >from what you are used to.  Still, any good regex package should only
> >match three characters there.  That's all your parens surround at
> >any time.
> 
> Yep. But my assertion was that the ()+ implied that it should match
> the three characters several times (as seperate substrings).

Yes.  And it does.  And the parens only capture three characters at
a time.  But parens around the whole pattern would capture the whole
schmeer.
 
> >And I seriously wonder if Netscape's pattern-matching should be held
> >up as any sort of standard for programming languages to aspire to.  :-)
> 
> It should if you're contracted by a company which produces standalone
> Web Browser set-top boxes that wants JavaScript support adding
> to their in-house written browser ;)

Ohhhhh.  Well, you have my deepest sympathies, if that's any
consolation.
:-)
 
> *** Added Note: Netscape/JavaScript's regexp handler is taken directly
> from Perl anyway.....

Hmm.  I didn't know that.  How does that work?

David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Mon, 26 Apr 1999 17:44:29 GMT
From: dirkse@my-dejanews.com
Subject: Recompile perl dist w/ O/S upgrade?
Message-Id: <7g28ls$pca$1@nnrp1.dejanews.com>

Is it necessary to recompile my Perl 5.003_0 distribution built w/
the HP ANSI C compiler when upgrading HP-UX from 10.10 to 10.20?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 26 Apr 1999 13:31:04 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <x71zh7b86f.fsf@home.sysarch.com>

>>>>> "TC" == Tom Christiansen <tchrist@mox.perl.com> writes:

  TC>     This usage is vaguely deprecated, and may be removed in some
  TC>     future version of Perl.

  TC> Notice *vaguely*.  If it doesn't give warnings under -w, it's not 
  TC> at risk.  

i noted vaguely, but i noted deprecated too. putting the two together is
not clear at all. in all my years of hacking perl i have never seen it
used much. i wonder if it would be possible to search dejanews for
mentions of it (i think /\?.*?\?/ would make their search engine barf).

  TC> Just many people don't know something doesn't mean to throw it away.
  TC> It is extremely useful, because it saves useless state variables.
  TC> I use it a good bit.  And it's not going away any time soon, if I 
  TC> have anything to say about it -- which, I think, I do. :-)

i thought the deprecation was the mark of throwing it away.

  TC> It's phenomenally useful in things like

  TC>     ( ?^$? : $in_header : $in_body ) = 1;
                 ^
      should be  ?

i would use different subs or loops for that state.

or this:

	$in_body = /^$/ unless $in_body ;

maybe i like to be more explicit about my state knowledge. i want that
in my data and not in operators. thought i do like scalar .. which does
keep state.

to each their own,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 26 Apr 1999 13:56:17 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <x7wvyz9sfy.fsf@home.sysarch.com>

>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

  DG> Uri Guttman <uri@sysarch.com> writes:
  >> >>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

  DG> <snip who uses ?PATTERN?>

  >> very obscure, 

  DG> It is no more obscure than the bizarre treatment of / / by
  DG> split.  Both are clearly documented in the manpages.

that is more commonly used as it is for emulation of awk's split behavior.

  DG> If a perl programmer has a problem with ?PATTERN?, then that person
  DG> needs to spend some more time with the manpages before representing
  DG> himself as a perl programmer.

  >> and can be easily done with the
  >> regular m// (as the camel says, just break out of the loop).

  DG> You have no idea what you are talking about.  You cannot recreate the
  DG> functionality of ?PATTERN?  by simply looping over m//, not without
  DG> keeping around a huge pile of variables to maintain state.

as i said in a followup to tom c., i prefer to control my own state for
these types of things. there are many ways of doing it and not all
involve state forests of variables.

  >> if i were to see m?? i might not even know what is is for a
  >> second.

  DG> That is your problem, not mine.

true but i (almost) never seen in in use until your 2 replies. as i
posted to tom, i wish we could search dejanews for it.

  DG> The reason it isn't too hard is that I don't have to worry
  DG> about creating, managing, and destroying a whole pile of
  DG> variables in the generated code.  Have you ever tried to
  DG> debug a program that writes most of its own code at runtime?
  DG> It isn't the easiest task in the world.

been there, doing it right now in a new module. yes it can be tricky.

  DG> Consider how this would have to be done if I didn't use ??.

  DG> while ($record = <INCOMING>) {
  DG>    $message {bad_uid}  = 1 if (!$seen_bad_uid             && 
  DG>                                 $record =~ /$bad_uid/     &&
  DG>                                 $seen_bad_uid = 1);
  DG>    $message {bad_conn} = 1 if (!$seen_bad_conn            && 
  DG>                                 $record =~ /$badd_conn/   &&
  DG>                                 $seen_bad_conn = 1); 
  DG>    .......
  DG> }

  DG> Besides the silly extraneous state variables that have to
  DG> be carefully maintained there is also an unnecessary test
  DG> on every line of code.  No, the test isn't enough of a bottleneck
  DG> to worry about normally, but in this case it is just another
  DG> problem that is introduced for no reason.

what about something like using a or-cache (hash) for all the states
(untested code):

	$message {bad_conn} = 1 unless ( $msg_seen{bad_conn} ||=
                                      $record =~ /$bad_conn/ ) ;

this makes for a nice symmetry of the 'bad_conn' strings which makes for
easier code generation too. then you can reset all the states with just
%msg_seen = () instead of reset.

i am not saying ?? is bad but there are definite simple ways to work
around it. i just don't like it for now. maybe i could change my mind
someday. it is not a needed tool in my perl arsenal. and if it is so
useful why even have the vaguely deprecated comment and why not more
useful examples?

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Mon, 26 Apr 1999 10:26:38 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: serial port
Message-Id: <3724A1CE.B2905959@mail.cor.epa.gov>

alainch wrote:
> 
> Hi all,
> 
> I'd like to have access and configure serial ports (such as ttya or
> ttyb) under unix
> with perl. Can someone help me ?

Lots of people can.  Because it's a FAQ.  Go to perlfaq8 and read the
text under the title "How do I read and write the serial port?"
The answer given is quite unix-centric.

Short answer: the serial ports are accessible through files in /dev .
Code snippets are in the FAQ waiting for you.  And if you're doing
this in Perl then you should already have it on your system.

> Thanks.

You're welcome,
David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Mon, 26 Apr 1999 12:41:40 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: STDOUT ??
Message-Id: <B34A0F849668202464@204.112.166.88>

In article <372389DA.605333D2@metronet.com>,
Jimx <jimx@metronet.com> wrote:

>how do i print a location command after a content-type? 

You can't.

>print "Content-type:text/html\n\n";
>print "some text and html";
>print "Location: $file_name\n\n";

These are mutually exclusive. You can print content *OR* you can redirect. 

If you want the contents of that file appended after the dynamic content,
you're going to have to read the file and echo it to STDOUT.

Lee 




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

Date: Mon, 26 Apr 1999 18:51:31 +0200
From: "Max Vilin" <max.vilen@home.se>
Subject: Very long strings
Message-Id: <7g25hk$b39$1@news.kth.se>

How would I go about to extract large text strings from a database and
presenting them without having to trucate them?

//Max




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

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

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