[6442] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 68 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 7 00:07:12 1997

Date: Thu, 6 Mar 97 21:01:34 -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           Thu, 6 Mar 1997     Volume: 8 Number: 68

Today's topics:
     Re: Perl 5 and GDBM <tchrist@mox.perl.com>
     Re: Print to Multiple Filehandles <tchrist@mox.perl.com>
     Re: Print to Multiple Filehandles (Andrew M. Langmead)
     Re: Print to Multiple Filehandles (Andrew M. Langmead)
     Re: Print to Multiple Filehandles <tchrist@mox.perl.com>
     Re: Print to Multiple Filehandles <tchrist@mox.perl.com>
     Re: Print to Multiple Filehandles <eryq@enteract.com>
     Re: Print to Multiple Filehandles <tchrist@mox.perl.com>
     Re: Question about floating point math w/perl <sadd@msc.cornell.edu>
     Regexp: Search outside of HTML tags <furu@infonett.hm.no>
     Re: Removing Carriage returns from a multi-line string <tchrist@mox.perl.com>
     Re: Returning a reference to a 'my' variable (Jeffrey)
     Simple PERL program - HELP! <audible@fox.nstn.ca>
     Trouble installing libwww on DEC Alpha/Unix 4.0B <ragoff@sandia.gov>
     using perl to check for plug-ins? <calvin@grin.net>
     Re: writing an inetd server in Perl <roderick@argon.org>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 7 Mar 1997 03:44:27 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl 5 and GDBM
Message-Id: <5fo2ur$co6$14@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    pcb@is.dal.ca (Bill Phu) writes:
:I am trying to get a pseudo-database setup using Perl.  I read the
:manpages and they all point me to tie(), but the man pages for tie are
:almost useless to a perl neophyte.  

Read the GDBM_File man page.
    http://www.perl.com/perl/nmanual/lib/GDBM_File.html

:I have a C brackground and was just
:wondering how I would get C 'structures' implemented in Perl 

Read the perltoot man page.
    http://www.perl.com/perl/all_about/perltoot.html

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

If I had any humility I would be perfect.
                --Ted Turner


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

Date: 7 Mar 1997 01:29:44 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Print to Multiple Filehandles
Message-Id: <5fnr28$8c9$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Tom Lynch <toml@synnet.com> writes:
:Greetings:
:
:	I have a couple of Filehandles open and would like
:	to print the same text to each one, only when a 
:	certain condition is hit. Currently I do
:	
:	print FILE1 "Todays Date\n";
:	print FILE2 "Todays Date\n";
:	print FILE3 "Todays Date\n";
:
:	Does perl have a way to just put this as one statement?
:	Like:
:
:	print (FILE1, FILE2, FILE3) " Today's Date\n";
:
:	I suppose I could put the files to a list, and do
:	a foreach to open, print then close each one here,
:	but I thought there might be a better way.


In the Perl FAQ qui venit in futuro:

    =head2 How do I print to more than one file at once?

    If you only have to do this once, you can do this:

	for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }

    But to connect up to one filehandle to several output filehandles,
    it's easiest to use the tee(1) program if you have it:

	open (FH, "| tee file1 file2 file3");

    And let it take care of the multiplexing.  Otherwise you'll
    have to write your own multiplexing print function--or your
    own tee program -- or use mine, at CPAN/authors/id/TOMC/scripts/tct.gz, 
    which is written in Perl.

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

The X server has to be the biggest program I've ever seen that doesn't 
do anything for you.  --Ken Thompson


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

Date: Thu, 6 Mar 1997 22:20:18 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Print to Multiple Filehandles
Message-Id: <E6n7Du.GtM@world.std.com>

Tom Lynch <toml@synnet.com> writes:

>	Does perl have a way to just put this as one statement?
>	Like:

>	print (FILE1, FILE2, FILE3) " Today's Date\n";

>	I suppose I could put the files to a list, and do
>	a foreach to open, print then close each one here,
>	but I thought there might be a better way.


How about wrappig the messiness up in a subroutine?

sub printmulti {
  my($fh_list, @args) = @_;
  my $fh;
  foreach $fh (@{$fh_list}) {
    print $fh, @args;
  }

}

printmulti [*FILE1, *FILE2, *FILE3], " Today's Date\n";
-- 
Andrew Langmead


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

Date: Thu, 6 Mar 1997 22:16:37 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Print to Multiple Filehandles
Message-Id: <E6n77q.Esp@world.std.com>

Michael Sadd <sadd@msc.cornell.edu> writes:

>The following appears to work, althought the -w gives
>an odd warning.  (Can anyone tell be why?  I clearly 
>reference the file handles twice.  Am I doing something
>that is bad form?)

>#!/usr/bin/perl -w

>open(FILE1,">&STDOUT");
>open(FILE2,">&STDOUT");
>open(FILE3,">&STDOUT");

