[16820] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4232 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 6 03:05:31 2000

Date: Wed, 6 Sep 2000 00: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: <968223915-v9-i4232@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4232

Today's topics:
    Re: "list" vs "array" (was: @_ as array) <anmcguire@ce.mediaone.net>
        A question about sleep(). <idleisidle@usa.net>
    Re: A question about sleep(). <wyzelli@yahoo.com>
    Re: A question about sleep(). (Martien Verbruggen)
    Re: Alarm function and cgi.pm <garry@zvolve.com>
    Re: cookies and SSI's <elephant@squirrelgroup.com>
    Re: Date format (Thorfinn)
    Re: dates Calculations <lr@hpl.hp.com>
        DBD:Oracle - building <Henrik.Springfors@klinfys.lu.se>
    Re: DBD:Oracle - building (Martien Verbruggen)
    Re: How to get my IP address as a string <lr@hpl.hp.com>
    Re: HTML::parse bug <elephant@squirrelgroup.com>
        memory leak perl_call_argv <y.baillet@traian.de>
        OT: News group app required <derek@realware.com.au>
    Re: OT: News group app required <ddorward@hotmail.com>
    Re: Pattern matching <lr@hpl.hp.com>
    Re: Perl -P switch (Rafael Garcia-Suarez)
    Re: Relative path on NT? <elephant@squirrelgroup.com>
    Re: Remove carriage returns from input <elephant@squirrelgroup.com>
    Re: Stable sorting <lr@hpl.hp.com>
    Re: Stable sorting (Abigail)
    Re: Stable sorting (Abigail)
    Re: translation! <elephant@squirrelgroup.com>
    Re: translation! (Gwyn Judd)
    Re: using the value of a variable for another varible's (Gwyn Judd)
    Re: using the value of a variable for another varible's <uri@sysarch.com>
    Re: using the value of a variable for another varible's (Gwyn Judd)
    Re: using the value of a variable for another varible's <uri@sysarch.com>
    Re: weird behavior of _ file handle <uri@sysarch.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 5 Sep 2000 23:23:58 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: "list" vs "array" (was: @_ as array)
Message-Id: <Pine.LNX.4.21.0009052311260.2693-100000@hawk.ce.mediaone.net>

On 5 Sep 2000, nobull@mail.com quoth:

~~ Date: 05 Sep 2000 12:37:05 +0100
~~ From: nobull@mail.com
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: "list" vs "array" (was: @_ as array)
~~ 
~~ dkcombs@netcom.com (David Combs) writes:
~~ 
~~ > Am confused about terminology: what is the difference
~~ > between a "list" and an "array"?
~~ 
~~ Please see FAQ: "What is the difference between a list and an array?"
~~ 
~~ > Does "list" refer ONLY to a "LITERAL" thing, eg
~~ >    (10, 20, "foo", (4, 5))
~~ 
~~ No.  The above is an expression.  So is foo(). 
~~ 
~~ In Perl an expression is evaluated in a list, scalar or void context.
~~ (Actually scalar subdivides into untyped-scalar, string, numeric, boolean
~~ and maybe some others).
~~ 
~~ If any expression is evaluated in a list context then it's a list.
~~ 
~~ Your above expression could be evaluated in a scalar context in which
~~ case it would just be a long way to write the scalar literal 5.
~~ 
~~ > When you ASSIGN a list (as above) to a variable, then
~~ > regardless of how you do it, you then have an ARRAY (or
~~ > ref to one)?
~~ 
~~ Yes.

[ snip ]

I do not think that is correct, what about:

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

my %hash = 1 .. 100;
print map "$_\n" => sort keys %hash;
__END__

anm
-- 
Andrew N. McGuire
anmcguire@ce.mediaone.net
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'



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

Date: Tue, 5 Sep 2000 23:56:43 -0500
From: "Ben Ben" <idleisidle@usa.net>
Subject: A question about sleep().
Message-Id: <N8kt5.467$Aq4.9243@vixen.cso.uiuc.edu>

Can anyone tell me how function sleep() works?
I use Active Perl on Win9X.
I have a perl program, and when I run it, it just likes dead rather than
sleep.
Could someone explain it for me?

#!/usr/local/bin/perl
print "Content-type:text/html\n\n";
print "<html>\n";
print "<head><title></title></head>\n";
print "<BODY BGCOLOR=\"#EEEEEE\">\n";
$I=1;
$K=1;
while ($I>0)
{
 print "$K<br>";
 sleep 100;
 $K=$K+1;
}
print "</body></html>";





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

