[8762] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2379 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 22 13:17:29 1998

Date: Wed, 22 Apr 98 10:08:57 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 22 Apr 1998     Volume: 8 Number: 2379

Today's topics:
        array elements -- how to exclude when reading in? (Michael Shavel)
    Re: array elements -- how to exclude when reading in? (brian d foy)
    Re: array elements -- how to exclude when reading in? <jdf@pobox.com>
    Re: array elements -- how to exclude when reading in? (Mark-Jason Dominus)
    Re: array elements -- how to exclude when reading in? <rjk@coos.dartmouth.edu>
    Re: array elements -- how to exclude when reading in? <lr@hpl.hp.com>
    Re: array elements -- how to exclude when reading in? <lr@hpl.hp.com>
    Re: array elements -- how to exclude when reading in? <ebohlman@netcom.com>
    Re: array elements -- how to exclude when reading in? <rjk@coos.dartmouth.edu>
    Re: array of matches in s/// (Abigail)
    Re: array of matches in s/// (Bart Lateur)
    Re: array of matches in s/// (Bart Lateur)
        ask people to wait <mhchau@cse.cuhk.edu.hk>
    Re: Attempt to speed up rand() <rootbeer@teleport.com>
    Re: Attempt to speed up rand() (Kevin Reid)
    Re: Attempt to speed up rand() (Jonathan Stowe)
    Re: Attempt to speed up rand() <sneaker@earthling.net>
    Re: Attempt to speed up rand() (Jonathan Stowe)
        Auto mailing in WIN32 PERL (Chua Boon Yiang)
    Re: Auto mailing in WIN32 PERL (Troy Denkinger)
    Re: Auto mailing in WIN32 PERL <scp@cadcentre.co.uk>
    Re: Auto mailing in WIN32 PERL (Martien Verbruggen)
        Beep to another NT-workstation (Vincent Veeger)
    Re: Beep to another NT-workstation <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
        Bidirectional pipe filehandles? (Alik Widge)
    Re: Bidirectional pipe filehandles? (brian d foy)
        Calculating business dates? <treed@cpr.com>
    Re: Can someone give me an example of rounding! <mck@rahul.net>
        Cannot get dbmopen to work, CORRECT <olm@mail1.csun.edu>
        Cannot get dbmopen to work <olm@mail1.csun.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Apr 1998 13:09:14 -0400
From: mshavel@erols.com (Michael Shavel)
Subject: array elements -- how to exclude when reading in?
Message-Id: <mshavel-2004981309140001@130.9.16.207>

Hi

 I'm using this to read in records from a file on the command line into
elements of an array :

while(<>)
{
$records[$index++] = $_;
}

I need to check BEFORE the record is read into the array for octal
character 026 and if this character is present in the record, I do NOT
want the record read into the array. 

I have used several methods AFTER the array has been created, including:

for (@records)
{
s/\026//g;
}

but I always seem to still have an entry for the record that contained
that 026 character. I am able to remove the character but when I cycle
through each element for processing later on in the script I still get an
entry for the array element that contained the 026 character. 

So the only solution I can see is to not include the record in the array
created during the "read in"  ie, while(<>){ $records[$index++] = $_   }

I have found a solution but it is less then ideal. I take out each record
that does NOT have \026, then open and write to a temp file I create.
There must be an easier way though.

If anyone has any ideas it would be very helpful. 

Thanks very much!

Sincerely 
Mike Shavel
mshavel@erols.com


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

Date: Mon, 20 Apr 1998 14:24:11 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <comdog-ya02408000R2004981424110001@news.panix.com>
Keywords: from just another new york perl hacker

In article <mshavel-2004981309140001@130.9.16.207>, mshavel@erols.com (Michael Shavel) posted:

>while(<>)
>{
>$records[$index++] = $_;
>}
>
>I need to check BEFORE the record is read into the array for octal
>character 026 and if this character is present in the record, I do NOT
>want the record read into the array. 

use next or one of its cousins...

while( ...whatever...)
   {
   next if ( ...some test...);
   $records[$index++] = $_;
   }

