[13699] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1109 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 18 15:05:41 1999

Date: Mon, 18 Oct 1999 12:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940273514-v9-i1109@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 18 Oct 1999     Volume: 9 Number: 1109

Today's topics:
    Re: 'use FileHandle' fails if indirectly referenced fro (Kragen Sitaker)
    Re: .htaccess <emschwar@rmi.net>
    Re: Apache/mod_perl/ApacheDBI problem <dwb1@home.com>
    Re: Baffled! (Larry Rosler)
    Re: cgi - sending misc mime types (Kragen Sitaker)
    Re: encryption and crypt() ? (Kragen Sitaker)
    Re: encryption and crypt() ? (Larry Rosler)
    Re: FTP: The fastest most efficient way to do this? bsrinivas@my-deja.com
        help for functioin fork under win98 <artax@shineline.it>
    Re: help for functioin fork under win98 <dan@tuatha.sidhe.org>
        how to install a pm on at a not my server <yhm@inter.net.il>
    Re: how to install a pm on at a not my server <nguyend7@msu.edu>
    Re: how to install a pm on at a not my server (Kragen Sitaker)
    Re: Ignore the idiots <kbandes@home.com>
    Re: Need help -- How to display an existing web page (Michael Budash)
    Re: Oh god! Not another Net::ftp question! bsrinivas@my-deja.com
        Printing to STDERR -> Console AND filelog? <mshiltonj@yahoo.com>
    Re: Printing to STDERR -> Console AND filelog? (Kragen Sitaker)
    Re: Problem w/ PERL and SQL (Kragen Sitaker)
    Re: Problem w/ PERL and SQL <nguyend7@msu.edu>
    Re: Problem w/ PERL and SQL (Kragen Sitaker)
    Re: Q: Truncate string length? (Craig Berry)
    Re: Range checking (Neko)
    Re: Substituting Only Within Matched Substring <aqumsieh@matrox.com>
    Re: what is SHTML ? (Kragen Sitaker)
    Re: what is SHTML ? <jeff@vpservices.com>
    Re: what is SHTML ? <nguyend7@msu.edu>
    Re: what is SHTML ? (Larry Rosler)
    Re: what is SHTML ? <dchristensen@california.com>
    Re: Windows -> UNIX text problems (Kragen Sitaker)
    Re: Windows -> UNIX text problems bsrinivas@my-deja.com
    Re: Your quoting strategy and the Jeopardy game <dchristensen@california.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Oct 1999 17:18:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: 'use FileHandle' fails if indirectly referenced from a setuid script
Message-Id: <4EIO3.14499$E_1.855664@typ11.nn.bcandid.com>

In article <7uevog$bv2$1@nnrp1.deja.com>, aml  <andrew.mclaren@swx.ch> wrote:
>The current model we are investigating is to access this via a root
>Perl CGI script with setuid rights, which can then assume the identity
>of any user (and, yes, there are a heap of authentication issues that
>we are still working through here!). To retain the connection context,
>we are using a local daemon package that already exists in-house. This
>transparently provides a background process running in the initiators
>context, together with the communication channels between this daemon
>and its clients. The client can disappear and reappear, while the
>daemon retains the static application connections (typically with some
>inactivity timeout). A mock-up of this is running without the setuid
>rights.

Maybe you should use suEXEC or cgiwrap to run your CGI script as the
correct user.  This would require you to make one copy of the script
for each user, but that's not necessarily a big deal, especially if the
script you call looks like

#!/usr/bin/perl -Tw
do '/usr/local/ourapp/ourapp.cgi';

>Now the specific problems, and some questions;
>
>1)  Many of our internal packages are accessed via the PERL5LIB
>environment variable. It appears that as soon as a Perl script has
>setuid rights, PERL5LIB is no longer loaded into @INC on activation.
>While I can find nothing specific about this, I can understand why Perl
>behaves this way. Currently the PERL5LIB definitions are being loaded
>manually into @INC in a BEGIN block, prior to any of the packages being
>required. Is there any other way of handling this?

use lib 'dir1', 'dir2', 'dir3' is essentially equivalent to what you're
doing.

If you don't want to have to do that, you can recompile Perl and add
more directories to the standard @INC.