Date: Wed, 6 Sep 2000 14:57:52 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: A question about sleep().
Message-Id: <LNkt5.41$%K.2439@vic.nntp.telstra.net>

"Ben Ben" <idleisidle@usa.net> wrote in message
news:N8kt5.467$Aq4.9243@vixen.cso.uiuc.edu...
> Can anyone tell me how function sleep() works?
> I use Active Perl on Win9X.
> I have a perl program, and when I run it, it just likes dead rather
than
> sleep.
> Could someone explain it for me?

sleep 100; # sleep 100 seconds.

> #!/usr/local/bin/perl
> print "Content-type:text/html\n\n";
> print "<html>\n";
> print "<head><title></title></head>\n";
> print "<BODY BGCOLOR=\"#EEEEEE\">\n";
> $I=1;
> $K=1;
> while ($I>0)

Is $I ever not > 0? (ie this while loop will run forever).

> {
>  print "$K<br>";
>  sleep 100;
>  $K=$K+1;
> }

So you never get to here...

> print "</body></html>";


Wyzelli




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

Date: Wed, 06 Sep 2000 05:49:02 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: A question about sleep().
Message-Id: <slrn8rbmlu.2cp.mgjv@verbruggen.comdyn.com.au>

On Tue, 5 Sep 2000 23:56:43 -0500,
	Ben Ben <idleisidle@usa.net> wrote:
> Can anyone tell me how function sleep() works?
> I use Active Perl on Win9X.
> I have a perl program, and when I run it, it just likes dead rather than
> sleep.

What do you mean? 'just likes dead'? It helps if you formulate a
problem as clearly as possible.

> Could someone explain it for me?

The documentation can (accessible with perldoc, or if you have the
ActiveState installation, as html from some menu entry somewhere).

# perldoc -f sleep
=item sleep EXPR

=item sleep

Causes the script to sleep for EXPR seconds, or forever if no EXPR.
[snip]

> #!/usr/local/bin/perl

no -w, and no use strict. You should really start using those.

> print "Content-type:text/html\n\n";
> print "<html>\n";
> print "<head><title></title></head>\n";
> print "<BODY BGCOLOR=\"#EEEEEE\">\n";

You could do all this with a here document (check the perldata
documentation).

> $I=1;
> $K=1;

capitalised variables are generally not used for these sorts of
things, because they 'say' something special to programmers. Just use
lowercase (read the perlstyle documentation).

> while ($I>0)

This will never terminate. You are aware of that? You never change $I.

> {
>  print "$K<br>";
>  sleep 100;

This will sleep for 100 seconds.

>  $K=$K+1;

$K++; # is a bit more idiomatic.

> }
> print "</body></html>";

This will never be printed, because you never get out of the loop.

So, the program above will print some stuff to STDOUT, then go into a
never-ending loop, printing to STDOUT a number followed by <br> every 100
seconds.

You may be running into buffering problems with the CGI interface, but
that has nothing to do with Perl, or with any language. It's a CGI
thing.  perlfaq part 5 talks about how to unbuffer filehandles, and
you could visit one of the comp.infosystems.www.* groups to talk about
how to create CGI-type scripts that provide 'continuous' output like
you seem to want to do.

You should probably also use something like www.deja.com to find some
articles in this group, as well as in the comp.infosystems.www
hierarchy about this.

One other word of advice: If you want to test things, test them with
scripts that don't run through a web server via the CGI. That mode of
running brings its own problems and caveats with it, which have
nothing to do with Perl. So, next time you have a problem like this,
read perlfaq part 9, then read the documentation of the thing you have
problems with, then follow the advice in perl faq 9. Then, if you
still have troubles, write a little standalone piece of code that
shows the problem that is _not_ a CGI script, and submit it to this
group. If you can't get the problem to appear in a script that doesn't
use the CGI, then you should be posting to one of the groups in
comp.infosystems.www.*

Just to repeat how you get the documentation:

# perldoc perldoc
# perldoc -f function
# perldoc -q question
# perldoc perl
# perldoc perlfaq
# perldoc perlfaq9
# perldoc Module

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  | 


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

Date: Wed, 6 Sep 2000 00:38:45 -0400
From: "Garry T. Williams" <garry@zvolve.com>
Subject: Re: Alarm function and cgi.pm
Message-Id: <Pine.SOL.4.21.0009060025530.15722-100000@ifr>

On Wed, 6 Sep 2000 xlr6drone@my-deja.com wrote:

> The Apache server I work with runs Perl 5.6.0
> 
> I'm trying to get a basic script to work that uses cgi.pm (it's one of
> the scripts from Lincoln Stein's book CGI.pm)
> 
> He mentioned in the book that some servers may not be able handle the
> alarm fucntion.  When I tried running the script I got the following
> errors from the server logs.
> 
> ----------
> 
> Too many arguments for lock at /users/www/domains/mcreative.com/cgi-bin/
> cgipm/guestbook.pl line 102, near "1)"
> 
> Too many arguments for lock at /users/www/domains/mcreative.com/cgi-bin/
> cgipm/guestbook.pl line 126, near "0)"
 ...
> Could lack of support for the alarm function be the culprit 

No.  

>                                                             or is it
> somehting else.  

Yes.  

>                  Here is the code for the script.  Any suggestions would
> be greatly appreciated.

1.  Use -w  

2.  use strict;

3.  perldoc -f lock (which seems to be incorrect)

4.  Don't use threaded perl

5.  Move the lock function to appear before you call it.  

 ...
> #!/usr/bin/perl
> # guestbook.pl
> 
> require 'CGI.pm';
> 
> use CGI qw/:standard :html3 :netscape/;
> use POSIX;
 ...
> sub write_guestbook {
>     my $fh = lock($GUESTBOOKFILE,1);
>     unless ($fh) {
 ...
> sub view_guestbook {
> 
>     print start_form,
>           submit(-name=>'Sign Guestbook'),
>           end_form
>           unless param('name');
> 
>     my $fh = lock($GUESTBOOKFILE,0);
> 
>     my @rows;
 ...
> sub lock {
>     my $path = shift;
>     my $for_writing = shift;
> 
>     my ($lock_type,$path_name,$description);
>     if ($for_writing) {
>         $lock_type = LOCK_EX;
>         $path_name = ">>$path";
>         $description = 'writing';
 ...



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

Date: Wed, 6 Sep 2000 15:16:11 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: cookies and SSI's
Message-Id: <MPG.1420620235904669989767@localhost>

Keith Calvert Ivey <kcivey@cpcug.org> wrote ..
>jason <elephant@squirrelgroup.com> wrote:
>>James Philip Ryan <jpryan@labs.tamu.edu> wrote ..
>
>>>The CGI::Cookie manual said the path was being set as "/" by default; I didn'
>>>consider that to be the problem.  Thanks for your help...  you rock
>>
>>hmm .. dunno which version that is .. but mine says that it's set to the 
>>full name of the script that sets the cookie by default
>>
>>if the PATH was '/' then EVERY script would have access to it
>
>Which is the way cookies are often set.  Version 1.06 of
>CGI::Cookie says
>
>    B<-path> points to a partial URL on the current server.  
>    The cookie will be returned to all URLs beginning with the
>    specified path.  If not specified, it defaults to '/', 
>    which returns the cookie to all pages at your site.
>
>It's the same in version 1.16.  It seems strange that the
>default would have been changed.

stranger still is that between v1.06 and v1.16 it was different from 
what you state it was in each of those versions

in CGI::Cookie v1.12 it says this

3. path
    If you provide a cookie path attribute, the browser will check it
    against your script's URL before returning the cookie. For example,
    if you specify the path "/cgi-bin", then the cookie will be returned
    to each of the scripts "/cgi-bin/tally.pl", "/cgi-bin/order.pl", and
    "/cgi-bin/customer_service/complain.pl", but not to the script
    "/cgi-private/site_admin.pl". By default, the path is set to your
    script, so that only it will receive the cookie.

moreover .. it is undeniable that the problem of a cookie not being 
visible to one script but visible to another would *not* have been a 
problem for the originator if the PATH attribute was actually being set 
to '/' because in that case - all scripts would have been able to access 
that cookie

I've just checked the documentation in the CGI module .. and this states 
what you state above - that the default is '/'

but .. I've tested the feature itself with v1.12 of CGI::Cookie and it 
certainly does set a non-supplied path to the name of the current script 
and *not* to '/' .. but then in 1.16 it's setting it to '/'

are you sure about that 1.06 thing ? .. LDS must have been in a very 
indecisive mood .. I think that the '/' behaviour is less helpful - it's 
much easier to set it to '/' manually if that loose behaviour is what 
you want .. but marginally less simple to set it to the current script 
name .. anyway

  [ lines exceeding 80 chars truncated ]

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 6 Sep 2000 05:38:45 GMT
From: thorfinn@netizen.com.au (Thorfinn)
Subject: Re: Date format
Message-Id: <slrn8rbm35.gkp.thorfinn@netizen.com.au>

In comp.lang.perl.misc, on Mon, 04 Sep 2000 09:09:57 GMT
jason <elephant@squirrelgroup.com> wrote:
> basically the $yy-100 will work for 2000 up to 2099 .. but in 2100 $yy 
> will be 200 and so $yy-100 will not work for a 2 digit date

Use %.  Mod is your friend.  $yy % 100.  Alternately, look into
perldoc POSIX and hunt for strftime(), which might be a *lot* more
suitable.  Or even look at Date::Format, if you feel like being a bit
more heavyweight.

POSIX::... time functions are *definitely* your friend.

Later,

  Thorf

-- 
David Goh <thorfinn@netizen.com.au>  ---  http://netizen.com.au/
 Internet and Open Source Development, Consulting and Training.
 Netizen Pty Ltd, GPO Box 2265U, Melbourne VIC 3000, Australia.
Tel: +61 3 9614 0949  Mob: +61 411 692 516  Fax: +61 3 9614 0948


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

Date: Tue, 5 Sep 2000 22:09:53 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: dates Calculations
Message-Id: <MPG.141f717c63771d6b98ad21@nntp.hpl.hp.com>

In article <qi3ars89oceluvro4dsdj8lshl25mdusom@4ax.com>, 
dave@dave.org.uk says...

 ...

> Your best bet is probably to add the correct number of seconds to the
> output from 'time' before passing it to 'localtime'.
> 
> my @tomorrow = localtime(time + 84_600); # Add one day
> my @next_wek = localtime(time + 7 * 84_600); # Add seven days.

Ooh.  Your computer  would calculate that better than you do!

    24 * 60 * 60 != 84_600

The technical term for this error is metathesis.  :-)

perlfaq4: "How do I find yesterday's date?" has this answer, and also 
wastes a lot of space on pedantry about Summer Time discontinuities.

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


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

Date: Tue, 05 Sep 2000 15:42:07 +0100
From: Henrik Springfors <Henrik.Springfors@klinfys.lu.se>
Subject: DBD:Oracle - building
Message-Id: <39B5063F.5E763DBB@klinfys.lu>

I need to build DBD:Oracle to connect to a remote database. My client
is a SPARC Ultra 5 under Solaris and the server is running under NT.

My questions are:

1) Is it possible to build the DBD without installing anything else on the
   client (not even SQL*Net)? Do I really need 'tnsnames.ora'? 

2) Is it legal to do so? The company administring the server
   has a concurrent RDBMS licence.



Thanks
	/Henrik
  
----------------------------------------------------
Please add .se to my reply-address.


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

Date: Wed, 06 Sep 2000 05:57:14 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: DBD:Oracle - building
Message-Id: <slrn8rbn5a.2cp.mgjv@verbruggen.comdyn.com.au>

On Tue, 05 Sep 2000 15:42:07 +0100,
	Henrik Springfors <Henrik.Springfors@klinfys.lu.se> wrote:
> I need to build DBD:Oracle to connect to a remote database. My client
> is a SPARC Ultra 5 under Solaris and the server is running under NT.
> 
> My questions are:
> 
> 1) Is it possible to build the DBD without installing anything else on the
>    client (not even SQL*Net)? Do I really need 'tnsnames.ora'? 

You will need the oracle client libraries. The DBD driver just uses
those.

> 2) Is it legal to do so? The company administring the server
>    has a concurrent RDBMS licence.