see the docs for more details.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 20 Apr 1998 14:22:19 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <d8ece1sk.fsf@mailhost.panix.com>

mshavel@erols.com (Michael Shavel) writes:

>  I'm using this to read in records from a file on the command line into
> elements of an array :
> 
> while(<>)
> {
> $records[$index++] = $_;
> }

If you just wanted to fill @records, you could say

   @records = <>;

Since the diamond operator returns a list in list context.  See perlop
for the lowdown on the diamond operator.

> I need to check BEFORE the record is read into the array for octal
> character 026 and if this character is present in the record, I do NOT
> want the record read into the array. 

In which case

   while(<>) {
      next if /\026/;
      push @records, $_;
   }

See perlsyn for the syntax of perl loops, including next, last, and redo.
Also, see push in perlfunc to see how to add elements to the end of an
array.  (Rather than $array[++$index] = $something).


> for (@records)
> {
> s/\026//g;
> }

This merely removes the \026 character from each element of @records
that contains it. To remove an array element you must use splice.  See
perlfunc.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: 20 Apr 1998 20:00:51 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <6hgnjj$ms0$1@monet.op.net>
Keywords: allot bladderwort ninth Watts


In article <mshavel-2004981309140001@130.9.16.207>,
Michael Shavel <mshavel@erols.com> wrote:
>while(<>)
>{
>$records[$index++] = $_;
>}
>
>I need to check BEFORE the record is read into the array for octal
>character 026 and if this character is present in the record, I do NOT
>want the record read into the array. 

Other people suggested the method I would use already, but why not

	while (<>) {
	  $records[$index++] = $_ unless /\026/;
	}

Is that too obvious or something?

Or the lightly less efficient but more charming

	while (<>) {
	  $records[$index++] = $_
	  $index-- if /\026/; 
	}

Actually this $index thing is unperlish and inefficient.  Better
versions of those two lops would be

	while (<>) {
	  push @records, $_ unless /\026/;
	}

and

	while (<>) {
	  push @records, $_;
	  pop @records if /\026/;
	}

>I have used several methods AFTER the array has been created, including:
>
>for (@records)
>{
>s/\026//g;
>}
>
>but I always seem to still have an entry for the record that contained
>that 026 character.

Well, yeah.  s/// modifies a string.  Suppose you had

	$string = 'fred';
	$string =~ s/r//;

You couldn't expect $string to disappear, would you?

Here's one I wouldn't really recommend:

	@records = grep {!/\026/} <>;




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

Date: Mon, 20 Apr 1998 23:59:06 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <353C198B.54D732B9@coos.dartmouth.edu>

