[9273] in Perl-Users-Digest
Perl-Users Digest, Issue: 2868 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 13 23:07:25 1998
Date: Sat, 13 Jun 98 20:00:29 -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 Sat, 13 Jun 1998 Volume: 8 Number: 2868
Today's topics:
Re: [Q] Help creating a perl cgi script - word1.txt [ (Bbirthisel)
Re: Certified Perl Programmers (Jeff Yoak)
Re: Certified Perl Programmers (Mark-Jason Dominus)
Re: CFV: comp.lang.perl.moderated moderated (John Stanley)
conditional curiosity... <REPLY_TO_damonbrent@earthlink.net>
Re: conditional curiosity... <rootbeer@teleport.com>
Re: Force garbage collection <bowlin@sirius.com>
Re: Had a small AHA on objects (Mark-Jason Dominus)
Re: Have we got a good free Perl manual? <abraham@dina.kvl.dk>
Re: Have we got a good free Perl manual? birgitt@my-dejanews.com
Missing cgi-lib.pl for Win32 Perl <zeos@gti.com>
Re: New module/pragma "enum.pm" (was "fields.pm") <schwartz@cs.tu-berlin.de>
Re: new to this - simple if statement question (Mark-Jason Dominus)
Re: Perl editor debugger (Patrick Timmins)
Re: Perl POP Email program <bowlin@sirius.com>
Re: Puzzle challenge (clarified) <bowlin@sirius.com>
Re: Puzzle challenge (clarified) (John Stanley)
Read the last record in a file info@insyte.com
Re: Read the last record in a file <rootbeer@teleport.com>
Re: Read the last record in a file <REPLY_TO_damonbrent@earthlink.net>
Re: Return values of comparison operators <pimlott@MATH.HARVARD.EDU>
Re: REVIEW: Perl CGI Programming - No Experience Requir (Mark-Jason Dominus)
Re: REVIEW: Perl CGI Programming - No Experience Requir <tchrist@mox.perl.com>
Re: REVIEW: Perl CGI Programming - No Experience Requir (Mark-Jason Dominus)
Writing to a file?? <rudedog@gcnet.com>
Re: Writing to a file?? <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jun 1998 00:20:34 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: [Q] Help creating a perl cgi script - word1.txt [1/1]
Message-Id: <1998061400203400.UAA29091@ladder01.news.aol.com>
** FLAME **
>Thanks for your fast responds. I have not started this at all since I am
>not a expert in perl. I was wondering if someone might be able to write
>one so I can learn from that.
The original poster is a lazy fool. I was going to reply privately until I
saw the return address (anon...). The world does not owe you any respect
unless you have enough self-respect to identify yourself with your
question.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Sun, 14 Jun 1998 00:50:16 GMT
From: jeff@yoak.com (Jeff Yoak)
Subject: Re: Certified Perl Programmers
Message-Id: <6lv6k9$3i1@sjx-ixn9.ix.netcom.com>
abigail@fnx.com (Abigail) wrote:
>Mark-Jason Dominus (mjd@op.net) wrote on MDCCXLVII September MCMXCIII in
><URL: news:6lsk5k$hba$1@monet.op.net>:
>++ In article <1998061223230300.TAA21653@ladder01.news.aol.com>,
>++ Bbirthisel <bbirthisel@aol.com> wrote:
>++ >You should make it downloadable from CPAN and indicate where to find
>++ >it in the FAQ. That would establish a suitable skill set - since anyone who
>++ >couldn't do that probably shouldn't have one.
>++
>++ But I want everyone to have one!
>Well, you could write a program that harvests email addresses, and then
>sends certificates to those addresses....
But what about people who munge their addresses? Shouldn't they be
able to be Perl certified?
Cheers,
Jeff
--
Jeff Yoak jeff@yoak.com
------------------------------
Date: 13 Jun 1998 21:22:32 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Certified Perl Programmers
Message-Id: <6lv8ko$lpe$1@monet.op.net>
Keywords: Flemish foggy plagiarism prize
In article <6lkmdd$bui$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>I may be mistaken, but I thought that TPI had specifically declined
>to issue certifications. Of course, that policy could be changed, if
>there is such a policy.
I didn't find anything on TPI's web site, but
<URL:http://www.perl.com/tpi.html>
quotes Jon Orwant:
# Q: Will TPI become involved in certification of Perl developers?
#
# No. Perl is popular because it makes easy things easy and hard things
# possible; people can be productive Perl programmers without knowing
# very much about the language at all.
#
# Certifying that someone can program Perl would be like certifying that
# someone can write. It's painting with too broad a brush. Different
# Perl jobs require different talents: database programming, system
# administration, graphic visualization, web development, financial
# applications, enterprise programming, Internet security, text
# processing, bioinformatics, or raw number crunching. We worry that any
# official-seeming test would give prospective employers (and employees)
# a false sense of security.
#
------------------------------
Date: 14 Jun 1998 00:32:55 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: CFV: comp.lang.perl.moderated moderated
Message-Id: <6lv5nn$gkg$1@news.NERO.NET>
In article <6ltuo1$l1k$1@pegasus.csx.cam.ac.uk>,
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>You could always have contacted the proponent after the first RFD.
>That's what I did.
This does not change the fact that the request for volunteers was made
elsewhere. I'm happy that you saw a list already prepared as an
invitation to volunteer. I see a list of 11 people for a 6 person panel
as not needing anyone else.
------------------------------
Date: Sat, 13 Jun 1998 20:37:30 -0400
From: "Brent Verner" <REPLY_TO_damonbrent@earthlink.net>
Subject: conditional curiosity...
Message-Id: <6lv5vv$amr$1@argentina.it.earthlink.net>
is there any benefit (aside from less lines of code) to using :
$a = $b if $b;
rather than :
if ($b)
{
$a = $b;
}
is the former less expensive?
thanks,
brent
------------------------------
Date: Sun, 14 Jun 1998 01:16:52 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: conditional curiosity...
Message-Id: <Pine.GSO.3.96.980613181550.27055D-100000@user2.teleport.com>
On Sat, 13 Jun 1998, Brent Verner wrote:
> is there any benefit (aside from less lines of code) to using :
>
> $a = $b if $b;
>
> rather than :
>
> if ($b)
> {
> $a = $b;
> }
They should be interchangeable for all practical purposes. Hope this
helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 13 Jun 1998 16:39:16 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: "Frangois Pinard" <pinard@iro.umontreal.ca>
Subject: Re: Force garbage collection
Message-Id: <35830DA4.F1A0237E@sirius.com>
Frangois Pinard wrote:
>
> Tom Christiansen <tchrist@mox.perl.com> writes:
>
> > [...] you'll run out of memory, too. If your data has no circular
> > references, it should be fine.
>
> The sentence seems to imply that, if I managed to build a structure having
> circular references, it would escape garbage collection. Yet, I suspect
> this is probably not what you wanted to say. What did you mean, then? :-)
Frangois, check out either page 299 of the Camel Book or perldoc perobj.
They both state explicitly that circular references escape garbage collection.
-- Jim Bowlin
------------------------------
Date: 13 Jun 1998 22:35:42 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Had a small AHA on objects
Message-Id: <6lvctu$m0n$1@monet.op.net>
Keywords: besmirch brown Garrisonian marijuana
In article <358125E9.AE583257@nortel.co.uk>,
F.Quednau <quednauf@nortel.co.uk> wrote:
>So all about an object is really that it miraculously knows everything what is
>going on inside its package
> (which I suppose it's main:: as default,
`bless' defaults to using the current package, whether or not the
current package is `main'.
The complete explanation of objects is:
1. `bless' associates a package name with a piece of data such
as a hash or an array. The data is now blessed.
2. If you say
X->Y(Z)
and X is a reference to a data that has been blessed into
package P, then Perl pretends that you wrote
P::Y(X, Z)
instead.
3. Not important right now; see below.
>$hashref->openthat( -DIR =>"/u/quednauf/temp");
Suppose $hashref refers to something that has been blessed into the
package Frank::Quednau. Then
$hashref->openthat( -DIR =>"/u/quednauf/temp");
is exactly the same as writing
Frank::Quednau::openthat($hashref, -DIR => "/u/quednauf/temp");
When you write `openthat', you can pretend that the user did write it
the second way, so:
package Frank::Quednau;
sub openthat {
my $self = shift; # Gets $hashref
my %ARGS = @_; # Get the rest of the arguments
my $dir = $ARGS{-DIR} || '.'; # Look for -DIR argument
# do something with $dir ...
}
>Can someone recommend me a module I can look at, which is relatively
>straightforward to grasp, but shows good programming techniques in
>Perl?
Don't look at any of mine.
----------------------------------------------------------------
The only important thing I left out of the Complete Description of
Objects above is this:
3. If there is no function named `Y' in package P, Perl
will search for a function named `Y' in the packages
mentioned in @P::ISA, if there are any.
That's all there is.
------------------------------
Date: 14 Jun 1998 01:46:21 +0200
From: Per Abrahamsen <abraham@dina.kvl.dk>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <rjyav0x3ua.fsf@zuse.+dina.kvl.dk>
[ FUT: gnu.misc.discuss ]
birgitt@my-dejanews.com writes:
> And why are these FSF style free manuals not written then ?
Because nobody has volunteered.
> Not a money issue ?
Probably so, but not in the sense Barry Margolin talks about.
The FSF has paid writers in the past. If they had more money, they'd
likely pay someone to do write the manuals in thier task list. But
they have not, so they can only hope someone volunteers
> Are all documentation writers going to be martyrs for the FSF ?
"Martyr" is a weird word to use. I write free software (and bad
documentation of it), but certainly don't consider myself a "martyr".
> Or are they allowed to be modestly recompensated for their work.
Of course they are. Everybody agrees on that.
------------------------------
Date: Sun, 14 Jun 1998 01:56:42 GMT
From: birgitt@my-dejanews.com
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6lvakq$vcv$1@nnrp1.dejanews.com>
In article <6lulgl$kml$1@Mercury.mcs.net>,
les@MCS.COM (Leslie Mikesell) wrote:
>
> In article <6luihn$vak$1@nnrp1.dejanews.com>, <birgitt@my-dejanews.com>
wrote:
> >In article <RJcg1.111$Fr5.1316181@cam-news-reader1.bbnplanet.com>,
>
> >> For RMS, it's clearly a moral issue. He considers himself a vanguard of
> >> the free software movement, and insists on using free software as much as
> >> feasible. When he needs software for a task and can't find a free version,
> >> he writes it himself or encourages others to do so.
> >>
> >
> >And why are these FSF style free manuals not written then ? Not a
> >money issue ? Are all documentation writers going to be martyrs
> >for the FSF ? Or are they allowed to be modestly recompensated
> >for their work.
>
> With free software/documention, things don't exist until someone wants
> to do it for free or manages to obtain funding by other-than-normal
> means. There is nothing wrong with maintaining a list of things that
> are desired/needed. You just have to realize that they may never be
> done and unlike the normal customer/vendor relationship the number
> of people who need something has absolutely no influence on whether
> it will be done.
>
Certainly nothing is wrong with maintaining the list.
I respect and admire the ideals of the FSF and the work which has been
done. I use and will only use free software and if I had the knowledge
to give something back, I wouldn't hesitate. The ideals seem just a bit too
ideal to me to survive forever economically. And other solutions like
writing books or distributing FAQs and manual with slightly other
licenses than the GPL'ed one do certainly help the free software community
as much as the pure GPL'ed documents. What I don't understand how
this issue can divide the community so much and the underlying motivation
to make this issue overly important.
I just don't like the argument that people who write books of
the quality O'Reilly publishes them, are criticized of not helping
the good cause.
And just imagine, if there were another real free (FSF style)
manual available, how many newbie questions you would get and
(and get upset about), asking: "Can you tell me which manual
to use, which one is better ?" I know how much you all like
that 8-).
There are already too many bad books out there,
and enough good manuals and documentation and a few very
good books. Why don't you guys make peace and kiss. 8-).
Birgitt Funk
make such a difference
that an endless discussion is necessary. I am just marveling
about the motivation behind all this.
> Les Mikesell
> les@mcs.com
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Sat, 13 Jun 1998 21:08:37 -0400
From: David Wasserstrum <zeos@gti.com>
Subject: Missing cgi-lib.pl for Win32 Perl
Message-Id: <35832295.292F3CD2@gti.com>
Is it just me or did perl forget to include that nice standard
cgi-lib.pl file with there windows version of Perl???
------------------------------
Date: 14 Jun 1998 00:11:08 GMT
From: Martin Schwartz <schwartz@cs.tu-berlin.de>
Subject: Re: New module/pragma "enum.pm" (was "fields.pm")
Message-Id: <6lv4es$mk5$1@news.cs.tu-berlin.de>
Hi Broc,
>> Speaking of which, anyone know an efficient way to see if a number
>> is a power of 2 without needing a lookup table?
> Probably not the "most" efficient, but is readable and may do the job
> depending on your application.
A little bit faster runs:
sub is_power_of_2 {
!($_[0] & ($_[0]-1));
}
--
// Le degre zero de l'ecriture? Zero probleme!
------------------------------
Date: 13 Jun 1998 20:46:28 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: new to this - simple if statement question
Message-Id: <6lv6h4$lne$1@monet.op.net>
In article <6luojs$7ut$1@news.ncal.verio.com>,
Greg Andrews <gerg@shell.> wrote:
>Most of the respondents also seem to have overlooked that the
>strings being compared against are barewords instead of being
>quoted.
>
>...Or did I overlook that that's not a problem?
It's only a problem if there's a function named `California'.
Even if there *is* a function named `California', it might not be a
problem. The declaration
use constant California => 90210;
creates such a function.
------------------------------
Date: Sat, 13 Jun 1998 23:10:35 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Perl editor debugger
Message-Id: <6lv0ta$hco$1@nnrp1.dejanews.com>
In article <6lufel$17me@r02n01.cac.psu.edu>,
<p-lanphier@psu.edu> wrote:
>
> What would you say is the best Perl editor/debugger available is
> commercially or free for Windows NT?
>
> Patrick Lanphier
> Applied Research Laboratory
> The Pennsylvania State University
>
>
Vim is great (if you know vi). Check out www.vim.org. It has color syntaxing
for numerous languages (including Perl) as well, but this is a whole other
religious war.
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Sat, 13 Jun 1998 16:25:50 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Colin Chaplin <Colin@ScoutBase.org.uk>
Subject: Re: Perl POP Email program
Message-Id: <35830A7E.CB1719C3@sirius.com>
Colin Chaplin wrote:
>
> Hi All,
>
> What I've been looking for is a perl program that can manipulate a POP
> mailbox. Reason for this is so I can modify it so that it reads a mailbox
> that only bounces will be going to, extracts the addresses then does stuff
> with it.
>
> I am competent enough in perl to do the vanilla stuff, but if anybody know
> of a source of a perl pop email client, I'd be delighted to hear about it
>
Get the Pop3Client module. The command "perldoc Pop3Client" will give
you instructions if you already have the module.
-- Jim Bowlin
------------------------------
Date: Sat, 13 Jun 1998 16:59:34 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Tim Bunce Tim Bunce <Tim.Bunce@ig.co.uk>
Subject: Re: Puzzle challenge (clarified)
Message-Id: <35831266.BD8F3C70@sirius.com>
Tim Bunce Tim Bunce wrote:
>
> [Here's a (hopefully) clarified restatement of the puzzle]
>
> A list of names in a specific order is given to a set of messengers
> in a remote land.
>
> The messengers travel independently to a destination were they
> give the names to you.
>
> The problem is that the messengers tend to be forgetful:
> They _often_ miss out one or more names (but not all).
> They _occasionally_ get the order wrong.
> (The only significance is that _most_ of the messages will have the
> right ordering of names.)
>
> Names are never repeated or changed, only missed or reordered. You
> don't know how long the original list of names was and it's possible
> that all the correctly ordered messages are missing one or more names.
> (The messengers always think they've got it right.)
>
> For example:
>
> Original list: foo bar baz boo
>
> Messenger A says: foo bar boo # bar missing
> Messenger B says: bar boo baz # reordered
> Messenger C says: foo bar baz boo # complete
> Messenger D says: boo foo bar baz # reordered
> Messenger E says: bar # foo baz boo missing
> Messenger F says: foo baz boo # bar missing
> Messenger G says: foo bar baz # boo missing
> Messenger H says: baz boo # foo bar missing
> Messenger I says: bar boo # foo baz missing
>
> The problem is to try find the full list of names and the original order
> as far as is possible.
>
> Suggestion (feel free to take another approach):
>
> 1. Separate the messages into groups which have the same name order.
> Messages which are subsets of others with different orders
> can be assigned to more than one group. (e.g. All but B & D in
> one group, B & E in another, and D & E in another.)
>
> 2. Discard all but the largest group (which has the highest
> probability of matching the original message.)
>
> 3. Merge the ordered lists to reconstitute the original list.
> (As far as possible with the available information. Note that
> it's not possible to be certain that the answer is complete.)
>
> A solution implemented in perl would be ideal. Obviously steps 1 and 3
> above are the interesting aspects of a perl implementation.
> (I'd be interested in seeing implementations of either in isolation.)
>
> Sorry, no prizes. Just the fun of the challenge and a thank you
> (and maybe an explanation of the application domain).
Here is a totally brute force approach. It takes every possible permuation
of all the words and scores each message against each permuation. I believe
this will give the best answer in all circumstances, but if the number of
words is greater than about five, it can take a very very long time to run.
The run time scales (I think) as WORDS! * MESSAGES.
I would like to see a faster solution that provides the same result.
--- Jim Bowlin
use strict;
my ($exact_cost, $miss_cost, $perm_cost ) = (0, 10, 100);
my @msg = (
[qw/foo bar boo/],
[qw/bar boo baz/],
[qw/foo bar baz boo/],
[qw/boo foo bar baz/],
[qw/foo bar baz/],
[qw/foo baz boo/],
);
my @str = map {"@$_"} @msg; #--- convert lists to strings
my (%word, %cost);
foreach( map {@$_} @msg) { $word{$_}++ } #--- get all words
#----- find the cost of every permuation of these words
foreach my $perm (permute(keys %word)) {
my %hash = map {$_, 1} submute(split / /, $perm);
foreach (@str) {
$cost{$perm} +=
$_ eq $perm ? $exact_cost :
$hash{$_} ? $miss_cost : $perm_cost;
}
}
#----- print out results
my $cnt = 5;
print "top $cnt guesses\n";
foreach (sort {$cost{$a} <=> $cost{$b}} keys %cost) {
last if $cnt-- <= 0;
print "$_ $cost{$_}\n";
}
#--- returns strings containing all permutations of args
#--- (a, b, c) => ("a b c", "a c b", "b a c", "b c a", "c a b", "c b a")
sub permute {
@_ == 1 and return @_;
my @out;
for( my $i = 0; $i < @_; $i++) {
my @a = @_;
my $first = splice(@a, $i, 1);
push @out, map "$first $_", permute(@a);
}
@out;
}
#--- returns strings containing words of args in the same order but
#--- with all possible dropped words. (a, b, c, d) =>
#--- ("a b c", "a b d", "a c d", "b c d", "a b", "a c" "a d", ...)
sub submute {
my @out;
for( my $i = 0; $i < @_; $i++) {
my @a = @_;
splice(@a, $i, 1);
push @out, "@a";
@a > 2 and push @out, submute(@a);
}
@out;
}
------------------------------
Date: 14 Jun 1998 00:39:18 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Puzzle challenge (clarified)
Message-Id: <6lv63m$gt5$1@news.NERO.NET>
In article <EuHuH2.28D@ig.co.uk>,
Tim Bunce) (Tim Bunce <Tim.Bunce@ig.co.uk> wrote:
> They _often_ miss out one or more names (but not all).
> They _occasionally_ get the order wrong.
If you give the right commands to the messengers and they do the wrong
thing, it is their fault. If you give them the wrong commands, ...
What does this problem have to do with perl? Which perl operator is
failing to function as you think it should?
Why does it seems that there has been an explosion in off-topic threads
and flames started by those who really want a new group because this
one is too noisy, since the RFD's for the new group have been appearing?
------------------------------
Date: Sun, 14 Jun 1998 00:15:31 GMT
From: info@insyte.com
Subject: Read the last record in a file
Message-Id: <6lv4n2$mu3$1@nnrp1.dejanews.com>
Neophyte question.
There must be an easy way to do this and I haven't found it yet. I have a flat
file consisting of a number of variable length, CSV, records terminating in
"\n". I have used the following sequence:
open (FILE, <"filename");
seek (FILE, 0, 2);
to get to the EOF. But because I don't know the length of any individual
record I can't simply position it using "seek (FILE, -rec_lenght, 2). Thus
far the only way I have come up with is to loop backward one character at a
time until I find the "\n" at the end of the penultimate record and then read
the data forward from there.
Isn't there a simple way to "back up" one record?
John Steele
jsteele AT insyte DOT com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Sun, 14 Jun 1998 01:15:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Read the last record in a file
Message-Id: <Pine.GSO.3.96.980613181006.27055C-100000@user2.teleport.com>
On Sun, 14 Jun 1998 info@insyte.com wrote:
> I have a flat file consisting of a number of variable length, CSV,
> records terminating in "\n". I have used the following sequence:
>
> open (FILE, <"filename");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
> seek (FILE, 0, 2);
>
> to get to the EOF. But because I don't know the length of any individual
> record I can't simply position it using "seek (FILE, -rec_lenght, 2).
> Isn't there a simple way to "back up" one record?
Search through section five of the FAQ for the part which begins, "If you
need to seek to an arbitrary line of a file" to find some information on
working with a line-oriented file. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 13 Jun 1998 21:53:24 -0400
From: "Brent Verner" <REPLY_TO_damonbrent@earthlink.net>
Subject: Re: Read the last record in a file
Message-Id: <6lvaeb$hjq$1@argentina.it.earthlink.net>
info@insyte.com wrote in message <6lv4n2$mu3$1@nnrp1.dejanews.com>...
>Neophyte question.
>
>There must be an easy way to do this and I haven't found it yet. I have a
flat
>file consisting of a number of variable length, CSV, records terminating in
>"\n". I have used the following sequence:
>
> open (FILE, <"filename");
> seek (FILE, 0, 2);
>
>to get to the EOF. But because I don't know the length of any individual
>record I can't simply position it using "seek (FILE, -rec_lenght, 2). Thus
>far the only way I have come up with is to loop backward one character at a
>time until I find the "\n" at the end of the penultimate record and then
read
>the data forward from there.
>
>Isn't there a simple way to "back up" one record?
I'm not sure i understand your FILE, but ...
open (FILE, "<$filename");
@array_name = <FILE>;
close (FILE);
$array_name[$#array_name]; ## yields last line of @array_name
$array_name[$#array_name -1]; ## yields next to last line of @array_name
basically, $#array_name is the number of lines in @array_name.
you access an individual line of @ by using $array_name[n] where n is the
position of the line you want.
{I'm relatively new at Perl, so my advice may be all wrong.}
perhaps the best set of references available::
http://agora.leeds.ac.uk/Perl/start.html - very basic Perl
http://www-cgi.cs.cmu.edu/cgi-bin/perl-man - in depth Perl 4
http://www.perl.com/CPAN-local/doc/manual/html/pod/index.html - in depth
Perl 5
>
>John Steele
>jsteele AT insyte DOT com
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Sat, 13 Jun 1998 19:05:36 -0400
From: Andrew Pimlott <pimlott@MATH.HARVARD.EDU>
Subject: Re: Return values of comparison operators
Message-Id: <Pine.SOL.3.91.980613185810.29671A-100000@abel>
On Sat, 13 Jun 1998, Tom Phoenix wrote:
> On 13 Jun 1998, Andrew Pimlott wrote:
>
> > I just read that in Icon you can do something like
> >
> > if (0 < x < 10)
> >
> > because < returns it's right operand.
>
> So, what does it do when you write something like this and x is zero?
>
> if (-10 < x < 10)
>
> Maybe 0 is a true value in Icon, but it's sure not in Perl! :-)
Right. I suppose the "0 but true" trick doesn't have a place in a core
operator...
Thanks,
Andrew
------------------------------
Date: 13 Jun 1998 20:40:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6lv65e$lmi$1@monet.op.net>
In article <6luu8f$p9f$1@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>I wish I understood why no one understands this.
I don't understand why you don't understand, since just last week you
submitted a huge patch to the man pages that corrected many instances
of `list' used where it should have said `array' or vice versa.
The Camel is similarly muddled.
------------------------------
Date: 14 Jun 1998 00:44:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6lv6dv$7rh$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
mjd@op.net (Mark-Jason Dominus) writes:
:
:In article <6luu8f$p9f$1@csnews.cs.colorado.edu>,
:I don't understand why you don't understand, since just last week you
:submitted a huge patch to the man pages that corrected many instances
:of `list' used where it should have said `array' or vice versa.
I've been explaining it for quite some time now, but haven't had a
change to fix documentation since shortly after the Camel came up.
It's still something that I feel that barely a dozen people understand,
and it's quite basic.
Maybe it's tied up in the whole notion of context.
:The Camel is similarly muddled.
I did notice one faux mot. If you'd like to submit patches,
this would be welcome. :-)
--tom
--
I think I can sum up the difference between *BSD and Linux as follows:
"In Linux, new users get flamed for asking questions in the newsgroups
(or heaven forfend, the wrong newsgroup). In *BSD the principals
flame each other." --Warner Losh
------------------------------
Date: 13 Jun 1998 21:50:03 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6lva8b$lrr$1@monet.op.net>
In article <35829de6.5684792@news.btinternet.com>,
Jonathan Stowe <Gellyfish@btinternet.com> wrote:
>Given the stated enterprise of this book and other similar ones I am
>surprised that they dont ever advocate the use of the available CGI
>libraries. But there you go.
Maybe they're written by people with no experience.
------------------------------
Date: Sat, 13 Jun 1998 19:40:34 -0500
From: "Matthew Wagley" <rudedog@gcnet.com>
Subject: Writing to a file??
Message-Id: <6lv66g$cci$1@opal.southwind.net>
I am going to write a script that allows someone to click something and it
writes the information to a file. What happens if two or three different
individual click the item at the same time?? Will it write the information
ok to the file??? Can it cgi handle the multiple hits and write to the same
file ok??
thanks.
------------------------------
Date: Sun, 14 Jun 1998 01:18:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Writing to a file??
Message-Id: <Pine.GSO.3.96.980613181730.27055E-100000@user2.teleport.com>
On Sat, 13 Jun 1998, Matthew Wagley wrote:
> I am going to write a script that allows someone to click something and
> it writes the information to a file. What happens if two or three
> different individual click the item at the same time??
Sounds as if you're writing a CGI script. I think you could use the
methods in Randal's fourth Web Techniques column, which explains how to
use flock() to avoid problems when multiple processes need to modify one
file. Hope this helps!
http://www.stonehenge.com/merlyn/WebTechniques/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 2868
**************************************