You will have to ask Oracle, or your business. I don't know what their
or your contract allows you to do. No one here does. Perl doesn't
magically give us access to your contacts :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If at first you don't succeed,
Commercial Dynamics Pty. Ltd.   | destroy all evidence that you tried.
NSW, Australia                  | 


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

Date: Tue, 5 Sep 2000 22:28:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to get my IP address as a string
Message-Id: <MPG.141f75c4bb6b1b6b98ad22@nntp.hpl.hp.com>

In article <39B555DD.36AA899F@ugsolutions.com>, hillr@ugsolutions.com 
says...
> 
> 
> Joe DiAdamo wrote:
> 
> > How can I get my IP address in "n.n.n.n" format for use as a string?  I
> > think I'm close to figuring it out using gethostbyname(), but I'm still
> > missing something ...
> >
> > thx ... joe
> 
> Try
> $ascii_address  = inet_ntoa($packed_address);
> $packed_address is what is returned by gethostbyname.

Put a 

  use Socket;

ahead of that.

Without a module:

  $ascii_address  = join '.' => unpack C4 => $packed_address;

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


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

Date: Wed, 6 Sep 2000 15:22:22 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: HTML::parse bug
Message-Id: <MPG.1420637d178aba2c989768@localhost>

Tim Cockle <T.Cockle@staffs.ac.uk> wrote ..
>I have found a bug somwwhere in HTML::parse. I have written a simple
>server wich works fine. However if I convert it into a forking server it
>crashes out.
>
>Does this sound fermular to anyone?
>
>If no one has seen this problem don't worry. I going to restart my
>investigation into the bug so will be able to proved a much better
>description shortly.