>map {print $_ "Today's Date.\n"}(FILE1,FILE2,FILE3);
>__END__

Since the filehandles aren't in places where filehandles are required,
perl is treating them as bareword string constants. It will then use
that string as a soft reference to the filehandle. I guess the easiest
way around that is to use either typeglobs.

map {print $_ "Today's Date.\n"}(*FILE1,*FILE2,*FILE3);

Or maybe the use filehandles created from the FileHandle package. (or
the IO::File package, but I haven't had time to look into it.)


$file1 = FileHandle->new ">&STDOUT";
$file2 = FileHandle->new ">&STDOUT";
$file2 = FileHandle->new ">&STDOUT";


map {print $_ "Today's Date.\n"}($file1, $file2, $file3);



-- 
Andrew Langmead


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

Date: 7 Mar 1997 03:34:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Print to Multiple Filehandles
Message-Id: <5fo2cq$co6$11@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Michael Sadd <sadd@msc.cornell.edu> writes:
:The following appears to work, althought the -w gives
:an odd warning.  (Can anyone tell be why?  I clearly 
:reference the file handles twice.  Am I doing something
:that is bad form?)
:
:#!/usr/bin/perl -w
:
:open(FILE1,">&STDOUT");
:open(FILE2,">&STDOUT");
:open(FILE3,">&STDOUT");
:
:map {print $_ "Today's Date.\n"}(FILE1,FILE2,FILE3);
:__END__

:Identifier "main::FILE1" used only once: possible typo at temp.pl line
:Identifier "main::FILE2" used only once: possible typo at temp.pl line
:Identifier "main::FILE3" used only once: possible typo at temp.pl line

(FILE1,FILE2,FILE3) is a list of strings, which use strict would
have commented upon.  Pass *FILE1 or \*FILE1 instead to quiet
the thing.

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

    "We have ways to make you scream." 
	--Intel advertisement, in the June 1989 Doctor Dobbs Journal


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

Date: 7 Mar 1997 03:06:36 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Print to Multiple Filehandles
Message-Id: <5fo0ns$co6$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, groves@goodnet.com writes:
:    print FILE1 "$msg";

Please don't quote things that needn't be quoted, and
which in some place mustn't be quoted.

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

    "The young think they are immortal, and are determined to prove otherwise."
    	--Larry Wall


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

Date: Thu, 06 Mar 1997 22:27:00 -0600
From: Eryq <eryq@enteract.com>
Subject: Re: Print to Multiple Filehandles
Message-Id: <331F9914.343CF913@enteract.com>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, Eryq <eryq@enteract.com> writes:
> :          print FILE1, @_;
>                       ^
>                       ^
>                       ^ tsk

D'OH!

(That comma shouldn't be there.)

(First time in 6 months I make that mistake, and it's in a 
c.l.p.misc posting... go figure.)

-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: 7 Mar 1997 03:32:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Print to Multiple Filehandles
Message-Id: <5fo28e$co6$10@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, Eryq <eryq@enteract.com> writes:
:	   print FILE1, @_;
		      ^
		      ^
		      ^ tsk

--tom


-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    "I have many friends who question authority.  For some reason most of 'em
    limit themselves to rhetorical questions."
    	--Larry Wall


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

Date: Thu, 06 Mar 1997 20:04:07 -0500
From: Michael Sadd <sadd@msc.cornell.edu>
To: Kendall S Hunter <hunterk@lace.colorado.edu>
Subject: Re: Question about floating point math w/perl
Message-Id: <331F6987.4D2735ED@msc.cornell.edu>

This may not be a complete answer to your question, but I
wonder if you might have really wanted exponentiation in the
denominator:

$integ = $dec*$vel/$rad**(3.*1.27-2.);

It would be unusual to want to XOR these floating point values.

	Mike

P.S.  This is a mistake I have made more than once...

Kendall S Hunter wrote:
> 
[...]
>   $integ = $dec*$vel/$rad^(3.*1.27-2.);
> 
[...]
> Kendall Hunter <hunterk@engine.colorado.edu>

-- 
| Michael Sadd                          | Cornell Univerisity        |
| Department of Physics and             | Ithaca, NY 14850           |
| Lab of Atomic and Solid State Physics | www.msc.cornell.edu/~sadd/ |


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

Date: Fri, 07 Mar 1997 03:45:06 +0100
From: Bjorn Furuknap <furu@infonett.hm.no>
Subject: Regexp: Search outside of HTML tags
Message-Id: <331F8132.6FD9@infonett.hm.no>

Hi, 

I want to make a searchengine to search HTML-files for a scalar. I don't
want, though, to search inside of any HTML-tags, but I have not been
successful in achieving this. 

I have the searchengine. I need a regexp to exclude tags, but include
non-tag 'hits'.

Example 1: Search for 'basketball' SHOULD NOT succeed:
<HTML><HEAD><TITLE>Sportspages</TITLE></HEAD>
<BODY BACKGROUND="/basketball/backgr.gif">
<IMG SRC="/basketball/over.gif"><BR>
</BODY></HTML>

Example 2: Search for 'basketball' SHOULD succeed:
<HTML><HEAD><TITLE>Sportspages</TITLE></HEAD>
<BODY BACKGROUND="/basketball/backgr.gif">
<H1>Basketball</H1>                           <-- Because of this line
</BODY></HTML>


Anyone who understands my question?
Thank you all in advance.

Y.s.
Bjxrn
-- 
- Bjxrn Furuknap - mailto:furu@infonett.hm.no
- 
- infonett a/s - Tlf. 62 95 19 35
-


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

Date: 7 Mar 1997 03:27:10 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Removing Carriage returns from a multi-line string
Message-Id: <5fo1ue$co6$9@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    asp@enterprise.net (Allan) writes:
:I am receiving some data from an HTML form <textarea>.  When the
:contents of the form <textarea> are submitted the data is extracted no
:problem, but I want to be able to remove any carriage returns from the
:text and concatenate the info to make just one long line.

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

--tom

-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "I think I'll side with the pissheads on this one." --Larry Wall


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

Date: 06 Mar 1997 07:18:36 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: stijnvd@cwi.nl (Stijn van Dongen)
Subject: Re: Returning a reference to a 'my' variable
Message-Id: <JFRIEDL.97Mar6161836@tubby.nff.ncl.omron.co.jp>


[mail and post]

Stijn van Dongen <stijnvd@cwi.nl> wrote:
|> Is there a difference in performance between doing
|> 
|> 	my $x = [];
|> 	# .. 
|> 	return $x;		# and
|> 
|> 	my @x;
|> 	# ..
|> 	return \@x;

The better question would be to benchmark them and then, if the results
didn't seem intutative to you, ask for insight as to what's behind them.

I benchmarked them and found the first one to be slightly (~5%) faster than
the second, at least on my machine with my Perl.

Why? I have no idea. /-:

	Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@ora.com> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: 7 Mar 1997 03:50:31 GMT
From: "Brian Cohen" <audible@fox.nstn.ca>
Subject: Simple PERL program - HELP!
Message-Id: <01bc2aaa$8e1b6c20$a511ba89@master>

Hi,

I was wondering if anybody could help. I would like to make a PERL program
that would validate a users password. All passwords would be on the PERL
program so I don't have to access a database.

Regards,

Michael
audible@fox.nstn.ca


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

Date: Thu, 06 Mar 1997 09:42:20 -0700
From: "Robert A. Goff" <ragoff@sandia.gov>
Subject: Trouble installing libwww on DEC Alpha/Unix 4.0B
Message-Id: <331EF3EC.167E@sandia.gov>

I'm trying to install libwww 5.07 on a DEC Alpha running Digital Unix
4.0B.  When I run 'make install', I get the error message:

mkdir /pub/man: File exists at /pub/lib/perl5/ExtUtils/Install.pm line
59
*** Exit 17
Stop.

'make uninstall' fails because it finds no packlist, presumably because
install didn't get that far.

I don't understand the installation process and what's going wrong.  I'd
appreciate any suggestions about how to figure this out.  Thanks.
-- 
=================================================
Robert Goff             email: ragoff@sandia.gov
Sandia National Labs    Phone: (505)284-3639


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

Date: Thu, 06 Mar 1997 18:07:11 +0000
From: Calvin <calvin@grin.net>
Subject: using perl to check for plug-ins?
Message-Id: <331F07CE.5356@grin.net>

Hi, can perl (as cgi) detect what plug-ins are installed on a users
machine?

TIA 
Calvin


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

Date: 6 Mar 1997 20:06:09 -0500
From: Roderick Schertler <roderick@argon.org>
To: des@corp.netcom.net.uk (Des Herriott)
Subject: Re: writing an inetd server in Perl
Message-Id: <pzendsldjp.fsf@eeyore.ibcinc.com>

On 5 Mar 1997 11:21:02 GMT, des@corp.netcom.net.uk (Des Herriott) said:
> 
> I've added the necessary stuff to /etc/services and /etc/inetd.conf.
> Here's the the gist of the entry from inetd.conf:
> 
>   myserver  stream tcp  wait nobody /path/to/server/myserver myserver

This should be nowait rather than wait.  Most services are nowait.  wait
is for services which listen on the socket themselves and timeout after
they don't receive any requests for a while.

Since you set wait inetd didn't do the accept() for you, it just gave
you the bound/listening socket as your stdin/out/err.  You can see this
by adding

    accept(NEW, STDIN);
    open(STDOUT, ">&NEW");

to the top of your script.

-- 
Roderick Schertler
roderick@argon.org


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

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

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