Andre L. wrote:
> 
> It would be nice if one could write:
> 
> @records = map { next if /\026/;
>                  $_ } <>
> 
> or
> 
> @records = map { $_ unless /\026/ } <>
> 
> Is there a way to do this sort of thing with map? (having map not return a
> value if we don't want it to?) I guess not. Maybe in Perl6?

Isn't that what grep is for?

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 20 Apr 1998 21:28:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <353C207D.1C814E72@hpl.hp.com>

Michael Shavel wrote:
 ...
> I have found a solution but it is less then ideal. I take out each record
> that does NOT have \026, then open and write to a temp file I create.
> There must be an easier way though.
> 
> If anyone has any ideas it would be very helpful.
> 
> Thanks very much!
> 
> Sincerely
> Mike Shavel
> mshavel@erols.com

Lots of ideas were presented, but no data to select among them.  Roll
out the Benchmarks:

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

timethese (8, {
    L0 => q{
	open IN, 'file' or die $!;
	my @a = map { /com/ ? () : $_ } <IN>;
    },
    L1 => q{
	open IN, 'file' or die $!;
	my @a = grep !/com/, <IN>;
    },
    L2 => q{
	my @a;
	open IN, 'file' or die $!;
	while (<IN>) {
		next if /com/;
		push @a, $_;
	}
    },
    L3 => q{
	my @a;
	open IN, 'file' or die $!;
	while (<IN>) { push @a, $_ unless /com/ }
    },
    L4 => q{
	my @a;
	open IN, 'file' or die $!;
	/com/ or push @a, $_ while <IN>;
    },
} );

Benchmark: timing 8 iterations of L0, L1, L2, L3, L4...
        L0: 13 secs (10.49 usr  0.25 sys = 10.74 cpu)
        L1:  9 secs ( 7.80 usr  0.18 sys =  7.98 cpu)
        L2:  8 secs ( 7.11 usr  0.18 sys =  7.29 cpu)
        L3:  8 secs ( 6.95 usr  0.18 sys =  7.13 cpu)
        L4:  7 secs ( 6.79 usr  0.18 sys =  6.97 cpu)

This is perl, version 5.004_03

The data file has about 1.11 MB, about 32000 lines.  The string /com/
appears in about 12000 of the lines.

My speculations:
L0 (map) vs L1 (grep):  No contest -- more work, same idea.
L1 (grep) vs L2 to L4 (loops):  Apparently the complete array of lines
is formed first, then pruned by grep.
L2 (next if) vs L3 (unless):  Just less work for the interpreter.
L3 (unless) vs L4 (or):  No block overhead per input line.

Perhaps those knowledgeable about the implementations of these
approaches will comment.  In particular, what valid generalizations can
be drawn from these observations (keep inner loops short and clean, and
avoid blocks unless necessary)?

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 21 Apr 1998 01:00:16 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: "Andre L." <alecler@cam.org>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <353C5210.968809CF@hpl.hp.com>

Andre L. wrote:
 ...
> @records = map { $_ unless /\026/ } <>
>
> Is there a way to do this sort of thing with map? (having map not return a
> value if we don't want it to?) I guess not. Maybe in Perl6?
> 
> A.L.

Sure.  It's called "grep"!  @records = grep !/\026/, <>;

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 22 Apr 1998 02:57:13 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <ebohlmanErso7D.Bq1@netcom.com>

Andre L. <alecler@cam.org> wrote:
: Actually, I was thinking of a mapping function that would return a
: _modified_ value conditionally, like a hybrid between map and grep, and
: which would allow this kind of statement, to keep the resulting array as
: small as possible:

: @b = grap { [ split /\t/ ] if Matches_criteria($_) } <MYFILE>;

@b = map {Matches_criteria($_) ?[ split /\t/ ] :$_ } <MYFILE>;



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

Date: Tue, 21 Apr 1998 23:03:08 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <353D5DEE.8084DFBE@coos.dartmouth.edu>

Andre L. wrote:
> 
> Actually, I was thinking of a mapping function that would return a
> _modified_ value conditionally, like a hybrid between map and grep, and
> which would allow this kind of statement, to keep the resulting array as
> small as possible:
> 
> @b = grap { [ split /\t/ ] if Matches_criteria($_) } <MYFILE>;
> 
> rather than doing:
> 
> @b = map  { [ split /\t/ ] }
>      grep { Matches_criteria($_) } <MYFILE>;
> 
> which seems like too much looping for nothing.

So it would be equivalent to

@b = map { Matches_criteria($_) ? [ split /\t/ ] : () } <MYFILE>;

right?

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 21 Apr 1998 21:35:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: array of matches in s///
Message-Id: <6hj3ep$di6$1@client2.news.psi.net>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MDCXCIV September
MCMXCIII in <URL: news:6hiqv6$msn$1@mathserv.mps.ohio-state.edu>:
++ 
++ Then doing $#< will give you a limit of $<i>.

Will that be known as the duck operation then?



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Sun, 19 Apr 1998 21:26:29 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: array of matches in s///
Message-Id: <353b648f.215965@news.tornado.be>

Charles DeRykus wrote:

>I just noticed though the substitution matching could be 
>avoided since the pattern is the same, i.e., 
>
>   if (my @matches = /^$key/) {
>         s//&interpolate($translate{$key}, @matches)/e;
>   }

No, 'cos now you keep both the original, and the translation.

This one might do it:

   if (my ($whole,@matches) = /^($key)/) {
         substr($_, 0 , length $whole) = 
                    &interpolate($translate{$key}, @matches);
   }

Hey, we've just replaced s/// with custom code. We might just drop s///
from the Perl syntaxl, it would make a more compact (simpler ?)
language. Who needs it anyway, if you can replace it with just a few
lines of code? ;-)

	Bart.


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

Date: Sun, 19 Apr 1998 21:26:32 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: array of matches in s///
Message-Id: <353c668d.725943@news.tornado.be>

Tom Phoenix wrote:

>I can't see what @& could hold which would be useful there. Can you
>describe your proposed feature in more detail?

Well, what it would hold, can be represented with this code example:

	(@match) = /$pattern/;

which basically does two things: the matching, and the returning of an
array. This line would be equivalent to:

	/$pattern/;
	@match = @&;

so my proposal is pretty much in agreement with the rest of Perl.

In s///, you can't get at this array of matches, which is a unhappy
circumstance for some applications, in particular if you don't know how
many submatches to expect.

In the same way, 

        s/$pattern/&someSub(@&)/e;

would have a similar effect as

        if (my @match = m/$pattern/)  {
           s/$pattern/&someSub(@match)/e;
        }

except it would do the matching only once, and it would look a lot
cleaner. Imagine having to add the //g option, the difference would be a
lot greater still.

Well, you could argue that the circumstances where you actually need it,
could be pretty rare.

But so is the need for pos.

In m//, you can very easily get at this array of matches. So, since m//
and s/// have so much in common, I expect that they share a lot of their
code. (If not, the coders should get a course in code reuse ;-)

That is why I think that retrieving an array of matches in s/// would
require very little patching.

	Bart.


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

Date: 22 Apr 1998 08:26:17 GMT
From: Sleep <mhchau@cse.cuhk.edu.hk>
Subject: ask people to wait
Message-Id: <6hk9j9$h1n@eng-ser1.erg.cuhk.edu.hk>

   Hail !
   I am writing a CGI(Perl of course :) programme that will verify 
a user and then do a search in another server. The problem is that 
Internet always has traffic congession. And the search may take up to few 
mins which, I believe, will confuse the user that the machine is hang !
   So I want to prompt a messag when the user suceed in the verification
 but searching hasn't finish. I've try the "server push" technique to 
show the user a page of "warning" and it work fine, but unlucky it's a 
Netscape "product" & so M$ doesn't "like" it  :(
   As I am not Bill that I can't choose the broswer for the reader. my 
question is:   Any other "universal" method can do the same thing ?


   Thanx for attention.

Regards,
Chau.

PS. I don't know which newgroup should I post. So please forward this post 
to a more appropraite one if u think it is :P


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

Date: Sun, 19 Apr 1998 17:06:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Jamie McCarthy <jamie@mccarthy.org>
Subject: Re: Attempt to speed up rand()
Message-Id: <Pine.GSO.3.96.980419100116.1173G-100000@user2.teleport.com>

On Fri, 17 Apr 1998, Jamie McCarthy wrote:

> The line of code added below can't hurt, and might make the page
> appear faster on a typical web browser.

> $| = 1; # disable buffering on STDOUT

Actually, it _can_ hurt, and it won't make the page appear faster if
the code is running on a typical web server. :-)

