[8411] in Perl-Users-Digest
Perl-Users Digest, Issue: 2028 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 5 00:07:29 1998
Date: Wed, 4 Mar 98 21:00:26 -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 Wed, 4 Mar 1998 Volume: 8 Number: 2028
Today's topics:
Re: <META HTTP-EQUIV="Refresh: QUESTION (D.A. Harris)
Re: Are perl $SIG{} handlers inherently unsafe? (Gabor)
Re: Are perl $SIG{} handlers inherently unsafe? (Ilya Zakharevich)
Re: better way to do this? (jay)
Re: CO-Branding Web Sites (Robert F. Harrison)
Connecting to a Database with Perl <akil1@mindspring.com>
Re: Easy Unix Problem (4 U Guys) (Abigail)
Re: Follow up to "PERL" puzzle (Lynn Johannesen)
Re: Help with complex data structures. <che@debian.org>
Re: Help with complex data structures. (Abigail)
Re: Help with complex data structures. <zamboni@cs.purdue.edu>
Re: Help with perl, immediate answers wanted! (Abigail)
Re: HELP!?!?!!?!?! How to use $| <zamboni@cs.purdue.edu>
how do I import subs from another file? <fiji@stetson.edu>
Re: Is there a cron written in perl for Win32? (Jim Michael)
Paragraph mode and $/ variable (Brian Springstead)
Re: Paragraph mode and $/ variable <uri@sysarch.com>
Re: Perl performs a second miracle. Prepare for canoni (Robert F. Harrison)
PERL question <s_farooq@hotmail.com>
Re: Q: How to (Gabor)
Re: QUIZ: answer and hash slice tutorial <jstern@world.northgrum.com>
Re: QUIZ: answer and hash slice tutorial <webmaster@fccjmail.fccj.cc.fl.us>
Re: safe file modification strategy (w/flock, new_tmpfi <uri@sysarch.com>
What I meant <bblum@earthlink.net>
Re: What is PERL? Learn JAVA instead? (Ilya Zakharevich)
Re: What is PERL? Learn JAVA instead? (Frank)
Re: What is PERL? Learn JAVA instead? (Robert F. Harrison)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Mar 1998 03:02:17 GMT
From: rodmur@ecst.csuchico.edu (D.A. Harris)
Subject: Re: <META HTTP-EQUIV="Refresh: QUESTION
Message-Id: <6dl4jp$5p$1@hubble.csuchico.edu>
In article <34f312bd.19341788@news.drenet.dnd.ca>,
at)dciem.dnd.ca (A. P. Beaudoin <my.addy.is@abeaudoi> wrote:
>On 9 Feb 98 00:24:34 GMT, "Charles Wilkins" <thehelm@ibm.net> wrote:
>
>
>>Is there an equivalent to <META HTTP-EQUIV="Refresh"
>>Content="10;URL=http://www.anywhere.com"> that
>>will work in the perl script.
>
>for(;;)
>{
> sleep(10);
> print "Location:http://www.anywhere.com\n\n";
>}
That is probably the way to do it if you want to keep to the HTTP standards.
But with the CGI module you can do something like:
use CGI qw(:cgi :html2);
print header(-Refresh=>"10; URL=http://www.anywhere.com");
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dale Harris <rodmur@csuchico.edu> PGP KeyID: E26EC5FD
Chico State home of the NCAA Div. II National Baseball Champs!
|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
------------------------------
Date: 5 Mar 1998 02:01:09 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Are perl $SIG{} handlers inherently unsafe?
Message-Id: <slrn6fs2ea.9vk.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Tom Christiansen <tchrist@mox.perl.com> wrote :
# [courtesy cc of this posting sent to cited author via email]
#
# In comp.lang.perl.misc, dac@kalypso.cybercom.net (Daniel Childers) writes:
# :Synopsis: are perl $SIG{} handlers inherently unsafe due to the danger of
# :concurrent malloc() calls (and/or higher-level perl data structure mods)
# :in user and interrupt context?
#
# Yes.
Is it unsafe to even just do this in a server
$SIG{CHLD} = sub { wait; };
?
gabor.
--
Besides, it's good to force C programmers to use the toolbox
occasionally. :-)
-- Larry Wall in <1991May31.181659.28817@jpl-devvax.jpl.nasa.gov>
------------------------------
Date: 5 Mar 1998 02:43:01 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Are perl $SIG{} handlers inherently unsafe?
Message-Id: <6dl3fl$oq3$2@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Gabor
<gabor@vmunix.com>],
who wrote in article <slrn6fs2ea.9vk.gabor@vnode.vmunix.com>:
> In comp.lang.perl.misc, Tom Christiansen <tchrist@mox.perl.com> wrote :
> # [courtesy cc of this posting sent to cited author via email]
> #
> # In comp.lang.perl.misc, dac@kalypso.cybercom.net (Daniel Childers) writes:
> # :Synopsis: are perl $SIG{} handlers inherently unsafe due to the danger of
> # :concurrent malloc() calls (and/or higher-level perl data structure mods)
> # :in user and interrupt context?
> #
> # Yes.
>
> Is it unsafe to even just do this in a server
>
> $SIG{CHLD} = sub { wait; };
>
> ?
You have seen the answer already. (Though I would think that
$SIG{CHLD} = sub { wait; return; };
is safe in my OS/2 binary release, which contains a voodoo patch which
is not allowed into the main distribution.)
Ilya
------------------------------
Date: Thu, 05 Mar 1998 04:24:48 GMT
From: mocat@spamtrap.best.com (jay)
Subject: Re: better way to do this?
Message-Id: <34fe290d.603393@nntp.best.com>
Haven't had much time to mess with this, so I haven't been able to
implement any of my ideas yet...
And... I'm still having a few problems. (please excuse my
newbieness... heh)
Here it is...
#!/usr/bin/perl -p
undef $/;
%images = (
jpg => "jpeg image",
jpeg => "jpeg image",
gif => "gif image",
);
($imgargs) = $_ =~ /(<img.*?>)/si;
if ($imgargs !~ /\balt\b/si) {
($alt) = $imgargs =~ /\bsrc\s?=\s?"(.*?)"/si;
$size = -s $alt;
($imgtype) = $alt =~ /\.([^.\/]*)$/si;
s/\bsrc/alt="$images{$imgtype}($size bytes)" src/si if
-e $alt; #wordwrap
s/\bsrc/alt="not found" src/si if !-e $alt && $alt !~
/^http:\/\//i; #wordwrap
s/\bsrc/alt="$alt" src/si if $alt =~ /^http:\/\//i;
}
Having trouble with the undef $/;
It works well if it goes through html such as:
<img src="foo.gif"><img src="flop.gif">
or html such as:
<img s
rc="f
oo.gif
">
(yikes!)
But with $/ set to undef, it will not parse $alt with http:// in it.
Works fine when I comment out undef $/;
I have a hunch that it has to do with the $imgtype regexp, but I could
be wrong, and probably am. Also, excuse my nasty abuse to regexp
arguments, I've just been adding each argument until it does
something. ;) Still learning.
I tried /gis but it did something funny.
Thanks for all the help, it's been a great learning experience...
cheers
-j
:mocat@best.com/www.best.com/~mocat:
------------------------------
Date: 5 Mar 98 01:48:16 GMT
From: harrison@pixi.com (Robert F. Harrison)
Subject: Re: CO-Branding Web Sites
Message-Id: <slrn6fs11s.2kk.harrison@localhost.localdomain>
[Cc'd to stacy-lacy@worldnet.att.net as well.]
On Tue, 03 Mar 1998 18:37:45 -0800, Stacy Lacy
<stacy-lacy@worldnet.att.net> wrote:
> Robert F. Harrison wrote:
> > On Sun, 01 Mar 1998 00:06:55 -0600, digitalstars@yahoo.com
>
> > <digitalstars@yahoo.com> wrote:
> > > Does anyone know of a script, or how one would go about
> > > co-branding your own web site for someone else? In other
> > > words, create an entire new site without the work.
>
> > I think simple intellectual theft would suffice in this case,
> > doesn't really require Perl. Indeed, that would be overkill.
>
> I don't think you really understand the question. Although I
> don't know the author, we have a similar need. CO-Branding
> most likely refers to the fact that a company may do business
> under multiple brand names. My company uses one brand name
> domestically, and other brand names in international markets.
I think you are correct in that I didn't understand the question and
popped off a reply without thinking too much. On the other hand, it is
a question better suited to the c.i.w.a.? groups.
Overall though, I do apologize to 'digitalstars' for what I said. I
only 'heard' the "create an entire new site without the work" part of
your question.
Thanks Stacy for pointing out my error.
--
rfh harrison@pixi.com
------------------------------
Date: Wed, 4 Mar 1998 20:16:00 -0500
From: "Kevin Bass" <akil1@mindspring.com>
Subject: Connecting to a Database with Perl
Message-Id: <6dl7ad$pus$1@camel20.mindspring.com>
How can I connect to an Oracle database and run a SQL statement in Perl
using DBI,
oraperl and/or any other method? Please give an example of a method(s)
stated
in prior sentence. [This is not for a class or any other instructor-based
education.]
Kevin
------------------------------
Date: 5 Mar 1998 03:12:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Easy Unix Problem (4 U Guys)
Message-Id: <6dl566$iih$1@client3.news.psi.net>
TomH (beans@bedford.net) wrote on 1647 September 1993 in
<URL: news:01bd44e2$ed9b0860$269163ce@beans.bedford.net>:
++ James Ludlow <jdludlow@millcomm.com> wrote in article
++ <34FC9D3C.5AC05BED@millcomm.com>...
++ > Elf Sternberg wrote:
++ > [snip]
++ > > To those reading this on comp.lang.perl, is there an easier
++ > > way to split a line 'every nth character' without the cockamamie
++ > > while/for/substr construction I've got up there? I actually have
++ > > wracked my brains on this before without coming up with a satisfactory
++ > > answer.
++ >
++ I wouldn't use something like this in a production environment, but it's
++ kind of cute:
++
<snip>
my $n = 7; # Or whatever.
my @chunks = $str =~ /(.${\('.?' x ($n - 1))})/gs;
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Thu, 5 Mar 1998 03:54:13 GMT
From: lynnj@netcom.com (Lynn Johannesen)
Subject: Re: Follow up to "PERL" puzzle
Message-Id: <lynnjEpBuuD.5Hz@netcom.com>
Greg Bacon (gbacon@cs.uah.edu) wrote:
: In article <34FDAAED.797BDBA0@wx3.com>,
: "Kevin J. Lin" <kevin@wx3.com> writes:
: : As promised, the solution to that "PERL" puzzle.
: [snip]
: That is quite possibly one of the most sick and twisted perversions I've
: ever come across in my entire life. Keep it up. :-)
For more fine examples of this kind of work, see the Obfuscated C
Contest.
------------------------------
Date: 04 Mar 1998 18:32:16 -0800
From: Ben Gertzfield <che@debian.org>
Subject: Re: Help with complex data structures.
Message-Id: <y9hogzleukv.fsf@always.got.net>
>>>>> "eheft" == eheft <eheft@dnaco.net> writes:
eheft> Hi I'm starting to get the feel for perl but building a
eheft> complex data structure is eluding me. In C I'd do the
eheft> following:
*snip* What you need is a quick trip to the 'perldsc' documentation
page! Run 'perldoc perldsc' to read up all about Perl data
structures in the Data Structures Cookbook.
In your case, what you want is an array of references to hashes. Like
so:
for (1..16) { # Loop 16 times..
push @data, { # push a reference to a hash into the list
title => '',
min => 0,
max => 0,
num_items => 0,
items => [], # this is a reference to a list
};
}
And to access, say, the 13th member of @data's title..
print $data[13]->{'title'};
Or to increase the number of items..
$data[13]->{num_items}++;
The perldsc talks about all sorts of things like this. Good luck!
--
Brought to you by the letters H and G and the number 3.
"If you turn both processors off, you will have to reboot." -- The Be Book
Ben Gertzfield <http://www.imsa.edu/~wilwonka/> Finger me for my public
PGP key. I'm on FurryMUCK as Che, and EFNet and YiffNet IRC as Che_Fox.
------------------------------
Date: 5 Mar 1998 02:41:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help with complex data structures.
Message-Id: <6dl3cp$i88$1@client3.news.psi.net>
eheft@dnaco.net (eheft@dnaco.net) wrote on 1647 September 1993 in
<URL: news:6dkukk$edm$1@nnrp1.dejanews.com>:
++ Hi
++ I'm starting to get the feel for perl but building a complex data
++ structure is eluding me. In C I'd do the following:
++
++ typedef struct {
++ char title[32]; // Title for a List of Items.
++ int min; // Minimum item
++ int max; // Maximum item
++ int numItems; // Number of items in items[]
++ int *items; // The list of Items.
++ } trDATA, *tpDATA;
++
++ trDATA data[16]; // Allocate 16 lists of items.
++
++ Could some kind soul show how to set a similar data structure in perl?
++ I've hashed out one but its seems really awkward to access say
++ data[0].items[5] or do a comparison like if (data[0].min < data[1].min)
Well, data[0].items[5] is the C way, isn't?
One way of doing it:
use constant title => 0;
use constant min => title + 1;
use constant max => min + 1;
# There's no need for storing the number of elements in a variable.
# Perl *knows*.
use constant items => max + 1;
my @data;
And then $data[0][items][5] will just work fine....
(That's right, no initialization/allocation, it just *works*).
And I don't think ``$data[0][items][5]'' is that much more awkward
then ``data[0].items[5]''. And you may even write it as
``$data [0] -> [items] [5]'' if you prefer.
Ain't Perl great?
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 04 Mar 1998 22:11:14 -0500
From: Diego Zamboni <zamboni@cs.purdue.edu>
To: eheft@dnaco.net
Subject: Re: Help with complex data structures.
Message-Id: <fwg1kxygq5.fsf@narnia.cs.purdue.edu>
eheft@dnaco.net writes:
> typedef struct {
> char title[32]; // Title for a List of Items.
> int min; // Minimum item
> int max; // Maximum item
> int numItems; // Number of items in items[]
> int *items; // The list of Items.
> } trDATA, *tpDATA;
>
> trDATA data[16]; // Allocate 16 lists of items.
>
> Could some kind soul show how to set a similar data structure in perl?
> I've hashed out one but its seems really awkward to access say
> data[0].items[5] or do a comparison like if (data[0].min < data[1].min)
Read the perldsc and perllol man pages. In Perl, you would not "declare"
the data structure type, but simply fill it in, like in:
for($i=0; $i<10; $i++) {
$data[$i]->{title}="This is title $i";
$data[$i]->{min}=$i-1;
$data[$i]->{max}=$i+2;
$data[$i]->{items}=(1, 2, 3, 4, 5);
# ... you get the idea
}
In this case, $data would be a list where each element is an anonymous
hash reference. In that hash you store your "fields", keyed by their names.
Each field can store anything you want, such as strings, numbers, lists,
or other references.
Hope this helps,
--Diego
------------------------------
Date: 5 Mar 1998 02:43:17 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help with perl, immediate answers wanted!
Message-Id: <6dl3g5$i88$2@client3.news.psi.net>
Brandon Blum (bblum@earthlink.net) wrote on 1646 September 1993 in
<URL: news:34FD8F46.A5FF9B1F@earthlink.net>:
++ Hi all, I was wondering if anyone could help me with a problem, well not
++ really problem but an answer. I wanted to write a form or something that
++ uses a form, i test them out on my machine with ms dos. Is there anyway
++ I could use html in that so I could see the form and enter stuff, or do
++ I need to put it on a webserver which I don't have. If anyone does have
++ one or a place I could put the scripts I could definetly make out some
++ kind of deal if you did let me use it!
What makes you think comp.lang.perl.misc is a more appropriate forum to
ask then say, rec.pets.flees?
Your question has *NOTHING* to do with Perl. Absolutely nothing.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 04 Mar 1998 22:04:11 -0500
From: Diego Zamboni <zamboni@cs.purdue.edu>
To: Patti Johnson <pjohnson@wcu.edu>
Subject: Re: HELP!?!?!!?!?! How to use $|
Message-Id: <fwiuptyh1w.fsf@narnia.cs.purdue.edu>
Patti Johnson <pjohnson@wcu.edu> writes:
> I've got a Perl script that writes form data to a file, no frills.
> But, it seems to take a notion to insert carriage returns whenever
> it wills. I see that the $| thingy is supposed to cause Perl to
> flush after every write "on the currently selected output channel."
> Well, how do I tell it to flush on a a file handle?
You use select to set the "currently selected output channel" to whatever
you want, then set $|. Something like this:
my $ofh=select(THEHANDLE); $|=1; select($ofh);
which stores the current default handle (normally STDOUT) and restores it
afterwards. In Perl wizardry mode, you could write
select((select(THEHANDLE), $|=1)[0]);
See the Camel book for a full explanation of this.
If you use IO::File or IO::Handle to handle your files, you can do
$myhandle->autoflush(1);
Cheers,
--Diego
------------------------------
Date: Thu, 05 Mar 1998 02:25:13 +0000
From: fiji <fiji@stetson.edu>
Subject: how do I import subs from another file?
Message-Id: <34FE0D09.31D3819E@stetson.edu>
Basically I have a perl script that has a billion subs. I would think
that I could put the subs{} in other files and include them as if I was
writing in c. Now I know that I will have to sometimes call these subs
numerous times. I originally tried something like:
in file extratest
sub test{
print "I am in extratest\n";
}
and then in file realtest
#!/usr/bin/perl
print "I am not realtest\n";
require 'extratest';
test;
but this does not work. What am I doing wrong or what is the best way to
do something like this?
-Fiji
------------------------------
Date: Thu, 5 Mar 1998 03:05:14 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Is there a cron written in perl for Win32?
Message-Id: <genepoolEpBsKq.Frw@netcom.com>
Kevin Hawley (cchkxh@ARCO.com) wrote:
: Hi, I'm looking for cron/crontab functionality for Win32. I have used
: p.s.Sorry for posting to this group; Should there be a
: ...perl....Win32.. group?
This has nothing to do with perl. The closest thing under NT is AT.
------------------------------
Date: Thu, 5 Mar 1998 02:56:27 GMT
From: bspring@j51.com (Brian Springstead)
Subject: Paragraph mode and $/ variable
Message-Id: <slrn6fs52i.mg9.bspring@j51.com>
Is it possible to set $/ = /^\s{2,}[A-Z]/; Not just the value, but have
that evaluated like a regular pattern match?
Here is my reason why:
I have 20 or more files (with new ones on the way) that have on ave.
from 10k to 300k of text. They were written by several different
authors so the paragraphs are indented with a tab, 2 spaces or
some up to five space, depending on author. The big problem is that
the paragraphs aren't separated by a newline (some are, most aren't).
I'm trying to write a script to format them all the same. I thought
that by using "paragraph" mode would simplify writing it. Here is an
example of the typical input:
This a typical example of the input that I would like to format to a
consistent form. This author uses 2-3 spaces to indent his paragraphs. If
he only inserted a blank line, my life would be much easier because I could
just set $/ = ""; blah, blah, blah, etc.
Here is the next thought by the same author, blah, blah, blah, blah
blah blah blah.
Some other authors use tabs. Oh why oh why is it my job to make all
of this files the same? :)
Can anyone point me in the right direction? Is this possible and I am just
using the wrong regular expression? I probably could write the script to
get one line at a time and work on it that way, but I really can see the value
to grabbing a paragraph at a time and I want to learn something new.
Thanks in advance.
Brian
--
Brian Springstead | SPOON!
Spoon! | Not in the face! Not in the face!
bspring@j51.com | The Tick and Aurthur's battle cry
------------------------------
Date: 04 Mar 1998 23:30:34 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Paragraph mode and $/ variable
Message-Id: <x77m69yd1x.fsf@sysarch.com>
bspring@j51.com (Brian Springstead) writes:
> Is it possible to set $/ = /^\s{2,}[A-Z]/; Not just the value, but have
> that evaluated like a regular pattern match?
$/ is only a fixed string match not a regex. there was a thread about
this a short time ago. find it at dejanews
> This a typical example of the input that I would like to format to a
> consistent form. This author uses 2-3 spaces to indent his paragraphs. If
> he only inserted a blank line, my life would be much easier because I could
> just set $/ = ""; blah, blah, blah, etc.
> Here is the next thought by the same author, blah, blah, blah, blah
> blah blah blah.
> Some other authors use tabs. Oh why oh why is it my job to make all
> of this files the same? :)
if the regex you have is correct for your data (and i believe it is
not), just slurp the entire file at one tiem and do a split with the
regex. you will get your paragraphs in a list. this (untested) code will
illustrate the idea:
$/ = undef ;
$file = <FILE> ;
#this regex will split on leading white space and remove it
@paras = split( /^\s+/, $file ) ;
foreach $para ( @paras ) {
blah, blah, blah
}
hope this helps
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 5 Mar 98 04:28:13 GMT
From: harrison@pixi.com (Robert F. Harrison)
Subject: Re: Perl performs a second miracle. Prepare for canonizaton!
Message-Id: <slrn6fsadq.2kk.harrison@localhost.localdomain>
On Wed, 04 Mar 1998 14:52:16 -0500, Joe Lannom <jlannom@ford.com> wrote:
> William Denton wrote:
>
> > I left it overnight, and, as before, the next morning
> > it worked.
>
> Beware of such programs... especially of they spent the night
> sleeping next to a .pod.
ROTFL
I've never had a script self correct itself by getting a good
night's rest. But...having found errors in minutes that dogged me
for hours the night before after a good sleep...
=begin rant
I'm beginning to think we could we could eliminate the bugs from
some large well known company's software by putting their staff
to sleep.
=end rant
:-)
--
rfh harrison@pixi.com
------------------------------
Date: 5 Mar 98 03:50:17 GMT
From: "Salman" <s_farooq@hotmail.com>
Subject: PERL question
Message-Id: <01bd47ea$0fc65f20$ec4a7fcb@salman>
Hi...
I want my java applet to execute a PERL program on the browser by
passing a parameter to it...
Can anybody help me how to execute the Perl file from an applet and how
I can pass a string to the pl file??
------------------------------
Date: 5 Mar 1998 02:06:48 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Q: How to
Message-Id: <slrn6fs2ot.9vk.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Lance <lsj@bnl.gov> wrote :
# This data file is like this, they are all small files:
# .1 14.650 .2155123 .0
# .1 14.70001 .2140399 .0
# .1 14.75001 .2124197 .0
# .1 14.80001 .2106409 .0
# .1 14.85001 .20869 .0
# .1 14.90001 .2065667 .0
# .1 14.95001 .2042442 .0
# .1 15.00001 .2017127 .0
# As you can see, the length is varying. I have no idea what the record size's
# going to be. So how to get the last record is still a problem. What I do now
# is:
# open(FF,$input) || die "Couldn't open $input: $!\n";
# $i=0;
# while (<FF>) {
# ($a1[$i],$a2[$i],$a3[$i],$a4[$i])= split(" ",$_);
$foo = (split /\s+/,$_)[3];
# $$i++;
# }
gabor.
--
This made me wonder, suddenly: can telnet be written in perl?
Of course it can be written in Perl. Now if you'd said nroff,
that would be more challenging...
-- Larry Wall
------------------------------
Date: Thu, 5 Mar 1998 01:59:50 GMT
From: Jim Stern <jstern@world.northgrum.com>
Subject: Re: QUIZ: answer and hash slice tutorial
Message-Id: <34FE0716.36D51FC7@world.northgrum.com>
John Porter wrote:
>
> Charles Margolin wrote:
> >
> > Uri Guttman wrote:
> >
> > > @array{ @array } = ( [ @array ] ) x @array ;
> >
> > Is there a reason to copy the original array into an anonymous array?
> > Why not use a reference to @array?
> >
> > @array{ @array } = ( \@array ) x @array ;
>
> It basically depends on whether you want to ensure that the
> array referenced by each hash entry is protected from
> modifications to @array later on.
> In general, I would guess that making a "protected" copy
> is more likely to be useful.
>
> John Porter
This is correct. I reply only to clarify by means of an example:
=snip
#!/usr/local/bin/perl -w
use strict;
my @array = (1..5);
my @a = (\@array) x 3;
my @b = ([@array]) x 3;
print "@{$a[0]}\n"; # 1..5
print "@{$b[0]}\n"; # 1..5
$array[0]=10;
print "@{$a[0]}\n"; # 10, 2..5
print "@{$b[0]}\n"; # 1..5
$a[1][1]=20;
print "@{$a[0]}\n"; # 10, 20, 3..5
print "@{$b[0]}\n"; # 1..5
=snip
In short:
@b consists of 3 elements and each is a reference to a different
copy of @array
@a consists of 3 elements and each refers to the same array, @array
Normally, the aliasing going on inside @a is a Bad Thing.
--
Jim Stern -- Views here are my own, not my employer's. (Hawthorne, CA)
------------------------------
Date: Thu, 05 Mar 1998 04:35:52 GMT
From: Bill Jones <webmaster@fccjmail.fccj.cc.fl.us>
Subject: Re: QUIZ: answer and hash slice tutorial
Message-Id: <34FE2A6E.1A5BF24A@fccjmail.fccj.cc.fl.us>
Original mailed, this one posted :-)
I wanted to split an address, like 207.203.61.2 into
207.203.61 and .2 :-)
Thx to Randal Schwartz, who was the first to answer
this fine question :-)
Bill
Randal Schwartz wrote:
> >>>>> "Bill" == Bill Jones <webmaster@fccjmail.fccj.cc.fl.us> writes:
>
> Bill> Hmmm. Since Perl was originally targeted to C programmers, maybe
> Bill> a start at the beginning would prove helpful for a 'beginners Quiz?'
>
> Bill> Something like -
> Bill> my($removeHostAddr) = substr(remote_addr, (rindex(remote_addr(),".")));
>
> Bill> Q1. What do you (ng readers not Uri, per se) think it does?
>
> The same thing as
>
> my($removeHostAddr) = remote_addr() =~ /.*(\..*)/;
>
> As in, grab the last part of the return value of &remote_addr (which
> you invoke twice :-) beginning with the final ".". (Did you really
> want the dot in your value?)
>
> Bill> Q2. How would that be written as a RegEx???
>
> Like I just did. :-)
>
> print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
> ## legal fund: $20,990.69 collected, $186,159.85 spent; just 181 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@teleport.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: 04 Mar 1998 23:11:17 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: safe file modification strategy (w/flock, new_tmpfile, and syscopy?)
Message-Id: <x790qpydy2.fsf@sysarch.com>
shaug@gromit.callamer.com (O'Shaughnessy Evans) writes:
> Hi, I've got a question on the safest strategy for modifying a file.
> I need to edit a RADIUS users file; it's critical for authentication
> of PPP users, so I want to minimize the risk of hosing it, even in
> case of a system crash while the program is running. My current
> algorithm is like this:
>
> open $file in seekable append mode
> exlusively flock $file
> make backup of $file w/syscopy
> rewind $file
> create $tmp w/new_tmpfile
>
> read $file, process, write to $tmp
>
> rewind and truncate $file
> rewind and flush $tmp
>
> read from $tmp -> write to $file
> close $file
> close $tmp
you are doing too much work. try this idea, use rename to atomically
move the new file to the old file. unix's rename is atomic and very fast
so a version of the file is always available
lock current file (prevent modifications)
open current file
read current file
close current file
open temp
process current file
write to temp
close temp
rename temp to current
the only issue i see is a possible race condition with users modifying
current after it is closed and before it is renamed so this may be the
correct order:
lock current file (prevent modifications)
open current file
read current file
open temp
process current file
write to temp
close temp
rename temp to current
close current file (releases lock)
hope this helps,
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: Wed, 04 Mar 1998 19:53:53 +0000
From: Brandon Blum <bblum@earthlink.net>
To: abigail@fnx.com
Subject: What I meant
Message-Id: <34FDB14C.FC64FAF6@earthlink.net>
Sorry all, what I meant was making a form in perl or anything else so
that it sends you an e-mail or something and when i run my perl script
from ms dos no html works, please read the first question and continue
from here!
Sorry for the confusion,
Brandon
Abigail wrote:
> Brandon Blum (bblum@earthlink.net) wrote on 1646 September 1993 in
> <URL: news:34FD8F46.A5FF9B1F@earthlink.net>:
> ++ Hi all, I was wondering if anyone could help me with a problem,
> well not
> ++ really problem but an answer. I wanted to write a form or something
> that
> ++ uses a form, i test them out on my machine with ms dos. Is there
> anyway
> ++ I could use html in that so I could see the form and enter stuff,
> or do
> ++ I need to put it on a webserver which I don't have. If anyone does
> have
> ++ one or a place I could put the scripts I could definetly make out
> some
> ++ kind of deal if you did let me use it!
>
> What makes you think comp.lang.perl.misc is a more appropriate forum
> to
> ask then say, rec.pets.flees?
>
> Your question has *NOTHING* to do with Perl. Absolutely nothing.
>
> Abigail
> --
> perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
> print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 5 Mar 1998 02:38:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <6dl36n$oq3$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Abigail
<abigail@fnx.com>],
who wrote in article <6dksti$sj3$7@client2.news.psi.net>:
> ++ That being said, two things that are easy to do in Java but
> ++ exceedingly difficult to do in Perl include:
> ++
> ++ - Work with cyclic structures. (AFAIK, Perl still uses
> ++ reference counting rather than true garbage collection, and so
> ++ cannot reclaim them automatically.)
>
> Bullocks. Perl does have true garbage collection, and more precisely,
> you know exactly when it kicks in.
Eh? And I was reading your comments to my patch for softreferences...
Too trusty ;-).
> ++ - Anything involving multiple threads of control.
> ++
> ++ I understand that this last will *finally* be addressed in Perl in the
> ++ near future..
>
> Yes, but threads are overhyped (just like Java). Many things don't
> really need threads.
Almost any interactive application wins if there is a *simple* access
to threads. If the access is complicated, then the win may be not
worth the effort.
Ilya
------------------------------
Date: Thu, 05 Mar 1998 02:36:58 GMT
From: FHeasley@chemistry.com (Frank)
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <34ff0efd.25879700@news.halcyon.com>
On 5 Mar 1998 00:48:19 GMT, abigail@fnx.com (Abigail) wrote:
>Frank (FHeasley@chemistry.com) wrote on 1646 September 1993 in
>++
>++ 1. Try running a perl script in your user's web browser.
>
>And this proves what? I can run Python applets in someones webbrowser.
>It's just that noone bothered to write a browser that can do Perl
>applets. That's probably because Perl isn't a toy language.
Dang! Just when I was starting to have fun with it, it turns out to
be just another work tool.
Frank ;-)
------------------------------
Date: 5 Mar 98 04:39:18 GMT
From: harrison@pixi.com (Robert F. Harrison)
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <slrn6fsb2j.2kk.harrison@localhost.localdomain>
On 4 Mar 1998 18:59:29 GMT, Michael J Gebis
<gebis@albrecht.ecn.purdue.edu> wrote:
> Brian Slone <bslone@earthlink.net> writes:
>
> }I really don't know crap about PERL. How is it different from
> }JAVA? Which one is better? What can I use it for?
>
> I can understand your confusion: "Java" was the code name for
> Perl 4.036, way back in the early 70's[1]. Unfortunately, "Ja
> Va" means "Yes Go" in Swedish/Spanish (per word) so the name
> was dropped. We are now calling Perl "Eiffel" which as far as
> anyone can tell, doesn't mean anything at all.
And here I thought Java's real name was Object-Intercal. Live and
learn.
--
rfh harrison@pixi.com
------------------------------
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 2028
**************************************