before you start .. you should be aware that HTML::Parse is deprecated 
 .. you should be using HTML::Parser

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 6 Sep 2000 07:30:58 +0200
From: "Yannis Baillet" <y.baillet@traian.de>
Subject: memory leak perl_call_argv
Message-Id: <cpk4p8.cgh.ln@traian.de>

hi,
i got huge memory leaks problem by calling a perl subroutine from a C++
programm (with perl_call_argv). The produced memory leaks are
proporrtional to the number of arguments.
Though reading of the corresponding man pages, i'm still confused about
the way I should (or should not) empty the perl stack ? Are my problems
really connected to the perl stack ? How can I explicit empty it ?
thanks in advance for any help.





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

Date: Wed, 6 Sep 2000 15:52:52 +1000
From: Derek Lavine <derek@realware.com.au>
Subject: OT: News group app required
Message-Id: <MPG.142086c047fb2be3989685@news.hutch.com.au>

Hi all,

I have a client that would like to have a news forum hosted on their 
site, for their customers. They want to provide a means for their 
customers to post questions/answers on monitored threads but all via 
their web site.

Is anyone aware of a product out there that is not expensive and for 
which source code is available.

Also the same client would like to provide a personal calender service to 
their customers, so there customers are able to receive email 
notification about things at times that they request. Again I would 
require the source code as we would need to customise things.

Thanks

Derek


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

Date: Wed, 06 Sep 2000 07:49:52 +0100
From: David Dorward <ddorward@hotmail.com>
To: Derek Lavine <derek@realware.com.au>
Subject: Re: OT: News group app required
Message-Id: <39B5E910.448705D3@hotmail.com>

Derek Lavine wrote:
> 
> Hi all,
> 
> I have a client that would like to have a news forum hosted on their
> site, for their customers. They want to provide a means for their
> customers to post questions/answers on monitored threads but all via
> their web site.
> 
> Is anyone aware of a product out there that is not expensive and for
> which source code is available.

It isn't Perl, but it is free and the source code is available:
http://php.resourceindex.com/Complete_Scripts/Clients_and_Servers/NNTP/


> Also the same client would like to provide a personal calender service to
> their customers, so there customers are able to receive email
> notification about things at times that they request. Again I would
> require the source code as we would need to customise things.

You can probably find something here:
http://cgi.resourceindex.com/Programs_and_Scripts/Perl/Calendars/




-- 
David Dorward
http://www.dorward.co.uk/


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

Date: Tue, 5 Sep 2000 23:22:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Pattern matching
Message-Id: <MPG.141f82a0551d15f998ad25@nntp.hpl.hp.com>