Buffering is done for efficiency reasons. It's faster to flush the output
only when needed, rather than at every opportunity. In the case of a CGI
script, it's normal for the server to send nothing until the entire page
has been generated, so changing the buffering won't speed the script's
runtime. 

Of course, this information on buffering is the same whether the CGI
program is written in Perl, C, or SNOBOL. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 19 Apr 1998 15:01:49 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Attempt to speed up rand()
Message-Id: <1d7pgoz.30p6vh1yicunmN@slip166-72-108-8.ny.us.ibm.net>

Mark Waterous <mail@silas.hypermart.net> wrote:

>       I have a short script that I wrote, mostly as a quick practice
> of my perl, but what it does is it loads a random page, depending on
> the result returned by the rand() function. The script is short, and
> looks like this:
<snip> 
>       What I am attempting to do now, though I don't know if it's
> possible, is to speed up the process a bit.

> --[begin default.pl]--
> #!/usr/local/bin/perl -w
> use diagnostics;

There's the problem. Remove "use diagnostics" and your script will start
much faster. You probably don't need it anyway except while debugging.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Sun, 19 Apr 1998 21:59:01 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Attempt to speed up rand()
Message-Id: <353a6f89.7036606@news.btinternet.com>

On Sun, 19 Apr 1998 17:06:10 GMT, Tom Phoenix <rootbeer@teleport.com>
wrote:

<snip>
>
>Of course, this information on buffering is the same whether the CGI
>program is written in Perl, C, or SNOBOL. Hope this helps!
>
QBasic, we want QBasic : its just not fair that you keep citing
SNOBOL.  ;-}

"Welcome to the fellowsip Sean"

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Sun, 19 Apr 1998 23:07:23 GMT
From: Bill 'Sneex' Jones <sneaker@earthling.net>
Subject: Re: Attempt to speed up rand()
Message-Id: <353A8211.D0B3579E@earthling.net>

Jonathan Stowe wrote:

> QBasic, we want QBasic : its just not fair that you keep citing
> SNOBOL.  ;-}
>

 QBasic, Snobol???   God, man, ya'll are really showing your age!

:-)

--
__________________________
Bill Jones...............|
Sneaker's Nest...........|
Chasecreek Systemhouse...|





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

Date: Tue, 21 Apr 1998 14:48:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Attempt to speed up rand()
Message-Id: <353c9a24.11447962@news.btinternet.com>

On Sun, 19 Apr 1998 23:07:23 GMT, Bill 'Sneex' Jones
<sneaker@earthling.net> wrote:

>Jonathan Stowe wrote:
>
>> QBasic, we want QBasic : its just not fair that you keep citing
>> SNOBOL.  ;-}
>>
>
> QBasic, Snobol???   God, man, ya'll are really showing your age!
>
Or a pathological degree of eclecticism.

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Mon, 20 Apr 1998 03:56:50 GMT
From: chuaby@hotmail.com (Chua Boon Yiang)
Subject: Auto mailing in WIN32 PERL
Message-Id: <353ac70a.12857521@news.cyberway.com.sg>

Hi,
may i know how can i send email in a cgi program written in PERL under
the WIN NT/ WIN95 env ? In unix i can easily do it using sendmail. but
wat is the equivalent for WIN95/NT ?

Thanks
Boon Yiang


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

Date: Mon, 20 Apr 1998 04:17:03 GMT
From: troy@whadda.com (Troy Denkinger)
Subject: Re: Auto mailing in WIN32 PERL
Message-Id: <6hei9v$c1f$1@hirame.wwa.com>

In article <353ac70a.12857521@news.cyberway.com.sg>, chuaby@hotmail.com (Chua Boon Yiang) wrote:

>may i know how can i send email in a cgi program written in PERL under
>the WIN NT/ WIN95 env ? In unix i can easily do it using sendmail. but
>wat is the equivalent for WIN95/NT ?

There is not standard Sendmail equivalent.  I use Net::SMTP 
and it works very well.

Regards,

Troy Denkinger


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

Date: Mon, 20 Apr 1998 14:03:35 +0100
From: "S.Plant" <scp@cadcentre.co.uk>
Subject: Re: Auto mailing in WIN32 PERL
Message-Id: <6hfh3u$qhf$1@flex.news.pipex.net>

I use a program called

  Wmailto

available from
 http://www.impaqcomp.com/jgaa/wmailto.html

Rgds
Simon Plant
Cadcentre Ltd
http://www.cadcentre.co.uk

Chua Boon Yiang wrote in message <353ac70a.12857521@news.cyberway.com.sg>...
>Hi,
>may i know how can i send email in a cgi program written in PERL under
>the WIN NT/ WIN95 env ? In unix i can easily do it using sendmail. but
>wat is the equivalent for WIN95/NT ?
>
>Thanks
>Boon Yiang




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