>2)   The package that provides the communication channels between the
>client and local daemon uses the FileHandle module to provide its
>communication primitives, which works perfectly outside setuid.
>However, as soon as setuid is set on the script, the following error is
>reported;
>
>    Can’t call method “import” without a package or object reference at
>….FileHandle.pm line 3
>Line 3 contains ‘use 5.003-11’

That's a little unusual.  I don't understand it.  But is it possible
your setuid perl (sperl) is a different version than your regular
perl?

HTH.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 18 Oct 1999 12:36:05 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: .htaccess
Message-Id: <xkfn1tgms8a.fsf@valdemar.col.hp.com>

kragen@dnaco.net (Kragen Sitaker) writes:
[about keyword searching]
> Also, it's deeply interwoven with domain knowledge.  If you think of
> ..htaccess as being one of many mechanisms for access control, searching
> for "access" seems relatively natural.  But if "access control" doesn't
> come to mind when you think of allow/deny rules, well, it's going to be
> a little more difficult.

This is why proper indexing is important, and why people get paid
inordinate amounts of money to create indexes for manuals-- it's a lot
more complicated than just grepping the text for words and corresponding
page numbers.  At least, if it's done right.

-=Eric
-- 
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
                -- Johnny Hart


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

Date: Mon, 18 Oct 1999 17:28:02 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Re: Apache/mod_perl/ApacheDBI problem
Message-Id: <Pine.LNX.4.10.9910181218200.9838-100000@cc569157-a.warn1.mi.home.com>

On Mon, 18 Oct 1999, Daniel W. Burke wrote:

> 
> 
> Hello,
> 
> I seem to be running into a problem with the ApacheDBI module.  When I
> try to use the module in httpd.conf, on startup I get an error from
> DynaLoader.pm, that it cannot load the DBI module.
> 
> When I built mod_perl, the "make test" gave me the similar error about
> loading File::IO, but I can load use File::IO without any trouble in
> a normal script, which is the confusing part.  (And I do have other
> scripts that communicate with our oracle database no trouble).  This 
> is the error apache gives on bootup:
> 

I forgot to mention that this is running on sun 5.5.1, with mod_perl 1.21,
apache 1.3.9, and apachedbi .87.  

Dan.




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

Date: Mon, 18 Oct 1999 11:05:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Baffled!
Message-Id: <MPG.1275013e52d5451198a0b7@nntp.hpl.hp.com>

In article <7uf83t$b4o@atle.abc.se> on 18 Oct 1999 15:42:21 +0200, Bror 
Hellman <m8100@abc.se> says...

 ...

> @barfoo = split('.',$incoming_name);

 ...

> Why can I split on an 's' and a '/' but not at a '.'???

A few weeks ago, I suggested that the use of a literal string as the 
first argument to split() should draw a warning.  If that were the case 
(and assuming the programmer used '-w'), this incessant problem *might* 
go away!

Sometimes I think Perl people enjoy the little 'gotchas', rather than 
working to eliminate them.

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


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

Date: Mon, 18 Oct 1999 17:36:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: cgi - sending misc mime types
Message-Id: <fUIO3.14566$E_1.857981@typ11.nn.bcandid.com>

In article <380ADBBE.9994AFD6@t-online.de>,
Henning Bekel  <h.bekel@t-online.de> wrote:
>print "content-type : audio/x-mpegurl \n\n http://xyz.com/xyz/test.mp3"
>
>to the Web Browser, but it only recieves a text/html file, no matter if
>i define that mime type in my local server or not...

Ask on a CGI newsgroup, please.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 18 Oct 1999 18:09:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: encryption and crypt() ?
Message-Id: <JnJO3.14697$E_1.861761@typ11.nn.bcandid.com>

In article <Pine.GSO.4.10.9910171157310.25558-100000@user2.teleport.com>,
Tom Phoenix  <rootbeer@redcat.com> wrote:
>On Sun, 17 Oct 1999, Martin Vorlaender wrote:
>
>> Should one just warn against such violations of the calling standard,
>> or try to do something about it?
>
>I'd say: Don't sweat it too much. I was thinking of checking only that
>there are actually two args, and maybe that the salt is at least two chars
>long.

Checking the second will probably break most scripts that call crypt(),
because most of them pass the whole password entry.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 18 Oct 1999 11:59:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: encryption and crypt() ?
Message-Id: <MPG.12750deb490f435198a0b9@nntp.hpl.hp.com>

