[18822] in Perl-Users-Digest
Perl-Users Digest, Issue: 990 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 26 00:06:01 2001
Date: Fri, 25 May 2001 21:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990849907-v10-i990@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 25 May 2001 Volume: 10 Number: 990
Today's topics:
Re: "Alan J. Flavell" wrote: <rebelvideo@hotmail.com>
ANNOUNCE: Inline::Files 0.60 (Damian Conway)
Re: Array slice: how about the remainder? <inieto@huemul.decom.uta.cl>
Dummies guide to OLE <justin.devanandan.allegakoen@intel.com>
Re: find executable files only (David Efflandt)
Re: hash array (Mark Jason Dominus)
Re: How do I use client text file for cgi script? <goldbb2@earthlink.net>
Re: I don't want global variables ? <ren@tivoli.com>
Re: I don't want global variables ? <ren@tivoli.com>
Re: Match Parsing Glitch (Eric Bohlman)
Re: parsing perl again (Damian Conway)
Perl syntax for multilevel hash (James Weisberg)
Re: Problem with scalar variables (Scott DiNitto)
Re: Problem with scalar variables <bart.lateur@skynet.be>
Re: Question on the "use strict" pragma <comdog@panix.com>
Re: random numbers <goldbb2@earthlink.net>
Re: random numbers <godzilla@stomp.stomp.tokyo>
Re: SCAN <godzilla@stomp.stomp.tokyo>
Re: SCAN (David Efflandt)
Scrubbing path and fragment from url (Craig Berry)
Re: setting priority from perl on linux <dball@bnb-lp.com>
Re: setting priority from perl on linux <dball@bnb-lp.com>
wml content type error with CGI <danparker276@yahoo.com>
Re: wwwboard.pl - Taint and Use Strict <trondmm-usenet@crusaders.no>
Re: wwwboard.pl - Taint and Use Strict <godzilla@stomp.stomp.tokyo>
Re: wwwboard.pl - Taint and Use Strict <buggs@geekmail.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 26 May 2001 11:41:39 +0930
From: Chris <rebelvideo@hotmail.com>
Subject: Re: "Alan J. Flavell" wrote:
Message-Id: <3B0F10DB.B26AC8C3@hotmail.com>
Hi Bart
Yes I know but as I said I had one very bad experience with a US server
and I like the thought that if something goes wrong, I can drive down to
my ISP and get in his face about it.
When my US server went offline I called them every day, and never got
past a "we are looking into it"
after two weeks I gave up and went to another ISP
Prior to the problem I had been getting excellent service, so how can
you tell?
If your companies server went down for some unexplained reason what
would they do ??
Thanks for the input.
Chris
Bart Lateur wrote:
>
> Chris wrote:
>
> >BUT I am in Australia, to find a suitable ISP is almost impossible as
> >most charge a commercial operation like mine for data at 18 -20c PER
> >MEGABYTE
>
> We are in Europe.
>
> The company I work for, rents a server in the USA. We can do whatever we
> want with it.
>
> Country borders are virtually meaningless.
>
> --
> Bart.
--
Regards
Chris
rebelvideo@hotmail.com
------------------------------
Date: 25 May 2001 22:19:45 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Inline::Files 0.60
Message-Id: <9emlq1$3rj$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release
==============================================================================
Release of version 0.60 of Inline::Files
==============================================================================
NAME
Inline::File - Multiple virtual files at the end of your code
SYNOPSIS
use Inline::Files;
my Code $here;
while (<FOO>) { print }
# etc.
__FOO__
This is a virtual file at the end
of the data
__BAR__
This is another
virtual
file
__FOO__
This is yet another
such file
DESCRIPTION
Inline::Files generalizes the notion of the `__DATA__' marker and the
associated `<DATA>' filehandle, to an arbitrary number of markers and
associated filehandles.
When you add the line:
use Inline::Files;
to a source file you can then specify an arbitrary number of
distinct virtual files at the end of the code.
AUTHOR
Damian Conway (damian@conway.org)
==============================================================================
AVAILABILITY
Inline::Files has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Inline-Files.tar.gz
==============================================================================
------------------------------
Date: Fri, 25 May 2001 20:27:12 -0400
From: Mister Satan <inieto@huemul.decom.uta.cl>
Subject: Re: Array slice: how about the remainder?
Message-Id: <Pine.OSF.3.96.1010525201214.1624D-100000@huemul.decom.uta.cl>
How about this:
# assuming @chosen is sorted
my @not_chosen = (
0 .. $chosen[0]-1,
map( {$chosen[$_-1]+1 .. $chosen[$_]-1} 1..$#chosen ),
$chosen[$#chosen]+1 .. $#array
);
my @stay_home = @array[@not_chosen];
--
map{print}map{(split//,'Jorlust hackPen')[$_]}map{$_%15}map{($A+=$_)++}
map{int}map{$_/2}map{$_*3}map{$_%4}map{$B+=$_}map{$_+!(++$C%12)}
map{$_-2?$_:(2,2)}map{$_%=3}map{$_-$D++}map{$_-1?$_:(2,1)}map{$_%=3}
map{$_-$E++}map{$_-2?$_:(2,1)}map{$_%3}map{$_-$F++}map{$_-1?(0,$_):(1,0)}
map{split//}map{$_-64}map{ord}split//,'TUK'
------------------------------
Date: Sat, 26 May 2001 11:49:55 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Dummies guide to OLE
Message-Id: <9en95a$esf@news.or.intel.com>
I happened to come accross Dave Roth's
excellent graph.pl, and I would like to
tailor it for my needs.
Unfortunately I'm not making much sense
out of the Powerpoint presentation that it
came from, and I havent the slightest
with regards to the OLEVIEW.exe.
Futhermore Microsoft's help files
arent telling me how I can add a y2
axis where the points are plotted
as Line type (one of the things
that I'm aiming for).
Has some kind soul written anything on
the above in lay mans terms? Like - this
is Peter, this is Jane, hello Peter, hello Jane.
Thanks and regards
------------------------------
Date: Fri, 25 May 2001 23:04:28 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: find executable files only
Message-Id: <slrn9gtp7r.2ao.see-sig@typhoon.xnet.com>
On Fri, 25 May 2001 04:34:23 GMT, Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "DE" == David Efflandt <see-sig@from.invalid> writes:
>
> DE> On Thu, 24 May 2001 16:34:06 -0400, Claudio Inglesi <cinglesi@puc.cl> wrote:
> >> Does anyone know how to use the find command so that it only finds files
> >> that are executable (files whose permissions are set as executable for the
> >> user, group or everybody).
> DE> $file = $File::Find::name;
> DE> $mode = (stat($_))[2];
> DE> $mode = sprintf "%lo",$mode; # convert to octal
> DE> if ($mode =~ /^(\d)\d\d(\d)(\d)(\d)/) {
> DE> return 0 unless $1 == 1; # file?
> DE> $owner = $2; $group = $3; $other = $4;
> DE> return 0 unless ($owner & 1 || $group & 1 || $other & 1);
> DE> } else { print "regex problem for $file $mode"; return 0; }
> DE> print "$file $owner$group$other\n";
>
> ever heard of -x?
Yes, but that only reports if the effective uid has execute permission and
that was not the question. The question was whether _ANY_ owner, group or
other has execute permission.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 26 May 2001 00:55:04 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: hash array
Message-Id: <3b0efed9.28c6$312@news.op.net>
In article <ndAP6.70962$I5.15872424@news1.rdc1.tn.home.com>,
Todd Smith <todd@designsouth.net> wrote:
>How do you ask a hash how big it used to be?
Devel::Peek, perhaps.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Fri, 25 May 2001 21:50:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How do I use client text file for cgi script?
Message-Id: <3B0F0BDC.51B5692@earthlink.net>
Sean Ressler wrote:
>
> I recently wrote a Perl script that transforms a text file to an HTML
> document. I would like to allow my users to call the script via web
> browser (cgi) and supply the text file from their local machine.
You can't make the CGI pull the file from the client.
You can however make the client send the file as part of the form data.
> The script runs from the command line by issuing the command:
> "<scriptname> <path/text filename>" without quotes.
>
> How do I supply / determine the <path/text filename> to the script
> that resides on the server?
Your <FORM> tag must have METHOD=POST and ENCODING=multipart/form-data
parameters. You then need to include an <NPUT> tag with TYPE=FILE.
Creating the HTML is the easy part. Creating the CGI is a bit harder.
If you are using the CGI.pm module, you can simply do
my $filename = $cgi->param("uploaded_file");
This will give you the name of the temporary file which was created to
hold the data the client sent.
Now you can simply call
system "<scriptname>", $filename;
If the script sends it's output to a file, you'll have to read the file
and send it to the browser. If the script sends it's output to its
stdout, then all you need is to put
print $cgi->header;
on the line before the system call.
Oh, and you should of course check that $filename is not empty before
you call system, and you should check the return value of system,
looking in $! and $? as necessary. If the script is the last thing you
call in your program, and you've tested once or twice that it works
right, you might change the call from system(...) to:
exec "<scriptname>", $filename;
die "exec failed for <scriptname>: $!";
--
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."
------------------------------
Date: 25 May 2001 17:01:13 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: I don't want global variables ?
Message-Id: <m3vgmp84wm.fsf@dhcp9-172.support.tivoli.com>
On Fri, 25 May 2001, uri@sysarch.com wrote:
>>>>>> "A" == Abigail <abigail@foad.org> writes:
>
> A> Nah. If "{}" introduces scope, variables can appear in
> A> enclosing scopes too.
>
>
> A> #!/opt/perl/bin/perl -l
> A> use strict;
>
> A> {
> A> ;+
> A> {
> A> my $foo = "Gotcha"
> A> , my $bar = "Really!"
> A> }
>
> A> ; # Enclosing scope.
> A> ; print $foo
>
> A> }
> A> __END__
> A> Gotcha
>
> try putting a my $baz before or after the inner {}. then strict will
> barf about the print $foo.
The inner {} is a hash ref. Putting something before or after it
breaks the expression, thus the error.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 25 May 2001 17:04:35 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: I don't want global variables ?
Message-Id: <m3r8xd84r0.fsf@dhcp9-172.support.tivoli.com>
On Fri, 25 May 2001, mjcarman@home.com wrote:
> Kevin Hancock wrote:
>> [H]ow do I prevent %in from being accesable to lower
>> procedures unless passed explicitely in to the procedure?
>
> You could move test() into a seperate module.
Alternatively, you could simply place test() before the my declaration
of %in. The scope of a lexical is from the my declaration to the end
of the block, so anything in the block but before the declaration will
not have access to the lexical.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 25 May 2001 22:42:04 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Match Parsing Glitch
Message-Id: <9emn3s$7kr$2@bob.news.rcn.net>
Eric <nospam@xx.com> wrote:
> Abe Timmerman wrote:
>> [ please do _not_ send stealth CC's ]
> What's a "stealth CC" ???
That's when you send someone an e-mail copy ("CC") of a post, but you
don't give any indication in the e-mail copy that it was also posted.
It's considered annoying because most people check their e-mail before
reading news, and more frequently than they read news, so if they see a
reply that doesn't indicate it was also posted, they're likely to compose
a private reply that doesn't go to the group. Then, when they read news,
they discover that they should have posted to the group instead.
------------------------------
Date: 25 May 2001 23:06:08 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: parsing perl again
Message-Id: <9emoh0$4u9$1@towncrier.cc.monash.edu.au>
Chris Stith <mischief@velma.motion.net> writes:
>>>Will the new version of RecDescent implement Perl6, Solve the Halting
>>>Problem, or be self-aware?
>> It will, of course, be a superposition all of three. Unfortunately, the
>> Uncertainty Principle will mean that when you use the module you'll only
>> get one of those capacities (at random) at any one time.
>But once the thing is self-aware, can it spawn a copy of itself in
>another process to implement Perl 6? Of course, cloning a sentient
>being for so little gain may be an ethical dilemma for it.
Curiously, I have a talk at TPC5 that is relevant to this increasingly
silly thread:
http://conferences.oreillynet.com/cs/os2001/view/e_sess/1512
You have been warned.
Damian
------------------------------
Date: Fri, 25 May 2001 22:22:53 GMT
From: chadbour@wwa.com (James Weisberg)
Subject: Perl syntax for multilevel hash
Message-Id: <1XAP6.6585$DW1.294416@iad-read.news.verio.net>
I have a syntax question. This might not be possible, but that's why I'm
asking. Let's say I have a function which orders three vars - $x,$y,$z -
and I want those vars to be keys to a multilevel hash. I could do:
1. my($a, $b, $c) = order();
2. $hash{$a}{$b}{$c}++;
sub order {
# fill x,y,z based on some ordering scheme
...
return($x, $y, $z);
}
and this would count for me how often the triplet ($a,$b,$c) appears
in the hash. What I'm wondering is simply if there is a syntactical way
to combine lines 1 and 2 into one statement. Something like:
$hash{ => }{ => }{ => } = order();
would be nice.
--
World's Greatest Living Poster
------------------------------
Date: Fri, 25 May 2001 23:22:26 GMT
From: usenet@infracore.dyndns.org (Scott DiNitto)
Subject: Re: Problem with scalar variables
Message-Id: <3b0ee73b.66338279@news-server.san.rr.com>
Sorry, I didn't read the whole thing. It was 4am and I read the
message after many drinks at the bar! The first line is all I guess I
got through "It will break it...". Now after reading the whole thing
it makes sense. (hungover too!). New rule: UseNet and Gin/tonics don't
mix.
My apologies uri,
SD
>Ever heard of the Guttman Rosler Transform? Ever wonder which
>Guttman that was? (The other name comes from Larry Rosler, BTW).
>
>Do a search on "Uri Guttman" on the web, or, better yet, search
>for "Guttman" on http://www.perl.com and see who produces results.
>
>Chris
>
>--
>You must not lose faith in humanity. Humanity is an ocean;
>if a few drops of the ocean are dirty, the ocean does not
>become dirty. -- Mohandas K. Gandhi
>
------------------------------
Date: Fri, 25 May 2001 23:50:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Problem with scalar variables
Message-Id: <uortgt4olip2f94m42md1rrgj2c9dglmqo@4ax.com>
Mark Patton wrote:
>Thank you kindly for the guidance. Obviously spoon feeding is preferable
>for babies, but I appreciate being pointed in the right direction to
>start looking. (I'd only reached page 4 of perlref but I wasn't aware
>the answer to my problem was in there).
So, in order to avoid the "XY" problem... what exactly is it what you
want to solve?
A possible solution to the "Y" is:
$variable = 3;
$array[$variable][1] = "second item";
$array[$variable][0] = "first item";
print @{$array[$variable]};
(Array items can only be scalars. A reference is a scalar. Thus, an
array can contain array references.)
So, what's the "X"?
--
Bart.
------------------------------
Date: Fri, 25 May 2001 20:43:25 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Question on the "use strict" pragma
Message-Id: <comdog-AB6A50.20432525052001@news.panix.com>
In article <3b0e8bc4.1e5b$3d9@news.op.net>, mjd@plover.com (Mark Jason
Dominus) wrote:
> In article <3b0dadee$1@news.iprimus.com.au>,
> Andrew Hamm <ahamm.NO$PAM@sanderson.NO$PAM.net.au> wrote:
> >Leo wrote in message <9ek8l3$58n$1@plutonium.btinternet.com>...
> >>1. Does adding use strict to my program slow it's execution down in any
> >way?
> >It's an instruction to the compiler. It may affect the speed of the initial
> >compilation (can't say whether it slows it down or actually speeds it up)
> >but it shouldn't have ANY affect at runtime. Not that I can think of.
> I don't understand why people keep saying this, since "strict refs" is
> obviously a run-time check.
perhaps because so few people run into trouble with symbolic
references. :)
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Fri, 25 May 2001 23:14:38 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: random numbers
Message-Id: <3B0F1F9E.654ACAEE@earthlink.net>
Garry Williams wrote:
>
> On Mon, 07 May 2001 21:35:05 GMT, Bart Lateur <bart.lateur@skynet.be>
> wrote:
> > sas wrote:
> >
> >> It must be a 5 digit random number which will be associated with a
> >> specific name, (an "ID" number), I want to check against a log file
> >> to be sure the number hasn't been used already and then add the
> >> number and associated name to that log file.
> >
> > Once you get over 100000 visitors, you'll be in trouble.
>
> Actually the trouble will creep up before then. :-)
Yes, since new random numbers will be increasingly likely to collide
with an id already in the file, so finding a number which hasn't been
used will take longer and longer and longer, and will evenutally hang
(loop forever) when trying to find an id for the 100000th person.
There are other [better] ways to do it.
All of these methods assume that you are not *just* adding ids to the
file, but are deleting ids on occasion. If you never delete, that makes
a difference.
Method one is to loop through all the ids. This can be quite slow,
since you search through ids you searched through before:
for( 0..99_999 ) { return $_ if unused $_; }
return undef;
Method two is to keep track of the last id you gave out, and increment
it until you find an unused id.
$last_id_given = restore_from_file;
for( 1..100_000 ) {
if( unused( $last_id_given ) ) {
store_to_file $last_id_given;
return $last_id_given;
} else {
$last_id_given = $last_id_given + 1 % 100_000;
}
}
return undef;
The first 100000 new ids gotten will take very little time. After that,
performance degrades slightly, due to skipping blocks of used ids. It
has the property that new ids are usually sequential, which may be
undesirable. (Why else would you be asking for random numbers?)
Method three is to choose a random number 0..99999, and if the id is
unused, return that, otherwise increment until you find an unused id.
This will give a more randomish distribution, but new ids will be biased
to occur following blocks of ids.
$new_id = int rand 100_000;
for( 1..100_000 ) {
if( unused( $new_id ) ) {
return $new_id;
} else {
$new_id = $new_id + 1 % 100_000;
}
}
return undef;
After the first 100_000 ids are given out, this should not be any
significantly worse than the first method, *and* it will have the
advantage of not having to store the last id given.
Method four is to generate a random permutation of all the numbers in
the range 0..99999, and use and delete one for each new user. Something
like:
@ids = restore_from_file;
for( 1..100_000 ) {
if( !@ids ) {
@ids = shuffle( 0 .. 99_999 );
$_ = 1;
}
if( unused( $new_id = pop ) ) {
write_to_file @ids;
return $last_id_given;
}
}
return undef;
This gives a good distribution, but has the overhead of having to store
a huge permutation -- 100_000 elements.
Method five is to replace the array with some sort of shuffler like I
described in my message on May 22, 2001 in the thread "non repeating
random numbers"
For a permutation of 100_000 elements, it would take up 4 arrays size
317, or 1268 array items (plus one scalar index). Assuming the code was
rewritten to be an object-oriented module, using it might look like:
$permutation = restore_from_file;
for( 1..100_000 ) {
if( !defined $new_id = $permutation->next ) {
$permutation = Permutation->new(0,99_999);
$new_id = $permutation->next;
}
if( unused( $new_id ) ) {
write_to_file $permutation;
return $new_id;
}
}
return undef;
This will run slightly slower than the permutation using a shuffled
array, but it will have *significantly* less overhead on disk.
Here's a sixth method:
@ids = grep { unused $_ } 0 .. 99_999;
return $ids[ int rand @ids ];
This is slower than *any* of the above, but it both gives a good
distribution, and doesn't require anything special stored to disk.
Plus it's very simple.
Here's a seventh, which uses less memory than the above:
$new_id = undef; $x = 1;
for( 0..99_999 ) {
$new_id = $_ if( unused($_) && (rand < 1/$x++) );
}
return $new_id;
Would anyone like to suggest any other algorithms?
--
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."
------------------------------
Date: Fri, 25 May 2001 20:27:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: random numbers
Message-Id: <3B0F2295.33884AC3@stomp.stomp.tokyo>
Benjamin Goldberg wrote:
> Garry Williams wrote:
> > Bart Lateur wrote:
> > > sas wrote:
(snipped lots of codes all of which take forever to run)
> Would anyone like to suggest any other algorithms?
Yes.
use Time::Local;
$id_number = timelocal (localtime()); sleep (1);
Godzilla!
------------------------------
Date: Fri, 25 May 2001 16:16:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: SCAN
Message-Id: <3B0EE7C8.9B55B74@stomp.stomp.tokyo>
karthy muthiah kasi wrote:
> After opening a file, is there a way that I can scan the next two lines
> without having to move the read cursor? The problem I am encountering is
> that after invoking <FILENAME>, the next line of the file is read and I am
> unable to read a previous line.
You have failed to state clear and concise parameters.
This is very illogical. No one person can provide you
with an answer without having to make a guess as to
what code you are using.
In lieu of any parameters stated by you, a presumption
is made you are referencing a while loop construct.
There is an easy work around for this problem. Although
easy, there will be bugs created if you are not more
careful than you are about not providing parameters.
My test script following my signature exemplifies one
method of many to deal with this. My code does nothing
more than temporarily store three variables per your
asked question. I have included some if conditionals
to show how you can control a while loop per certain
established criteria.
You will note there are inherent bugs, though not truly
bugs. You ask for two lines beyond the first line. This
method of mine works fine for files with an even number
of lines. However, a file with an odd number of lines
will cause it to crash and burn; not print correctly.
Another "bug" is exemplified with a line only consisting
of a newline \n character.
My test.txt for my first printed results contains:
line1
line2
line3
line4
line5
line6
with no newline \n after line 6.
My second printed results are produced when line 6
is removed in its entirety.
Third printed results occur when line 6 is only \n.
My intent is to provide one method of many how to
work with a while loop and, to provide a bit of a
warning about a couple of things which may go wrong
so you will know to program carefully and, to give
your database careful consideration.
Godzilla!
--
#!perl
open (FILEHANDLE, "test.txt");
while (<FILEHANDLE>)
{
$one = $_;
$two = <FILEHANDLE>;
$three = <FILEHANDLE>;
if (!($three))
{ print "\n\nEncountered End Of File Before Complete."; last; }
if ($three eq "\n")
{ print "\n\nThree Is A Newline. Loop Exited."; last; }
print "One: $one\nTwo: $two\nThree: $three\n";
if (substr ($one, -2, 1) == substr ($two, -2, 1) - 1)
{ print "One is one less than Two\n\n"; }
if (substr ($one, -2, 1) == substr ($three, -2, 1) - 2)
{ print "One is two less than Three\n\n"; }
}
close (FILEHANDLE);
exit;
PRINTED RESULTS WITH AN EVEN NUMBER OF LINES:
_____________________________________________
One: line 1
Two: line 2
Three: line 3
One is one less than Two
One is two less than Three
One: line 4
Two: line 5
Three: line 6
One is one less than Two
One is two less than Three
PRINTED RESULTS WITH AN ODD NUMBER OF LINES:
____________________________________
One: line 1
Two: line 2
Three: line 3
One is one less than Two
One is two less than Three
Encountered End Of File Before Complete.
PRINTED RESULTS FOR LINE 6 A NEWLINE ONLY:
__________________________________________
One: line 1
Two: line 2
Three: line 3
One is one less than Two
One is two less than Three
Three Is A Newline. Loop Exited.
------------------------------
Date: Fri, 25 May 2001 23:19:12 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: SCAN
Message-Id: <slrn9gtq3g.2ao.see-sig@typhoon.xnet.com>
On Fri, 25 May 2001, karthy muthiah kasi <kasi@students.uiuc.edu> wrote:
>
> After opening a file, is there a way that I can scan the next two lines
> without having to move the read cursor? The problem I am encountering is
> that after invoking <FILENAME>, the next line of the file is read and I am
> unable to read a previous line.
Another reply gave one method if the file is not too big for memory (read
it into list or array).
For really big files you could simply save the current cursor position and
go back to it if you need to. But it is best to also flock the file if
something else might try to do something with it while it is open.
perldoc -f seek
perldoc -f tell
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 26 May 2001 00:53:42 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Scrubbing path and fragment from url
Message-Id: <tgtvkmkg6civ6e@corp.supernews.com>
I am using the URI.pm module to...well, manipulate some URIs, amazingly
enough. One trick I need to pull is to take an existing absolute URI and
strip away any query or fragment parts from the end. Here's how I'm doing
it now (code snipped from context, $res is another URI):
my $url = URI->new_abs($_->[2], $res->base);
my $path = $url->path || '/';
if ($url->scheme =~ m!^https?$! &&
$url->authority =~ m!$domain$!io &&
$path =~ m!(\.html?|/)$!i) {
push @pending, $url->scheme . '://' . $url->authority . $path;
}
Is there a better way to build the no-query-or-fragment URI I'm pushing
onto the pending list?
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: Fri, 25 May 2001 18:18:22 -0700
From: David Ball <dball@bnb-lp.com>
Subject: Re: setting priority from perl on linux
Message-Id: <9k0ugtglanv4tomomvdui065t8vshn485s@4ax.com>
On 25 May 2001 13:01:47 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>According to David Ball <dball@bnb-lp.com>:
>> On Thu, 24 May 2001 11:58:52 +0000 (UTC), abigail@foad.org (Abigail)
>> wrote:
>>
>> >David Ball (dball@bnb-lp.com) wrote on MMDCCCXXII September MCMXCIII in
>> ><URL:news:h53mgtk7tpkcr8baq78mpl8r8qpuj3hcap@4ax.com>:
>> >@@
>> >@@ Do you know of any scripts that will build an index of html pages
>> >@@ and then search it from a CGI ?
>> >
>> >
>> >Yes.
>> >
>> >
>> >Please use a web search to find such programs. Discussing of such programs
>> >(which have nothing to do with Perl) don't belong in this group, just
>> >like discussing your favourite brand of toilet paper doesn't.
>>
>> Gee, you mean discussing perl scripts doesn't belong in a perl
>> newsgroup. That's just plain stupid Abigail.
>
>Watch out whom you call stupid. It may make *you* look stupid.
*chuckle*
>Discussion of "any scripts that will build an index of html pages..."
>has nothing to do with Perl and is off topic. Not to mention that
>you didn't ask for discussion but how to find such a script. That's
>off topic as well. Use a search engine. So long.
>
>Anno
If you read the original post I made, you'll see that the remark
abigail objected to was made in response to something else in the
thread.
I've looked for scripts using search engines, but didn't find
anything suitable. The ones I found either cost too much or are too
limited.
The name of this newsgroup is "comp.lang.perl.misc"... As a usenet
admin, I don't see anything wrong with posting such a question. The
only mistake I made was expecting someone here to be helpful instead
of being a jerk.
-- David
------------------------------
Date: Fri, 25 May 2001 18:42:45 -0700
From: David Ball <dball@bnb-lp.com>
Subject: Re: setting priority from perl on linux
Message-Id: <p82ugtobv6uv34ovkeejot24slcenq6ic7@4ax.com>
On 25 May 2001 13:01:47 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>According to David Ball <dball@bnb-lp.com>:
>> On Thu, 24 May 2001 11:58:52 +0000 (UTC), abigail@foad.org (Abigail)
>> wrote:
>>
>> >David Ball (dball@bnb-lp.com) wrote on MMDCCCXXII September MCMXCIII in
>> ><URL:news:h53mgtk7tpkcr8baq78mpl8r8qpuj3hcap@4ax.com>:
>> >@@
>> >@@ Do you know of any scripts that will build an index of html pages
>> >@@ and then search it from a CGI ?
>> >
>> >
>> >Yes.
>> >
>> >
>> >Please use a web search to find such programs. Discussing of such programs
>> >(which have nothing to do with Perl) don't belong in this group, just
>> >like discussing your favourite brand of toilet paper doesn't.
>>
>> Gee, you mean discussing perl scripts doesn't belong in a perl
>> newsgroup. That's just plain stupid Abigail.
>
>Watch out whom you call stupid. It may make *you* look stupid.
Just to clarify things Anno, since it was mentioned elsewhere that
you are still learning english, I said the action was stupid. I
didn't say that Abigail was stupid.
-- David
------------------------------
Date: Fri, 25 May 2001 16:38:03 -0700
From: "Krusty" <danparker276@yahoo.com>
Subject: wml content type error with CGI
Message-Id: <T2CP6.121$df1.110312@news.pacbell.net>
I'm running a cgi, try to get WML page to come up. I get an error from the
phone browers saying it's can't support text/html content type.
The first line of my cgi is
print "Content-Type: text/vnd.wap.wml\n\n";
Anyone have any ideas what is happening? This is on a unix box
when I run this file with perl I get the first line being
Content-Type: text/vnd.wap.wml\n\n
------------------------------
Date: Fri, 25 May 2001 23:07:43 GMT
From: "Trond Michelsen" <trondmm-usenet@crusaders.no>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <3BBP6.4320$qR5.223172@news01.chello.no>
Godzilla! <godzilla@stomp.stomp.tokyo> skrev i
meldingsnyheter:3B0EC2A1.F6B01241@stomp.stomp.tokyo...
>> If you check CPAN, you'll see that many of the useful modules are
>> written by regulars in this newsgroup.
> I expected at least one person to mention modules, which
> is fair. Those who write modules do exhibit a quality
> of programming skill directly proportionate to the
> quality of their module or modules. However, modules
> are utility programs, not full featured programs.
> Nonetheless, appropriate credit is due to those
> creating modules.
>
> Snipped from my original article, my words included:
>
> "I have yet to witness any of you actually writing a
> full featured program."
>
> This is a true statement. I only know of a few, very few,
> participating here who have written full featured programs.
uhm.. do you mean "written" or "released"?
The idea that all the regulars on this group that often contribute modules
to CPAN, never ever have written a single program, seems pretty absurd to
me. You write programs to solve very specific needs, and you write modules
to solve the general cases. In many cases, a set of modules is a byproduct
of the development of a program. The modules tend to end up at CPAN, while
the program itself remains with whomever it was created for.
If wwwboard is an example of a "full featured" program, then I'm sure more
than 60% of last months posters in this group has written at least one from
scratch by themselves.
--
Trond Michelsen
------------------------------
Date: Fri, 25 May 2001 16:35:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <3B0EEC37.E7F582F3@stomp.stomp.tokyo>
Trond Michelsen wrote:
> Godzilla! wrote:
(snipped)
> Trond Michelsen
Well gosh, aren't you a brandy new Newbie here.
Do you find it odd, from a historical viewpoint,
so many, hundreds in fact, so many sudden Newbies
show up to counter my articles?
Clearly I have a magical pheromone aura about me
which draws spanking new Newbies from all over the
world like moths to a candle flame.
I am hot!!!
* listens to sounds of sizzling fingers *
Very hot.
Godzilla!
------------------------------
Date: Sat, 26 May 2001 03:31:51 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <9en11g$r8d$00$1@news.t-online.com>
Godzilla! realized:
> Clearly I have a magical pheromone aura about me
Having also the feeling that you smell.
> Godzilla!
Buggs
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 990
**************************************