[6886] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 510 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 21 19:06:14 1997

Date: Wed, 21 May 97 16:00:45 -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, 21 May 1997     Volume: 8 Number: 510

Today's topics:
     +?* matching (Andrey Yushkov)
     Re: +?* matching <usenet-tag@qz.little-neck.ny.us>
     Re: +?* matching (Mike Stok)
     Re: adding to an array within a while(<>) (Steve Wainstead)
     Re: Address parsing one-liner <jwd@graphics.cornell.edu>
     ANNOUNCE: VORTEXperl(tm) <boei@trifox.com>
     Re: ARGV and WinNT Perl <pkaartin@cc.helsinki.fi>
     Re: ARGV and WinNT Perl (Wolfram Schmidt)
     Re: avoiding "Use of uninitialized value..." warning <rootbeer@teleport.com>
     Re: Berkeley DB 1.85 Recovery (Paul Marquess)
     Re: BUG in matching ? (Ilya Zakharevich)
     Re: BUG in matching ? <usenet-tag@qz.little-neck.ny.us>
     Re: Change or Delete a line in a FILE <jl-muir@cat.ncsa.uiuc.edu>
     Re: Clearing a Form when using the Back Button (Chipmunk)
     Re: Closing open files in child process. How? <mkornell@bridges.com>
     Form parsing problem <Camille.Madany@nmp.nokia.com>
     Re: getting next line in while (Mike Stok)
     Re: getting next line in while (Honza Pazdziora)
     Re: Help in Removing lines with duplicate Field Ones (Andrew M. Langmead)
     Help Needed with Perl Script under OpenVMS simon@shrsys.hslc.org
     Re: Help: How to Split a file at a Null Line??? (Chipmunk)
     Re: http in perl for win32 <Jan.Krynicky@st.ms.mff.cuni.cz>
     Re: http in perl for win32 (Nathan V. Patwardhan)
     Re: Installing GD library (Nathan V. Patwardhan)
     Re: Installing GD library (Nathan V. Patwardhan)
     Re: Installing GD library <merlyn@stonehenge.com>
     make error in setting up PERL carter@ce-hydro.unl.edu
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 21 May 1997 16:40:54 GMT
From: andy@fly.donetsk.ua (Andrey Yushkov)
Subject: +?* matching
Message-Id: <5lv8im$old@anega.aist.net>

Hi!
Help me please!
Can't cut the word with ++ :(
Here is the test programm:
==============
#!/usr/local/bin/perl -w

$str =
"word_with_++_and_other Good words";
print "$str\n";

@arr = split(/\s+/, $str);
print "$arr[0]\n";
print "$arr[1]\n";

# Try to cut the first word!
# Wrong search operator
$str =~ s/^$arr[0]/ /;

## Very Bad method
#$str = substr $str, length $arr[0];

print "\n$str";
==============

Here is result:
==============
word_with_++_and_other Good words
word_with_++_and_other
Good
/^word_with_++_and_other/: nested *?+ in regexp at tmp.pl line 12.
==============

What's wrong? What must I do for deleting any word with + or ? or * 


--
 Andrey Yushkov     <*>   http://fly.donetsk.ua/~andy  


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

Date: 21 May 1997 17:54:52 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: +?* matching
Message-Id: <5lvctc$rrt$1@news.netusa.net>

Andrey Yushkov <andy@fly.donetsk.ua> wrote:

ua == Ukraine?

>Can't cut the word with ++ :(

+ is a special character to regexps. I am certain this is your
problem. I am uncertain what you want to do.

>@arr = split(/\s+/, $str);

Do you mean "split(/[\s+]/, $str)"? Or did you want + to be special
there?

># Try to cut the first word!
># Wrong search operator
>$str =~ s/^$arr[0]/ /;

You probably want:

 $str =~ s/^\Q${arr[0]}\E/ /;

>What's wrong? What must I do for deleting any word with + or ? or * 

Quote the special characters when trying to match them exactly.

Elijah
------
hoping I got the {[]} bit right


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

Date: 21 May 1997 17:56:18 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: +?* matching
Message-Id: <5lvd02$ask@news-central.tiac.net>

In article <5lv8im$old@anega.aist.net>,
Andrey Yushkov <andy@fly.donetsk.ua> wrote:
>Hi!
>Help me please!
>Can't cut the word with ++ :(
>Here is the test programm:
>==============
>#!/usr/local/bin/perl -w
>
>$str =
>"word_with_++_and_other Good words";
>print "$str\n";
>
>@arr = split(/\s+/, $str);
>print "$arr[0]\n";
>print "$arr[1]\n";
>
># Try to cut the first word!
># Wrong search operator
>$str =~ s/^$arr[0]/ /;