In article <JnJO3.14697$E_1.861761@typ11.nn.bcandid.com> on Mon, 18 Oct 
1999 18:09:45 GMT, Kragen Sitaker <kragen@dnaco.net> says...
> In article <Pine.GSO.4.10.9910171157310.25558-100000@user2.teleport.com>,
> Tom Phoenix  <rootbeer@redcat.com> wrote:
> >On Sun, 17 Oct 1999, Martin Vorlaender wrote:
> >> Should one just warn against such violations of the calling standard,
> >> or try to do something about it?
> >
> >I'd say: Don't sweat it too much. I was thinking of checking only that
> >there are actually two args, and maybe that the salt is at least two chars
                                                           ^^^^^^^^
> >long.
> 
> Checking the second will probably break most scripts that call crypt(),
> because most of them pass the whole password entry.

As they should, because why waste a useless substr?  But you overlooked 
the 'at least' in TomP's response, which is of course correct.  Nothing 
should break.

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


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

Date: Mon, 18 Oct 1999 18:06:39 GMT
From: bsrinivas@my-deja.com
Subject: Re: FTP: The fastest most efficient way to do this?
Message-Id: <7ufnj6$ruf$1@nnrp1.deja.com>

In article <7uere9$9g4$1@nnrp1.deja.com>,
  Richard Lawrence <ralawrence@my-deja.com> wrote:
> Oops, I meant to type "since this function will be called [a couple of
> hundred times and the user will be sitting there waiting for the
> results] I need it to be ..."

Take a look at Net::FTP module. This may help you.

-Srinivas


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 16 Oct 1999 17:21:18 +0200
From: "Federico" <artax@shineline.it>
Subject: help for functioin fork under win98
Message-Id: <7ufjfh$dvr$5@fe2.cs.interbusiness.it>

 .... when i try to use the fork function with the Win98 Perl 5 compiler this
error message compares: "the Unsupported fork functioin is unimplemented at
line...". Why? How can i do?

Thank you, Federico.




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

Date: Mon, 18 Oct 1999 20:10:34 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: help for functioin fork under win98
Message-Id: <_8LO3.1489$IZ5.22811@news.rdc1.ct.home.com>

Federico <artax@shineline.it> wrote:
> .... when i try to use the fork function with the Win98 Perl 5 compiler this
> error message compares: "the Unsupported fork functioin is unimplemented at
> line...". Why? How can i do?

Because Windows can't fork, and you're out of luck. Try another approach.

					Dan


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

Date: Mon, 18 Oct 1999 19:02:54 +0200
From: "Yuval Hamberg" <yhm@inter.net.il>
Subject: how to install a pm on at a not my server
Message-Id: <7ufk75$98p$1@news2.inter.net.il>

I have a free account at www.virtualave.net . I would like to use a pm file.
is there a way I can install it without accessing the perl directory?
I have only FTP not telnet or something else and they use Unix.

I think I can't so what sould I do. take the part I need from the pm and
post it in my perl file? will it work? and will it work good?

thanks




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

Date: 18 Oct 1999 17:32:14 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: how to install a pm on at a not my server
Message-Id: <7ufliu$lk5$3@msunews.cl.msu.edu>

Yuval Hamberg <yhm@inter.net.il> wrote:
: I have a free account at www.virtualave.net . I would like to use a pm file.
: is there a way I can install it without accessing the perl directory?
: I have only FTP not telnet or something else and they use Unix.

Well if your trying need the Perl module for a cgi script, are you
even sure you have cgi access?  

If it's not a cgi script.  How do you expect to run anything?

-- 
       Dan Nguyen          | It is with true love as it is with ghosts;
    nguyend7@msu.edu       | everyone talks of it, but few have seen it.
     dnn@debian.org        |               -Maxime De La Rochefoucauld
            25 2F 99 19 6C C9 19 D6  1B 9F F1 E0 E9 10 4C 16


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

Date: Mon, 18 Oct 1999 17:44:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to install a pm on at a not my server
Message-Id: <H%IO3.14594$E_1.858594@typ11.nn.bcandid.com>

In article <7ufk75$98p$1@news2.inter.net.il>,
Yuval Hamberg <yhm@inter.net.il> wrote:
>I have a free account at www.virtualave.net . I would like to use a pm file.
>is there a way I can install it without accessing the perl directory?
>I have only FTP not telnet or something else and they use Unix.
>
>I think I can't so what sould I do. take the part I need from the pm and
>post it in my perl file? will it work? and will it work good?