In article <39B57B6A.36D60F46@cc.gatech.edu>, stephenk@cc.gatech.edu 
says...
> Sven Rixen wrote:
> 
> > Hello
> >
> > I've got a little problem with a matching operation.
> >
> > In a script I use the term
> >
> > if(${$searchfield1} =~ /$search_for1/){

A symbolic reference?  Ugh.  The data should be kept in a hash and keyed 
on the string.

> > The problem is now, that if you type just one letter - let's say an 's'
> > the script will return the first datarow it encounters where the
> > searched word begins with an 's'.
> >
> > How can I force the script to compare the complete words and not just
> > stop after it finds a partial match?
> 
> Use ^ to match the beginning of the string, and $ to match the end.
> It sounds like you need the regex to be /^$search_for1$/

Sven says he wants to compare complete words, not complete lines.  The 
proper anchors are then each \b .  Also, there may be issues of regex 
metacharacters in the interpolated string.  So:

      /\b\Q$search_for1\E\b/

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


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

Date: Wed, 06 Sep 2000 06:41:21 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Perl -P switch
Message-Id: <slrn8rbq42.iv9.rgarciasuarez@rafael.kazibao.net>

sunvenu@my-deja.com wrote in comp.lang.perl.misc:
>I am trying to use some macros in my perl scripts. But when I tried to
>run Perl  with -P switch, I am getting an error saying "gcc not found".
>How can I make perl use "CC" compiler instead of gcc.

It seems that your perl has been compiled with gcc. To be sure, run
this command:
  perl -MConfig -e 'print "$Config{cc}\n"'
The Config manpage lists all configuration variables. To change the
preprocessor used by the -P switch, you can try to:
  * Edit Config.pm (look for the cpprun or cppstdin variable),
    results not guaranteed, maybe you'll have to play a little bit with
    it.
  * Recompile perl yourself.

-- 
Rafael Garcia-Suarez


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

Date: Wed, 6 Sep 2000 15:23:34 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Relative path on NT?
Message-Id: <MPG.142063c2a63da4e2989769@localhost>

James R <reevehotNOSPAM@hotmail.com> wrote ..
>In Matt's guestbook script there is a variable $guestbookreal that is for
>the system location of the guestbook data file.

you wandered into comp.lang.perl.misc by mistake .. you were looking for 
alt.support.matt.wright .. here - I'll show you out

*plonk*

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 6 Sep 2000 16:46:56 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Remove carriage returns from input
Message-Id: <MPG.142077479c1e437198976b@localhost>

Dave Brondsema <brondsem@my-deja.com> wrote ..
>In article <PM6t5.15421$gg.4088888@typhoon.southeast.rr.com>,
>  "Philip Garrett" <philipg@atl.mediaone.net> wrote:
>> RGA <rga@io.com> wrote in message
>> news:Ru6t5.61106$g53.970650@news5.giganews.com...
>> > Hope I don't stimulate too many of the Unsenet police with this
>silly Q,
>> >
>> > I need to strip out any carriage returns from my input.
>> >
>> > What's the character to match on.
>> > I have 2 books, but can't find ..
>> >
>> > Can't I do a simple
>> >
>> >  $results =~ s/chr(10)//g;
>> >
>> >   Whatever that nasty carriage return is ?
>>
>> Carriage return is "\r".  Try s/\r//g.
>
>AND s/\n//g
>
>\r is return (ascii 13)
>\n is newline (ascii 10)

'newline' is a term representing a logical sequence of characters that 
signify a new line .. in Win32 a newline is CRLF .. in UNIX it's LF and 
in MacOS I think it's CR

the characters themselves are called Carriage Return (or in some 
circles Carriage Feed) which is character 13 in ASCII and translates to 
Ctrl+M .. and Line Feed which is character 10 and translates to Ctrl+J

>It depends where your input is coming from, but I'd do 2 s///
>statements, one to remove your returns and then again to remove your
>newlines.

but the originator specifically said that they wanted to strip out 
Carriage Returns (ie. CRs)

>This simple answer was the result of a ~2 hr frustrating search.

just to recap .. "\n" has nothing to do with Carriage Return .. it is 
called LF or Line Feed .. and it is a different character

*however* Perl is nice in that if you output "\n" to a text output 
handle then it will convert it into the appropriate new line sequence 
for your operating system

so in Win32 it will convert all "\n"s into CRLFs before writing them to 
the output handle

ditto with input handles .. if you read from an input handle then Perl 
will convert all new line character sequences into the single "\n" 
character

to get Perl to bypass these conversions you use the binmode function on 
the handle before reading or writing

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 5 Sep 2000 23:13:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Stable sorting
Message-Id: <MPG.141f80506bb2de6c98ad24@nntp.hpl.hp.com>

In article <x7wvgql3mn.fsf@home.sysarch.com>, uri@sysarch.com says...
+ >>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:
+ 
+ >>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> writes:
+ 
+   Randal> For example, the GRT cannot sort "strings of arbitrary
+   Randal> length, case insensitive", a fairly common requirement.
+   Randal> You have todefine an upper bound for the length of a string.
+   Randal> Whereas this is trivial with an ST.
+ 
+   Randal> Unless I misunderstand the entire subtleties of the GRT.
+ 
+   RLS> And after rereading the paper, I'm more convinced of this.  If
+   RLS> you restrict your input data to "strings that don't contain
+   RLS> NULs", or "strings that do not exceed X chars", you can do it
+   RLS> with GRT.  But a general solution cannot use the GRT, hence
+   RLS> back to the ST or (gasp!) the original sorting.
+ 
+ if you want you could encode an arbitrary length strings in hex and
+ separate those by null bytes. not the best idea but should work fine.
+ the data encoding/conversion tricks of the GRT are not always easy and
+ are usually only worth it for large sorts where speed matters. and how
+ often do you sort arbitrary length strings with embedded null bytes? 
+ 
+ (i am waiting for larry to chime in here).

<AOL> Me too! </AOL>

The problem of uniquely concatenating arbitrary strings wan't considered 
serious enough to discourage multi-dimensional hash simulation in Perl 
4, using $; as the string separator.  It seems a bit 'precious' to pick 
on improbable and manageable ambiguities to disqualify a sorting method.  

It is easy to design a unique separator if it really matters, as Uri 
shows above.

+ and we have never claimed that the GRT should replace the ST. in fact
+ i use ST more often as it is easier to code up for basic cases. i
+ don't actually do massive sorts so i don't care about any speed
+ issues. and for short datasets it is irrelevent what sort method you
+ use.

I replaced an ST in a production CGI program by a GRT and cut the 
response time for a large data set from about 30 sec to about 15 sec.

Remember that the ST and GRT use the same elegant map/sort/map paradigm.  
The only difference is whether the sortkeys and data are carried along 
in anonymous arrays or in concatenated strings.  I find the ST and GRT 
now equally easy to write, and use whichever is convenient for small 
problems, for example in responding in this newsgroup.  The extra speed 
of the GRT comes from the idiosyncratic speed of the callback-less 
default sort.  Sometimes, as I showed above, this is worth fighting for.

+ bart asked for a faster sort and i gave him one. so it would be
+ obvious that i meant faster in this case. but in general we found that
+ for equivilent sorts (or large enough data sets) the GRT is faster as 
+ the perl callback is removed from the compare code. all the
+ encoding/decoding is meant to allow the default string compare to be
+ used. we found many ways to create those encodings for almost any
+ combination of sort fields (as i have shown above for your worst case
+ scenario).

<AOL> Me too! </AOL>

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


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

Date: 06 Sep 2000 02:56:32 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Stable sorting
Message-Id: <slrn8rbqj7.tjm.abigail@alexandra.foad.org>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMDLXII September
MCMXCIII in <URL:news:m1lmx6o45x.fsf@halfdome.holdit.com>:
|| 
|| For example, the GRT cannot sort "strings of arbitrary length, case
|| insensitive", a fairly common requirement.  You have to define an
|| upper bound for the length of a string.  Whereas this is trivial with
|| an ST.

GRT can easily sort strings of arbitrary length, as any fixed data set
has an element with maximal length. You can find the maximum length with
a single pass over your data. And before you say "but that means I've to
do an extra pass", ST already does two passes over the data (and so does
GRT). And while you are doing the extra pass to determine the maximum
length, it's trivial to get rid of NULs using a standard byte stuffing
technique - NULs will be restored in the post pass.

