[13287] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 697 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 1 17:07:28 1999

Date: Wed, 1 Sep 1999 14:05:10 -0700 (PDT)
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, 1 Sep 1999     Volume: 9 Number: 697

Today's topics:
        BSDOS: use B (The Perl Compiler) problem <elf@halcyon.com>
    Re: Building perl <ark@leviathan.soest.ucsd.edu>
    Re: Case insensitive SQL query (Malcolm Ray)
    Re: CGI DownLoad File on the PC Client (Bill Moseley)
    Re: CGI DownLoad File on the PC Client (Larry Rosler)
    Re: CGI question: CGI output being mixed with older out <mcardeiroNOnxSPAM@yahoo.com>
        Counting duplicate list elements in Perl charlie1009@my-deja.com
    Re: Counting duplicate list elements in Perl (Graham Ashton)
    Re: Counting duplicate list elements in Perl <latsharj@my-deja.com>
    Re: editors?? <AgitatorsBand@yahoo.com>
    Re: email address verification (Kai Henningsen)
    Re: Invalid C++ syntax in CPAN packages lvirden@cas.org
        Logical operators ("willow")
    Re: Logical operators (John Porter)
        Perl5 sendmail (John Casey)
    Re: Perl5 sendmail (Greg Bacon)
    Re: PPT I have a diff XSUB agutier@my-deja.com
    Re: PPT I have a diff XSUB (John Porter)
        PROCESS CERTAIN BLOCK OF DATA IN A FILE ? tvn007@my-deja.com
        Question (Jimtaylor5)
    Re: Question (Greg Bacon)
        reading email (Ronald E Jeffries)
    Re: Redirecting STDERR to STDOUT (on NT) (Bart Lateur)
        repost (PROCESS CERTAIN BLOCK OF DATA IN A FILE ? tvn007@my-deja.com
        Safe way to terminate blocking sub-threads? <martin@sluka.de>
        Script within a script-can it be done? <kimgraham@hotmail.com>
    Re: shebang question for Win32 Perl/Apache <bmetcalf@nortelnetworks.com>
    Re: shebang question for Win32 Perl/Apache (Bill Moseley)
    Re: shebang question for Win32 Perl/Apache (Larry Rosler)
    Re: Simulating Carriage Returns <bryan@ets02.jpl.nasa.gov>
    Re: Simulating Carriage Returns (Larry Rosler)
        system <anspa@spiff.hr.att.com>
    Re: Tracking progress of a Net::FTP download <ecliptica.ww@nospam.virgin.net>
        What does the perl debugger do? <Patrick.Wright@msfc.nasa.gov>
        writing string with some '%' to a file <jspeers@open.uoguelph.ca>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 1 Sep 1999 12:58:27 -0700
From: Elf Sternberg <elf@halcyon.com>
Subject: BSDOS: use B (The Perl Compiler) problem
Message-Id: <Pine.GSO.4.10.9909011248300.18112-100000@king.halcyon.com>

I'm working with perl 5.005_03 on a P166 running 
BSDOS 3.1.  It builds fine and all the other modules
that use dynamic loading work.  I even wrote my own
XS module and it loads fine.

But, when I try to use B, the Perl Compiler, which 
is shipped with the core distribution (yes, I know
it's experimental, but it works under linux), I get 
the error message:

Can't load '/usr/local/packages/perl/lib/5.00503/i386-bsdos/auto/B/B.o' for module B:
can't resolve undefined symbols: Inappropriate file type or format at
/usr/local/packages/perl/lib/5.00503/i386-bsdos/DynaLoader.pm line 168. 
at - line 0
BEGIN failed--compilation aborted.

Anyone seen this before?  Anyone got an answer?

Elf M. Sternberg, rational romantic mystic cynical idealist
     MST3K - Help save the saving grace of television.
A.A 1493                        http://www.halcyon.com/elf/



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

Date: Wed, 01 Sep 1999 10:00:44 -1000
From: Andrew Keyes <ark@leviathan.soest.ucsd.edu>
Subject: Re: Building perl
Message-Id: <37CD85EB.B0ACAB9A@leviathan.soest.ucsd.edu>

Elaine -HFB- Ashton wrote:

> Andrew Keyes wrote:
> >  Is this possiblity what it should be doing ? Or did something go wrong
> > a along the way. I didn't expect it to
> > take 100's of MB of diskspace to build perl.
>
> Something is very wrong. What version of Perl and which compiler are you
> using? Did you check the READMEs for build gotchas?
>
> e.

Here's the info on the C compiler
 cc -v
Reading specs from /lib/m68k/specs
NeXT Computer, Inc. version cc-437.2.6, gcc version 2.5.8

And the info on what the -v flag does
(man cc)
   -v   Print (on standard error output) the commands  executed
          to  run the stages of compilation.  Also print the ver-
          sion number of the compiler driver program and  of  the
          preprocessor and the compiler proper.

And the perl source is 5.005_03

I just did a make clean and started
doing another make and this is how it starts
% make
`sh  cflags libperl.5.dylib miniperlmain.o`  miniperlmain.c
          CCCMD =  cc -DPERL_CORE -c -dynamic -fno-common -DUSE_NEXT_CTYPE
-DUSE_PERL_SBRK -DHIDEMYMALLOC -I/usr/local/include -O
Starting parse
Entering state 0
Reading a token: Next token is 260 (SCSPEC)
Reducing via rule 3 (line 247),  -> @1
state stack now 0
Entering state 2
Next token is 260 (SCSPEC)

And it goes on and on,
Any help would be so much appreciated, I really like perl and I'd really
like to get it running on my machine.

Thank you,
Andrew Keyes
SOEST
Univ of Hawaii, Manoa




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

Date: 1 Sep 1999 20:11:00 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Case insensitive SQL query
Message-Id: <slrn7sr22k.g1h.M.Ray@carlova.ulcc.ac.uk>

On Tue, 31 Aug 1999 19:28:23 GMT, mrbog@my-deja.com <mrbog@my-deja.com> wrote:
>Oh please, SQL is obviously tangentially related to perl.

Why?  I don't see why you'd think that.

>Not only
>that but I'm sure my question is a common one and doesn't require heaps
>of documentation to solve.

The same is true of recipes for pasta sauces, but you wouldn't ask about
that in clpm.

By the way, having access to heaps of documentation is *good*.  You make
it sound like a bad thing.

>And BTW mysql.com doesn't solve my problem.

Like Perl, MySQL comes with 'heaps of documentation'.  Did you consult
it?  It will be on your system, and is also available at www.mysql.com.
It has this to say:

  SQL pattern matching allows you to use `_' to match any single
  character, and `%' to match an arbitrary number of characters (including
  zero characters).  SQL patterns are case insensitive.  Some examples are
  shown below.  Note that you do not use `=' or `!=' when you use SQL
  patterns; use the `LIKE' or `NOT LIKE' comparison operators instead.
  
  To find names beginning with `b':
  
       mysql> SELECT * FROM pet WHERE name LIKE "b%";
       +--------+--------+---------+------+------------+------------+
       | name   | owner  | species | sex  | birth      | death      |
       +--------+--------+---------+------+------------+------------+
       | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
       | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
       +--------+--------+---------+------+------------+------------+

 ...which contradicts the problem you're seeing.

If your LIKE clauses are case-sensitive when tried like this from the
MySQL monitor, then clearly it's not a Perl matter and you'd be better
asking somewhere database people hang out, like maybe comp.databases.
If they're case-insensitive, as desired, in the monitor but somehow
become case-sensitive when using DBI from Perl, then obviously clpm
is a reasonable place to discuss the problem.

My guess is that you have an elderly version of MySQL: it used to
have some inconsistencies around case-sensitivity in LIKE.  Test your
queries from the monitor, find out what version of MySQL you're running,
consult the documentation at www.mysql.com to find out whether that
version suffers from that bug, and then upgrade, because if it's that
old you have other problems.

-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Wed, 1 Sep 1999 13:09:55 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: CGI DownLoad File on the PC Client
Message-Id: <MPG.123727f17fd50e469896e9@nntp1.ba.best.com>

Edouard Ouin (Edouard.Ouin@tinet.ie) seems to say...
> Hi,
> 
> Is it a way to download a file directly to the client via the "save as"
> generic window to save a file on the local machine.
> 
> PS: in perl of course, via CGI if it's possible.

This is an HTTP issue (and you would do better asking in a group that 
deals with such) and you can't control what people's browsers do.  But 
you can send something like:

    print "Content-Type: x-text/comma-separated-values\n",
          "Content-Disposition: attachment; filename=$filename\n\n";

But the browser can ignore this if it wants.  It all depends on what the 
browser is set up to do with a given Content-Type:

Again, this isn't a perl question.

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Wed, 1 Sep 1999 13:51:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI DownLoad File on the PC Client
Message-Id: <MPG.123731a8c2f452a6989f07@nntp.hpl.hp.com>

In article <37CD5C0D.CB1DCC62@tinet.ie> on Wed, 01 Sep 1999 17:02:05 
+0000, Edouard Ouin <Edouard.Ouin@tinet.ie> says...
> Is it a way to download a file directly to the client via the "save as"
> generic window to save a file on the local machine.
> 
> PS: in perl of course, via CGI if it's possible.

The only reliable way I know of is to send the file with Content-Type 
'application/octet-stream'.  Then the client browser will ask the user 
what to do with the file.

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


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

Date: Wed, 01 Sep 1999 12:08:42 -0700
From: mike cardeiro <mcardeiroNOnxSPAM@yahoo.com>
Subject: Re: CGI question: CGI output being mixed with older output, how to avoid?
Message-Id: <03e6ae67.26d122ad@usw-ex0102-014.remarq.com>

In article <IK1z3.11340$914.693745@typ11.nn.bcandid.com>, 
"The News" <cshannon@mdo.net> wrote:
>Hi,
>
>I just made a script that sends mail to my address from a 
form.
>
>(1) 2 e-mails, not one, were sent to my address.  The first 
one was
>completely blank, and the second one was the actual 
message.

I had this same problem a couple of months ago and the 
problem appeared to be even though i only hit submit once 
the form was being submitted twice. the way i got around 
this was when the form was created a unique number was 
inserted in a hidden field in the form.  when the form is 
submitted the script checks the number in the hidden field 
against a database.  if the number is not in the database 
the data is formatted and mailed and the number is put in 
the database and the thank you page is printed.  if the 
number is in the database the data has already been sent(uhm 
at least that was the case with me) so the script skips over 
the email part and just prints the thank you page.  

it worked for me, hope it helps you.


mike cardeiro

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Wed, 01 Sep 1999 19:30:07 GMT
From: charlie1009@my-deja.com
Subject: Counting duplicate list elements in Perl
Message-Id: <7qjurf$2dj$1@nnrp1.deja.com>

Hi everyone, I'm looking for a way to sort a list of strings
with Perl while counting the number of duplicate entries.

For example, the list

apple
orange
cherry
cherry
tomato
apple
cherry

should sort to:

apple,2
cherry,3
orange,1
tomato,1

One approach might be to loop through the output of Perl's
default sort routine (which retains only the unique entries) and
for each entry search the entire unsorted list for matches,
but this seems really silly.

Any better ideas anyone?  Thanks a million.

- Charlie



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 1 Sep 1999 19:47:48 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Re: Counting duplicate list elements in Perl
Message-Id: <slrn7sr0n4.fkp.billynospam@wing.mirror.bt.co.uk>

In article <7qjurf$2dj$1@nnrp1.deja.com>, charlie1009@my-deja.com wrote:

>Hi everyone, I'm looking for a way to sort a list of strings
>with Perl while counting the number of duplicate entries.

You need a hash.

>For example, the list
>
>[snip]
>
>should sort to:
>
>apple,2
>cherry,3
>orange,1
>tomato,1

@list = qw( apple cherry cherry apple orange tomato cherry );

foreach $fruit (@list) { $count{$fruit}++ };
foreach $fruit (sort keys %count) { print "$fruit, $count{$fruit}\n"; }

I tested it too.

-- 
Graham


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

Date: Wed, 01 Sep 1999 20:06:07 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: Counting duplicate list elements in Perl
Message-Id: <7qk0v6$44t$1@nnrp1.deja.com>

In article <7qjurf$2dj$1@nnrp1.deja.com>,
  charlie1009@my-deja.com wrote:
> Hi everyone, I'm looking for a way to sort a list of strings
> with Perl while counting the number of duplicate entries.
>
> For example, the list
>
> apple
> orange
> cherry
> cherry
> tomato
> apple
> cherry
>
> should sort to:
>
> apple,2
> cherry,3
> orange,1
> tomato,1

#!/e/perl/bin/perl -w
use strict;
my %hash;
while(<DATA>) {
    chomp;
    $hash{$_}++;
}
for (sort keys %hash) {
    print $_,',',$hash{$_},"\n";
}
__DATA__
apple
orange
cherry
cherry
tomato
apple
cherry
--
Regards,
Dick


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 01 Sep 1999 20:15:40 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: editors??
Message-Id: <MPfz3.933$1k5.306144@news.shore.net>

Gabor <gabor@vmunix.com> wrote:
: In comp.lang.perl.misc, Caper <stevencNOSPAM@nbnet.nb.ca> wrote :
: # Any good Perl debuggers or editors to suggest?

: Perl has a builtin debugger.  As far as editors, whatever you're
: comfortable with and can edit ascii text with.

Something that matches parentheses, braces and such will probably come in
handy. Something that will easily indent or unindent would probably make
some tasks quicker, as would the ability to create your own macros (e.g.
for commenting out lines of code).

If you're working in a non-Unix environment and uploading your scripts to
a Unix host you'll probably want something that can handle different
line-ending characters gracefully.

For Windows, I really like TextPad. For Mac, BBEdit or BBEdit Lite. For
Unix, whatever you're comfortable with.

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 01 Sep 1999 19:57:00 +0200
From: kaih=7O2jHZZmw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: email address verification
Message-Id: <7O2jHZZmw-B@khms.westfalen.de>

cassell@mail.cor.epa.gov (David Cassell)  wrote on 23.08.99 in <37C1C968.E2BB8E92@mail.cor.epa.gov>:

> [2] It is virtually impossible to do this, since there are
> valid e-mail addresses which are not legal according to the
> specs (hey, don't blame me!),

Do you have any example?

Because this one:

> which are technically legal.  For example, the following
> is a real, legal e-mail address: *@qz.to  Really!  It belongs

 ... is definitely legal according to the spec.

Kai
-- 
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
  - Russ Allbery (rra@stanford.edu)


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

Date: 1 Sep 1999 18:13:43 GMT
From: lvirden@cas.org
Subject: Re: Invalid C++ syntax in CPAN packages
Message-Id: <7qjqcn$2fv$1@srv38.cas.org>


According to Bob Kline <bobklin@idt.net>:
:Does anyone know why so many of the CPAN distributions include code which
:uses K&R function definitions, which are not legal C++?  The first time I

Most likely because so few people are using C++ compilers.

-- 
<URL: mailto:lvirden@cas.org> Quote: Save us from the snobs.
<*> O- <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Wed, 01 Sep 1999 10:43:11 -0800
From: chettah@msn.com ("willow")
Subject: Logical operators
Message-Id: <Boez3.514$Zd.284994@WReNphoon3>

I am trying some file test logic like this:

if ( ( -z AGGIN ) && ( -z AGGOUT ) ) {
     die "Input file returned no rows, nothing to validate \n";
}
I would like the program to end if both files are empty, but it is ending if
only one file is empty.

and here:

if ( -z AGGIN || -z AGGOUT ) {
     print "One sorted file is empty, continuing \n";
}
I want the program to process if one, not both files are empty, but it is
giving the message when BOTH files are NOT empty.  I don't understand why I
am getting these results.  I played around with () and spaces to no avail.
I have also tested these independently and combined with "elsif".  Any
suggestions?

Thank you,

Tara



   -**** Posted from RemarQ, http://www.remarq.com/?a ****-
 Search and Read Usenet Discussions in your Browser - FREE -


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

Date: Wed, 01 Sep 1999 19:46:51 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Logical operators
Message-Id: <slrn7sr0la.bf8.jdporter@min.net>

In article <Boez3.514$Zd.284994@WReNphoon3>, willow wrote:
>I am trying some file test logic like this:
>
>if ( ( -z AGGIN ) && ( -z AGGOUT ) ) {
>     die "Input file returned no rows, nothing to validate \n";
>}
>I would like the program to end if both files are empty, but it is ending if
>only one file is empty.

Is it possible that one of those file handles -- say, AGGOUT --
has been opened for writing instead of reading?

And is it possible that -z applied to such a handle always returns true?

-- 
John Porter



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

Date: Wed, 01 Sep 1999 19:49:23 GMT
From: jcasey@workingventures.ca (John Casey)
Subject: Perl5 sendmail
Message-Id: <37cd819c.604095283@wv-proxy>

Hello all;

I am kinda new to PERL. I am trying to e-mail a form...sounds simple
enough, but all the documentation I find refers to UNIX
"\usr\lib\sendmail". I have PERL 5.004 installed, but can't find
anything similar to sendmail in bin or lib.

Thanks in advance


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

Date: 1 Sep 1999 20:06:13 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Perl5 sendmail
Message-Id: <7qk0vl$jmd$1@info2.uah.edu>

In article <37cd819c.604095283@wv-proxy>,
	jcasey@workingventures.ca (John Casey) writes:

: I am kinda new to PERL. I am trying to e-mail a form...sounds simple
: enough, but all the documentation I find refers to UNIX
: "\usr\lib\sendmail". I have PERL 5.004 installed, but can't find
: anything similar to sendmail in bin or lib.

You're using NT, aren't you?

Greg
-- 
It's a miracle that curiosity survives formal education.
    -- Albert Einstein


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

Date: Wed, 01 Sep 1999 18:02:47 GMT
From: agutier@my-deja.com
Subject: Re: PPT I have a diff XSUB
Message-Id: <7qjpnt$u6j$1@nnrp1.deja.com>

Fine. Then let it be known that I have this available.

In article <slrn7sql77.2ml.jdporter@min.net>,
  jdporter@min.net (John Porter) wrote:
> In article <7qjhl8$noj$1@nnrp1.deja.com>, agutier@my-deja.com wrote:
> >I have an XSUB that is based off of GNU diff. It works very well. It
> >runs under Linux and Windows NT. What do I do now? How do I submit it
> >to PPT?
>
> Unfortunately, this does not qualify for PPT, because the goal of
> PPT is to implement in Pure Perl.
>
> --
> John Porter
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 01 Sep 1999 19:39:47 GMT
From: jdporter@min.net (John Porter)
Subject: Re: PPT I have a diff XSUB
Message-Id: <slrn7sr083.bf8.jdporter@min.net>

In article <7qjpnt$u6j$1@nnrp1.deja.com>, agutier@my-deja.com wrote:
>In article <slrn7sql77.2ml.jdporter@min.net>,
>  jdporter@min.net (John Porter) wrote:
>> In article <7qjhl8$noj$1@nnrp1.deja.com>, agutier@my-deja.com wrote:
>> >I have an XSUB that is based off of GNU diff. It works very well. It
>> >runs under Linux and Windows NT. What do I do now? How do I submit it
>> >to PPT?
>>
>> Unfortunately, this does not qualify for PPT, because the goal of
>> PPT is to implement in Pure Perl.
>
>Fine. Then let it be known that I have this available.

It sounds very useful.  Have you considered uploading it to CPAN?

-- 
John Porter



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

Date: Wed, 01 Sep 1999 18:02:13 GMT
From: tvn007@my-deja.com
Subject: PROCESS CERTAIN BLOCK OF DATA IN A FILE ?
Message-Id: <7qjpmr$u65$1@nnrp1.deja.com>

#!/usr/local/bin/perl -w
$inputfile = $ARGV[0];
open(DATA,$inputfile)||die "ERROR: cannot open input file\n";
while (<DATA>) {
 			chomp;
			tr /(/ /d;
($tab1,$tab2,$spec_name,$spec_name2) = split /\t/,$_,4 ;
			push (@row ,$spec_name);
			}
		}
#############FIlE to read in $inputfile ############################
(spec-form	 #line1
		(:symbol	:item	:description	:gender	 #line 2
		(Tom	        "dc1"	"nice guy"	"M"	#line 3
		(John	        "dc2"	"good guy       "M"	#line 4
 ))                                                             #line 5

##################end of file $inputfile ############################

Would someone please help me on this ?

How do I modify the script file above so that it can start process
the data only starting at line 3 and stop at line 5 by using
":symbol" at the starting point and "))" at ending point

Thanks in advance for your help,


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 01 Sep 1999 19:53:45 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Question
Message-Id: <19990901155345.14123.00001718@ng-ft1.aol.com>


   chop($new_line) if $new_line =~ /\n$/;

 Would this do the same as chomp and be less dangerous in certain
circumstances? or is there a problem with this also? Thanks!



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

Date: 1 Sep 1999 20:08:08 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Question
Message-Id: <7qk138$jmd$2@info2.uah.edu>

In article <19990901155345.14123.00001718@ng-ft1.aol.com>,
	jimtaylor5@aol.com (Jimtaylor5) writes:

:    chop($new_line) if $new_line =~ /\n$/;
: 
:  Would this do the same as chomp and be less dangerous in certain
: circumstances? or is there a problem with this also? Thanks!

Gee, I don't know.

    This is a slightly safer version of chop().  It removes any line
    ending that corresponds to the current value of C<$/> (also known as
    $INPUT_RECORD_SEPARATOR in the CEnglish module).

Amazing!  I found that in the perlfunc documentation for chomp.

Greg
-- 
In theory there is no difference between theory and practice. In practice,
there is.


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

Date: Wed, 01 Sep 1999 18:45:58 GMT
From: ronERASEjeffries@ERASEacm.org (Ronald E Jeffries)
Subject: reading email
Message-Id: <37cd7383.27463743@news.det.ameritech.net>

I'm new to perl, though not programming, and am a bit over my head
here. Please point me to what I should read or otherwise do. 

I'm trying to write a little script to hide in my cgi directory to let
me read email from a web browser when I'm out of town. The ISP is
running NT.

I gather that Net:POP3 would be one way to do it. I've been unable so
far to find any documentation on that, or to get it downloaded and
installed.

Some patient help will be appreciated!

Thanks!

Ron Jeffries
http://www.XProgramming.com
"Meddle not in the affairs of dragons, for you are crunchy and taste
  good with ketchup" -- Fred Baker, Cisco Systems Inc.


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

Date: Wed, 01 Sep 1999 18:19:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Redirecting STDERR to STDOUT (on NT)
Message-Id: <37cf6dc7.1128598@news.skynet.be>

Larry Rosler wrote:

>How about this clever replacement for your 'die "\n"':
>
>    exit;

Try this in an "eval". You program will STILL quit.

    #! perl -w
    BEGIN {
        $SIG{__WARN__} = sub { print STDOUT "Oops: @_"; };
        $SIG{__DIE__} = sub {
            print STDOUT "Argh!: @_"."I'm dead."; exit};
    }
    eval {
         print $x/$y;
    	 print "Heh.\n";
    };
    print "Resuming\n";
-->
  Oops: Name "main::x" used only once: possible typo at test.pl line 8.
  Oops: Name "main::y" used only once: possible typo at test.pl line 8.
  Oops: Use of uninitialized value at test.pl line 8.
  Oops: Use of uninitialized value at test.pl line 8.
  Argh!: Illegal division by zero at test.pl line 8.
  I'm dead.

No "Resuming".

That's why I use "die" inside the SIG handler too. I assume there must
be a "resume dying" syntax, I though I had seen it once, but I can't
find it any more. A simeple "die;" is not it.

-- 
	Bart.


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

Date: Wed, 01 Sep 1999 19:15:01 GMT
From: tvn007@my-deja.com
Subject: repost (PROCESS CERTAIN BLOCK OF DATA IN A FILE ?
Message-Id: <7qjtv8$1rn$1@nnrp1.deja.com>





#!/usr/local/bin/perl -w
$inputfile = $ARGV[0];
open(DATA,$inputfile)||die "ERROR: cannot open input file\n";
 while (<DATA>) {
         chomp;
 tr /(/ /d;
($tab1,$tab2,$spec_name,$spec_name2) = split /\t/,$_,4 ;
 push (@row ,$spec_name);

         }
######## FIlE to read in $inputfile
(spec-form                                        #line1
         (:symbol  :item   :description  :gender  #line 2
         (Tom      "dc1"   "nice guy"    "M"      #line 3
         (John     "dc2"   "good guy     "M"      #line 4
))                                                #line 5

###############end of file $inputfile

 Would someone please help me on this ?

 How do I modify the script file above so that it can start process the
data only starting at line 3 and stop at line 4 by using
":symbol" at the starting point and "))" at ending point

Thanks in advance for your help,




Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 1 Sep 1999 18:32:57 GMT
From: Martin H. Sluka <martin@sluka.de>
Subject: Safe way to terminate blocking sub-threads?
Message-Id: <7qjrgp$ne1$1@fons.sluka.de>

I'm currently working on the data collector script for a monitoring
system. The basic idea is to have a script running as a daemon, that
each 30 seconds spawns a number of worker threads--say about a dozen--,
which themselves each call one external helper script or program that
does some data collecting--e.g., but not only, via SNMP--, handle the
results back to the main thread, which then validates the data and
delivers it to a central SQL database.

I'd like to implement the whole task mainly using Perl's new threading
capabilites. The problem however is, that the external scripts that are
started by the worker threads are supposed to be potentially dumb and
therefore maybe blocking, so the child threads would also block.

Therefore I had planned to have them do their work in an eval() block
and set a timeout using alarm() and a $SIG{ALRM} = sub die {"TIMEOUT\n"}
handler.

However, after experimenting a bit with threads and such a handler, I
found out, that whereever I set the timeout, it always and only seems
to affect the main thread, so the worker threads would still block.
Needless to say, this is not what I wanted.

I then again took a look at perlthrtut(1) and the various Thread::*
manpages to find a way to safely interrupt and stop a blocking sub
thread, but found none.

Now, as a workaround I came up with the following concept (which I have
_not_ implemented yet):

The data collector daemon (DCD) would fork() a new sub process (SP)
each 30 seconds. This sub process then creates the threads which start
the external helper scripts. Each of these threads gets a Thread::Queue
to communicate with the SP.

The SP then waits some time to give its worker threads a chance to
collect the data, then examines the queues to see which of them
successfully completed their work, validates the data, writes it into
the database and then simple kills itself with all its possibly still
blocking sub threads.

The longer I think about that, the uglier it seems to me. :-) :-/

So the questions remains: Is there any nicer way to solve this problem?
Is using threads perhaps the wrong way at all?

Would it perhaps be better instead to have the SPs run as distinct pro-
cess so that I can individually set a timeout in each of them, and have
them pass the results of the helper scripts they call to the DCD using
sockets?

Or to just do it the old-fashioned way, that is, forget about that
whole threading thing, leave it at calculating prime numbers, :-) and
open()ing the helper scripts right from the main program with pipes--
which of course also do an implicit fork()--and use a select()-loop,
killing the child processes if they didn't terminate within the given
period?

Sorry, I just came up with that idea while writing this article. Sounds
reasonable to me, "pretty straightforward", as perlthrtut(1) would cer-
tainly say. ;-) Are there any severe pitfalls to it?

The central point is, that I want to keep the _helper_ scripts as dumb
as possible, so I don't want to have them to talk to the main process
via sockets or anything like that, but simply get their parameters on
the commandline, put their results on STDOUT, and also possibly block
if there is say a networking problem.

Open to any suggestions,
Martin.

-- 
___________________________________________________________________
Martin H. Sluka  \ tel: +49-700-19751024 / "Urmel aus dem IRC(net)"
Pirckheimerstr. 1 >---------------------/ <mailto:martin@sluka.de>
D-91207 Lauf     / fax: +49-9123-13875 /  <http://martin.sluka.de/>


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

Date: Wed, 01 Sep 1999 11:21:46 -0700
From: Kim <kimgraham@hotmail.com>
Subject: Script within a script-can it be done?
Message-Id: <37CD6EB9.CC00D2AC@hotmail.com>

I have a web site that runs a web store perl script.  I would like to be
able to run my counter on some of the navigational pages, and my form
script on the pages with forms.  I don't want people to have to lose
their carts anywhere in the site.  Do I need to program the other
scripts as subroutines in the shopping cart?  Or is there another
solution I don't know about.

Thanks in advance,
Kim



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

Date: Wed, 01 Sep 1999 12:07:49 -0700
From: Brandon Metcalf <bmetcalf@nortelnetworks.com>
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <37CD7985.7CDE3861@nortelnetworks.com>

> The closest I've been able to come is to create a directory
> at c:\usr\bin to house a copy of perl.exe, and use
> #!c:/usr/bin/perl locally (because it at least works with forward
> slashes).
>
> Has anyone been able to do this so that they can omit the
> "c:" entirely?  Or am I SOL and going to have to always remember
> to modify this when I upload to production?

How about executing your Perl program on the windows side using "perl
mypogram"?

Brandon



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

Date: Wed, 1 Sep 1999 13:20:16 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <MPG.12372a607527b9a19896ea@nntp1.ba.best.com>

Daniel Kirkdorffer (see.email.address@bottom.in.sig) seems to say...
> and I've been hunting down solutions to a problem
> with the shebang line that starts all my Perl scripts so that I can
> continue to write #!/usr/bin/perl (which is where Perl is on
> the Linux production box), rather than #!c:\perl\bin\perl .

Much better luck asking this question in a group that deals with Apache.

Read the Apache docs.  1.3.6 Apache allowed the option to use a registry 
setting to run instead of the #! line.

http://www.apache.org/docs/mod/core.html#scriptinterpretersource




-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Wed, 1 Sep 1999 13:54:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <MPG.12373262de199abb989f08@nntp.hpl.hp.com>

In article <37CD5DC9.6D57020C@bottom.in.sig> on Wed, 01 Sep 1999 
10:09:29 -0700, Daniel Kirkdorffer <see.email.address@bottom.in.sig> 
says...
> I recently installed Apache 1.3.9 on my Win95 box to put the OS
> to good use ;^) and I've been hunting down solutions to a problem
> with the shebang line that starts all my Perl scripts so that I can
> continue to write #!/usr/bin/perl (which is where Perl is on
> the Linux production box), rather than #!c:\perl\bin\perl .
> 
> The closest I've been able to come is to create a directory
> at c:\usr\bin to house a copy of perl.exe, and use
> #!c:/usr/bin/perl locally (because it at least works with forward 
> slashes).
> 
> Has anyone been able to do this so that they can omit the
> "c:" entirely?  Or am I SOL and going to have to always remember
> to modify this when I upload to production?

Try omitting the 'c:'.  If Apache is installed on drive C: and/or the 
web cgi-bin directory is on drive C:, there is no reason to assume the 
current drive would be anything but drive C:.

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


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

Date: 01 Sep 1999 12:31:31 -0700
From: Bryan D Howard <bryan@ets02.jpl.nasa.gov>
Subject: Re: Simulating Carriage Returns
Message-Id: <7c671uig30.fsf@ets02.jpl.nasa.gov>

[[courtesy cc sent to original poster]]

Stone Cold <paulm@dirigo.com> writes:
> I could use the localtime mod, but it doesn't print out zeros in front
> of the months and/or days that are only 1 digit (e.g. 1999-9-1 --->
> need this to be 1999-09-01).
> 
> Any experience with the length statement?  Need to write an if
> statement that will print out "01" if month/day is 1 digit.

Oh, come on now.  RTFM.

% perl -e '@f=(localtime)[3..5]; $f[1]++; $f[2] += 1900; printf "%04d-%02d-%02d\n", reverse @f;'
1999-09-01

{Bryan}
-- 
Bryan D Howard, EIS FIL Unix Toolbuilder
JPL Section 363, Pasadena, CA, USA            <bryan@solstice.jpl.nasa.gov>


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

Date: Wed, 1 Sep 1999 13:46:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simulating Carriage Returns
Message-Id: <MPG.12373065a196df5e989f06@nntp.hpl.hp.com>

In article <7c671uig30.fsf@ets02.jpl.nasa.gov> on 01 Sep 1999 12:31:31 -
0700, Bryan D Howard <bryan@ets02.jpl.nasa.gov> says...
 ... 
> % perl -e '@f=(localtime)[3..5]; $f[1]++; $f[2] += 1900;
>           printf "%04d-%02d-%02d\n", reverse @f;'
                     ^^
That '04' is to ensure printing four digits should $f[2] be less than
-900, for example, -901.  :-)

> 1999-09-01

  0999-09-01

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


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

Date: Wed, 01 Sep 1999 15:26:50 -0400
From: "G.P. Singh" <anspa@spiff.hr.att.com>
Subject: system
Message-Id: <37CD7DFA.2AAD621@spiff.hr.att.com>

Hi,

A newbie question,

how i use to system"" to add a user
$user=<STDIN>;
$group=<STDIN>;
system "useradd -g $group $user"

it gives an error.

thanks
psingh@spiff.att.com



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

Date: Wed, 01 Sep 1999 21:38:15 +0100
From: cb <ecliptica.ww@nospam.virgin.net>
Subject: Re: Tracking progress of a Net::FTP download
Message-Id: <37CD8EB7.83E14042@nospam.virgin.net>

Thanks for that suggestion Bill ....

What the author of the lwp cookbook seems to be doing with the LWP::UserAgent
$ua->request() method is passing a subroutine as the second argument to the
method where in other circs a local filename is passed.

The Net::FTP $ftp->get() method can also take a local filename as the second,
so what I may try is constructing a subroutine to do the same sort of thing as
is being done in the lwp cookbook with $ua->request() but passing it into
$ftp->get(). I can't (perhaps in naivety) see any reason why that shouldn't
work. It's certainly worth a try, and looks a lot easier than messing about
with all that signal handling stuff!!

Many thanks for the pointer!!

Cheers ... CB ...

Bill Moseley wrote:

> cb (ecliptica.ww@nospam.virgin.net) seems to say...
> > I'm working on a Perl program which automates a regular download of
> > files using Net::FTP with  Perl 5.005 and  FreeBSD 3.2 UNIX on a P2/300.
> > It works fine, but, as it is, the best ways I can come up with of
> > telling whether the download is proceeding normally are (1) watch the
> > Hard Drive light to see whether stuff is being written to disk, or (2)
> > open another TTY console and issue "ls -l [filename]" commands to see
> > (hopefully) the number of bytes increasing.
>
> I'm not sure about Net::FTP, but if you use LWP::UserAgent you can do
> this.  There's an example in perldoc lwpcook
>





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

Date: 1 Sep 1999 18:37:24 GMT
From: "Patrick D. Wright" <Patrick.Wright@msfc.nasa.gov>
Subject: What does the perl debugger do?
Message-Id: <37CD7263.5FCC55B9@msfc.nasa.gov>

I am trying to run this function on a Dec (Compaq) running Tru64 Unix
(OSF1 4.0D).

sub Get_ipcs_dec_osf {
   use strict;
   my(@input) = @_;
   use Shell qw(ipcs);
   my($answer,@array);
   
   @array = ipcs("-m");
   foreach (@array) {print;};
   $answer = $#array - 3;
   return ($answer);
}

I am using perl version 5.005_03. The routine works (with a couple of
modifications) on an SGI running IRIX 6.5 and on a PC running Linux
2.2.5-22. On the SGI and the PC I get a listing of the shared memory
segments and the number of shared memory segments. On the Dec computer I
get "-4". 

I tried running the program in the debugger. If I set breakpoints
outside the function I get -4 for the return value. If I set a
breakpoint in the routine I get the correct output. So, my questions are

a) What am I doing wrong?
or
b) What does setting a breakpoint in the subroutine do that would cause
the routine to work?

Thank You
--  Patrick


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

Date: Wed, 01 Sep 1999 16:22:34 -0400
From: Jason Speers <jspeers@open.uoguelph.ca>
Subject: writing string with some '%' to a file
Message-Id: <37CD8B09.B739447A@open.uoguelph.ca>

Hi,

When I write a string containing any number of % characters in it to a
file, I get unexpected results in the file.  i.e. %%%% becomes %%  or
234%567 becomes 2340.0000000567  ... and sometimes this will not occur??

Is there something about the percent sign within a string that I do not
know about?  Or is there something about writing a percent sign to a
file that I do now know about?  Or perhaps I just need to brush up on my
perl skills??!?

Jason



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

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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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