See perlfaq8, "How do I keep my own module/library directory?", which
answers this better than I could.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 18 Oct 1999 13:29:59 -0400
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: Ignore the idiots
Message-Id: <380B5917.CB0CFDD3@home.com>

> Ignore Abigail - People like him make this place a whole lot more
> intimidating to use (which is their intent, I think). I mean what hell
> is this forum for if you can't ask a simple Perl question like you did?

Maybe for not-so-simple questions that you can't easily answer
yourself.

I used to feel that way too - I was quite taken aback at first at
the nastiness, and I still feel it's kind of over-the-top.

But right now, my news reader tells me I've 785 unread posts in clpm.
That's a lot of dirt to root through to get to the few truffles of
really intelligent, thoughtful posts (and by the way, many of those
come from Abigail among others).  Just taking the time to figure out 
which posts are worthwhile and which are not would probably lose me
my job or my marriage.  A little more homework and self-editing by
people with simple Perl questions would make this a much more
useful group.

Ken Bandes


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

Date: Mon, 18 Oct 1999 10:26:38 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Need help -- How to display an existing web page
Message-Id: <mbudash-1810991026380001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>

In article <Pine.GS4.4.10.9910180955170.93-100000@pan.as.utexas.edu>,
Michael Yuan <juntao@pan.as.utexas.edu> wrote:

>Hi, I am quite new here. So, excuse me if I am asking a dumb question, but
>I do need your help ...
>
>The problem is that I have a set of  existing web pages. It is a folder
>containing several .html files and several .jpg images. All the links and
>images are inside this folder using relative paths. So, there is no
>problem to display them if I install them under "test" directory under my
>document root and point the browser to http://whatever.edu/test/index.html
>
>However, I want to use a perl script to display them (I do not want the
>user to see its path). I can write one to read "test/index.html" and print
>line-by-line to the browser and see all the text from index.html But since
>the relative paths to images and other html files are not correct (I am in
>cgi-bin not test directory, I believe), the images and links are broken. 
>
>Can anyone tell me how to do that? Your help is appreciated.
>
>Michael 

either use your script to insert an appropriate <BASE HREF='...'> in the
html file, or change the links to be absolute rather than relative.

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Mon, 18 Oct 1999 17:55:47 GMT
From: bsrinivas@my-deja.com
Subject: Re: Oh god! Not another Net::ftp question!
Message-Id: <7ufmut$rht$1@nnrp1.deja.com>

In article <7ueu21$au9$1@nnrp1.deja.com>,
  Richard Lawrence <ralawrence@my-deja.com> wrote:
> Hello there,
>
> Following a previous post I'm using net::ftp to validate a list of ftp
> sites. I've got a bit of code (easily enough) but have several
> questions I was wondering if anyone could help me with. I've looked at
> the Net::FTP docs, the FAQ for it and search deja unsucessfully.
>
> #!/usr/bin/perl
> use Net::FTP;
> $ftp = Net::FTP->new("mysite.com", Port => 21);
>
> Q: How do I add other variables onto the end of this (such as the
> timeout option)? All my efforts have been rewarded with compiler
errors.
>
For time out, this should work:

$ftp = Net::FTP->new("mysite.com", Port => 21, TIMEOUT=>60);
if ($ftp->response()==CMD_OK) {
  print "Every thing is okay...\n";
  print join("\n",$ftp->ls());
} else {
  print "Can not connect to mysite.com with the specified time\n";
}

Hope this helps.

-Srinivas


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 18 Oct 1999 17:27:38 GMT
From: M Steven Hilton Jr <mshiltonj@yahoo.com>
Subject: Printing to STDERR -> Console AND filelog?
Message-Id: <7ufl9u$qbu$1@nnrp1.deja.com>

I would like to make messages printed to STDERR go to both the console
and to a log file. Is there a way to do this?


--
M. Steven Hilton, Jr. <mshiltonj@yahoo.com>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 18 Oct 1999 17:54:29 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Printing to STDERR -> Console AND filelog?
Message-Id: <p9JO3.14632$E_1.859960@typ11.nn.bcandid.com>

In article <7ufl9u$qbu$1@nnrp1.deja.com>,
M Steven Hilton Jr  <mshiltonj@yahoo.com> wrote:
>I would like to make messages printed to STDERR go to both the console
>and to a log file. Is there a way to do this?

