[6460] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 85 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 10 23:17:15 1997

Date: Mon, 10 Mar 97 20:00:25 -0800
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, 10 Mar 1997     Volume: 8 Number: 85

Today's topics:
     Re: /\b\*((\w+\s*){1,3}\**){2,}/ <tchrist@mox.perl.com>
     Re: /\b\*((\w+\s*){1,3}\**){2,}/ (Tad McClellan)
     Re: /\b\*((\w+\s*){1,3}\**){2,}/ <owt1@cornell.edu>
     Re: 10 commandments (was re: Which one is the best (pat <tchrist@mox.perl.com>
     Re: 10 commandments (was re: Which one is the best (pat <dduncan@realogic.com>
     Re: 10 commandments (was re: Which one is the best (pat <tchrist@mox.perl.com>
     Re: [Q] Extract a regex < hansm@icgned.nl>
     Re: bizarre problem: any ideas (Tad McClellan)
     Re: bizarre problem: any ideas <dbenhur@egames.com>
     Re: Does Llama book really cover perl 5? Yes!  No! really_eliot@dg-rtp.dg.com_but_mangled_to_stop_junk_email
     entrust Perl Extension <rsmith@proteus.arc.nasa.gov>
     FAQ or "manual" on using DBI with Oracle. Tim.Middleton@health.wa.gov.au
     Re: HELP: Perl newbie need some help (Tad McClellan)
     How to select either scripts for a form bz7328113@ntuvax.ntu.ac.sg
     Re: Install help for 5.003 on Solaris? (Albert Briner)
     Re: Looking for Interactive Training CD-ROM for Perl (Lisa McClure)
     Re: Need FILE1 copied to FILE2 (minus the spaces, tabs, <tchrist@mox.perl.com>
     Re: Need FILE1 copied to FILE2 (minus the spaces, tabs, <wkuhn@uconect.net>
     On implementing tie (Gregory Tucker-Kellogg)
     Re: Parsing a form with enctype=multipart (A. Deckers)
     patch substr to fetch rightmost n characters <dcd@tc.fluke.com>
     Re: Perl uudecoder - for Web NNTP server (Eric Bohlman)
     Re: PLEASE HELP! (Tad McClellan)
     Re: Please Respond (Billy Chambless)
     Re: Please Respond (Tad McClellan)
     Q:How to turn off taint checking locally in a function? <rayyu@cup.hp.com>
     Re: Say hi to the punk (Tad McClellan)
     Re: simple tutorial on writing perl cgi for NT bz7328113@ntuvax.ntu.ac.sg
     Re: Sort question viet@airmail.net
     WANTED: Perlscript for WebChat (Anders F{ltros)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Harold Stevens)
     Re: Who makes more $$ - Windows vs. Unix programmers? (John Bickers)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 11 Mar 1997 01:33:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: /\b\*((\w+\s*){1,3}\**){2,}/
Message-Id: <5g2coo$h6b$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Eli the Bearded <usenet-tag@qz.little-neck.ny.us> writes:
:Can someone help me understand why this RE:
:	/\b\*((\w+\s*){1,3}\**){2,}/
:doesn't match this line:
:	**this is junk**this is junk**this is junk**


Right at the start, you ask for 

    a word boundary
    a star
    an alphanumeric

I don't see such a thing in your line.  What's the confusion?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
There are still some other things to do, so don't think if I didn't fix
your favorite bug that your bug report is in the bit bucket.  (It may be,
but don't think it.  :-)  Larry Wall in <7238@jpl-devvax.JPL.NASA.GOV>


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

Date: Mon, 10 Mar 1997 18:53:55 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: /\b\*((\w+\s*){1,3}\**){2,}/
Message-Id: <3fa2g5.fn.ln@localhost>

Eli the Bearded (usenet-tag@qz.little-neck.ny.us) wrote:

: Can someone help me understand why this RE:
: 	/\b\*((\w+\s*){1,3}\**){2,}/
: doesn't match this line:
: 	**this is junk**this is junk**this is junk**


Yes.


: Is the {1,3} trying to match the same word one to three times?


No. It is trying to match _any_ word ont to three times. That part 
isn't your problem anyway...


It is the word-boundary (\b) that is messing you up.

**this is junk**this is junk**this is junk**
^^

There is NOT a word boundary between those two characters.


\b matches when there is a \w followed by a \W (or vice-versa).

What you have there is two \W's so... no match!


So, either remove the \b or try to match:


*this is junk*this is junk*this is junk**


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 10 Mar 1997 21:07:45 -0500
From: Owen Taylor <owt1@cornell.edu>
Subject: Re: /\b\*((\w+\s*){1,3}\**){2,}/
Message-Id: <lzn2sbrxji.fsf@cu-dialup-1128.cit.cornell.edu>

Eli the Bearded <usenet-tag@qz.little-neck.ny.us> writes:

> Can someone help me understand why this RE:
> 
> 	/\b\*((\w+\s*){1,3}\**){2,}/
> 
> doesn't match this line:
> 
> 	**this is junk**this is junk**this is junk**

from the perlre man page:

 A word boundary (\b) is defined as a spot between two
 characters that has a \w on one side of it and and a \W on
 the other side of it (in either order) [ ... ]

So the first \* in your regex could match:

	**this is junk**this is junk**this is junk**
                      ^             ^             ^
         
Clearly, none of these positions is followed by a \w. 

 	/\*((\w+\s*){1,3}\**){2,}/
           ------------------

is probably closer to what you want, but note that the
underlined part could match any single character. (Making
the {2,} pretty useless). So I would guess you really want
something like:

 	/(\*(\w+\s*){1,3}\**){2,}/

Regards,
                                        Owen


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

Date: 11 Mar 1997 02:27:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: 10 commandments (was re: Which one is the best (pattern matching))
Message-Id: <5g2fu0$jve$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    dbenhur@egames.com writes:
:> 9) Thou shall check return stati of functions

Oh boy, two grammatical errors in one sentence.

    1) The second person of shall is shalt (well, to my ear; the OED
       has six pages on "shall", and includes quite a few variant 2nd
       person forms).  Don't use thou without conjugating its verb
       into the second person as well.  Otherwise it sounds like "I are
       returning now."

    2) If for some bizarre reason you simply cannot bring yourself to
	use the normal English plural form "statuses", then you must learn
	that the true plural of status is statUs, with a macro over the u
	and pronounced "statoose".  That's because status comes from the
	Latin declension that forms plurals according to that particular
	rule, which incidentally is just like the plurals of apparatus
	and prospectus, but unlike the plural of words like radius,
	which becomes radii because it's from a different declension,
	and also unlike genus and corpus, which go to genera and corpora
	respectively because they are from still another declension.
	And please don't ask me about octopus, since it's Greek not Latin,
	and we do not care to offend any sensitive octopedal feelings. :-)
	Wouldn't it be much easier to simply s/$/es/?

A word to the wise: don't use fancy forms out of yesteryear unless you 
really REALLY do know how they work(ed).  It just sounds silly.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "Help save the world!"              --Larry Wall in README


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

Date: Mon, 10 Mar 1997 17:51:43 -0500
From: Diana Duncan <dduncan@realogic.com>
Subject: Re: 10 commandments (was re: Which one is the best (pattern matching))
Message-Id: <3324907F.6DED@realogic.com>

Jagadeesh K. Venugopal wrote:
> 
> Zenin wrote:
> >
> 
> [About use strict]
> 
> >         IMHO, when they get past ~200 it's almost mandatory, and if you go
> >         over ~1k it would be death without it...
> > --
> 
> Sometimes I get the feeling that -w and strict must be default options
> with -no_w and 'use nostrict' as choosable options. I have discovered
> many problems with my scripts after developing them, when I ran them
> under 'strict'.
> --
> ______________________________________________________________________
> Jagadeesh K. Venugopal
> Cambridge Technology Partners, 304 Vassar Street Cambridge, MA 02139
> Phone: 617.374.2028; Fax: 617.374.8300; E-mail: jvenu@ctp.com
> ______________________________________________________________________

What I don't like about *always* using strict and -w is that it
restricts my free-and-easy variable creation.  I will turn them on
whilst debugging, but I truly love the freedom from declaration that
Perl provides.

I guess my problem is with the whole "Commandments" idea.  If one is
comfortable and proficient in the language, one should be able to do
what one wishes, "an' it hurt none."  Perl is a remarkably tolerant
language for "atheists" who wish to do it their own way.  Let's keep it
that way!
-- 
Diana Duncan	     | My opinions are my own.
Sr. Consultant	     | 
REALOGIC, Inc.	     | Excitement, Adventure and
dduncan@realogic.com | Really Wild Things - Z.B.


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

Date: 11 Mar 1997 02:31:44 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: 10 commandments (was re: Which one is the best (pattern matching))
Message-Id: <5g2g6g$jve$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, hansm@icgned.nl writes:
:*All* functions?
:Even print?

That depends on whether you care about filling up the disk.
Usually in practice checking the close() is all people do.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "They'll get my perl when they pry it from my cold, dead /usr/local/bin."
	    Randy Futor in  <1992Sep13.175035.5623@tc.fluke.COM>


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

Date: 11 Mar 1997 00:00:17 GMT
From: Hans Mulder< hansm@icgned.nl>
Subject: Re: [Q] Extract a regex
Message-Id: <5g27ah$1pt@news.euro.net>

>Vegard Bakke <vegardb@knoll.hibu.no> wrote:
> I would like to "move" the matching pattern from a regex in
> a string to a new variable.
 
> Lets use the three first random cahacters as an example ( /^.{3}/ ).
> $OrgStr="1234567890";
> $NewStr="";
> In this example I would like the result to be:
> $OrgStr="4567890";
> $NewStr="123";

How about:

	$OrgStr = $';
	$NewStr = $&;

Perhaps you want to do something with $` as well.

Hope this helps,

-- HansM


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

Date: Mon, 10 Mar 1997 19:20:50 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: bizarre problem: any ideas
Message-Id: <i1c2g5.uo.ln@localhost>

Clive Holloway (clive@bigfish.co.uk) wrote:
: I have a script that works when run from the command line.

: When I run it from Netscape, through Win HTTPD server (win 3.1) I get
: everything up to an 'open(FILEHANDLE,">filename.dat");'


If it works from the command line, but not as a CGI then you
have a CGI problem, and the place to ask for help would be:

comp.infosystems.www.authoring.cgi


: Is it me being a newbie, or a config problem on win HTTPD? If anyone can

You likely have a permissions problem. Change it to:

open(FILEHANDLE,">filename.dat") || die "oops.   $!";

and then go read the server error log.


: help, please mail me!!

Ask it here, get the answer here (but only one time for off-topic
questions ;-)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Mon, 10 Mar 1997 17:52:21 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: clive@bigfish.co.uk
Subject: Re: bizarre problem: any ideas
Message-Id: <3324BAD5.3C61@egames.com>

[mailed & posted]
Clive Holloway wrote:
> I have a script that works when run from the command line.
> 
> When I run it from Netscape, through Win HTTPD server (win 3.1) I get
> everything up to an 'open(FILEHANDLE,">filename.dat");'

Right here we know it probably isn't a Perl problem.
Try posting again to the correct newsgroup:
  comp.infosystems.www.authoring.cgi

My first guess is that the user your CGI program runs
as (nobody) doesn't have permission to write into the
directory where you're trying to open that file for
output.

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks"  O-
    -- Sonia Orin Lyris



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

Date: 10 Mar 1997 21:11:18 GMT
From: really_eliot@dg-rtp.dg.com_but_mangled_to_stop_junk_email
Subject: Re: Does Llama book really cover perl 5? Yes!  No!
Message-Id: <ELIOT.97Mar10161118@kern1.dg.com>

In article <ELIOT.97Mar10140517@kern1.dg.com> eliot@kern1.dg.com (Topher Eliot) writes:


      Is there really a Llama for Perl 5? I bought mine recently and it's the 
      Perl 4 version.

   I have the new one. ISBN 1-56592-149-6.  $40 or so.
   I also have the old one, so I'm sure the new one is new.  It even says
   "Covers Perl 5" on the front cover, and "second edition" inside.

   Having spent a bunch of time using just the Llama book(s), I am now reading
   the camel book, and so far have found it worthwhile.  I would recommend it
   as a starting point.

How embarrassing.  Well as bioligists go, I make a fair programmer.
I got "Llama" and "Camel" mixed.  Sorry about that.

Topher Eliot                           Data General Unix Core Development
(919) 248-6371                                        eliot at dg-rtp.dg.com
Obviously, I speak for myself, not for DG.
Visit misc.consumers.house archive at http://www.geocities.com/Heartland/7400
"I like to get the chicks messy."  
	-- Peter, age 4, on why he likes the barnyard-scene cereal bowl.


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

Date: Mon, 10 Mar 1997 16:46:36 -0800
From: Roger Smith <rsmith@proteus.arc.nasa.gov>
Subject: entrust Perl Extension
Message-Id: <3324AB6C.5498@proteus.arc.nasa.gov>

Hi

Does anybody have, or know of someone who is working on, a perl
extension for the entrust authentication and privacy package?
Particularly, the EntrustFile interface?

Heres hoping,

Roger Smith
NASA-Ames Research Center


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

Date: Mon, 10 Mar 1997 19:41:29 -0600
From: Tim.Middleton@health.wa.gov.au
Subject: FAQ or "manual" on using DBI with Oracle.
Message-Id: <858044104.15638@dejanews.com>

Hi, I am using DBI version 0.75 and DBD version .44 , and Oracle 7.3.2
and would like to know if there is a FAQ or list of commands such as
ora_open, etc.

TIA.

Please Email Me.

Tim.Middleton@health.wa.gov.au

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Mon, 10 Mar 1997 20:21:06 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP: Perl newbie need some help
Message-Id: <iif2g5.831.ln@localhost>

Jean-Christophe Rioux (rioux@cam.org) wrote:
: (P.S. SORRY FOR THE ENGLISH, I'M FRENCH SPEAKING)

: I have a question to ask you...

: I want to delete text that is between two tag like in this exemple:

: --------------------------

[snip example]

: ------------------------
: I want to delete the text between the <!--mme###--> and <!--fmme###-->
: and delete the two tag in the same time...

: (Important: note that the <!--mme###--> or <!--fmme###--> are not on the
: same line as the text!!!)


I just answered this very question yesterday. I gave only three
ways to do it though.

Go to http://www.dejanews.com and search for 
Subject: Re: Simple PERL Question



: I try this script but is realy dont work:

: -------------------------

: $/ =1;
: open (FILE,"$index");
: $data=<FILE>;
: $data =~ s/<!--mme$FORM{'ID'}-->.+?<!--fmme$FORM{'ID'}-->//mg;
                                                             ^
                                                             ^
You probably want an 's' here. 

The 'm' has no effect for this particular pattern...


: ----------------------

: I'm not a "pro" in PERL5 so please be very CLEAR in your explanation...

: Thanks in advance for your help form all the the guy who are waitiing
: for this cgi and who want to see me dead,
                   ^^^^^^^^^^^^^^^^^^^^^^^

Rough crowd you run with  ;-)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 11 Mar 1997 11:41:04 +0800
From: bz7328113@ntuvax.ntu.ac.sg
Subject: How to select either scripts for a form
Message-Id: <Pine.PMDF.3.91.970311113416.656599941B-100000@ntuvax.ntu.ac.sg>

Hi! I'm interested in finding how would I be able to select which perl 
scripts to run when I submitted a form. In other words, in the html file,
there is a choice in < FORM ......ACTION= form1.cgi or ACTION = form2.cgi>

Hope someone will reply.

Your replies are greatly appreciated. 

Thanks in advance.

kkchiang.

kkchiang@pacific.net.sg



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

Date: Tue, 11 Mar 1997 02:37:30 GMT
From: albert@materhorn.mv.com (Albert Briner)
Subject: Re: Install help for 5.003 on Solaris?
Message-Id: <albert-1003972135420001@matterhorn.mv.com>

In article <rudolf-1003971413040001@jim.metadesign.de>,
rudolf@metadesign.de (Jim Rudolf) wrote:

> Briefly, Configure makes a list of *hundreds* of signal names, and
> that causes problems later in the script. 

Jim, what kind of problems are you getting? My Configure script exits
with a Shell syntax error and I'm wondering if it's the same problem.
Don't have a solution yet. I'm still stuck and looking for help also.
Did you find any helpful documentation in the mean time?

Thanks,

Albert Briner

albert@matterhorn.mv.com

-- 
Real email address: albert@matterhorn.mv.com


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

Date: Tue, 11 Mar 1997 03:22:40 GMT
From: mcclure@dimensional.com (Lisa McClure)
Subject: Re: Looking for Interactive Training CD-ROM for Perl
Message-Id: <33249448.3875289@news.dimensional.com>

>
>>Looking for Interactive Training CD-ROM for Perl
>>Any advice?
>>
>>Rocky Kahn
>>rokahn@hplb.hpl.hp.com
>
>
>I just saw at Barnes & Noble (big bookstore chain) a new series of
>books called "Interactive <insert language here>". It has a CD and
>gives you access to their website where you can take online tests and
>if you pass all of them, you get a certificate.  Check 'em out.
>

The book is titled, 'Perl 5, Interactive Course' at
http://www.wait.com/ezone.

Another on-line web book for learning Perl is 'Perl 5 by Example' at
http://www.mtolive.com/pbe/

Lisa McClure



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

Date: 11 Mar 1997 01:57:58 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Need FILE1 copied to FILE2 (minus the spaces, tabs, CR, or any other invisible characters)
Message-Id: <5g2e76$igl$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    mas@cyberspy.com (michael allen smith) writes:
:This is my 1st day using PERL and my goal is remove all spaces, tabs,
:and line feeds from a DATA file.  I've played with the ~ s and have
:been able to remove spaces, tabs, and some CR, but not without
:corrupting the data.  Is PERL the right choice for the job?       

    perl -i.bak -pe 's/\s//g' file

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    "What is the sound of Perl?  Is it not the sound of a wall that
     people have stopped banging their heads against?"
		--Larry Wall in <1992Aug26.184221.29627@netlabs.com>


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

Date: Mon, 10 Mar 1997 21:32:26 -0500
From: Bill Kuhn <wkuhn@uconect.net>
Subject: Re: Need FILE1 copied to FILE2 (minus the spaces, tabs, CR, or any other invisible characters)
Message-Id: <3324C43A.7ED61867@uconect.net>

michael allen smith wrote:
> 
> This is my 1st day using PERL and my goal is remove all spaces, tabs,
> and line feeds from a DATA file.  I've played with the ~ s and have
> been able to remove spaces, tabs, and some CR, but not without
> corrupting the data.  Is PERL the right choice for the job?
> 
> thanks,
> mas
What do you consider "corrupting the data"?

If filtering out certain characters is your objective, perl definitely
is the right choice for the job.

Why don't you repost and example of what you mean by corrupt data and
maybe someone can help you out.

The following is what I would do to remove all whitespace from a string:

$data = "one two\nthree\r\nfour\t\t" ;

$data =~ s/\s+//g ;

print $data,"\n" ;

-Bill
-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 10 Mar 1997 23:20:33 GMT
From: gtk@walsh.med.harvard.edu (Gregory Tucker-Kellogg)
Subject: On implementing tie
Message-Id: <5g2501$igh@mufasa.harvard.edu>
Keywords: tie, FETCH, HASHTIE

I'm trying to tie a hash.  I won't bore you with the whole
implementation, but the parts I'm having trouble with look like this:

  package GTK::PeakFile
  use Tie::Hash;

  sub TIEHASH { 
   # Lots of code deleted, hauling data into a %list
    print $list{HEADER}[0];
    return bless $list,$self;
  }

  sub FETCH { 
    my $self = shift;
    my $key = shift;
    if (defined $self->{$key}) { 
      print "$self->{$key}\n";
      return $self->{$key}
    }
    else {
      print $self, "->{" , $key, "} undefined\n";
      return undef;
    }
  }

When I run this perl program;
  #!/bin/perl
  use GTK::PeakFile;
  tie (%foo,'GTK::PeakFile','my.peaks');
  print $foo{HEADER};
  untie %foo;

I get the following output:

  # Number of dimensions 2
  GTK::PeakFile=HASH(0x1001aed4)->{HEADER} undefined

The first line is output from TIEHASH, and is the contents of
$list{HEADER}[0], which I thought should mean that $foo{HEADER} should
at least be defined.  I'm sure that I've made a stupid mistake, and
would appreciate somebody pointing it out to me.

If I try "print $foo->{HEADER}", then it never even enters the FETCH
routine. 

TIA,

Greg

--
Gregory Tucker-Kellogg
Department of Biological Chemistry and Molecular Pharmacology
Harvard Medical School, Boston MA 02115
"Mojo Dobro"    Finger for PGP info



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

Date: 10 Mar 1997 22:45:30 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: Parsing a form with enctype=multipart
Message-Id: <slrn5i93ob.f0l.Alain.Deckers@nessie.mcc.ac.uk>

In <33245D68.1610@campus.ruv.itesm.mx>,
	Luis Torres <ltorres@campus.ruv.itesm.mx> wrote:
>Hi, anyone know if there's a difference between parsing a form with
>enctype = multipart and one without enctype? I tried to parse the form
>contents with the sub I was using before and now with multipart I dont
>get any data!
>
>Any help will be useful
>
>L.T.

This punk made a very incompetent attempt at a mini mail-bomb when I
pointed out the inanity of his question and the difference between CGI
and Perl.

*plonk*

[followup set]
-- 
Alain.Deckers@man.ac.uk          <URL:http://www.man.ac.uk/%7Embzalgd/>


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

Date: Mon, 10 Mar 1997 15:55:44 -0800
From: David Dyck <dcd@tc.fluke.com>
Subject: patch substr to fetch rightmost n characters
Message-Id: <Pine.LNX.3.95.970310132717.3360F-100000@jd>


This is not a 'porting' issue, but I've 
cc'd the list since many of the experts are there.

to extract the the first 3 (or less characters in a
string one can say

$ perl -le '$x="abcdefg"; print substr($x , 0, 3)'
abc
$ perl -le '$x="ab"; print substr($x , 0, 3)'
ab


but to print the last 3 characters (or less)
the analogy doesn't work.

$ perl -le '$x="abcdefg"; print substr($x , -3)'
efg
$ perl -le '$x="ab"; print substr($x , -3)'


I was trying to let a string grow, but keep
it shorter than some maximum length.

Of course a work around is to check the length of 
the string, eg

$ perl -le '$x="ab"; print length($x)<3?$x:substr($x , 0, 3)'
ab

but this doesn't seem reasonable.

Can anyone think of a reason against changing substr
to allow this feature.  I had expected it to work this way.
(as it does with the following patch)

$ ./perl -wle '$x="ab"; print substr($x , -3)'
ab


--- pp.c.orig	Mon Mar 10 13:41:10 1997
+++ pp.c	Mon Mar 10 13:42:29 1997
@@ -1511,8 +1511,10 @@
     pos = POPi - arybase;
     sv = POPs;
     tmps = SvPV(sv, curlen);
-    if (pos < 0)
+    if (pos < 0) {
 	pos += curlen + arybase;
+	if (pos < 0 && MAXARG < 3) pos = 0;
+    }
     if (pos < 0 || pos > curlen) {
 	if (dowarn || lvalue)
 	    warn("substr outside of string");



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

Date: Tue, 11 Mar 1997 00:38:38 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Perl uudecoder - for Web NNTP server
Message-Id: <ebohlmanE6usGE.I0q@netcom.com>

Kevin (swarts@razorlogic.com) wrote:
: I'm looking for some source code that will take an entire document, and on the 
: fly find a uuencoded file, and decode it.

There's a program that does just that in the "eg" directory of the Perl 
distribution.  Surprisingly, it's called "uudecode."  You may have to 
tweak it a bit for your particular application, but why re-invent the wheel?



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

Date: Mon, 10 Mar 1997 19:09:52 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: PLEASE HELP!
Message-Id: <0db2g5.uo.ln@localhost>

Al Medur (medal44@ix.netcom.com) wrote:
: Hi, I am new with all of this...

You have made that glaringly apparent by not putting a subject
in your Subject.

Everyone knows you are lacking clues without even reading your article.

Kinda embarrassing.

Most just skipped it without reading.

There is a periodic posting to this newsgroup about choosing
a good Subject. Heed what it says, or expect that the most
knowledgeable of people here will never read what you write...



: I downloaded a perl cgi script for a chat  room. However, I would love
: to change a few things...

[ snip stuff ]

: I know in the basic language, it would be an easy IF THEN statement,
: such as this...


It would be and easy 'if' in perl too!


: IF name$ = "bigdave" THEN name$ = "<img src="bigdave.gif">"
                                    ^^^^^^^^^^^           ^^^

except for your having those _two_ strings there with some
other stuff that is not a string in between them.

$name = "<img src="\bigdave.gif\">" if $name eq "bigdave"; 
                   ^           ^ escape the quotes


: I just don't know what this would be in PERL. 


Well, the usual approach would then be to read the free documentation
that is included with the perl distribution.

'if' would seem to have been a good thing to look up...



: Thanks alot to those
: kind enough to help me out!


Uh huh.

You are expected to make some small effort to answer your own
problem before asking the newsgroup to expend effort for you...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 11 Mar 1997 01:09:54 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: Please Respond
Message-Id: <5g2bd2$1gu@NNTP.MsState.Edu>

In article <33249825.43E@campus.ruv.itesm.mx>, Luis Torres <ltorres@campus.ruv.itesm.mx> writes:
|> A. Deckers wrote:
 
|> > That's a seriously sucky subject line. It tells readers *nothing* about
|> > the subject of your enquiry and is likely to put some people off reading

|> Give an answer boy... dont just complain...

Betetr than an answer -- he gave the guy a clue as to how to GET
answers. By the way, what was your post? Did you give an answer, or did
you just complain?
-- 
"The bottom line on experience is this -- do you get 10 years of experience 
or do you get 1 year of experience 10 times?"
	--- Steve McConnell  in _Code Complete_



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

Date: Mon, 10 Mar 1997 20:11:28 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Please Respond
Message-Id: <g0f2g5.121.ln@localhost>

Luis Torres (ltorres@campus.ruv.itesm.mx) wrote:
: A. Deckers wrote:
: > 
: > In <33186BD7.1FD5@ix.netcom.com>,
: >         Scott Green <mogreen@ix.netcom.com> wrote:
: > >Subject: Please Respond
: > 
: > That's a seriously sucky subject line. It tells readers *nothing* about
: > the subject of your enquiry and is likely to put some people off reading


: Give an answer boy... 

He did. What part of his answer do you not understand?

(Calling people names is pretty small of you too)


: dont just complain...

Putting in a good Subject will _help_ people get their questions
answered. I'd call it helping rather than complaining...


I notice that *you* _didn't_ give an answer, just complained.

Practice what you preach...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Mon, 10 Mar 1997 17:34:18 -0800
From: Raymond Yu <rayyu@cup.hp.com>
Subject: Q:How to turn off taint checking locally in a function?
Message-Id: <3324B69A.6E2E@cup.hp.com>

Can any one tell me how to turn off taint checking locally in a
function?

For example, I have a CGI script that looks something like this:

#!/usr/local/bin/perl -wT

 ...some code here...

  &delete_data_file($project);


----

I would like to turn off taint checking because I need to do something
like:

	unlink <*.dat>;

But with -T, I can't.


Thanks.

Raymond


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

Date: Mon, 10 Mar 1997 19:24:03 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Say hi to the punk
Message-Id: <j7c2g5.uo.ln@localhost>

Luis Torres (ltorres@campus.ruv.itesm.mx) wrote:
: This punk is a self centered idiot who doesnt understand the concept of
: helping people...

As you are the only person associated with this message, I guess
you are referring to yourself. In that case:

Don't be so hard on yourself. We all have bad days...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 11 Mar 1997 11:32:26 +0800
From: bz7328113@ntuvax.ntu.ac.sg
Subject: Re: simple tutorial on writing perl cgi for NT
Message-Id: <Pine.PMDF.3.91.970311112718.656599941A-100000@ntuvax.ntu.ac.sg>

Hi! U can try to run the following perl script:
( Note : remember to put in this line : print "Content-type: text/html\n\n";
  This line is very important for displaying text in the browser. 
)

Hope it works for u. :)

kkchiang@pacific.net.sg

<----------------------------------------Cut here ----------------------->

print "Content-type: text/html\n\n";
print "<head>\n";
print "<title>hello, world</title>";
print "</head>\n";
print "<body>\n";
print "<h1>hello, world</h1>\n";
print "</body>\n"



On 10 Mar 1997, Webfirst wrote:

> my subject line asks the question.
> I am looking for a simple way to setup
> cgi using perl on windows nt. I keep getting the
> error 500 server error
> Message
> CGI OUTPUT  from c:/website/cgi-shl/script.pl contained no blank
> line separating header and data.
> 
> I have no idea what this means. the script.pl just
> contains
> 
> print "hello world\n";
> 
> 
> thanks
> sanjay
> spatel@webfirst.com
> please cc me if you can, thanks
> 
> 
> 


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

Date: 11 Mar 1997 00:17:46 GMT
From: viet@airmail.net
Subject: Re: Sort question
Message-Id: <viet-1003971823340001@dal20-29.ppp.iadfw.net>

It worked great, thanks a lot!

In article <33236453.404113654@news.oz.net>, tgy@chocobo.org (Tim Gim Yee)
wrote:

>On 9 Mar 1997 23:46:45 GMT, viet@airmail.net wrote:
>
>>How do I sort a list with elements: ("Dec96", "Nov96", "Jan97", "Feb97",
>>...) so that the latest the newest (Feb97) would come out first? I checked
>>a technique called Schwartian Transform but could not figure out how to
>>make it work with my list. Would somebody please help?
>
>I'll try.  The following snippet applies the Schwartian Transform to
>your problem.  HTH...
>
>---------------
>#!/usr/bin/perl
>
># Wanted to give the 'here docs' a try :)
>@array = split /\n/, <<KUPO;
>Dec96
>Nov96
>Jan97
>Feb97
>Aug96
>Feb92
>KUPO
>
># It was fun the first time.
># A hash:  Jan => 0, Feb => 1...
>%hash = map {ucfirst $_, $no++} split /\n/, <<LALI;
>jan
>feb
>mar
>apr
>may
>jun
>jul
>aug
>sep
>oct
>nov
>dec
>LALI
>
>@sorted = map  {$_->[0]} 
>          sort {$b->[2] <=> $a->[2] or $b->[1] <=> $a->[1]} 
>          map  {/(\w\w\w)(\d\d)/; [$_, $hash{$1}, $2]}
>          @array;
>
>-------------
>
>
>
>
>--
>Tim Gim Yee             tgy@chocobo.org
>http://www.chocobo.org/~tgy/moogle.html
>'po!

-- 

------------
Viet Hoang
viet@airmail.net


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

Date: 10 Mar 1997 23:42:42 GMT
From: afs@ludd.luth.se (Anders F{ltros)
Subject: WANTED: Perlscript for WebChat
Message-Id: <5g269i$990@news.luth.se>

Wanted: Perlscript for WebChat!
Some time ago there was a perlscript for a WebChat out here somewhere,
but now I can't find in anymore (might have been on WWW also..)
Can anyone help me find it again (or a similar ...)

Plese help me out!
/Anders
-- 
@------------------------ afs@ludd.luth.se -----------------------@


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

Date: 11 Mar 1997 01:04:56 GMT
From: stevens@adam.dseg.ti.com (Harold Stevens)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g2b3o$r2c@sf18.dseg.ti.com>

In article <5g1okc$n5e@asgard.actrix.gen.nz>, jjbicker@atlantis.actrix.gen.nz (John Bickers) writes:
|> In article <5g0s9b$ld@sf18.dseg.ti.com>, Harold Stevens <wyrd@ti.com> wrote:
|> 
|> > Thank you for injecting some sanity in an inane thread. I've been in the
|> > business 25 years and seen language/OS fads come and go with abandon. It

[Snip...]
 
|>     Is this a record for both left and right text alignment without
|>     inserted spaces or artificial filling?

Probably not. For inquiring minds, there's always DejaNews.   :)

FWIW: I'm looking to grab the KOTM moniker from Dimitri Vulis ASAP.  :)

I went round and round with Jeffrey Friedl <jfriedl@wg.omron.co.jp> today
in email over it. But I would prefer discussing comments on the *content*
rather than the *style* now, as I suggested to him earlier. So: how about
this March Madness thingee, or would anyone rather discuss the pursuit of
happiness via filthy lucre as our thread wanders out into tallgrass?  :)

						Regards, Weird
						(Harold Stevens)
						wyrd@ti.com


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

Date: 10 Mar 1997 19:49:32 GMT
From: jjbicker@atlantis.actrix.gen.nz (John Bickers)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g1okc$n5e@asgard.actrix.gen.nz>

In article <5g0s9b$ld@sf18.dseg.ti.com>, Harold Stevens <wyrd@ti.com> wrote:

> Thank you for injecting some sanity in an inane thread. I've been in the
> business 25 years and seen language/OS fads come and go with abandon. It

    Is this a record for both left and right text alignment without
    inserted spaces or artificial filling?


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 85
************************************

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