>What's wrong? What must I do for deleting any word with + or ? or * 

In perl 5 you can say 

  $str =~ s/^\Q$arr[0]\E/ /;

where \Q and \E bracket a chunk of string where metacharacters (for
regexes) are escaped with a \

If you want to do it the perl4 way you can say

  ($copy = $arr[0]) =~ s/(\W)/\\$1/g;
  $str =~ s/^$copy/ /;

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 21 May 1997 21:04:13 GMT
From: swain@panic.pdnewmedia.com (Steve Wainstead)
Subject: Re: adding to an array within a while(<>)
Message-Id: <5lvo0d$j1u$1@iagnews.iagnet.net>

Steve Wainstead (swain@panic.pdnewmedia.com) wrote:

: while ($something == 'TRUE') {
:    # perform something useful
:    # creating some value $new_item
:    push(@array, $new_item);
: }

Doh! I mean ($something eq 'TRUE') 

:-P

--
Steve Wainstead |||||||||||||||||||||||||| Cleveland Live
http://www.cleveland.com/
|||||||||||||||||||||


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

Date: 21 May 1997 17:11:44 -0400
From: James Durkin <jwd@graphics.cornell.edu>
Subject: Re: Address parsing one-liner
Message-Id: <resozgr0mn.fsf@eyrie.graphics.cornell.edu>

I-hate-cyber-promo@man.ac.uk (A. Deckers) writes:

>> Does anyone have a one-liner hanging around that will parse the email
>> address out of the headers of mail message or newsgroup post?  I know
> 
> while (<>) {
> 	last if /^$/;
> 	m/^From: (.+)$/ and $from = $1;
> }

Maybe I should have been more specific.  I don't want everything in
the From: header, but just the email address (sans name and associated
nonsense).

-- 
James Durkin
jwd@graphics.cornell.edu



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

Date: Wed, 21 May 1997 13:02:04 -0700
From: Bob Eisner <boei@trifox.com>
Subject: ANNOUNCE: VORTEXperl(tm)
Message-Id: <338354BC.41B@trifox.com>

VORTEXperl(tm) Announcement

Perl applications and relational databases with platform
independence! 

VORTEXPerl provides a simple interface for Perl applications to
access all leading relational and legacy databases via the
VORTEX database access and performance boosters, like
VORTEXaccelerator, the industry-leading high performance
transaction process monitor. With VORTEXPerl you can quickly
access DBMS information from CGI applications and spend your
time making your application great without bothering with DBMS
details. 

VORTEXPerl reads and writes data directly to and from TCP/IP
socket stream protocols which: 
 
-  Eliminates the need for any development work on the client
   side. 

-  Provides the best possible security and ensures compatibility
   with any Perl client. 

Servers that are currently supported include: 

       Windows NT             Unix
       OS/2                   OpenVMS
                              MVS

VORTEXPerl minimizes network traffic thereby improving
performance, with the following advanced features: 

-  Cursor caching -- Client side cursors are automatically
   cached, reducing actual interactions between the Perl client and
   the RDBMS server. 

-  Bulk operations -- SELECT, INSERT, UPDATE, and
   DELETE requests operate on multiple records in a single network
   transaction. 

How To Get VORTEXPerl

The file vtxperl.tar.Z includes a set of .HTML files, .pm files, and a
few sample Perl applications for you to examine. To run and test
the driver, you need a copy of VORTEXserver. We provide a
fully-functional copy for the evaluation (which expires after 90
days). 

Please see http://www.trifox.com/j/vortex/vtxperl.html#getit too obtain
your evaluation.

Regards,

Bob Eisner
408 369-2392



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

Date: 21 May 1997 13:26:12 GMT
From: Petrus Kaartinen <pkaartin@cc.helsinki.fi>
Subject: Re: ARGV and WinNT Perl
Message-Id: <5lut5k$hja$1@oravannahka.Helsinki.FI>

Petrus Kaartinen <pkaartin@cc.helsinki.fi> wrote:
: Used to do this in Unix:
: foreach (@ARGV) {
:         print "$_\n";
: }

: Doesn't work with Windows NT Perl5. Anyone knows how to read the
: commandline arguments in NT?

Thanks for all the answer here and via e-mail:

The problem was that I invoked my perl script
C:\> test.pl huu haa
C:\> 