See perlfaq5, "How do I print to more than one file at once?", which
answers the question better than I could.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 18 Oct 1999 17:08:09 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problem w/ PERL and SQL
Message-Id: <ZtIO3.14464$E_1.853723@typ11.nn.bcandid.com>

In article <380b6397.2603734@news.vnet.net>,  <mirak63@yahoo.com> wrote:
>I know this may not be the right forum for this question
>and if it isn't please direct me to a NG that is better suited...
>
>When I push a scaler in to a SQL database (SQL 7)
>the data shows up OK. However, when I retrieve the same 
>data using PERL, the data is truncated to 255 characters.
>
>Does anyone have any ideas as to why?

Many databases have arbitrary limits on the size of data you can store
in them.  (It's called the "80-column mind" syndrome.)  Some SQL
interfaces also have arbitrary limits on the size of data that can be
passed each way.  You should try to figure out whether it's sending the
data to the database, storing the data in the database, or retrieving
the data from the database that causes the problem.

It sounds like you're sure it's the third, because you've retrieved the
data by other means.  Are you linking via ODBC, or native DBD, or what?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 18 Oct 1999 17:30:05 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: Problem w/ PERL and SQL
Message-Id: <7uflet$lk5$2@msunews.cl.msu.edu>

mirak63@yahoo.com wrote:
: When I push a scaler in to a SQL database (SQL 7)
: the data shows up OK. However, when I retrieve the same 
: data using PERL, the data is truncated to 255 characters.

I wonder why people assume MSSQL 7 is the only relational database
that uses sql?


-- 
       Dan Nguyen          | It is with true love as it is with ghosts;
    nguyend7@msu.edu       | everyone talks of it, but few have seen it.
     dnn@debian.org        |               -Maxime De La Rochefoucauld
            25 2F 99 19 6C C9 19 D6  1B 9F F1 E0 E9 10 4C 16


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

Date: Mon, 18 Oct 1999 17:46:28 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problem w/ PERL and SQL
Message-Id: <U1JO3.14603$E_1.858419@typ11.nn.bcandid.com>

In article <7uflet$lk5$2@msunews.cl.msu.edu>,
Dan Nguyen  <nguyend7@msu.edu> wrote:
>mirak63@yahoo.com wrote:
>: When I push a scaler in to a SQL database (SQL 7)
>
>I wonder why people assume MSSQL 7 is the only relational database
>that uses sql?

Probably because the database is called "SQL Server".  Microsoft tries
to name many of their products generically: "Windows", "DOS", "Word".
If they made a car, it would be called "Microsoft Transit", and people
would talk about getting to work by "transit", meaning the Microsoft car.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 18 Oct 1999 17:46:50 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Q: Truncate string length?
Message-Id: <s0mn8aur0186@corp.supernews.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote:
: <cberry@cinenet.net>],
: who wrote in article <s0l9hfeer0160@corp.supernews.com>:
: > You have it, right there...what do you think should go next?  If you mean
: > how do you make it apply back to $TheField, just assign the value:
: > 
: >   $TheField = substr($TheField, 0, 500);
: 
: I would think it is *ways* better do it the other way around:
: 
:    substr($TheField, 500) = "";

Seemed plausible, but Benchmark disagrees with you:

#!/usr/bin/perl -w
# trunc - benchmark different ways of truncating a string
# Craig Berry (19991018)

use strict;
use Benchmark;

my $sample = 'a' x 1000;

timethese(10000, {
  substr_rv     => sub {
                     $_ = $sample;
                     $_ = substr($_, 0, 500);
                   },
  substr_lv     => sub {
                     $_ = $sample;
                     substr($_, 500) = '';
                   },
  substitute    => sub {
                     $_ = $sample;
                     s/(.{0,500}).*/$1/s;
                   },
  match         => sub {
                     $_ = $sample;
                     ($_) = m/(.{0,500})/;
                   }
});

__END__


Benchmark: timing 10000 iterations of match, substitute, substr_lv,
substr_rv...
     match:  5 secs ( 4.99 usr  0.00 sys =  4.99 cpu)
