[12436] in Perl-Users-Digest
Perl-Users Digest, Issue: 6036 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 17 19:07:25 1999
Date: Thu, 17 Jun 99 16:00:23 -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 Thu, 17 Jun 1999 Volume: 8 Number: 6036
Today's topics:
Re: Afraid to ask about Y2K! finsol@ts.co.nz
background CGI process? pittelli@envmed.rochester.edu
Re: background CGI process? <upsetter@ziplink.net>
Re: background CGI process? (Elf Sternberg)
Re: blank row in array (Tad McClellan)
C::Scan <bcboy@cisco.com>
Re: C::Scan (Ilya Zakharevich)
Re: cgi query error <uucon@my-deja.com>
changing text in a file? <fake@nospam.edu>
Re: changing text in a file? <upsetter@ziplink.net>
Re: changing text in a file? <cassell@mail.cor.epa.gov>
having dots on screen while waiting (Steve .)
Help debugging odd Perl + Perl module interaction <jlarke@ans.net>
Re: Help debugging odd Perl + Perl module interaction (Ilya Zakharevich)
Re: How can I 'edit' a datafile? <mhc@Eng.Sun.COM>
Re: How do I the equiv. of csh echo $0 in perl? <mhc@Eng.Sun.COM>
Re: How do I the equiv. of csh echo $0 in perl? (Elf Sternberg)
Re: how to change a line of text in a file? (Greg Bacon)
Re: how to change a line of text in a file? <fake@nospam.edu>
Re: how to change a line of text in a file? (Greg Bacon)
Re: how to change a line of text in a file? <cassell@mail.cor.epa.gov>
Re: Newbie Array Question <hojo@i-tel.com>
OO-Trap! I am confused <janning@vygen.de>
Re: Personal Rant (was Re: Does Perl have a future?) <cassell@mail.cor.epa.gov>
Re: qr// doesn't save my day! <jll@skynet.be>
Re: qr// doesn't save my day! (Ilya Zakharevich)
Re: Regex Help Needed (John Frank)
Sending output only to browser, not to user... <ketanp@XYZABCxwebdesign.com>
Re: SIGCHLD problems (Michael Helm)
Re: Signature removal regex? (J. Moreno)
Re: Signature removal regex? (J. Moreno)
Sorting an Array <jim.ray@west.boeing.com>
Re: Sorting an Array (Andrew Johnson)
Re: win32 perl problems gheppner@my-deja.com
Re: win32 perl problems <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Jun 1999 21:25:50 GMT
From: finsol@ts.co.nz
Subject: Re: Afraid to ask about Y2K!
Message-Id: <7kbp4i$v46$1@nnrp1.deja.com>
In article <376942C0.860F1144@mindspring.com>,
keithmur@mindspring.com wrote:
> finsol@ts.co.nz wrote:
> >
<SNIP>
>
> Here's the suggestion, finsol, or whoever:
>
> grep all the damn source code to find all references to localtime.
> Follow all the code ...
The Y2K problem in Perl code goes beyond just the localtime booby trap.
The localtime issue is just the most obvious but even so few Perl coders
on this site acknowledge it as being a problem their reasoning being
that the manual states quite clearly how localtime should be used.
For more Y2K problems that may affect Perl code, you may want to check
out this URL:
http://www.idg.co.nz/WWWfeat/Y2000/ja190499.htm
Others problems that may be of interest are described at:
http://www.y2kinfo.com/journal/features/0499_amon.html
http://www.idg.co.nz/WWWfeat/Y2000/amon0914.htm
BTW, I have NEVER stated that the Perl programming language is not Y2K
compliant - I do know the distinction. Most languages are Y2K compliant
but the Y2K issue is about fixing the applications written in those
languages - any language. ANSI COBOL has always been Y2K compliant but
millions are being spent fixing the code. Getting defensive about Perl
clouds the issue that it is just as likely as any language to have Y2K
problems - possibly more so due to the booby trap problem it shares with
a handful of other languages.
Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 17 Jun 1999 20:32:33 GMT
From: pittelli@envmed.rochester.edu
Subject: background CGI process?
Message-Id: <7kbm11$tsn$1@nnrp1.deja.com>
I have a CGI script which sends HTML to the
client, then sends email to someone else.
However, I cannot figure out how to kill the
connection to the web-server/browser (not sure
which it is) so that the browser doesn't wait
around for the mail script to finish.
I already have:
$| = 1;
&send_html;
$| = 0;
&send_mail;
...which does send the HTML to the browser before
waiting for the email to be sent. However, the
browser still waits (as if it's waiting to keep
loading data) until the mail is sent.
Any way to have the mail job be done totally in
the backround?
If not a nuisance, please cc to:
pittelli@envmed.rochester.edu
Thanks.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 17 Jun 1999 22:06:54 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: background CGI process?
Message-Id: <2kea3.315$7X1.70028@news.shore.net>
pittelli@envmed.rochester.edu wrote:
: I have a CGI script which sends HTML to the
: client, then sends email to someone else.
: However, I cannot figure out how to kill the
: connection to the web-server/browser (not sure
: which it is) so that the browser doesn't wait
: around for the mail script to finish.
You probably want to fork off a separate process to handle the email.
Start with perldoc -f fork and take it from there.
Good luck!
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 17 Jun 1999 22:20:12 GMT
From: elf@halcyon.com (Elf Sternberg)
Subject: Re: background CGI process?
Message-Id: <7kbsas$ebk$1@brokaw.wa.com>
In article <7kbm11$tsn$1@nnrp1.deja.com>
pittelli@envmed.rochester.edu writes:
>I have a CGI script which sends HTML to the
>client, then sends email to someone else.
>However, I cannot figure out how to kill the
>connection to the web-server/browser (not sure
>which it is) so that the browser doesn't wait
>around for the mail script to finish.
>Any way to have the mail job be done totally in
>the backround?
Two things. First:
close(STDOUT);
will tell the server and by extension the browser that you're
done sending stuff to the browser. Secondly, take a look at fork();
It might be what you want. It allows your program to spawn off a
detached process to complete what you wanted to accomplish. Your
original process can then terminate, really closing down the
connection. Make sure you spawn it off completely-- give it its own
process group and everything-- before the parent process terminates,
or it'll still be a descendent of the webserver, and some webservers
"clean up" detached processes to prevent runaways from eating the CPU.
Elf
--
Elf M. Sternberg, rational romantic mystic cynical idealist
If you're so smart, why aren't you naked?
A.A 1493 http://www.halcyon.com/elf/
------------------------------
Date: Thu, 17 Jun 1999 12:55:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: blank row in array
Message-Id: <699bk7.p6k.ln@magna.metronet.com>
Michael Hill (l463520@lmtas.lmco.com) wrote:
: I created this array like this:
: @myarr = ($mypart);
That creates an array with one element in it.
: then populated it like:
: push (@myarr, "parta");
: push (@myarr, "partb");
: push (@myarr, "partc");
: Then when i display the array I have a blank row.
: I had to modify my code like below to prevent the blank row.
: @myarr = ($mypart);
: pop(@myarr);
: push (@myarr, "parta");
: push (@myarr, "partb");
: push (@myarr, "partc");
: Shouldn't I be able to create the array empty instead of with a blank
: row?
Yes you should.
You *asked* for the value of $mypart to be put into the array.
If you don't want it in there, then don't put it in there.
You don't need to (though you should _have_ to, since non-script
kiddies always use strict) "create" an array.
You can just do the three push()es alone...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 17 Jun 1999 14:32:28 -0700
From: Brian Craft <bcboy@cisco.com>
Subject: C::Scan
Message-Id: <3769696C.F8755801@cisco.com>
Hey -- Has anyone gotten C::Scan to work on Linux? It always exits with
this error:
Expecting parenth after identifier in `int32_t __random (void) '
after `int32_t ' at /usr/lib/perl5/site_perl/C/Scan.pm line 494.
...which seems to be from a system header which is included
automatically.
b.c.
------------------------------
Date: 17 Jun 1999 22:40:03 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: C::Scan
Message-Id: <7kbtg3$cuj$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Brian Craft
<bcboy@cisco.com>],
who wrote in article <3769696C.F8755801@cisco.com>:
> Hey -- Has anyone gotten C::Scan to work on Linux? It always exits with
> this error:
>
> Expecting parenth after identifier in `int32_t __random (void) '
> after `int32_t ' at /usr/lib/perl5/site_perl/C/Scan.pm line 494.
Apparently your headers are not in C, but in some GNU dialect. The
latest version tries to compensate for this __attribute__ line noise.
Please report after upgrading.
Thanks,
Ilya
------------------------------
Date: Thu, 17 Jun 1999 20:36:45 GMT
From: Ryan Corder <uucon@my-deja.com>
Subject: Re: cgi query error
Message-Id: <7kbm8s$tvt$1@nnrp1.deja.com>
I checked the perldiag man page. and didnt get anything out of it.
ryan
In article <Pine.GSO.4.02A.9906171121090.13900-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Thu, 17 Jun 1999, Ryan Corder wrote:
>
> > Can't call method "param" without a package or object reference at
>
> Have you seen what the perldiag manpage says about this message? Cheers!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 17 Jun 1999 14:58:37 -0700
From: "Ariel" <fake@nospam.edu>
Subject: changing text in a file?
Message-Id: <7kbqv0$njf@news.or.intel.com>
first of all i apologize if there are multiple/repetive postings of mine, i
had to cancel a few messages, etc. anyways...
to change a few lines of text in a file, my code went like this:
$myfile = "example.txt";
open(MYFILE, $myfile);
while (<MYFILE>) { #check each line
#use pattern matching to check each line ($_) against a pattern, and if so
replace it with something else
close(MYFILE);
but the problem is, this doesn't work. when i say $_ = "blah, blah" , i go
back and look at $myfile (example.txt) and it's the same as it was before.
and i've tried instead to open $myfile with the ">" operator or whatever (to
open for writing) but that completely erases the file.
BTW--i *have* found a way around this, but it's quite annoying. i just
create another temporary file, like, temp.txt. in the while loop, i copy
each line into that file, and when it comes to the line(s) that need
replacing, i just copy the new changed line(s) into the temporary file. then
in the end, i rename temp.txt as the original file, and delete the temporary
one. it works and everything, but i was wondering if there is a simpler way
to do it, without creating extra files, etc.
thanks to whomever answers (if anybody does. ;-D )
anita-ariel
------------------------------
Date: Thu, 17 Jun 1999 22:27:53 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: changing text in a file?
Message-Id: <JDea3.316$7X1.70028@news.shore.net>
Ariel <fake@nospam.edu> wrote:
: BTW--i *have* found a way around this, but it's quite annoying. i just
: create another temporary file, like, temp.txt. in the while loop, i copy
: each line into that file, and when it comes to the line(s) that need
: replacing, i just copy the new changed line(s) into the temporary file. then
: in the end, i rename temp.txt as the original file, and delete the temporary
: one. it works and everything, but i was wondering if there is a simpler way
: to do it, without creating extra files, etc.
What's wrong with that method? If your program crashes (or is terminated)
halfway through, your file doesn't get corrupted.
However, if you really want to edit it "in place", you probably want to
open it with the mode "<+" (read and write) rather than ">" (write, which,
as you pointed out, nukes the original file).
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 17 Jun 1999 15:57:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: changing text in a file?
Message-Id: <37697D3C.36C3B8F9@mail.cor.epa.gov>
Ariel wrote:
>
> first of all i apologize if there are multiple/repetive postings of mine, i
> had to cancel a few messages, etc. anyways...
>
> to change a few lines of text in a file, my code went like this:
>
> $myfile = "example.txt";
> open(MYFILE, $myfile);
> while (<MYFILE>) { #check each line
> #use pattern matching to check each line ($_) against a pattern, and if so
> replace it with something else
> close(MYFILE);
> but the problem is, this doesn't work. when i say $_ = "blah, blah" , i go
> back and look at $myfile (example.txt) and it's the same as it was before.
Right. You opened the file for reading, and didn't ever write
any changes to it.
> and i've tried instead to open $myfile with the ">" operator or whatever (to
> open for writing) but that completely erases the file.
Right again. That's what ">" is supposed to do. If you really
want to read-write a file, you'll need to use "+<". If you try
"+>", it will truncate the file to nothing and *then* give you
read-write access. Useful, huh?
> BTW--i *have* found a way around this, but it's quite annoying. i just
> create another temporary file, like, temp.txt. in the while loop, i copy
> each line into that file, and when it comes to the line(s) that need
> replacing, i just copy the new changed line(s) into the temporary file. then
> in the end, i rename temp.txt as the original file, and delete the temporary
> one. it works and everything, but i was wondering if there is a simpler way
> to do it, without creating extra files, etc.
Actually, this is a *good* thing to do. If you keep a backup
copy while you're hacking the file, any disaster [like a system
crash] won't destroy your work, just leave you with a re-named
file.
> thanks to whomever answers (if anybody does. ;-D )
For more, see my reply to your other post.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 17 Jun 1999 22:17:03 GMT
From: syarbrou@nospam.enteract.com (Steve .)
Subject: having dots on screen while waiting
Message-Id: <37697365.74584864@news.enteract.com>
I have a while loop. At certain points in the look there can be
delays in excess of 5 minutes. This is normal and fine. I would
however like to make sure things stay active so would like a dot to be
displayed in the screen every 15 seconds when nothing is being
displayed.
while ( <PGP_READ> )
{
print;
print "\n";
}
The above is basically pulling info from an open3 shell script. Is
there a way to add what I am looking for into the above loop? Thanks.
Steve
------------------------------
Date: 17 Jun 1999 17:08:23 -0400
From: Jason Larke <jlarke@ans.net>
Subject: Help debugging odd Perl + Perl module interaction
Message-Id: <vatwvx24jso.fsf@anthem.aa.ans.net>
I'm trying to get ARSPerl working. It's a Perl module for
interfacing with Remedy.
It builds without incident, but then I get this odd behavior:
jlarke@anthem ~/src/Perl-modules/ARSperl-1.6403% perl5.00503 -MARS
$ENV{PATH}="/usr/local/bin";
Bus error
Yes, that's right, any attempt to run change $ENV results in a
bus error.
Running under gdb, I get "bad free ignored" instead.
OK, something bad is being free'd, I get that from perldiag. But
how do I figure out what?
This is all with Perl 5.005_03, ARSPerl 1.6403, Solaris 2.5.1 on
a Sparc. As an aside, using Perl 5.005_02, I can get the same
Perl code to SIGBUS under the gdb debugger. The backtrace there
is:
#0 0x2b2c8 in free ()
#1 0x8023c in Perl_my_setenv ()
#2 0x827dc in Perl_magic_setenv ()
#3 0x815b8 in Perl_mg_set ()
#4 0x8e0fc in Perl_pp_concat ()
#5 0xe1f24 in Perl_runops_standard ()
#6 0x264e4 in perl_run ()
#7 0x23a9c in main ()
But if the problem is in Perl_my_setenv, how come the problem
only occurs when I use the ARS module?
I'm afraid my knowledge of honest programming techniques is
limited, too. :|
Thanks for any help anyone can provide.
--
Jason Larke- jlarke@ans.net- http://www.nnaf.net/~jlarke Send mail for PGP key
I don't speak for UUnet Worldcom or the international communist conspiracy.
"The Rock can't say I quit, because the Rock only talks in the third person."
"People change, and smile: but the agony abides."-T.S. Eliot, The Dry Salvages
------------------------------
Date: 17 Jun 1999 22:46:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Help debugging odd Perl + Perl module interaction
Message-Id: <7kbtss$d2e$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jason Larke
<jlarke@ans.net>],
who wrote in article <vatwvx24jso.fsf@anthem.aa.ans.net>:
> I'm trying to get ARSPerl working. It's a Perl module for
> interfacing with Remedy.
>
> It builds without incident, but then I get this odd behavior:
>
> jlarke@anthem ~/src/Perl-modules/ARSperl-1.6403% perl5.00503 -MARS
> $ENV{PATH}="/usr/local/bin";
> Bus error
>
> Yes, that's right, any attempt to run change $ENV results in a
> bus error.
>
> Running under gdb, I get "bad free ignored" instead.
>
> OK, something bad is being free'd, I get that from perldiag. But
> how do I figure out what?
>
> This is all with Perl 5.005_03, ARSPerl 1.6403, Solaris 2.5.1 on
> a Sparc. As an aside, using Perl 5.005_02, I can get the same
> Perl code to SIGBUS under the gdb debugger. The backtrace there
> is:
>
> #0 0x2b2c8 in free ()
> #1 0x8023c in Perl_my_setenv ()
> #2 0x827dc in Perl_magic_setenv ()
The first idea is that ARSes muck with environment, and use a
different malloc() for this. Try recompiling without Perl's malloc.
Ilya
------------------------------
Date: 17 Jun 1999 15:23:01 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: How can I 'edit' a datafile?
Message-Id: <8p6g13qjwl6.fsf@Eng.Sun.COM>
jhawk39@idt.net (AJ) writes:
> I have no problem appending to a file or even 'writing over' a file
> with data from a form.
>
> Here's my problem. I can't find a way to change specific lines or
> elements in that file.
>
> I can set the file up to in any shape....delimited with colons,
> pipes...doesn't matter to me.
>
> Let's say the datafile looks like this:
> 001|Client 1| Bob
> 002|Client 2| Steve
> 003|Client 3| Frank
> ...
> 050|Client 50|Gary
>
> basically,
> client #|Company name| contact name
> From a form, I would like to be able to replace one of those lines
> with other information. In other words, I want the script to take data
> from the form (using those 3 elements)...find the line in the datafile
> and replace it with the new information.
>
> I simply cannot figure out a way to do this.
Any reason you can't just copy it to a new file with changes and then
rename the new file? This has the good property that if something
fails, you aren't left with a corrupted file. If this takes too long,
there's a good change you should be using something other than a flat
file to begin with.
-mike
my $file = "whatever";
open IN, "< $file" or die qq{cannot read "$file: $!"};
open OUT, "> $file.$$" or die qq{cannot write $file.$$: $!\n};
while (<IN>) {
my ($client, $company, $contact) = split /[|\n]/;
$contact = "xyz" if $company eq "foo";
print OUT "$client|$company|$contact\n" or
die qq{cannot write to file "$file.$$":$!\n};
}
rename("$file.$$", "$file") or
die qq{cannot rename "$file.$$" to "$file"\n};
------------------------------
Date: 17 Jun 1999 14:51:46 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: How do I the equiv. of csh echo $0 in perl?
Message-Id: <8p6hfo6jy19.fsf@Eng.Sun.COM>
Kevin Inscoe <inscoe@iag.net> writes:
> In a csh script I can print the full patch of the script
> by doing an echo $0 such as:
>
> #!/bin/csh -f
>
> echo $0 " executing"
>
> $ test.csh
> /opt/bin/test.csh executing
>
> How can I do this in Perl 5?
>
> I tried $argv[0] but aprently shell stacks params differently
> then perl does.
Perl puts argv[0] in $0 and shifts the other params over. Try this:
print "$0 executing\n";
-mike
------------------------------
Date: 17 Jun 1999 15:07:13 -0700
From: elf@halcyon.com (Elf Sternberg)
Subject: Re: How do I the equiv. of csh echo $0 in perl?
Message-Id: <7kbrih$fd1$1@halcyon.com>
In article <7kbnvo$ohu$1@news.iag.net>, Kevin Inscoe <inscoe@iag.net> wrote:
>In a csh script I can print the full patch of the script
>by doing an echo $0 such as:
>How can I do this in Perl 5?
>I tried $argv[0] but aprently shell stacks params differently
>then perl does.
Have you tried "print $0\n"?
Elf
--
Elf M. Sternberg, rational romantic mystic cynical idealist
If you're so smart, why aren't you naked?
A.A 1493 http://www.halcyon.com/elf/
------------------------------
Date: 17 Jun 1999 21:36:45 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: how to change a line of text in a file?
Message-Id: <7kbppd$bul$1@info2.uah.edu>
In article <7kbpdc$m30@news.or.intel.com>,
"Ariel" <fake@nospam.edu> writes:
: Hi, i just started learning Perl on monday, i bought a book on it, but i
: still have a few questions...first one..how do you change a line of text in
: a file??
Read the FAQ. Apply the knowledge.
Greg
--
I have not finished with a woman until I have had her all three ways.
-- John F. Kennedy.
------------------------------
Date: Thu, 17 Jun 1999 14:52:16 -0700
From: "Ariel" <fake@nospam.edu>
Subject: Re: how to change a line of text in a file?
Message-Id: <7kbqj7$n9m@news.or.intel.com>
Greg Bacon wrote in message <7kbppd$bul$1@info2.uah.edu>...
>In article <7kbpdc$m30@news.or.intel.com>,
> "Ariel" <fake@nospam.edu> writes:
>: Hi, i just started learning Perl on monday, i bought a book on it, but i
>: still have a few questions...first one..how do you change a line of text
in
>: a file??
>
>Read the FAQ. Apply the knowledge.
>
i did read several FAQs online...but none of them seemed to help with my
specific problem. and another thing is i'm currently using perl for win32
(not unix, so a lot of stuff they have on there does not apply)
>Greg
>--
>I have not finished with a woman until I have had her all three ways.
> -- John F. Kennedy.
------------------------------
Date: 17 Jun 1999 22:08:36 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: how to change a line of text in a file?
Message-Id: <7kbrl4$c70$2@info2.uah.edu>
In article <7kbqj7$n9m@news.or.intel.com>,
"Ariel" <fake@nospam.edu> writes:
: Greg Bacon wrote in message <7kbppd$bul$1@info2.uah.edu>...
: >Read the FAQ. Apply the knowledge.
:
: i did read several FAQs online...but none of them seemed to help with my
: specific problem. and another thing is i'm currently using perl for win32
: (not unix, so a lot of stuff they have on there does not apply)
% man perlfaq5
[...]
How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the
beginning of a file?
[...]
Greg
--
I feel like a God-damned mushroom - kept in the dark and fed bullshit!
-- Impulse
------------------------------
Date: Thu, 17 Jun 1999 15:36:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Ariel <anita.villanueva@intel.com>
Subject: Re: how to change a line of text in a file?
Message-Id: <3769787F.BAFE0FFF@mail.cor.epa.gov>
[courtesy cc sent to poster]
Ariel wrote:
>
> Greg Bacon wrote in message <7kbppd$bul$1@info2.uah.edu>...
> >In article <7kbpdc$m30@news.or.intel.com>,
> > "Ariel" <fake@nospam.edu> writes:
> >: Hi, i just started learning Perl on monday, i bought a book on it,
I hope it's "Learning Perl" by Randal and Tom, and not one of
those books which call you names or promise you magic in a set
number of days. Those others have been found to have some
serious blunders, which might not be obvious to the new Perlite
until you got yourself into a miserable jam later.
> [snip]
> i did read several FAQs online...but none of them seemed to help with my
> specific problem. and another thing is i'm currently using perl for win32
> (not unix, so a lot of stuff they have on there does not apply)
I'll assume you're using ActiveState Perl. If so, you not only
have all the core Perl FAQ on your machine, but you also have an
HTML tree as part of the install, with a shortcut placed on your
Start Menu for extra convenience. You'll be able to open this
up in your favorite browser, page down to perlfaq5, and click on
the relevant line, to which Greg was referring. You'll be glad to
know that this material should work on win32 as well.
And there's also an ActivePerl FAQ included, which has a couple
sections on win95/NT and 'quirks'. Read these, and you'll know
what parts of Perl don't work on win32. Calls to unix utilities
using system() or open() can be persuaded to work if you go to
http://language.perl.com/ppt/ and download the needed utilities
(written in Perl of course). So then you're only stuck with
the problem of no fork() and no alarm() . [There are a few other
lapses, but those are the biggies for me.] And in a few months,
ActiveState is expected to come out with a new Perl version with
a working fork() too. Until then, you might be able to make do
with Win32::Process::Create .
And read up on ppm, so you'll know how to get modules already
built for ActiveState Perl instead of going to CPAN for them.
[Bonus tip: do *not* try to download XML::Parser using ppm.
It will trash ppm. XML::Parser is already on your system.]
BTW, using a fake address doesn't protect you from spam-address-
harvesters if you're putting your real address in your Reply-To
line. It does make it easier for me to reply, though.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 17 Jun 1999 20:36:47 GMT
From: hojo <hojo@i-tel.com>
Subject: Re: Newbie Array Question
Message-Id: <7kbm8u$tvu$1@nnrp1.deja.com>
>
> simply scop it as such:
> my @array = (0..3) #for empty array length 4 (0,1,2,3)
> Remember though, with perl this array is dynamic so you can increase
the size at any given time!
Well, this is my bad as it actually fills the array. This will make an
array with all elements as undef.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 18 Jun 1999 00:10:04 +0200
From: Janning Vygen <janning@vygen.de>
Subject: OO-Trap! I am confused
Message-Id: <3769723C.A57CC937@vygen.de>
***PLEASE ANSWER VIA E-MAIL TOO ***
i have designed some objects like described in the camel book chapter 5
"autoloading methods" (page 311 in the german version)
the only difference is, that i have array references as field values
because the object can have more than one "card".
what happens is, that the two objects share the same reference for cards
and coins, so initializing one object, changes the other object too.
so if i give one customer a credit card, every costomer gains it.
This might be called a feature :-)
how can i disable it?
here it goes:
---------------------------
package Customer;
my %fields = (
cards => [],
coins => [],
);
sub new {
my $class = shift;
my $self = {
%fields,
};
return bless $self, $class;
}
package main;
$foo1 = Foo->new();
$foo2 = Foo->new();
$foo1->{'cards'}->[0] = "VISACard";
print $foo2->{'cards'}->[0];
------------------------------
output: "VISACard"
should be: ""
Greetings,
Janning
------------------------------
Date: Thu, 17 Jun 1999 14:18:35 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Personal Rant (was Re: Does Perl have a future?)
Message-Id: <3769662B.E2D7F515@mail.cor.epa.gov>
Daniel Grisinger wrote:
> Watcher <watcher_q@my-deja.com> writes:
> > Of course, Sun would say that they are the best. Which company won't?
> > Sun is course worried. If Java slips on the server side, its
> > importance will greatly diminished in the enterprise space. Then, the
> > only place that Java would exist would be in the device space (eg Jini,
> > etc).
>
> It should be pointed out that the device space is larger than all
> other application spaces combined.
Which is why they're making a grab for it. As is IBM, and...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 17 Jun 1999 23:12:44 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: qr// doesn't save my day!
Message-Id: <VA.00000352.00e5eb48@enterprise>
> Someone has misinformed you that qr// precompiles a pattern to make it
> faster
I tripled the speed of a program that uses dynamic patterns by using qr//, as
suggested by the Perl Cookbook.
Just why, I dunno, but qr// made my day that day :)
Note that pitting qr// against m//o is unfair. m//o won't do dynamic patterns
without going through strange eval hoops.
Hmm, perhaps this is a Perl version issue?
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy/
------------------------------
Date: 17 Jun 1999 22:37:32 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: qr// doesn't save my day!
Message-Id: <7kbtbc$ctc$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Gareth Rees
<garethr@cre.canon.co.uk>],
who wrote in article <siemja1y9f.fsf@cre.canon.co.uk>:
> The perlop manpage for 5.005_57 doesn't make the same "very efficient"
> claim, but says instead:
>
> Since Perl may compile the pattern at the moment of execution of
> qr() operator, using qr() may have speed advantages in some
> situations, notably if the result of qr() is used standalone:
In the situation in question the precompiled value is going to be
used. Thus it should be better. Some benchmarking should be done,
and some analisys by -Mre=debugcolor as well.
However, if you want benchmarking, you benchmark things, you do not
use this `use Benchmark' toy. I would never trust results of
Benchmark's benchmarks. Not while they try to compensate 10x overhead
of the infrastructure.
Ilya
------------------------------
Date: Thu, 17 Jun 1999 22:35:38 GMT
From: jwfrank@toad.net (John Frank)
Subject: Re: Regex Help Needed
Message-Id: <_Kea3.1426$ZD4.7734@newsfeed.slurp.net>
Thanks for the suggestions. I tried the s/^a... and it
didn't do what I need. I forgot to mention that I am doing this
in 'gasp' Windows NT 'gasp'. I would prefer a Unix machine but
I am stuck with this for this particular problem. I will try
the other suggestions and see if they work (I sure hope so
this is starting to get to me). For what it's worth I think
it's the _ character that is causing my problem but I just
haven't come up with a way to deal with it.
Jack
------------------------------
Date: Thu, 17 Jun 1999 18:29:25 -0400
From: Ketan Patel <ketanp@XYZABCxwebdesign.com>
Subject: Sending output only to browser, not to user...
Message-Id: <376976C5.556DCC08@XYZABCxwebdesign.com>
I am trying to use perl to send a javascript source file by doing:
print "Content-type: application/x-javascript\n\n";
print "document.write('JS stuff here')";
and include it in HTML pages using code similar to:
<script src = "js.cgi"></script>
It works fine, but if a user goes directly to js.cgi in their browser,
it sends the file and asks them to save or open, in which case they can
save the code.
My perl question is, how can I specify that it should only be sent to
the browser? I tried using "if($ENV{'HTTP_REFERER'}" but it doesn't
seem to work all the time... Is there some other env variable that will
only be set if the script is called from inside that <script> tag, but
not if a user goes directly to the script?
Thanks!
------------------------------
Date: 17 Jun 1999 21:30:40 GMT
From: mike@baldur.lbl.gov (Michael Helm)
Subject: Re: SIGCHLD problems
Message-Id: <7kbpe0$3qo2@overload.lbl.gov>
Charles DeRykus writes:
>>How can I debug this problem? How can I trace the changes to the
>>perl data structures that manage signal handling, and/or any other
>
>What're the symptoms of the problem - children reaped in the
>bud, core dumps, signal havoc, etc. ... ?
Occasional bus error - type coredumps; more commonly, the process(es)
hang, & observation with truss on solaris seems to show them spinning
in what I think is a signal handler set to respond to SIGCHLD.
I'm beginning to think this is some kind of Oracle or Oracle module
problem, but I don't know how to prove or disprove this.
------------------------------
Date: Thu, 17 Jun 1999 17:30:52 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Signature removal regex?
Message-Id: <1dtk0av.syw4gff7uncwN@roxboro0-0013.dyn.interpath.net>
I.J. Garlick <ijg@csc.liv.ac.uk> wrote:
> Hi, can anyone spot what I missed in the following?
>
> I need to remove the signature from a mail message but only the last one.
>
> Before I receive responses telling me it's impossible I am only trying to
> remove signatures that are in the following form
Why would anybody tell you that? It's not a sig if it's not preceded by
a sigdash.
> -- \r?\n
> Whoever\r?\n
> etc....\r?\n
>
> I have put the \r?\n in by hand to show what is potentially there, you
> obviously don't see them normally just the effect they have.
>
> I came up with this
>
> $q->param('sig',1) if ($msg =~ s/-- \r?\n.*?$//s);
>
-snip-
>
> Anyway, to cut a long story short I eventually got to this
>
> my @xxx = split /-- \r?\n/, $msg;
> pop @xxx and $q->param('sig',1) if @xxx > 1;
> $msg = join "-- \n", @xxx;
>
> Which does just about all I want, but it's not perfect as it can fail in
> certain situations.
>
> Still I can't help feeling it's possible with a regex, and I just don't
> know enough.
>
> Maybe the split, pop, join method is the best/fastest, I don't know and
> since I don't have the regex anyway I can't benchmark them.
>
> So any of you good hearted regex guru's care to lend a hand?
I'm not a guru, but what's wrong with
$msg =~ s/(.+)\n-- \n.+/$1/s; # delete the sig
?
--
John Moreno
------------------------------
Date: Thu, 17 Jun 1999 17:55:19 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Signature removal regex?
Message-Id: <1dtk19j.1gy597wxp2tv1N@roxboro0-0023.dyn.interpath.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> # now reduce miswrapped lines from idiotic broken PC newsreaders
It's not just PC newsreaders that do this, and not all PC newsreaders
do. AdBuster doesn't for instance, neither does Xnews.
> # into what they should have been
> s/(>.*)\n\s*([a-zA-Z])/$1 $2/g;
Good thing this isn't critical or for display -- this line and 1 of the
2 above will count as quoted. Probably more reliable to check to see if
it's from an Outlook Express user -- it'll screw up quoting a lot more
often than the user will not insert a extra line, and it's the number 1
program I see doing so.
--
John Moreno
------------------------------
Date: Thu, 17 Jun 1999 20:12:37 GMT
From: "news.boeing.com" <jim.ray@west.boeing.com>
Subject: Sorting an Array
Message-Id: <FDHMt3.DtB@news.boeing.com>
Is there a way to sort and array.
Case:
I have 7 fields delimited by a ;
I want to sort on field 5.
Then I willl write the file back out.
Thank you.
--
Jim Ray
Delta Program NT Administrator
The Boeing Company
714-896-2038
jim.ray@west.boeing.com
------------------------------
Date: Thu, 17 Jun 1999 21:23:00 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Sorting an Array
Message-Id: <UGda3.33$36.1667@news2.rdc1.on.home.com>
In article <FDHMt3.DtB@news.boeing.com>,
news.boeing.com <jim.ray@west.boeing.com> wrote:
! Is there a way to sort and array.
!
! Case:
! I have 7 fields delimited by a ;
! I want to sort on field 5.
! Then I willl write the file back out.
please search perlfaq4 for the entry:
How do I sort an array by (anything)?
you may also wish to check out the Sort::Fields
module on CPAN
regards
andrew
------------------------------
Date: Thu, 17 Jun 1999 20:47:10 GMT
From: gheppner@my-deja.com
Subject: Re: win32 perl problems
Message-Id: <7kbmsb$u6r$1@nnrp1.deja.com>
David,
thanks for the reply. The NTGetCWD function is a sub under the porting
section of cwd.pm. As far as I know it wasn't a home grown function
someone threw in, it looks like it comes with it.
In article <37681E4B.1F3B14D9@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
> [courtesy cc sent to poster]
>
>
> Hmmm. I don't have a CWD module. There is a Cwd module, but
> it does *not* have a NTGetCWD function in it. Is this a
> homegrown function, or does it come from one of the 300-series
> ActiveState builds?
>
> You may have to change this to one of the functions in Cwd.pm
> such as cwd(), getcwd(), fastgetcwd(), abs_path(), or
> fast_abs_path() . One [or more] of these should do what you
> want.
>
> HTH,
> David
> --
> David Cassell, OAO cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 17 Jun 1999 15:49:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: gheppner@my-deja.com
Subject: Re: win32 perl problems
Message-Id: <37697B7A.BF2941C9@mail.cor.epa.gov>
[courtesy cc sent to poster]
gheppner@my-deja.com wrote:
>
> David,
>
> thanks for the reply. The NTGetCWD function is a sub under the porting
> section of cwd.pm. As far as I know it wasn't a home grown function
> someone threw in, it looks like it comes with it.
Umm, I just looked through Cwd.pm and the sub under the porting
section is [1] not named NTGetCWD; and [2] is not exported
under normal circumstances.
So I really think that you want to just go with the cwd()
function instead. If that should give you any trouble with
slash-vs-backslash weirdness, then you can transform the output
as suggested in the porting section, which uses Win32::GetCwd()
and s/// to change \\ to / for Perl:
$ENV{'PWD'} = Win32::GetCwd();
$ENV{'PWD'} =~ s:\\:/:g ;
But try just using cwd. It's nice and portable.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 6036
**************************************