which didn't do anything. Instead

C:\> perl test.pl huu haa
huu
haa
C:\> 

worked fine. Didn't even think it might matter (otherwise I would've
tried of course...).

-Petrus


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

Date: 21 May 1997 20:57:59 GMT
From: wschmidt@ikos2.iao.fhg.de (Wolfram Schmidt)
Subject: Re: ARGV and WinNT Perl
Message-Id: <5lvnkn$3im$1@news.belwue.de>

In article <5lev9k$s1u$1@oravannahka.Helsinki.FI>,
Petrus Kaartinen  <pkaartin@cc.helsinki.fi> wrote:
] Used to do this in Unix:
] foreach (@ARGV) {
]         print "$_\n";
] }
] 
] Doesn't work with Windows NT Perl5. Anyone knows how to read the
] commandline arguments in NT?
] 
] -Petrus
] 
] -- 
] eat  --  Petrus Kaartinen, U of Helsinki, Depts of Economics and CompS
]     the  --  http://www.helsinki.fi/~pkaartin/
]         rich  --  "life is for learning":


Are the commands passed to the program?

Here it looks like this:
C:\tmp> assoc .pl
 .pl=perlscript
C:\tmp> ftype perlscript
perlscript=perl %1 %*
C:\tmp>

Regards

Wolfram Schmidt


-- 
Email: Wolfram.Schmidt@iao.fhg.de
Voice: +49 711 970 2431
Fax: +49 711 970 2401
Office: Fraunhofer IAO, Holzgartenstr. 17, 70174 Stuttgart, Germany


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

Date: Wed, 21 May 1997 13:53:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Timothy H. Keitt" <tkeitt@santafe.edu>
Subject: Re: avoiding "Use of uninitialized value..." warning
Message-Id: <Pine.GSO.3.96.970521135157.735N-100000@kelly.teleport.com>

On Tue, 20 May 1997, Timothy H. Keitt wrote:

> I commonly write perl scripts that accumulate sums over several
> variables.  In general, I don't know a priori how large the hash or
> array of sums will be (it depends on the input data file).  For example,
> 
> #!/opt/bin/perl5 -w
> while ( <> ) {
> 	chomp;
> 	($a, $b) = split;
> 	$sum{$a} += $b;
> # -- or --
> 	$sum[$a] += $b;
> }
> 
> Perl is great for this because I don't need to know much about the data;
> the hash (or array) grows as needed.  The problem is that when I use the
> "-w" switch I get lots of "Use of uninitialized value" warnings.  

Many of 5.003's somewhat overeager warnings are now fixed in 5.004,
including this one. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 21 May 1997 20:45:11 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: Berkeley DB 1.85 Recovery
Message-Id: <5lvmsn$md6$1@pheidippides.axion.bt.co.uk>

[Posted & Mailed]

Michael Lew (mlew@wi.leidenuniv.nl) wrote:
: Are there any tools or utilities for recovering a
: dbm file made from Berkeley DB 1.85?

Nope.

: While creating a rather large keyword database using
: DB_File, perl ran out of memory and quit, leaving the
: dbm file in a state where the tie function gives the
: error "Invalid argument"

: I had looked at the current Berkeley DB at ver. 2.0,
: but the formats and API have significantly changed 
: from ver. 1.85.

Yep, 2,0 is very different from 1.85.

You may be interested in the latest release I made for DB_File (version
1.51). This can build with either 1.86/6 or 2.0 (but not both at the
same time). When built with DB 2.0 it attepts to work just like 1.85,
so your existing scripts should continure to work. You should also be
able to, at least attempt to, recover from catastrophic failures like
you encountered.

Paul

ps I would class DB_File 1.51 as Beta quality code. It is available on
   CPAN if you are interested.


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

Date: 21 May 1997 18:48:53 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: BUG in matching ?
Message-Id: <5lvg2l$1fo$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Mike Stok
<mike@stok.co.uk>],
who wrote in article <5luqb5$jk8@news-central.tiac.net>:
> In article <3382D738.5098@itba.mi.cnr.it>,
> Luca Barbetta (!KiChKaHa!) <barbetta@itba.mi.cnr.it> wrote:
> >Hello!
> >
> >I have a little observation...
> >
> >
> >I used this
> >
> >            while ($tmp=~m/^(.{1,32768})(.*)$/)
> >               {
> >               print OUTPUT $ID.$1.$End_Row;
> >	       $tmp=$2;
> >               }
> 
> The perl manual page distributed with perl 5.004 says:
> 
>   While none of the built-in data types have any arbitrary size limits (apart
>   from memory size), there are still a few arbitrary limits:  a given
>   variable name may not be longer than 255 characters, and no component of
>   your PATH may be longer than 255 if you use -S.  A regular expression may
>   not compile to more than 32767 bytes internally.
> 
> and you may have run into that,  one workaround might use index (to check
> for \n) and substr to carve up the string.