substitute: 12 secs ( 6.23 usr  0.00 sys =  6.23 cpu)
 substr_lv:  3 secs ( 2.51 usr  0.00 sys =  2.51 cpu)
 substr_rv:  3 secs ( 2.52 usr  0.00 sys =  2.52 cpu)

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: Mon, 18 Oct 1999 10:34:58 -0700
From: tgy@chocobo.org (Neko)
Subject: Re: Range checking
Message-Id: <pUYLOM6e4i2Uch2AUc1C97Gvaf0=@4ax.com>

On 18 Oct 1999 03:06:38 -0400, Uri Guttman <uri@sysarch.com> wrote:

>>>>>> "N" == Neko  <tgy@chocobo.org> writes:
>
>  N> On Sun, 17 Oct 1999 11:49:19 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>
>  >> if ($min < $x && $x <= $max)
>  >> Short of the seven superfluous spaces, no one will beat par on this 
>  >> hole.
>
>  N>    if ($min < $x & $x <= $max)
>
>  N> What do I win? :)
>
>a whack on the nose with larry's 2 iron. that isn't the same logic as
>his short circuits and yours doesn't. i see the :) so i think you know
>that. 

Yes.  But in Perl golf, the only efficiency that counts is the number of
strokes it takes to roll the little ball into the cup.

>in this case with no (obvious) side effects that is fine. what if
>any of those scalars were tied with hidden side effects? 

Then the '&&' and '&' conditionals would both still evaluate to the same
values.  Any side effects would be outside the conditional.  But if we are
allowed to redesign the golf course, I can just as easily overload '<', '&&',
and '<=' to send Larry's drive into a water hazard. :)

>if you wrote
>that for real i would join larry in beating you to a pulp.

If I ever find myself on a real golf course with you and Larry, I will be
sure to invite Matt Wright to make it a foursome. :)

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: Mon, 18 Oct 1999 11:38:25 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Substituting Only Within Matched Substring
Message-Id: <x3yvh84brwv.fsf@tigre.matrox.com>


Jim Monty <monty@primenet.com> writes:

> There's gotta be a better way to do this:
> 
>     if (/^(\S+\s+)(\S.*  .*)/s) {
>         ($label, $value) = ($1, $2);
>         $value =~ s/  +/ /g;
>         $_ = $label . $value;
>     }
> 
> What is it?

You seem to want to compress all occurrences of consecutive white
spaces (except for the first one) into a single space. Perlfaq4 has
something helpful:

	How do I change the Nth occurrence of something?

which led me to this:

	{ my $n = 0; s/(\s+)/++$n > 1 ? " " : $1/ge; }

I had to use one temp. variable, $n. 

HTH,
--Ala



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

Date: Mon, 18 Oct 1999 17:08:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: what is SHTML ?
Message-Id: <zuIO3.14467$E_1.853799@typ11.nn.bcandid.com>

In article <380BF886.71538C91@shinbiro.com>,
Ally Kwon  <ewha95@shinbiro.com> wrote:
>i know what HTML is, but what is SHTML ?
>how is it different from HTML ?

They are similar in that both are off-topic in this newsgroup.  See
your web-server's documentation for details.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 18 Oct 1999 16:43:12 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: what is SHTML ?
Message-Id: <380B4E01.D748F54A@vpservices.com>

Ally Kwon wrote:
> 
> i know what HTML is, but what is SHTML ?
> how is it different from HTML ?

Hmm, I wonder what makes you think that those are appropriate questions
for comp.lang.perl.misc since they do not, by the longest stretch of the
imagination, have anything to do with Perl.  Do you think that maybe a
newsgroup having something to do with HTML might be a better place to
ask?  Or even better, what happens when you type the magic words "what
is SHTML" in a search engine?  Mine gives me a pointer to about a dozen
pages on the web that answer the question.

-- 
Jeff


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

Date: 18 Oct 1999 17:28:23 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: what is SHTML ?
Message-Id: <7uflbn$lk5$1@msunews.cl.msu.edu>

Jeff Zucker <jeff@vpservices.com> wrote:
: Ally Kwon wrote:
:> 
:> i know what HTML is, but what is SHTML ?
:> how is it different from HTML ?

: Hmm, I wonder what makes you think that those are appropriate questions
: for comp.lang.perl.misc since they do not, by the longest stretch of the
: imagination, have anything to do with Perl.

Perhaps c.l.p.m should be renamed
comp.lang.perl.misc.not.html.not.webservers.not.general.cgi.aka.rtfm.or.rtff 