A worst case scenario for GRT would be a data set with lots of relatively
short keys, and one gigantic key. If you would make all keys have the
same size, you might end up with a sort that's quadratic in the size of
the input, where the size is the total number of bytes - not the number
of strings.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: 06 Sep 2000 02:57:28 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Stable sorting
Message-Id: <slrn8rbql0.tjm.abigail@alexandra.foad.org>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDLXII September MCMXCIII
in <URL:news:6gpars002219jch28f334jbgucnetsk18m@4ax.com>:
`' I wonder what techniques are considered smart, with regards to creating
`' a "stable sort", i.e. all things being  equal, the original item order
`' is preserved.

Perl 5.7.0 uses merge sort to implement sort(). Merge sort is stable.



Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub   _   {push         @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_              and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20000906


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

Date: Wed, 6 Sep 2000 16:06:19 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: translation!
Message-Id: <MPG.14206dc3e0c3780698976a@localhost>

Tim Cockle <T.Cockle@staffs.ac.uk> wrote ..
>Can someone give me a hint to what this means?
>
>Attempt to free non-existent shared string at (eval
>2)[C:/Perl/lib/DynaLoader.pm:219] line 1.

yes .. the perldiag section of the Perl documentation can give you a 
hint

(typing use Diagnostics; at the top of the script left as an exercise 
for the reader)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 06 Sep 2000 05:32:13 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: translation!
Message-Id: <slrn8rblmq.arq.tjla@thislove.dyndns.org>

I was shocked! How could Dave Brondsema <brondsem@my-deja.com>
say such a terrible thing:
>In article <39B4E4BB.48736B3B@staffs.ac.uk>,
>  Tim Cockle <T.Cockle@staffs.ac.uk> wrote:
>> Can someone give me a hint to what this means?
>>
>> Attempt to free non-existent shared string at (eval
>> 2)[C:/Perl/lib/DynaLoader.pm:219] line 1.
>
>What script do you have on line 1 of C:/Perl/lib/DynaLoader.pm?   Or
>maybe line 219?

It's line 1 of the second eval() on line 219 of Dynaloader.pm

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Now and then an innocent person is sent to the legislature.


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

Date: Wed, 06 Sep 2000 04:29:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <slrn8rbi10.arq.tjla@thislove.dyndns.org>

I was shocked! How could Rick Delaney <rick.delaney@home.com>
say such a terrible thing:
>
>Gwyn Judd wrote:
>> 
>> Whoops, mark that one up as a learning experience. I rewrote it so they
>> are now visible (having it run cleanly under 'use strict' should have
>> been a large whack over the head with a clue-stick *doh*).
>
>It's running cleanly under 'use strict' wasn't the problem, since strict
>isn't active in Benchmark.pm.  But you still have a problem.

Yes but that should have been an indication that what I thought was
happening, actually wasn't.

> 
>> my $day = 'monday';
>> my $monday = '11 am';
>[snip]
>>                 $temp = $$day
>
>What do you expect is the value of $temp?  Lexical variables have
>nothing to do with symrefs.

That's an example of reading from a reference for the purposes of
benchmarking. I think. No it isn't. Whoops. Thats the fault of thinking
references are like pointers in C. Interestingly this works:

my $monday = '11 am';
my $ref = \$monday;
print $$ref, "\n";

But this doesn't:

my $day = 'monday';
my $monday = '11 am';
print $$day, "\n";

There's a symmetry that I feel should be there but it just isn't. I wont
post the (finally) corrected version of my script.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Basic is a high level languish.  APL is a high level anguish.


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

Date: Wed, 06 Sep 2000 04:54:29 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <x7itsaktmj.fsf@home.sysarch.com>

>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:

  GJ> references are like pointers in C. Interestingly this works:

  GJ> my $monday = '11 am';
  GJ> my $ref = \$monday;
  GJ> print $$ref, "\n";

because that is a hard reference. you can take refs of lexicals and
deref later on.

  GJ> But this doesn't:

  GJ> my $day = 'monday';
  GJ> my $monday = '11 am';
  GJ> print $$day, "\n";

because $monday has no entry in the symbol table as it is lexical. so
you can't access it with a symref.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 06 Sep 2000 05:59:23 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <slrn8rbn9o.arq.tjla@thislove.dyndns.org>

I was shocked! How could Uri Guttman <uri@sysarch.com>
say such a terrible thing:
>>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:

>  GJ> But this doesn't:
>
>  GJ> my $day = 'monday';
>  GJ> my $monday = '11 am';
>  GJ> print $$day, "\n";
>
>because $monday has no entry in the symbol table as it is lexical. so
>you can't access it with a symref.

Okay that makes sense...seems a shame though

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
GET OFF THE FUCKING SYSTEM THIS INSTANT, YOU ASSHOLE!!!!


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

Date: Wed, 06 Sep 2000 06:11:21 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <x7em2ykq2g.fsf@home.sysarch.com>

>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:

  GJ> my $day = 'monday';
  GJ> my $monday = '11 am';
  GJ> print $$day, "\n";
  >> 
  >> because $monday has no entry in the symbol table as it is lexical. so
  >> you can't access it with a symref.

  GJ> Okay that makes sense...seems a shame though

why is it a shame? the whole point of lexicals is they don't exist in
the symbol table. they are safer for that reason and because they
require hard refs. there is no way to have what you want as they are not
compatible ideas.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 06 Sep 2000 04:10:32 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: weird behavior of _ file handle
Message-Id: <x7n1hmkvnt.fsf@home.sysarch.com>

>>>>> "RC" == Richard Chen <qchen@snet.net> writes:

  RC> print "Text\n" if -T _;

  RC> $ chmod 111 /tmp/hosts
  RC> $ perl tmp.pl
  RC> $size=
  RC> $size2=942

  RC> So, after the -T _ test, -s _ does not work any more, contrary to
  RC> documentation!.
  RC> One has to use another stat system call to get the correct result.

111 is execute only permission so you can't read the file. -T is not a
standard -X function that only deals with the stat info, it has to
actually read the the first block of the file to see (really guesses) if
it is a text file. so it will fail with your setup. i bet this is
causing the _ handle to be marked as invalid which makes the next call
to -s _ to fail as well.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

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


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