Wrong. This has nothing to do with the *size* of regexp.  I still get
no round tuits to add a croak/warn if an iterator quantifier is bigger
than 32766.  Anything bigger than this will confuse RE engine, but it
remains silent...

Ilya


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

Date: 21 May 1997 17:42:20 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: BUG in matching ?
Message-Id: <5lvc5s$rit$1@news.netusa.net>

Luca Barbetta (!KiChKaHa!) <barbetta@itba.mi.cnr.it> wrote:
>I used this
>            while ($tmp=~m/^(.{1,32768})(.*)$/)

Ugh. There are much more efficent ways of getting substrings. Try
a solution involving substr and length.

>The problem is that if I use 32767 instead of 32768 this little
>procedure dont work absolutely! The result is the ID and all $tmp string
>(also if his lenght is > 32767) 

Grep for "3276" in the perl man pages. I believe this is documented.

Elijah
------
this is one of those hints that you are doing something the wrong way


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

Date: Wed, 21 May 1997 12:20:10 -0500
From: "J. Lewis Muir" <jl-muir@cat.ncsa.uiuc.edu>
Subject: Re: Change or Delete a line in a FILE
Message-Id: <33832ECA.12DB@cat.ncsa.uiuc.edu>

Cheetat Yap wrote:
> 
> Dear Sirs/Madams
> 
>         Can anyone suggest a direct way to change or delete a line in the
> middle of a TEXT FILE.....
> 
>         Thanks in advance...
> 
> 
> CheeTat
> tat@pc.jaring.my
> 
> ps: I did read the PERL' FAQ.

One way would be to read through the file line by line outputing each
line to a new file and then when you get to the line you want to change,
change it and write it out to the new file, or if you want to delete it,
skip it.  And then write the rest of the file out to the new file.

In pseudocode would be something like this:

copy tfile.txt to tfile.bak
while not at end of tfile.bak
  readline tfile.bak
  if it is the line you want to change
    then change it and write it out to tfile.txt
  if it is the line you want to delete
    then just go to the next iteration of the loop
  else then write current line out to tfile.txt
end while


If the file is big and you know you only want to change one line then
once you find the line, do what you want to do, then you might put a
loop like the following to avoid all of the comparisons since you know
you don't want to change anything else:

while(!eof(FILEHANDLE)) {
  $line = <FILEHANDLE>;
  print DESTINATIONFILEHANDLE $line;
}
last;


-Lewis Muir


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

Date: 21 May 1997 19:41:27 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Clearing a Form when using the Back Button
Message-Id: <5lvj57$925$1@dartvax.dartmouth.edu>

In article <5lq5sn$fbu@news.gvsu.edu>
luxt@gvsu.edu (Timothy Lux) writes:

> In article <EAFuMx.HzG@nonexistent.com>, abigail@fnx.com wrote:
> >Uhm, what has this to do with Perl?
> >
> >Try rec.collecting.sport.football, maybe they know.
> >
> 
> Uhm, maybe the answer lies in how the script was processed? Thanks for being 
> rude...

There have been much ruder responses sent to posters in this newsgroup
who ask questions that are either unrelated to Perl or answered in the
FAQ or man pages.  While I strongly disapprove of such replies, I think
you could have had much worse than Abigail's response.

Chipmunk


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

Date: Wed, 21 May 1997 13:46:42 -0700
From: "Mark Kornell" <mkornell@bridges.com>
Subject: Re: Closing open files in child process. How?
Message-Id: <5lvmsg$dq4@fountain.mindlink.net>

NOFILE is just a symbolic constant referring to the maximum # of allowed
open files.  Varies from platform to platform, even from kernel build to
kernel build...

The equivalent in Perl: (apologies for formatting, or lack thereof :-)

#not my code, grabbed from somewhere I can't remember
my $NOFILE = 32; #pick a reasonable number.
my $SYS_close = (`uname -s` =~ /irix/i) ? 1006 : 6;
        for ($i=0; $i<$NOFILE; $i++) {
              syscall($SYS_close, $i+0);  #force numeric context for $i
        }


--mark;
--
Mark Kornell < mkornell@bridges.com >






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