-- 
       Dan Nguyen          | It is with true love as it is with ghosts;
    nguyend7@msu.edu       | everyone talks of it, but few have seen it.
     dnn@debian.org        |               -Maxime De La Rochefoucauld
            25 2F 99 19 6C C9 19 D6  1B 9F F1 E0 E9 10 4C 16


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

Date: Mon, 18 Oct 1999 11:12:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: what is SHTML ?
Message-Id: <MPG.127503085ec4047c98a0b8@nntp.hpl.hp.com>

In article <380BF886.71538C91@shinbiro.com> on Tue, 19 Oct 1999 00:50:14 
-0400, Ally Kwon <ewha95@shinbiro.com> says...
> i know what HTML is, but what is SHTML ?
> how is it different from HTML ?

And your Perl question is?  (Thanks, Abigail.)

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


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

Date: Mon, 18 Oct 1999 12:12:37 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: what is SHTML ?
Message-Id: <380b6daa_5@news5.newsfeeds.com>

Ally:

>i know what HTML is, but what is SHTML ?

I think it is an acronym for "scripted HTML" -- e.g. an html page
that contains scripting code.  You name your file foo.shtml to
alert your web server that it needs to interpret the page and not
just send it.

--
David Christensen
dchristensen@california.com





  -----------== 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: Mon, 18 Oct 1999 17:32:03 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Windows -> UNIX text problems
Message-Id: <nQIO3.14549$E_1.857210@typ11.nn.bcandid.com>

In article <7ufj5c$oq6$1@nnrp1.deja.com>,
Richard Lawrence  <ralawrence@my-deja.com> wrote:
>Hello there, I wonder if anyone can help.
>
>I have a Windows program that connects to a webpage and downloads its
>contents for processing. These contents are generated by a perl program
>running on the server.
>
>Now when it is downloaded the file looks exactly like the sort of file
>you'd get if you downloaded a text file in BIN mode. The CR's are
>screwed up because of the difference in the way Windows and UNIX
>handles them.

You should probably add CRs before the NLs then.

>Is there any way I can get my perl program to output the text in a
>"Windows friendly" format for downloading? I tried to manually add CR
>and LF to the end of each line with:
>
>#!/usr/bin/perl -w
>use strict;
>open (FILE, ">file.txt") || die "can't write to file.txt: $!";
>print FILE "hello\13\10";
>print FILE "there\13\10";
>close FILE;
>
>but when I sent the file across this didn't work.

Unless you binmode the filehandle, all \n's (aka ASCII 10, \0a) you
write to it will be translated to \r\n (aka ASCII 13 10, \0d\0a).

Writing \13 (control-N, ASCII 11) and \10 (control-H, backspace, ASCII
8) will make matters worse :)

Suggested solution:
- open the file.
- open another file for output.
- read lines from the first file; write them to the second file.

You can do this with 'perl -pe "" infile > outfile', at least in bash.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 18 Oct 1999 18:03:27 GMT
From: bsrinivas@my-deja.com
Subject: Re: Windows -> UNIX text problems
Message-Id: <7ufnd7$rlf$1@nnrp1.deja.com>

Not knowing what is your windows program doing exactly it would be
difficult to guess where the problem is.

> Now when it is downloaded the file looks exactly like the sort of file
> you'd get if you downloaded a text file in BIN mode. The CR's are
> screwed up because of the difference in the way Windows and UNIX
> handles them.

But you can try this in your perl script:

print "my information\r\n";

Notice the "\r" instead of "\13" etc....Hope this helps.

-Srinivas


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 18 Oct 1999 11:28:46 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Your quoting strategy and the Jeopardy game
Message-Id: <380b635f_5@news5.newsfeeds.com>

comp.lang.perl.misc:

>    To send better messages, please trim and summarize what you're
replying to, and integrate your quoted text with the body of your
message. Don't just put everything at the end.

I plead guilty, with the following explanation:  Sometimes when I'm
searching through newsgroups and/or archives, I come across very
interesting replies but can't find the original. Replies with the
complete, unaltered original are far more useful in such cases.
Therefore, I sometimes leave the original at the end of my reply --
the original is not "too long", it contains a bunch of nitty-gritty
info, I'm giving a short answer, etc..



Should I abandon the above considerations and always follow the
guidelines?

--
David Christensen
dchristensen@california.com







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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 1109
**************************************


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