Date: 21 Apr 1998 03:49:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Auto mailing in WIN32 PERL
Message-Id: <6hh50m$qgq$2@comdyn.comdyn.com.au>

In article <353ac70a.12857521@news.cyberway.com.sg>,
	chuaby@hotmail.com (Chua Boon Yiang) writes:
> Hi,
> may i know how can i send email in a cgi program written in PERL under

Actually, it's Perl, for the language or perl, for the interpreter.
Not PERL.

> the WIN NT/ WIN95 env ? In unix i can easily do it using sendmail. but

Even on unices, you shouldn't really be using sendmail.

> wat is the equivalent for WIN95/NT ?

This is answered in the win32 FAQ, which you can read at www.perl.com.
Since that answer might not be what you want to hear, the best advise
that I have for you is to use Net::SMTP, or one of the other Mail
modules on CPAN:

http://www.perl.com/CPAN/

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd.       | am.
NSW, Australia                      | 


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

Date: Tue, 21 Apr 1998 08:12:58 GMT
From: veeger@iaehv.nl (Vincent Veeger)
Subject: Beep to another NT-workstation
Message-Id: <353c51ca.4399125@news.iaehv.nl>

In my search to find out a way to send a BEEP to another user of an
NT-WS 4.0 I figured out learning to program this was a little
overdone.  Hoping a script-language like Perl could do the job eassier
I downloaded and installed the file PW32i316, but (while I'm sure its
easy to do this whithin Perl for a professional) I have to conclude
that this is way over my hat.

So my question: can somebody supply me with a Perl-script which can
send a BEEP from one NT 4.0 WS to another, something like:
net send <username> beep, but then without a message.

Thanks in advance,

Vincent Veeger


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

Date: Tue, 21 Apr 1998 20:26:07 -0700
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Beep to another NT-workstation
Message-Id: <6hjnvs$gm0@bgtnsc02.worldnet.att.net>

Hi Vince,

I'm not at all sure you can do what you're looking for other than by
setting up a server-like program on the workstation you want to make
beep. There are examples of how to do this in Learning Perl and
Programming Perl, if I remember correctly. The "server" would listen for
a connection from the other machine and beep when it gets one. But it
seems to me to be an awful lot of work for a beep. :D

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl

Vincent Veeger wrote in message <353c820c.16752158@news.iaehv.nl>...
>I'm afraid my question was not clear, net send <username> <text> works
>perfectly from the command line, generating a BEEP-Tone AND the
>message "text" at the receivers end, but I would like to generate a
>BEEP-tone at another WS without the popup-message the NET SEND-command
>generates.





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

Date: Mon, 20 Apr 1998 00:34:20 -0500
From: alik.widge@dartmouth.edu (Alik Widge)
Subject: Bidirectional pipe filehandles?
Message-Id: <alik.widge-2004980034200001@alpha-theta-bp-197.dartmouth.edu>

What I've got is a C executable of which I need to run 11 copies at once,
being able to switch which copy I'm communicating with at will. Commands
from stdin (unless preceded by a metacharacter) go to the currently-active
copy, and anything it puts on its stdout should go to the stdout of the
wrapping script.