Date: Tue, 20 May 1997 16:34:36 -0700
From: Camille Madany <Camille.Madany@nmp.nokia.com>
Subject: Form parsing problem
Message-Id: <3382350C.2BA8@nmp.nokia.com>

I am having a problem parsing information from one pl script into
another. The layout is:

  1) "query.html" page with post action to "process.pl" (passes it
     arguements)
  2) "process.pl" creates a html page for the user using the passed
     arguements and asks for more
  3) user fills in more information and submits with post action
     to "submit.pl" 
  4) "submit.pl" parses data passed to it and writes it to a file.

The problem is that no data is passed to step (4), created file is
empty.
In "submit.pl", I have the section: 

  &parse_form_data(*process);
  $name = $process{'name'};

Is this correct? I can't combine steps 1&2 to get around this.

Thanks.


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

Date: 21 May 1997 17:49:55 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: getting next line in while
Message-Id: <5lvck3$afl@news-central.tiac.net>

In article <5lva65$qpr$1@news.netusa.net>,
Eli the Bearded  <usenet-tag@qz.little-neck.ny.us> wrote:

>Don't forget that "while(<FILEHANDLE>)" is just a handy shorthand for
>"while($_=<FILEHANDLE>)".

  or even

   while (defined ($_ = <FILEHANDLE>)) 

  Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 21 May 1997 17:07:29 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: getting next line in while
Message-Id: <adelton.864234449@aisa.fi.muni.cz>

etfinley@ece.ucdavis.edu (Eric Finley) writes:

> How can I get the next line of the file while in the while loop without going through the
> next iteration of the while.  My code looks like:
> 
> while (<FILE>) {
>     if (/foo/) {
> 	print;
>     }
>     if (/bar/) {
> 	print;
> 	get next line;
> 	print next line;
>     }
> }

Do additional read inside of the loop:

if (/bar/) {
	print;
	$_ = <FILE>;
	print;
	}

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Wed, 21 May 1997 16:58:05 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Help in Removing lines with duplicate Field Ones
Message-Id: <EAJJ4t.JrE@world.std.com>
Keywords: Duplicate

guest@blueline.east.sun.com (Guest Account) writes:

>Purpose:   Keep only those records in the file which have a UNIQUE
>	   field #1.

Do the unique records need to stay in the same order?

If not, then maybe save each copy of field 1 in a hash, keeping the
count of the number time times seen and the record. When done reading
the file, output all of the ones whose count equals 1.


while(<>) {
  ($field1) = unpack 'A8', $_;
  $records{$field1}{count}++;
  $records{$field1}{data} = $_;
}

foreach $record (keys %records) {
  print $record->{data} if $record->{count} == 1;
}

If they do have to stay in the same order, then maybe something like:

while(<>) {
  ($field1) = unpack 'A8', $_;
  $seen{$field1}++;
  push @records, { data => $_, count => \$seen{$field1} };
  #maybe adding an "if $seen{$field1}" statement modifier if memory is tight.
  # as long as the %seen hash is correct, there is no reason to store
  # data we won't print.
}

foreach $record (@records) {
  print $record->{data} if $record->{count} == 1;
}

Basically, use the hash to keep count of records, store each record,
and only print out the records whose count equals 1.

-- 
Andrew Langmead


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

Date: Wed, 21 May 97 11:43:02 -500  
From: simon@shrsys.hslc.org
Subject: Help Needed with Perl Script under OpenVMS
Message-Id: <3383178c.0@news.hslc.org>

I am trying to run the attached canned script with Perl5_003-99a under OpenVMS.

I get the following error with perl:

%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=00000000,
PC
=00224BFC, PS=0000001B
%TRACE-F-TRACEBACK, symbolic stack dump follows
 Image Name   Module Name     Routine Name    Line Number  rel PC      abs PC
 SOCKETSHR_NE                                           0 0002ABFC    00224BFC
 SOCKETSHR_NE                                           0 00021B44    0021BB44
 PERLSHR                                                0 000DC560    0011E560
 PERLSHR                                                0 000DC404    0011E404
 PERLSHR                                                0 00082900    000C4900
 PERLSHR                                                0 00045A58    00087A58
 PERL         PERLMAIN        main                  26045 00000198    00020198
 PERL         PERLMAIN        __main                    0 00000070    00020070
                                                        0 90BA4170    90BA4170

I get the following error with perl -d (xxxxx indicates secure but valid data
entered):

