[10728] in Perl-Users-Digest
Perl-Users Digest, Issue: 4327 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 30 21:07:24 1998
Date: Mon, 30 Nov 98 18:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 30 Nov 1998 Volume: 8 Number: 4327
Today's topics:
`Scripting languages' are marketing deceipts (was: Y2K <tchrist@mox.perl.com>
Breaking a string into fixed lengths steve.cooke@wmc.com.au
Re: Breaking a string into fixed lengths <zenin@bawdycaste.org>
Re: Breaking a string into fixed lengths (Tad McClellan)
Can I redirect STDERR with Win32::Process::Create ? <charles@atheist.com>
Re: Date file created check? (Andre L.)
Re: Does (.*?) do what I think it does? (rise)
emulating sed's "/start/,/stop/<do something>"? (David Combs)
Re: emulating sed's "/start/,/stop/<do something>"? <zenin@bawdycaste.org>
Re: emulating sed's "/start/,/stop/<do something>"? (Tad McClellan)
Re: Excel Spreadsheets, Perl, CGI and Linux mike808@mo.net
Re: field selection using "split" - question (John Callender)
Re: Folder Recurison <r28629@email.sps.mot.com>
Help - replacing a substring <dales@enhanced-performance.com>
How to change acl in the registry with a perl script? pgkq@my-dejanews.com
Re: how to exec java class in a html file <nguyend7@msu.edu>
re: LWP::UserAgent leaks memory? weinerk@usa.net
Re: Multiplayer Roleplaying Game, Web-Based, Written in dturley@pobox.com
Re: Multiplayer Roleplaying Game, Web-Based, Written in (Erik)
re: Need Help on code! jubame@hotmail.com
Re: Need Help on code! (Tad McClellan)
Perl and Cgi resources <mikem@interlog.com>
Re: Perl CGI program (Abigail)
Perl for old, outdated, ancient systems <keith_paschal@hp.com>
Re: Perl for old, outdated, ancient systems <zenin@bawdycaste.org>
Script question... <jsack@ctron.com>
String Insertion <gewing@wharton.upenn.edu>
Re: String Insertion (Tad McClellan)
Re: When does CLOSE not FLUSH? (Abigail)
Re: Y2K and Programmer Denial finsol@ts.co.nz
Re: Y2K and Programmer Denial (David Formosa)
Re: Y2K and Programmer Denial (Tad McClellan)
Re: Y2K work - need suggestions <bsh@rainey.blueneptune.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Dec 1998 01:17:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: `Scripting languages' are marketing deceipts (was: Y2K and Programmer Denial)
Message-Id: <73vg2h$ci5$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, finsol@ts.co.nz writes:
: The distinctions between programming languages, scripting languages,
There is no such distinction. It is a myth.
--tom
--
X-Windows: Complex nonsolutions to simple nonproblems.
--Jamie Zawinski
------------------------------
Date: Tue, 01 Dec 1998 00:39:34 GMT
From: steve.cooke@wmc.com.au
Subject: Breaking a string into fixed lengths
Message-Id: <73vds4$79p$1@nnrp1.dejanews.com>
Hi, I have a requirement to break a string into sub-strings of 20 characters
(provided the original string is longer than 20 chars). I have written some
code to do this (it works!) but I would like to know if this is the most
efficient way. Any comments on my code would be very welcome.
#!/wmc/share/bin/perl -w
use strict;
my $string = "The granite makes it hard to see the lapilli tuff.";
my $str = length $string;
my @split_str;
my $split_str;
my $i = 0;
my $j = 20;
my $k = 0;
while ($k < length $string) {
print "line too long. Will try to split.\n";
$split_str = substr $string,$k,$j;
$split_str[$i] = $split_str;
$k = $k + 20;
$i++;
}
$i = 0;
foreach (@split_str) {
print "$split_str[$i]\n";
$i++;
}
exit();
Steve Cooke
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 01 Dec 1998 01:39:16 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Breaking a string into fixed lengths
Message-Id: <912476449.414250@thrush.omix.com>
steve.cooke@wmc.com.au wrote:
: Hi, I have a requirement to break a string into sub-strings of 20 characters
: (provided the original string is longer than 20 chars). I have written some
: code to do this (it works!) but I would like to know if this is the most
: efficient way. Any comments on my code would be very welcome.
I don't think you can get much faster (without going to C), but you
can do it in much less code:
## Split string into 20 byte chunks
push @split_str, $1 while ($string =~ /(.{1,20})/g);
It's a tad slower (a few clock ticks at best) though.
: while ($k < length $string) {
: print "line too long. Will try to split.\n";
: $split_str = substr $string,$k,$j;
: $split_str[$i] = $split_str;
: $k = $k + 20;
: $i++;
: }
Hmm, you could also just use the result of the substr() for the
test:
my $pos = 0;
local $^W; ## Avoid -w's "substr outside of string" warnings
for (
my $piece;
$piece = substr $string, $pos, 20;
$pos += 20
) {
push @split_str, $piece;
}
This does make it a couple clock ticks faster, but not likely
enough to notice.
: $i = 0;
: foreach (@split_str) {
: print "$split_str[$i]\n";
: $i++;
: }
You work to hard. :-)
for (@split_str) {
print "$_\n";
}
Or...
foreach my $piece (@split_str) {
print "$piece\n";
}
Or...
print join "\n", @split_str, '';
Or... :-)
: exit();
Most of us just let out code run out to exit(). :-)
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 30 Nov 1998 20:39:02 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Breaking a string into fixed lengths
Message-Id: <6skv37.o82.ln@flash.net>
steve.cooke@wmc.com.au wrote:
: Hi, I have a requirement to break a string into sub-strings of 20 characters
: (provided the original string is longer than 20 chars). I have written some
: code to do this (it works!) but I would like to know if this is the most
: efficient way. Any comments on my code would be very welcome.
How's this?
----------------
#!/usr/bin/perl -w
use strict;
my $string = "The granite makes it hard to see the lapilli tuff.";
while ($string =~ /(.{1,20})/g ) {
print "$1\n";
}
----------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Nov 1998 21:53:33 GMT
From: "Charles F. Radley" <charles@atheist.com>
Subject: Can I redirect STDERR with Win32::Process::Create ?
Message-Id: <01be1cab$2f8ba9a0$83352293@galileo>
Can I redirect STDERR with Win32::Process::Create ?
I need to trap both STDERR and STDOUT to a file (or even to two separate
files) on Win32 from a created process.
Using the options CREATE_DEFAULT_ERROR_MODE and DETACHED_PROCESS result in
failure of the process to launch, and nothing is sent to STDERR nor to
SDTOUT.
Using the option: CREATE_NEW_CONSOLE causes the process to launch
successfully in a new window, but none of the STDERR nor STDOUT is trapped.
Should I have inherit file handles turned ON or OFF ?
Any advice would be appreciated.
Thanks in advance, Charles R.
------------------------------
Date: Mon, 30 Nov 1998 19:31:29 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Date file created check?
Message-Id: <alecler-3011981931290001@dialup-466.hip.cam.org>
In article <MPG.10cc86107347368b98989b@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:
> In article <97pu37.a2.ln@flash.net> on Mon, 30 Nov 1998 12:47:05 -0600,
> Tad McClellan <tadmc@flash.net> says...
[...]
>
> 10 ctime inode change time (NOT creation time!) since the epoch
>
> WROMG for Windows/DOS (no inodes, after all). I don't know about Macs
> or other filesystems. Yes, there really *are* other filesystems. :-)
(If anybody cares)
In MacPerl, ctime gives a time that corresponds to the creation date.
Just to be sure, one can use a Toolbox call instead:
use Mac::Files;
$file = 'Path:To:Thisfile';
$params = FSpGetCatInfo($file)
or die "Couldn't get cat info for '$file'.\n";
print scalar(localtime $params->ioDrCrDat), "\n";
Andre
------------------------------
Date: 30 Nov 1998 22:39:11 GMT
From: rise@ugcs.caltech.edu (rise)
Subject: Re: Does (.*?) do what I think it does?
Message-Id: <73v6qf$6ce@gap.cco.caltech.edu>
Jerome O'Neil <jeromeo@atrieva.com> writes:
>Edward Broyles wrote:
>>
>> Will this do what I want:
>>
>> /(.*?),(.*?),(.*?)/
>>
>> $abc = $1;
>> $def = $2;
>> $ghi = $3;
>> What I want to do is read each comma delimited item into its own variable.
>I might, but it will be easier if you do this.
>my($abc,$def,$ghi) = split(/,/,$bigstring);
Are you trying to parse true comma-delimited text or comma separated
values format files? If the latter you should look at the Text::ParseWords
module (possible for the former too, but I've never used it that way). The
following is a script to turn a .csv file into a | delimited file by way
of an array of strings.
## Begin Script
use Text::ParseWords;
open(TEST, 'example.csv') || die "That didn't work.";
open(OUTFILE, ">exampleOUT.dat") || die "That didn't
work.";
open(EXCPFILE, ">exampleEXCEPTIONS.dat") || die "That
didn't work.";
$line = <TEST>;
chomp($line);
@fields = parse_csv($line);
print EXCPFILE "Field Headers : $#fields\n ";
$linenumber = 0;
while(defined($line = <TEST>)) {
print "$linenumber\n";
chomp($line);
@fields = parse_csv($line);
if ($#fields != 27) {
print EXCPFILE "Fields: $#fields Line: $linenumber\n";
for ($i = 0; $i < @fields; $i++) {
if ( $i == 0) {
print EXCPFILE " $fields[$i]";
} else {
print EXCPFILE "| $fields[$i]";
if ( $i == $#fields ) {
print EXCPFILE "\n";
}
}
}
}
else {
for ($i = 0; $i < @fields; $i++) {
if ( $i == 0) {
print OUTFILE " $fields[$i]";
} else {
print OUTFILE "| $fields[$i]";
}
}
print OUTFILE "\n";
}
$linenumber += 1;
}
close(TEST) || die "That didn't work either.";
close(OUTFILE) || die "That didn't work either.";
close(EXCPFILE) || die "That didn't work either.";
## This is the subroutine that calls Text::ParseWords
sub parse_csv {
return quotewords( ",", 0, $_[0]);
}
------------------------------
Date: Mon, 30 Nov 1998 23:17:05 GMT
From: dkcombs@netcom.com (David Combs)
Subject: emulating sed's "/start/,/stop/<do something>"?
Message-Id: <dkcombsF39CoH.8JL@netcom.com>
I read in one of the many perl books I have about some
nifty mode or something by which perl can emulate
sed's "/startHere/,/stopdoingitHere/<do something>",
which REPEATEDLY, going through its standard input,
when it saw a /startHere/ would switch "on" the
<do something>, for that and subsequent lines, UNTIL
just after the line that matched /stopdoingitHere/,
at which point it would turn "off" the doing,
and would keep going through the lines, doing nothing, UNTIL it
saw ANOTHER /startHere/, at which point it would AGAIN turn "on"
the <dosomething> action.
It's really neat, for eg html, tex, etc,
EXCEPT for the fact that sed doesn't
have a -i switch (the way egrep DOES have) for case-independence.
Now, of course I could write a (perl) PROGRAM to do this, manually
turning on a switch when I saw the first regex, and turning
it off after the line with the second regex, all that being
within a line-reading <> loop.
But I recall reading that there was some way to do this in perl
"AUTOMATICALLY" -- but I can't find it documented, not via the index,
etc, anyway.
Any ideas?
THANKS!
David
------------------------------
Date: 01 Dec 1998 01:04:10 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: emulating sed's "/start/,/stop/<do something>"?
Message-Id: <912474343.658446@thrush.omix.com>
[posted & mailed]
David Combs <dkcombs@netcom.com> wrote:
>snip<
: But I recall reading that there was some way to do this in perl
: "AUTOMATICALLY" -- but I can't find it documented, not via the index,
: etc, anyway.
:
: Any ideas?
man perlop
And look for the ".." (aka "flip-flop") operator.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 30 Nov 1998 19:59:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: emulating sed's "/start/,/stop/<do something>"?
Message-Id: <5iiv37.432.ln@flash.net>
David Combs (dkcombs@netcom.com) wrote:
: I read in one of the many perl books I have about some
: nifty mode or something by which perl can emulate
: sed's "/startHere/,/stopdoingitHere/<do something>",
: which REPEATEDLY, going through its standard input,
: when it saw a /startHere/ would switch "on" the
: <do something>, for that and subsequent lines, UNTIL
: just after the line that matched /stopdoingitHere/,
: at which point it would turn "off" the doing,
: But I recall reading that there was some way to do this in perl
: "AUTOMATICALLY" -- but I can't find it documented, not via the index,
: etc, anyway.
It is covered in the "Range Operators" section of the 'perlop'
man page.
------------------------
#!/usr/bin/perl -w
while (<DATA>) {
s/foo/bar/ if /startHere/i .. /stopdoingitHere/i;
print;
}
__DATA__
startHere
a foo here
another foo here
stopdoingitHere
leave this foo alone
untouchable foo here
Starthere
change this foo
Stopdoingithere
another foo to leave alone
------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 01 Dec 1998 00:28:15 GMT
From: mike808@mo.net
Subject: Re: Excel Spreadsheets, Perl, CGI and Linux
Message-Id: <73vd6c$6or$1@nnrp1.dejanews.com>
In article <73v2ra$thf$1@nnrp1.dejanews.com>,
michalk@awpi.com wrote:
> I have a shared networked Excel spreadsheet that I would like to make
> available to the web via CGI and Perl on a Linux machine.
> Is there anything that will allow me to natively query the spreadsheet from
> Perl?
Not unless you find a module that can decrypt Microsoft-proprietary trade-
secret Excel spreadsheets.
That's not to say you can't shovel the files out in binary form
(application/ms- excel or some such pseudo-mime type) and give the poor user
no choice but to use Micro$oft Excel on a Micro$oft OS Wintel PC to read your
MS-encrypted data.
Try exporting your stuff to CSV data files and let the user use whatever
spreadsheet they would like to. Or find a common (at least amongst your
audience) encryption format (Lotus 1-2-3 .wks springs to mind) and serve the
file directly.
If you want to have a web user "remote-control" Excel on your MS host, then
you are talking much more sophistication (and points of failure) than fits
here in clpm.
Another michaelk.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 30 Nov 1998 14:23:19 -0800
From: jbc@west.net (John Callender)
Subject: Re: field selection using "split" - question
Message-Id: <73v5sn$179@acme.sb.west.net>
Jonathan Cook (j.cook@ion.ucl.ac.uk) wrote:
: Does anyone know a more elegant way of selecting the last field from
: an arbitrary length string like this:
:
: $str = "/dir1/dir2/filename";
I don't know that it's especially elegant, but another way is to just do
a regexp match and use a backreference:
if ($str =~ m#/([^/]+)$#) {
$filename = $1;
}
------------------------------
Date: Mon, 30 Nov 1998 15:44:09 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Folder Recurison
Message-Id: <366311A9.12B0F2A7@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Larry Rosler wrote:
>
> [Posted to comp.lang.perl.misc and a copy mailed.]
>
> In article <3662EAF5.6310D2A7@email.sps.mot.com> on Mon, 30 Nov 1998
> 12:59:01 -0600, Tk Soh <r28629@email.sps.mot.com> says...
>
> > Mario Luoni wrote:
> ...
> > > scan( "$path\\$file" );
> ...
> >
> > for most purposes, the File::Find standard module more than adequate,
> > and more portable (you code woud likedly break when moved to Windose or
> > Mac).
>
> No, the code would in fact break when moved *from* Windoze. :-)
Hmm, unfortunately I could only try it on Mac and *nix (I thought
someone mentiones in this ng both '/' and '\' work on the Windoze
system, but maybe I am wrong), and the document doesn't mention about
the portability. I took a quick look at the code, but only found the
is_VMS thing. Perhaps we should gather info from the users (c.l.p.m) on
what platforms File::Find run on, or possibly improve its coverage
(portability).
-TK
------------------------------
Date: Mon, 30 Nov 1998 17:58:51 -0800
From: Dale Sutcliffe <dales@enhanced-performance.com>
Subject: Help - replacing a substring
Message-Id: <36634D5B.9F454533@enhanced-performance.com>
I would like to replace the a substring (| with &) in a string. How can I do it without prior knowledge of location of the substring or without
tearing apart the string?
Thanks
------------------------------
Date: Mon, 30 Nov 1998 23:02:37 GMT
From: pgkq@my-dejanews.com
Subject: How to change acl in the registry with a perl script?
Message-Id: <73v861$2aa$1@nnrp1.dejanews.com>
I have 80 stand alone workstations (NT 4.0 sp3) that are NOT part of a
domain. When I need to make a change I use PERL, .bat files, or whatever to
get things done. I am trying to put winexit.scr in place (users keep walking
off and leaving their workstations logged on). In order for a user to use
winexit permissions need to be changed in the registry. Everyone needs Set
Value and Create Subkey on
HKEY_Local_Machine\Software\Microsoft\WindowsNT\CurrentVersion.
How do I remotely change permissions on a registry key?
Thanks,
Kim
pgkq@heb.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 30 Nov 1998 23:11:19 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: how to exec java class in a html file
Message-Id: <73v8mn$cgf$1@msunews.cl.msu.edu>
Liu, Xin <xliu@ecs.umass.edu> wrote:
: print "<applet code=form1.class name=form1 width=1200 height=800>\n";
You may need to add a "codebase" to the applet tag. Netscape may not
be able to find the class file.
--
Dan Nguyen | There is only one happiness in
nguyend7@msu.edu | life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 | -George Sand
------------------------------
Date: Mon, 30 Nov 1998 21:45:52 GMT
From: weinerk@usa.net
Subject: re: LWP::UserAgent leaks memory?
Message-Id: <73v3ma$ud3$1@nnrp1.dejanews.com>
LWP::UserAgent leaks memory?
checked with the following script
and it monotonically increases mem usage
use strict 'vars';
use LWP::UserAgent;
while (1) {
get_http();
}
sub get_http {
my ($req, $res);
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla");
$req = new HTTP::Request GET => "http://site/";
$res = $ua->request($req);
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 01 Dec 1998 01:22:56 GMT
From: dturley@pobox.com
Subject: Re: Multiplayer Roleplaying Game, Web-Based, Written in Perl.
Message-Id: <73vgcv$9dq$1@nnrp1.dejanews.com>
In article <MPG.10ccb5f985594d869896fb@news.oit.umass.edu>,
llopis@zonker.ecs.umass.edu (Noel Llopis) wrote:
> In article <73unup$jvu$1@nnrp1.dejanews.com>, wyndo@cxo.com says...
> > Tomorrow (December 1st) we will be opening LUNATIX ONLINE: GLOBAL INSANITY
> > CRISIS for public play. It's still in Beta and is still undergoing some
^^^^^^^^^^^^^^^^^^^
> > development, but it's very playable and integrated chat works -- billions of
> They "forgot" to tell us that we'll be paying for the honor of
> using a Beta version and help them in the development process.
> How nice of them.
Guess Noel "forgot" what he read. :-)
--
David Turley
dturley@pobox.com
http://www.binary.net/dturley/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 1 Dec 1998 01:53:44 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Multiplayer Roleplaying Game, Web-Based, Written in Perl.
Message-Id: <73vi78$mlk$1@news.cyberhighway.net>
In article <73vgcv$9dq$1@nnrp1.dejanews.com>,
dturley@pobox.com writes:
> In article <MPG.10ccb5f985594d869896fb@news.oit.umass.edu>,
> llopis@zonker.ecs.umass.edu (Noel Llopis) wrote:
>> In article <73unup$jvu$1@nnrp1.dejanews.com>, wyndo@cxo.com says...
>
>> > Tomorrow (December 1st) we will be opening LUNATIX ONLINE: GLOBAL INSANITY
>> > CRISIS for public play. It's still in Beta and is still undergoing some
> ^^^^^^^^^^^^^^^^^^^
>> > development, but it's very playable and integrated chat works -- billions of
>
>> They "forgot" to tell us that we'll be paying for the honor of
>> using a Beta version and help them in the development process.
>> How nice of them.
>
>
> Guess Noel "forgot" what he read. :-)
I'm guessing he was miffed about the paying for it part rather than the beta
testing part.
--
Erik Nielsen, Cyberhighway Internet Services NOC
You want it in one line? Does it have to fit in 80 columns? :-)
-- Larry Wall in <7349@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Mon, 30 Nov 1998 22:13:26 GMT
From: jubame@hotmail.com
Subject: re: Need Help on code!
Message-Id: <73v59m$vt2$1@nnrp1.dejanews.com>
Hi folks,
I have the following input file contains customer info. Each customer info is
separated by a blank line. What I need to do is to read each cusomter info
into a single variable, I have tried using (/^Customer:(.*)(\n)/ ) but no
luck. Any ideas will be greatly appreciated. Thanks....
--------------------------
Customer: Customer1
1234 Dummy St
Houston, TX
(111)111-1111
Customer: Customer2
123 Dummy Ave
Dallas, TX
What I am trying to do is to read each customer into a variable, any ideas how
to do it?
Thanks...
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 30 Nov 1998 17:36:01 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Need Help on code!
Message-Id: <15av37.5j1.ln@flash.net>
jubame@hotmail.com wrote:
: I have the following input file contains customer info. Each customer info is
: separated by a blank line. What I need to do is to read each cusomter info
: into a single variable, I have tried using (/^Customer:(.*)(\n)/ ) but no
: luck. Any ideas will be greatly appreciated. Thanks....
Setting $/ = '' will get "paragraph mode" which reads chunks
marked by blank lines.
The $/ special variable is described in the 'perlvar' man page:
----------------------
=item $/
The input record separator, newline by default. Works like B<awk>'s RS
variable, including treating empty lines as delimiters if set to the
null string. (Note: An empty line cannot contain any spaces or tabs.)
...
----------------------
You should localize changes to Perl's special variables:
----------------------
#!/usr/bin/perl -w
{ local $/ = ''; # paragraph mode
while (<DATA>) {
print "==>$_<==\n";
}
}
__DATA__
Customer: Customer1
1234 Dummy St
Houston, TX
(111)111-1111
Customer: Customer2
123 Dummy Ave
Dallas, TX
----------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 30 Nov 1998 16:55:08 -0500
From: Mike Moore <mikem@interlog.com>
Subject: Perl and Cgi resources
Message-Id: <3663143C.7681A1FD@interlog.com>
Could someone recommend a tutorial or resources
for a programming moron like myself to learn
perl and cgi
Thanks,
mike
------------------------------
Date: 30 Nov 1998 22:27:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl CGI program
Message-Id: <73v652$cef$1@client3.news.psi.net>
Dr. Perry Xiao (xiaop@sbu.ac.uk) wrote on MCMXVII September MCMXCIII in
<URL:news:3662E5C0.8B960A00@sbu.ac.uk>:
++
++ ***********************************************************************
++ Method Not Allowed
++
++ The requested method POST is not allowed for the URL
++ /~xiaop/cgi-bin/guestbook.pl.
++ ***********************************************************************
++
++ Does anybody know what the problem is?????????
Yes. The requested method POST is not allowed for that URL.
That's quite clear to me.
Abigail
------------------------------
Date: Mon, 30 Nov 1998 17:18:34 -0800
From: Keith Paschal <keith_paschal@hp.com>
Subject: Perl for old, outdated, ancient systems
Message-Id: <366343EA.EF1C4B43@hp.com>
Aside from going out and spending a few hundred bucks on a newer laptop,
is there a version of Perl that will run on my clunky old 486/MS-DOS/Win
3.1 (Uhhhhgggg dreaded MS) system?
------------------------------
Date: 01 Dec 1998 01:42:22 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl for old, outdated, ancient systems
Message-Id: <912476634.307768@thrush.omix.com>
[posted & mailed]
Keith Paschal <keith_paschal@hp.com> wrote:
: Aside from going out and spending a few hundred bucks on a newer laptop,
: is there a version of Perl that will run on my clunky old 486/MS-DOS/Win
: 3.1 (Uhhhhgggg dreaded MS) system?
At your local CPAN, checkout the msdos, win16, and win31 sections
under the $CPAN/ports directory:
ftp://ftp.digital.com/pub/plan/perl/CPAN/ports
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 30 Nov 1998 18:22:38 -0500
From: Jeff Sack <jsack@ctron.com>
Subject: Script question...
Message-Id: <366328BE.3C11@ctron.com>
I was wondering if anyone could help me out with this one (maybe there
is already a utility that'll do this?)
I need to monitor all files under a certain directory (including
subdirectories). I need the script to keep an eye out for files and
report any files that are accessed (opened) and the time accessed. I've
been experimenting with the Perl command stat (using 8th index of its
return value), but haven't been having a whole lot of luck with it. Any
ideas? Suggestions? I know this is probably a very simple script, so
if anyone can at least point me in the right direction, I'd greatly
appreciate it.
Thanks.
------------------------------
Date: Mon, 30 Nov 1998 18:29:53 -0500
From: Greg Ewing <gewing@wharton.upenn.edu>
Subject: String Insertion
Message-Id: <36632A70.5C019150@wharton.upenn.edu>
I echo the Thanksgiving message sent by Allan. Thanks to all.
I'm working on a script that will take a template HTML file, ask a user
a question such as "What would you like the title to be?" and then take
the user input and insert it into the template file. Finally the script
takes this substituted file and writes it to the file (output.html).
My question is how do I insert the input text as opposed to just writing
the text after the proper tag and overwriting the following text.
I want to take <title>TITLE</title> and replace TITLE with whatever the
user inputs(longer or shorter then 5 characters).
--CODE----
#!/usr/bin/perl
open (IN, "template.html") || die "Couldn't open IN";
open (OUT, ">output.html") || die "Couldn't open OUT";
while (<IN>)
{
if (/title/)
{
&change ("title", 6);
}
elsif (/body/)
{
&change ("body", 5);
}
else
{
print OUT "$_";
}
}
close(IN);
close(OUT);
sub change {
print "What do you want as your $_[0]?";
$input = <STDIN>;
chomp($input);
$count = ($input =~ tr/\s/\S/) + 1;
$start_I = index($_, $_[0]) + $_[1];
$temp = substr($_, $start_I);
substr($_, $start_I) = "";
substr($_, $start_I, $count) = $input;
print OUT "$_"."</$_[0]>";
print OUT "$temp";
}
----
Greg Ewing
gewing@wharton.upenn.edu
------------------------------
Date: Mon, 30 Nov 1998 20:16:30 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: String Insertion
Message-Id: <uhjv37.162.ln@flash.net>
Greg Ewing (gewing@wharton.upenn.edu) wrote:
: I'm working on a script that will take a template HTML file, ask a user
: a question such as "What would you like the title to be?" and then take
: the user input and insert it into the template file. Finally the script
: takes this substituted file and writes it to the file (output.html).
: My question is how do I insert the input text as opposed to just writing
: the text after the proper tag and overwriting the following text.
s/// (the substitution operator) is often used to do substitutions ;-)
: I want to take <title>TITLE</title> and replace TITLE with whatever the
: user inputs(longer or shorter then 5 characters).
: --CODE----
: #!/usr/bin/perl
You should use the -w switch on *every* Perl script.
Really.
On all of them.
#!/usr/bin/perl -w
Maybe this will help:
-----------------------
#!/usr/bin/perl -w
while (<DATA>)
{
if (/<title>/) {
s/TITLE/change('TITLE')/e;
}
elsif (/<body>/) {
s/BODY/change('BODY')/e;
}
print;
}
sub change {
print "What do you want as your \L$_[0]? ";
chomp($input = <STDIN>);
return $input;
}
__DATA__
<html>
<title>TITLE</title>
<body>BODY</body>
</html>
-----------------------
But since you can control what the template looks like (ie. ensure
that the string 'TITLE' appears only where you want to do the
substitution), you can simplify the while() loop to:
while (<DATA>)
{
s/TITLE/change('TITLE')/e;
s/BODY/change('BODY')/e;
print;
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Nov 1998 22:38:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: When does CLOSE not FLUSH?
Message-Id: <73v6ps$cef$2@client3.news.psi.net>
Clinton Gormley (cgormley@netcomuk.co.uk) wrote on MCMXVII September
MCMXCIII in <URL:news:73uihb$htn$1@taliesin.netcom.net.uk>:
++ I'm running perl scripts on Solaris and am having difficulty with locking
++ and flushing.
++
++ The process of the script is :
++ (1) open (>>FH)
++ (2) flock (FH,LOCK_EX)
++ (3) print FH encrypted "foobar"-->takes about 4 seconds.
++ (4) close (FH);
++
++ more than one script can run at the same time.
++
++ My understanding was that close would (1) flush the file buffer and
++ (2)unlock the file.
++
++ in practice, I found that if 10 scripts were called, only 1 or 2 lines of
++ (encrypted "foobar") were being written to the file. The LOCK_EX was
++ working however.
++
++ I then found that if set $| for FH to 1, then this worked perfectly. Why?
++ Surely the close should sort out the file buffering before the lock is
++ removed.
++
++ I originally tried it with flock (FH,LOCK_UN) as well, without success.
++ Although, to be honest, I haven't tried to reimplement it since I have
++ pinpointed the problem.
++
++ Any ideas?
As the example on 'perldoc -f flock' tells you, you need to do a seek
after you got the lock.
open FH, ">> /my/file" or die $!;
flock FH, LOCK_EX or die $!;
seek FH, 2, 0 or die $!; # Seek to the end.
print FH encrypted "foobar";
close FH or die $!;
Abigail
------------------------------
Date: Mon, 30 Nov 1998 22:53:55 GMT
From: finsol@ts.co.nz
Subject: Re: Y2K and Programmer Denial
Message-Id: <73v7lr$20v$1@nnrp1.dejanews.com>
In article <73urot$g1a$1@marina.cinenet.net>,
cberry@cinenet.net (Craig Berry) wrote:
> finsol@ts.co.nz wrote:
> [snip]
> : Many of you following the debate may be interested in reading further on
> : the subject discussed. My first article was on 'booby trap code', a
> : problem that affects
>
> It is very difficult to take anything else you say seriously when your
> list of 'programming languages' --
>
> : programming languages such as Perl, MacPerl, C, C++, Java,
> : Javascript, CGI, MVS and CICS.
>
> -- consists of two variants of the same language, two languages that share
> the same time-handling underpinnings, two other languages, and then -- the
> kicker -- an interface specification and two operating systems.
>
> I stopped reading at this point.
>
I was writing for both a technical and non-technical audience. For the
purposes of the article, there is no necessity to make the distinctions you
mention. It does not improve meaning, it just adds unnecessary jargon.
Technical people may dearly love to use jargon to show how very clever they
are, but does not always assist in the understanding of the subject matter.
And yes, it is important to name the variants - in particular MacPerl - many
people still think their Mac's Y2K immune. And C++ - same again for OO
languages.
I'm surprised you didn't also throw in the fact that one was a scripting
language! To a lot of non-technical people (or even some of us techies)
programming is what we are doing when we instruct a computer to do something.
The distinctions between programming languages, scripting languages,
operating system instructions, JCL etc. are irrelevant - it comes down to the
fact that they can ALL cause Y2K problems. That is the issue and a very
important one. Getting into a huff because someone, in your opinion, has
failed to make these distinctions does not make this issue go away. You seem
to need to find reasons to ignore this issue. I know Y2K work is very boring,
we'd all love to be doing the really clever stuff, we hate to find bugs -
especially if they are our own BUT some very serious problems may occur if
this message is lost.
Jocelyn Amon
http://www.ts.co.nz/~finsol/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 1 Dec 1998 00:42:49 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Y2K and Programmer Denial
Message-Id: <slrn766es8.1dt.dformosa@godzilla.zeta.org.au>
In article <73v7lr$20v$1@nnrp1.dejanews.com>, finsol@ts.co.nz wrote:
>In article <73urot$g1a$1@marina.cinenet.net>,
> cberry@cinenet.net (Craig Berry) wrote:
[...]
>> : programming languages such as Perl, MacPerl, C, C++, Java,
>> : Javascript, CGI, MVS and CICS.
>>
>> -- consists of two variants of the same language, two languages that share
>> the same time-handling underpinnings, two other languages, and then -- the
>> kicker -- an interface specification and two operating systems. [...]
>I was writing for both a technical and non-technical audience. For the
>purposes of the article, there is no necessity to make the distinctions you
>mention.
However it makes you look like you don't know what your talking about.
Its like saying "The rabbit plage effects fruit trees such as Apples,
Oringers, Figs and weat.
> It does not improve meaning, it just adds unnecessary jargon.
And is missleading, it is saying that CGI and MVS are programing
languages when there not.
[...]
>I'm surprised you didn't also throw in the fact that one was a scripting
>language!
Because the distinction between a scripting language and a programing
languge is not that importent or clear cut, but the distiction between
a programing languge, an OS and an interface are.
> To a lot of non-technical people (or even some of us techies)
>programming is what we are doing when we instruct a computer to do
>something.
I don't think dragging a file into a bin counts as programming. To me
programming is where you instruct a computer to do a sequence of
things. That being said, how do you program in CGI or in MVS.
> The distinctions between programming languages, scripting languages,
>operating system instructions, JCL etc. are irrelevant - it comes down to the
>fact that they can ALL cause Y2K problems. That is the issue
Currently the issue is your creadablity to talk on Y2K
[...]
> I know Y2K work is very boring, we'd all love to be doing the really
>clever stuff,
Talking about Y2K is very boring because we have already done it
before and wrote up documentation to cover the issues.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
------------------------------
Date: Mon, 30 Nov 1998 20:32:19 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Y2K and Programmer Denial
Message-Id: <jfkv37.o82.ln@flash.net>
finsol@ts.co.nz wrote:
: In article <73urot$g1a$1@marina.cinenet.net>,
: cberry@cinenet.net (Craig Berry) wrote:
: > finsol@ts.co.nz wrote:
: > [snip]
: > : Many of you following the debate may be interested in reading further on
: > : the subject discussed. My first article was on 'booby trap code', a
: > : problem that affects
: >
: > It is very difficult to take anything else you say seriously when your
: > list of 'programming languages' --
: >
: > : programming languages such as Perl, MacPerl, C, C++, Java,
: > : Javascript, CGI, MVS and CICS.
: I'm surprised you didn't also throw in the fact that one was a scripting
: language! To a lot of non-technical people (or even some of us techies)
^^^^^^^^^^
I think you are four months and one day early for such statements...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Nov 1998 23:54:11 GMT
From: brian hiles <bsh@rainey.blueneptune.com>
Subject: Re: Y2K work - need suggestions
Message-Id: <73vb73$j7v$5@supernews.com>
In comp.unix.shell Citizen Joe <no@spam.org> wrote:
> In comp.unix.admin John Kroll <krollj@worldnet.att.net> wrote:
> ...
> Thanks. I can do 2 things. First, I will minimize disk I/O. Secondly, I can
> do it in parallel, but this can have consequences in terms of network
> load. I don't want to pump too much stuff at the same time. I will have to
> dicuss this with the network people who know what the through-put is. I
> will do (1) and see how much that helps before I do anything else. I would
> rather wait 10 hours for a script with no network load than do it half an
> hour and stress it out, even at night.
The best solutions are always hierarchical in nature: have you solved the
_simplest_ problems first? And now that I see that you have, why not
for the final optimization compile your perl scripts to run not only an
order or two faster but also obviate portability problems?
Search CPAN for experimental Perl compilers that will presumably not choke
on relatively simple scripts. And if need be, you might also try "undump"
which turns any core file (created with a ^\) drectly into an executable.
A wonderful idea, "undump"--I should write Henry Spenser a fan letter. It
may be found via archie search, or within the "emacs" distribution package.
-Brian
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4327
**************************************