Doing the switching between copies and executing the 11 copies was easy
enough; doing an (open "FILE$i", "| <executable-name>) 11 times was
basically all I needed.

This gives me the ability to send them commands, but I can't read back
what they write. I tried redirecting their stdouts to a file, but they
don't actually write data to the file until they quit, and that's not much
use. I tried a very ugly hack where their output was piped to another
script which then opened a socket connection back to the originating
script, but the data *still* doesn't show up until the programs of
interest have quit.

Now, on page 163 of the 1st Edition camel book (the "open" reference),
Larry and Randal tell me that an open command which pipes both in and out
should be easy to build. How, though? I've been poring over the pipe() and
fork() man pages and function references for a couple hours now, and I'm
not seeing it.

Alik


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

Date: Mon, 20 Apr 1998 03:25:40 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Bidirectional pipe filehandles?
Message-Id: <comdog-ya02408000R2004980325400001@news.panix.com>
Keywords: from just another new york perl hacker

In article <alik.widge-2004980034200001@alpha-theta-bp-197.dartmouth.edu>, alik.widge@dartmouth.edu (Alik Widge) posted:


>Now, on page 163 of the 1st Edition camel book (the "open" reference),
>Larry and Randal tell me that an open command which pipes both in and out
>should be easy to build. How, though?

check the perlipc manpage as well as the IPC::Open3 (or Open2) modules.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Wed, 22 Apr 1998 04:17:07 GMT
From: Timothy Reed <treed@cpr.com>
Subject: Calculating business dates?
Message-Id: <353D716D.5DB98A7F@cpr.com>

Hi,
I need to determine if a given date falls (or fell) on a business date.  I also
need to tell if a day x days ahead or behind is a business date or note.  Has
anyone worked out a solution in Perl? 

Thanks,
Tim


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

Date: 19 Apr 1998 22:18:52 GMT
From: David McKay <mck@rahul.net>
Subject: Re: Can someone give me an example of rounding!
Message-Id: <6hdt8c$3da$1@samba.rahul.net>

Tom Christiansen  <tchrist@mox.perl.com> wrote:
: ...
: I don't know why people think printf truncates; it certainly rounds.
: You could have found this out by reading the documentation, or by using
: a trivial test:
:     % perl -e 'printf "%4.2f\n", 2.5555'
:     2.56

I tried your suggested trivial test, with slightly different numbers:

  % perl -e 'printf "%4.2f\n", 2.005'
  2.00
  % perl -e 'printf "%4.2f\n", 2.0051'
  2.01

That first response of 2.00 looks like a rounding error to me -- maybe not
by printf's definition, but I hope my bank isn't using the same method in
interest calculations.  

Could this be because the internal representation of 2.005 is
2.004999999..., which when added to 0.005 results in something like 
2.009999999... ? 

                                                -- David McKay


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

Date: Tue, 21 Apr 1998 14:50:54 -0700
From: Ovanes Manucharyan <olm@mail1.csun.edu>
Subject: Cannot get dbmopen to work, CORRECT
Message-Id: <353D14BE.1F1ABCE0@mail1.csun.edu>

OOPS, I inadvertantly removed a line from the original posting.


Hi,

for some reason the after the following, I end up with a  0 byte dbm
file

dbmopen (%CMSDATA, $dbmFile, 0666) or die "Cannot open \$dbmfile $!\n";
%cms=%CMSDATA;
    while ($key = each %CMSDATA) {
        @array = @{$CMSDATA{$key}};
        $array = join ":", @array;      # THIS LINE WAS MISSING.
         $cms{$key} = $array;
    }
    %CMSDATA=%cms;
dbmclose %CMSDATA;

It creates the file but doesn't write anything to it.

HELP.... PLEASE



--
----------------------------------------------------
Ovanes Manucharyan   olm@csun.edu
    California State University, Northridge
----------------------------------------------------




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

Date: Tue, 21 Apr 1998 14:29:57 -0700
From: Ovanes Manucharyan <olm@mail1.csun.edu>
Subject: Cannot get dbmopen to work
Message-Id: <353D0FD4.684A5475@mail1.csun.edu>

Hi,

for some reason the after the following, I end up with a  0 byte dbm
file

dbmopen (%CMSDATA, $dbmFile, 0666) or die "Cannot open \$dbmfile $!\n";
%cms=%CMSDATA;
    while ($key = each %CMSDATA) {
        @array = @{$CMSDATA{$key}};
         $cms{$key} = $array;
    }
    %CMSDATA=%cms;
dbmclose %CMSDATA;

It creates the file but doesn't write anything to it.

HELP.... PLEASE





--
----------------------------------------------------
Ovanes Manucharyan   olm@csun.edu
    California State University, Northridge
----------------------------------------------------




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

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

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