$ perl -d poppass.cgi host=mail.hslc.org username=xxxxx password=xxxxxxx -
	newpassword1=xxxxxxx newpassword2=xxxxxxx

Loading DB routines from perl5db.pl version 1
Emacs support available.

Enter h or `h h' for help.

main::(poppass.cgi:38): open(STDERR,">&STDOUT") || die "Can't dup stdout: $!\n";
  DB<1> r
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Change Your Password</TITLE>
<LINK REV=MADE HREF="mailto:Jerry Workman">
<BASE HREF="http://localhost/poppass.cgi">
<META NAME="copyright" CONTENT="Copyright 1996 Jerry Workman">
</HEAD><BODY BGCOLOR="#FFFFFF">Signal BUS at poppass.cgi line 122
        eval {...} called at poppass.cgi line 120
        main::poppass('mail.hslc.org', 'xxxxxx', 'xxxxxxx', 'xxxxxxx') called at
 poppass.cgi line 84


Can anyone shed any light on why this script doesn't work?


POPPASS.CGI
===========
#!/usr/local/bin/perl

# PopPass - a CGI script in Perl to allow users to changes their password
# using a WWW interface. PopPass uses poppassd version 1.2 (available at
# ftp.qualcom.com/quest/unix/servers/password/pwserve-4 to actually make 
# the password change. It can therefore run as an unprivilaged user on any 
# server (not necessarly the server where the password file exists). The 
# Perl 5 modules LWP:Socket and CGI are also required (available from your 
# favorite CPAN site).
# ==========================================================================
# Created: 2 Feb 96 by Jerry Workman (jerry@newwave.net)
# Last Revised: 27 Nov 96
# ==========================================================================
#.COPYRIGHT NOTICE
# ==========================================================================
# Copyright Jerry Workman 1996 - All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose is hereby granted without fee, provided
# that the above copyright notice appear in all copies and that both that
# copyright notice, this permission notice, and the following disclaimer
# appear in supporting documentation, and that the names of the copyright
# holders, not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior permission.
#
# THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR ANY PARTICULAR PURPOSE.  IN NO EVENT SHALL JERRY WORKMAN
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA, OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
# --------------------------------------------------------------------------
use LWP::Socket;	# network socket module
use CGI qw(:all);	# CGI forms etc
# --------------------------------------------------------------------------
open(STDERR,">&STDOUT") || die "Can't dup stdout: $!\n";
select(STDERR); $| = 1; # Make unbuffered.
select(STDOUT); $| = 1; # Make unbuffered.
# --------------------------------------------------------------------------
$DEBUG		= 0;
$TIMEOUT	= 30; 		# Read / Write timeout
$BGCOLOR	= '#FFFFFF';
$DEFAULTHOST	= 'localhost';	# host name if different from web server
$TITLE		= 'Change Your Password';
$AUTHOR		= 'Jerry Workman';
$COPYRIGHT	= "Copyright 1996 $AUTHOR";
$HOME		= hr. a({href=>"/"}, "Home"); # Very Basic Home link
$MESSAGE	= <<EOM;
Enter your UserName, current password, and new password (twice for
verification) then click on Change Password. Passwords must be
at least 6 characters and can be mixed case.
EOM
# ** End of Configurable Parameters (unless you're a Perl hacker) **
# --------------------------------------------------------------------------
$host 		= param('host') || $DEFAULTHOST;
$username 	= param('username');
$password 	= param('password');
$newpassword1 	= param('newpassword1');
$newpassword2 	= param('newpassword2');
# --------------------------------------------------------------------------
print header, 
      start_html(-"title"=>$TITLE,
                 -"author"=>$AUTHOR,
                 -"base"=>'true',
                 -"meta"=>{'copyright'=>$COPYRIGHT},
                 -BGCOLOR=>$BGCOLOR);
print dump if $debug;
if(!param()) {
  showform();
} else {
  error_exit("You must supply a UserName") 
    if (!$username);
  error_exit("New Passwords do not match") 
    if ($newpassword1 ne $newpassword2);
  error_exit("The New Password can not be blank") 
    if length($newpassword1) == 0;
  $newpassword = $newpassword1;
  error_exit("New Password can not contain spaces") 
    if $newpassword =~ / /;
  error_exit ("Password must be six or more characters")
    if length($newpassword) < 6;
  if(poppass($host, $username, $password, $newpassword)) {
    print p, center(h2("Password Changed Successfully")), "\n";
  } else {
    error_exit("$msg");
  }
  print hr, "<I>Be sure to change your password in both your dialer" .
            " and E-mail programs</I>";
}
print $HOME, end_html;
# --------------------------------------------------------------------------
# Subroutines
# --------------------------------------------------------------------------
sub showform {
  print p, center(h2('Change Password')), hr, 
    $MESSAGE, hr, center(pre(startform(),
    "<b>           UserName: </b>", textfield('username','', 25), "\n",
    "<b>       Old Password: </b>", password_field('password','', 25), "\n",
    "<b>       New Password: </b>", password_field('newpassword1','',25),"\n",
    "<b>Verify New Password: </b>", password_field('newpassword2','',25),"\n\n",
    submit('action','Change Password'),
    endform)), "\n";
}
# --------------------------------------------------------------------------
sub error_exit {
  my($msg) = @_;
  print h1("Error:"), h2($msg), hr,
       "Return to the previous page and make the necessary corrections",
       $HOME, end_html;
  exit;
}
# --------------------------------------------------------------------------
# Change the password using service poppassd at port 106
#
sub poppass
{
  my($host, $username, $password, $newpassword) = @_;
  eval {
    $socket = new LWP::Socket;
    $socket->connect($host, 106);
    while ($socket->read_until("\n", \$_, undef, $TIMEOUT)) {
      print ($_, br) if $debug;
      /^200 poppassd/ && 
        ($socket->write("user $username\n", $TIMEOUT), next );
      /^200 your password please/ && 
        ($socket->write("pass $password\n", $TIMEOUT), next );
      /^200 your new password please/ &&
        ($socket->write("newpass $newpassword\n", $TIMEOUT), next );
      /^200 Password changed, thank-you/ && 
        ( $msg = "Password successfully changed", $status = 1, last );
      /^200 Bye/ && last;
      /^500/ && ( s/500//, $msg = $_, $status = undef, last );
      // && ( $msg = "No Response from server", $status = 0, last );
    }
    $socket = undef;  # close
  };
  if ($@) {
    ($msg) = split(/:/, $@);
    $msg =~ /[Tt]imeout/ && ($msg = "Server is Busy, try again later.");
    $status = 0;
  }
  $status
}


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

Date: 21 May 1997 19:54:05 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Help: How to Split a file at a Null Line???
Message-Id: <5lvjst$92q$1@dartvax.dartmouth.edu>

In article <tcyangEAG3C7.4Jy@netcom.com>
tcyang@netcom.com (Tung-chiang Yang) writes:

> Tad McClellan (tadmc@flash.net) wrote:
> 
> : #! /usr/bin/perl -w
> 
> : open(OUT, ">file1") || die "could not open file1  $!";
> 
> : while (<>) {
> :    if (/^$/) {  # found an empty line
> :       # open() below does an implicit close(OUT) first
> :       open(OUT, ">file2") || die "could not open file2  $!";
          ^^^^^^^^^^^^^^^^^^^
> :       next;
> :    }
> :    print OUT;
> : }
> 
> : close(OUT);

> This seems to be a better idea.  However, if there are more than
> one empty line in the input file, say
> 
> ---
> lines 1-13
> 
> lines 14-35
> 
> lines 36-87
> 
> lines 88-90
> ---
> 
> Will your program leave lines 1-13 in 'file1' and lines 88-90 in
> 'file2' and skip over lines 14-35 and 36-87?
> 
> (Of course for the original question, it is O.K. if we know for sure
> there is only one empty line in the file)

It won't 'skip over' lines 14-35 and 36-87, but, I think they'll be
missing from the second output file.  It looks like the second file is
overwritten every time a blank line is encountered.

That would be easy to fix, of course, either by opening for append
  open(OUT, ">>file2")
or by adding a flag so that the second file is only opened once
  if (!$opened) { open(OUT, ">file2") || die "could not open file2  $!"
}
  $opened = 1;

In any case, it's a clever solution, and I wish I'd thought of it!

Chipmunk


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

Date: Wed, 21 May 1997 20:51:36 -0700
From: Jan Krynicky <Jan.Krynicky@st.ms.mff.cuni.cz>
To: Rien used-to-be-sick-but-now-I'm-Heald <rheald@tfs.net>
Subject: Re: http in perl for win32
Message-Id: <3383C2C8.47AC@st.ms.mff.cuni.cz>

Rien used-to-be-sick-but-now-I'm-Heald wrote:
> 
> I've installed perl for win32 on Win95 (similar to per previously) and
> am needing to do some HTTP with this from a command line prompt.  I
> understand I could use lwp to accomplish this, and have thus downloaded
> lwp with this intent.  However, I can't get lwp to install.  I found a
> script to help install it, supposedly, but that's not working.  So....
> 
> 1) Any ideas on how to install lwp to get it to work w/ perl for win32?
> 
> 2) Any other ideas on how to do http w/out lwp?
> 
> Thanks.
> 
> replies here or e-mail either way.  If you put it here we all benefit
> except those who think NT and 95 are OS aberrations 8-).

use Win32::Internet;

I think it's in the standard set of the Activeware port.
If not, contact CPAN.

http://www.perl.com/CPAN

Hi, Jenda


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

Date: 21 May 1997 19:18:12 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: http in perl for win32
Message-Id: <5lvhpk$83l@fridge-nf0.shore.net>

Rien used-to-be-sick-but-now-I'm-Heald (rheald@tfs.net) wrote:

: 1) Any ideas on how to install lwp to get it to work w/ perl for win32?

>From Chris Russo (crusso@mit.edu);

ftp://cogen.mit.edu/software/perl/libwww-win32-fix.zip

==========

This file contains the files necessary for running LWP/libwww under
Activeware's port of Perl for Win32 5.003 or higher.

1) Get and install Perl for Win32 version 5.003 build 303
or higher from www.activeware.com.  5.001 will not work with
this procedure!

2) Get the libwww distribution from www.sn.no/libwww-perl and copy
the files into the corresponding sub directories in your PERLLIB
directory.  You can't run the makefile on Win32.  Copy the LWP.pm 
file directly into the PERLLIB directory.  

3) Unzip this distribution (which you've presumably already done) 
copy all of the *.al files into the corresponding directories
in your PERLLIB\auto tree.  You shouldn't have to overwrite anything 
to do this.  

4) Open the file UserAgent.pm in a text editor, and change the line

	'use_alarm'   => 1,

to

	'use_alarm'   => 0,

and close and save the file.

5) To verify installation, try this simple script:

use LWP::Simple;
$doc = get "http://www.yahoo.com/";
print $doc;

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 21 May 1997 18:41:03 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Installing GD library
Message-Id: <5lvfjv$4li@fridge-nf0.shore.net>

Maarten (maartenn@vademecum.be) wrote:
: Thanks Nathan but can someone explain how to build it because I only use
: perl on the UNIX machine of my provider and I am not authorized to run
: shell commands.

Sheesh, I hope you're able to able to run shell commands, or this whole
process might be rather, umm, difficult.

There are better ways to do this, but here's a way you might find
effective:

(1) run perl Makefile.PL (you *must* be using Perl, version 5)
(2) edit the PREFIX in the Makefile to be the area where you wish to
    install GD.
(3) run make
(4) run make install

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 21 May 1997 21:24:17 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Installing GD library
Message-Id: <5lvp61$fm1@fridge-nf0.shore.net>

Randal Schwartz (merlyn@stonehenge.com) wrote:
[author CC'ed]

: Nathan> (2) edit the PREFIX in the Makefile to be the area where you wish to
: Nathan>     install GD.
: Nathan> (3) run make
: Nathan> (4) run make install

: Step 2 is not required if in either step 1 or step 4 you add:

: 	PREFIX=/what/ever

You are correct, sir.  perl Makefile.PL PREFIX=/path/to/install/locally
works just fine.  *doink*

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 21 May 1997 14:14:59 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Installing GD library
Message-Id: <8c91188r3g.fsf@gadget.cscaper.com>

>>>>> "Nathan" == Nathan V Patwardhan <nvp@shore.net> writes:

Nathan> There are better ways to do this, but here's a way you might find
Nathan> effective:

Nathan> (1) run perl Makefile.PL (you *must* be using Perl, version 5)
Nathan> (2) edit the PREFIX in the Makefile to be the area where you wish to
Nathan>     install GD.
Nathan> (3) run make
Nathan> (4) run make install

Step 2 is not required if in either step 1 or step 4 you add:

	PREFIX=/what/ever

to the command line.  At least, that's my understanding from reading
the MakeMaker docs.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 467 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 21 May 1997 21:51:59 GMT
From: carter@ce-hydro.unl.edu
Subject: make error in setting up PERL
Message-Id: <5lvqpv$6u2@crcnis3.unl.edu>

I'm getting the following error message when I try to use the make command as I 
install PERL 5.004.   Does anybody know how to fix this?

panic: corrupt saved stack index, <IN> chunk 31355.
*** Error code 139
make: Fatal error: Command failed for target 'preplibrary'


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

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

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