[18226] in Perl-Users-Digest
Perl-Users Digest, Issue: 394 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 2 06:05:37 2001
Date: Fri, 2 Mar 2001 03:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983531111-v10-i394@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 2 Mar 2001 Volume: 10 Number: 394
Today's topics:
compile probem (URGENT) <alan.carter@flytxt.com>
Re: compile probem (URGENT) (Gwyn Judd)
Re: compile probem (URGENT) <gtoomey@usa.net>
Re: Convert dates in format "3/1/2001" to dd-Month-yy <c_clarkson@hotmail.com>
Re: Convert dates in format "3/1/2001" to dd-Month-yy (Peter J. Acklam)
flock and close with empty read strangeness <groovyt@erols.com>
Re: flock and close with empty read strangeness (Anno Siegel)
Re: Help Matt with small programs <bart.lateur@skynet.be>
HelpOnHashes?!?! <r51446@email.sps.mot.com>
Re: How do I test whether a CODE reference is an NOP? <rick.delaney@home.com>
Invalid URI in request GET (???) with Apache <awolst@lodderapplicaties.nl>
Re: Invalid URI in request GET (???) with Apache (Rafael Garcia-Suarez)
Look at browser-sent request headers with Perl program? <jbailey@cyberconnect.com>
Re: Look at browser-sent request headers with Perl prog (Wyzelli)
Re: Look at browser-sent request headers with Perl prog (Rafael Garcia-Suarez)
mod_perl and conventional perl scripts simultaniously ? (Fischer Markus)
more regex <tfiedler@zen.moldsandwich.com>
Re: more regex (Gwyn Judd)
Re: Opening STDERR for input (Ilya Zakharevich)
Re: Opening STDERR for input (Villy Kruse)
Re: Perl CGI.pm RESET problem <godzilla@stomp.stomp.tokyo>
Re: Perl CGI.pm RESET problem <joeykid6@yahoo.com>
Re: Perl CGI.pm RESET problem <joeykid6@yahoo.com>
Re: Perl CGI.pm RESET problem (BUCK NAKED1)
Re: Perl CGI.pm RESET problem <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 2 Mar 2001 09:11:03 -0000
From: "Alan Carter" <alan.carter@flytxt.com>
Subject: compile probem (URGENT)
Message-Id: <DnJn6.228$jo4.990@news.uk.colt.net>
Anyone have any ideas out there? I am getting this error when trying to
compile my perl script! I am clue-less the only thing is that I am use the
"use Socket;" in the code. Should this compile. The reason I am doing this I
because the script in question is being run about 20 times a second, and i
am trying to bring down the startup time, is there any other way I might
achive this?
Undefined first referenced
symbol in file
boot_DynaLoader /var/tmp/cc1UEeA6.o
ld: fatal: Symbol referencing errors. No output written to smsc_test
collect2: ld returned 1 exit status
------------------------------
Date: Fri, 02 Mar 2001 09:47:14 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: compile probem (URGENT)
Message-Id: <slrn99ur10.6ko.tjla@thislove.dyndns.org>
I was shocked! How could Alan Carter <alan.carter@flytxt.com>
say such a terrible thing:
>Anyone have any ideas out there? I am getting this error when trying to
>compile my perl script! I am clue-less the only thing is that I am use the
>"use Socket;" in the code. Should this compile. The reason I am doing this I
>because the script in question is being run about 20 times a second, and i
>am trying to bring down the startup time, is there any other way I might
>achive this?
Well if it's an urgent problem then by the time you get this you'll
probably already have been fired. That said I want to congratulate you
on winning this weeks "comp.lang.perl.misc's most useless problem
description" award. Thanks for enriching all of our lives like this,
please do come again (hopefully with some actual code for us to
laugh^H^H^H^Hook at).
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
For violence, like Achilles' lance, can heal the wounds it has inflicted.
-Frantz Fanos, "The Wretched of the Earth"
------------------------------
Date: Fri, 2 Mar 2001 21:04:19 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: compile probem (URGENT)
Message-Id: <JUKn6.6652$v5.24158@newsfeeds.bigpond.com>
Yup Alan - clue-less is a very good description of your start of mind.
---------------
"Gwyn Judd" <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn99ur10.6ko.tjla@thislove.dyndns.org...
> I was shocked! How could Alan Carter <alan.carter@flytxt.com>
> say such a terrible thing:
> >Anyone have any ideas out there? I am getting this error when trying to
> >compile my perl script! I am clue-less the only thing is that I am use
the
> >"use Socket;" in the code. Should this compile. The reason I am doing
this I
> >because the script in question is being run about 20 times a second, and
i
> >am trying to bring down the startup time, is there any other way I might
> >achive this?
>
> Well if it's an urgent problem then by the time you get this you'll
> probably already have been fired. That said I want to congratulate you
> on winning this weeks "comp.lang.perl.misc's most useless problem
> description" award. Thanks for enriching all of our lives like this,
> please do come again (hopefully with some actual code for us to
> laugh^H^H^H^Hook at).
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> For violence, like Achilles' lance, can heal the wounds it has inflicted.
> -Frantz Fanos, "The Wretched of the Earth"
------------------------------
Date: Fri, 2 Mar 2001 01:05:32 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Convert dates in format "3/1/2001" to dd-Month-yy
Message-Id: <84C532ED3D3B53E6.D472D7F29E88106B.BBF0761449D9570E@lp.airnews.net>
"John Smith" <creafin1998@yahoo.com> wrote:
: Does anyone know the most efficient way to convert dates in the format
: "m/d/yyyy" to dd-Month-yy using pattern matching?
:
: thanks in advance.
print format_date('3/1/2001');
sub format_date {
my @month_name = (qw/January Febuary March April May June July
August September October November
December/);
my ($month, $day, $year) = split '/', shift;
return (sprintf "%02d-%s-%02d",
$day, $month_name[$month - 1], $year %
100);
}
HTH,
Charles K. Clarkson
------------------------------
Date: 02 Mar 2001 10:26:47 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: Convert dates in format "3/1/2001" to dd-Month-yy
Message-Id: <wkd7c0y10o.fsf@math.uio.no>
"John Smith" <creafin1998@yahoo.com> writes:
> Does anyone know the most efficient way to convert dates in the
> format "m/d/yyyy" to dd-Month-yy using pattern matching?
s{
(\d+) / (\d+) / (\d+)
}{
sprintf '%02d-%s-%02d', $2,
qw(January February March April May June July
August September October November December)[$1-1],
$3 % 100;
}ex;
Peter
--
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!
------------------------------
Date: Fri, 02 Mar 2001 05:07:54 -0500
From: ZepHead <groovyt@erols.com>
Subject: flock and close with empty read strangeness
Message-Id: <groovyt-F9AF10.05075302032001@virt-reader.news.rcn.net>
should you use a flock with unlock if your next call is just going to be a
close? i read that it causing a race condition???
Does close flush the cache and unlock always?
also what are your thoughts on
if(open(FILEHANDLE,"<$dirpath"))
versus
open(FILEHANDLE,"<$dirpath") or die "can't open for reading. $!";
etc... for flock and close and print to the file.
I'm asking because i have a log file that is getting hit 10,000 times an hour
and about 1 time every thousand reads the above read returns an empty file
even though the data is there correctly in the file on the next read.
I'm locking the read and writes and checking for true and die (tried both of the
above ways ) for the open/flocks/close and they are good to go yet still an
empty read.
this is on a BSD Unix box and I'm at a loss for why this is happening : (
is there a trick/tip or gotcha I'm missing?
thanks
Russ
------------------------------
Date: 2 Mar 2001 10:33:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: flock and close with empty read strangeness
Message-Id: <97nste$41r$1@mamenchi.zrz.TU-Berlin.DE>
According to ZepHead <groovyt@erols.com>:
> should you use a flock with unlock if your next call is just going to be a
> close? i read that it causing a race condition???
> Does close flush the cache and unlock always?
Yes and yes. Close flushes all buffers that were assigned on open()
(it wants to de-allocate them). It also releases all locks on the
filehandle, since the filehandle is about to go away.
This is one of the advantages of flock() over ersatz lock mechanisms
using lock files in the file system: When a process goes away, its
filehandles go away and so do the locks it holds. There are no
stale locks.
> also what are your thoughts on
>
> if(open(FILEHANDLE,"<$dirpath"))
>
> versus
>
> open(FILEHANDLE,"<$dirpath") or die "can't open for reading. $!";
>
> etc... for flock and close and print to the file.
That depends entirely on your needs. Only you can decide if your
program can work around the error or if you have to give up.
Anno
------------------------------
Date: Fri, 02 Mar 2001 10:19:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help Matt with small programs
Message-Id: <4jsu9tc4n7celchntn6ji1blruvkies38q@4ax.com>
mshort wrote:
>$num=0;
>while ($num>=0){
>
>#####Insert code#####
>
> print "$num ";
> $num++;
>}
I wonder how people expect $num to become less than zero, if all you do
is increment it.
This does the same:
$num=0;
while (1){
#####Insert code#####
print "$num ";
$num++;
}
>Ok here's one program that I did that I THOUGHT should just print 0 through
>100 and then exit
>
>$num=0;
>while ($num>=0){
> next if ($num==0);
> last if $num==100;
> print "$num ";$num++;
> }
Reason why it doesn't work, is because you start at zero, and $num never
gets incremented. You jump from the "next" statement directly back to
the "while", without going through "$num++". So, you get an indefinite
loop.
It is safer to put the $num++ in a continue block:
my $num = 0;
while(1) {
next if $num==0;
last if $num==100;
print "$num\n";
} continue {
$num++;
}
Here, "next" first jumps to the "continue" block.
>I couldn't get this one to work either:
>
>$num=0;
>while ($num>=0){
> next if (int($num / 5) != ($num/5));
> last if $num==100;
> print "$num ";$num++;
> }
>
>Any help would be greatly appreciated.
The reason is the same: as soon as you get a multiple of 5, $num no
longer gets incremented.
BTW there's also the "modulo" operator, "%". ($num % 5) is 0 if the
number is divisible by 5.
--
Bart.
------------------------------
Date: Fri, 02 Mar 2001 02:32:13 -0700
From: Robert Joost <r51446@email.sps.mot.com>
Subject: HelpOnHashes?!?!
Message-Id: <3A9F689D.58F797C4@email.sps.mot.com>
This is a multi-part message in MIME format.
--------------94D1D8E494C46C3E998A5860
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
RTFM, yes. I want to open a directory, get the list of tickets, all of
which are of the format, for example, 2001-03-01-16:08:52.outage ( the
file names = savefile ( field in the ticket))
After reading in that directory and setting the contents up in an array,
@outages, I want to open a Report and append the contents of *.outage
to that report. For all the outage tickets in the directory being
opened, each ticket consists several fields---
# cat 2001-02-22-22:19:32.outage
userid=rxxxxx
date=22%20Feb%202001%201550
duration=3%20min
remedy=
server=prodserver
app=Static_Site
description=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
savefile=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
action=SAVE
=
I want to split each line off into key/value pairs, but what I am
scouring the net/faqs/books/mags for is how to
make the hash write out to Report like this -- ( without action=SAVE
and = )
rxxxxx 22 Feb 2001 1550 20min prodserver
Static_Site adsfadfadsfasdfasdfadfadfad adsfadfadsfasdfasdfadfadfa
in tab-delimited fields ??
sub report_parameters {
#use diagnostics;
opendir(TICKETS, "/usr/local/apache/htdocs/outages/tickets"); #open
the directory with the files
my @outages = readdir(TICKETS); # set up the array of files
closedir(TICKETS);
open(REPORT, ">>/usr/local/apache/htdocs/outages/Report"); # open the
Report for append
foreach $outage (@outages) { #for each file
open(TICKET, "/usr/local/apache/htdocs/outages/tickets/$outage"); #
open the file
while ($line = <TICKET>) { #iterate over the line in each file
(each file has only one line)
chomp $line;
($key, $val) = split /=/, $line; # split the line by "=" for
key/value pairs
$config{$key} = $val; # get the value
}
print "\n";
print REPORT "$config{$val}"; # print to Report the value in
tab-delimited format
close(REPORT);
close(TICKET);
}
}
I have tried numerous possiblities, but everytime I click on the submit
button that calls this procedure, the Report file is not touched at all
(Solaris env), perl 5, use CGI....
I have no problem in this script to grab all the fields and to create
the tickets, and, I can create this Report no problem with the field
variables, but, I just can't get an iteration
like this to build the report. Note that the filename = savefile, so
that could server as some kind of a primary key.
I am turning to people now for help. I am a new inductee into perl and
love it, having graduated from korn shell out of necessity!
I have come across tons of ideas, like hashes of hashes, dbm, etc, etc,
so please only respond if you can just help me out.
Thanks!!!
--------------94D1D8E494C46C3E998A5860
Content-Type: text/x-vcard; charset=us-ascii;
name="r51446.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Robert Joost
Content-Disposition: attachment;
filename="r51446.vcf"
begin:vcard
n:Joost;Robert
x-mozilla-html:FALSE
org:Motorola Semiconductor Product Sector;e-Business Infrastructure & Operations
adr:;;;;;;
version:2.1
email;internet:Robert.Joost@Motorola.com
title:Systems Engineer
note;quoted-printable:The supreme happiness of life is the conviction that we are loved.=0D=0A Victor Hugo (in Les Miserables)
x-mozilla-cpt:;-8032
fn:Robert Joost
end:vcard
--------------94D1D8E494C46C3E998A5860--
------------------------------
Date: Fri, 02 Mar 2001 05:26:19 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How do I test whether a CODE reference is an NOP?
Message-Id: <3A9F323F.4B7690C@home.com>
Rafael Garcia-Suarez wrote:
>
> John Lin wrote in comp.lang.perl.misc:
> >
> > Wow, B::Deparse is so powerful.
> > Why don't Data::Dumper take this advantage?
> I didn't dig into this; however, if you think it's doable, try to
> implement this into Data::Dumper. If you run into problems, you'll
> understand the author opinion. If not (don't forget to do a lot of
> tests) patches are welcome.
Wasn't a patch for this recently rejected? Searching...yep, here it is:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-01/msg00475.html
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 2 Mar 2001 09:54:09 +0100
From: "Arthur Wolst" <awolst@lodderapplicaties.nl>
Subject: Invalid URI in request GET (???) with Apache
Message-Id: <97nn46$qfn$1@porthos.nl.uu.net>
Hello,
I've written a Perl script which accesses a Paradox DB through COM, and
I want to use it with the Apache Web server. The script works fine when I
execute it from the command line, but Apache gives the following error:
Invalid URI in request GET /Perl/test.pl HTTP/1.1
I think there's some additional work to do, to get Perl scripts working on
Apache. But I don't know what, perhaps the way of calling the script (right
now, I just type 192.168.0.86/Perl/test.pl in my browser. (see Additional
info
below for more details).
Does anyone have any ideas? Thanks in advance for your help!
Arthur.
Additional info:
I extended Apache's httpd.conf with the following lines:
ScriptAlias /perl/ "/perl"
AddType application/x-httpd-perl .pl
Action application/x-httpd-perl "c:/program files/perl/bin/perl.exe"
I got PHP to work correctly in the same way.
The first line of the script file:
#!C:/Program Files/Perl/Bin/perl -w
Script works from the command line, so this should be correct.
I also tried quotes because of the space between Program and Files
but it won't work either with Apache.
------------------------------
Date: Fri, 02 Mar 2001 09:02:50 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Invalid URI in request GET (???) with Apache
Message-Id: <slrn99uod7.6r9.rgarciasuarez@rafael.kazibao.net>
Arthur Wolst wrote in comp.lang.perl.misc:
> Hello,
>
> I've written a Perl script which accesses a Paradox DB through COM, and
> I want to use it with the Apache Web server. The script works fine when I
> execute it from the command line, but Apache gives the following error:
>
> Invalid URI in request GET /Perl/test.pl HTTP/1.1
This error message is generated by Apache. Apparently your perl script
get never executed.
You might want to ask in comp.infosystems.www.servers.ms-windows
(apparently you're using windows) questions about configuring apache on
windows. Followups set.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Fri, 2 Mar 2001 00:03:51 -0600
From: "Scuttlebutt" <jbailey@cyberconnect.com>
Subject: Look at browser-sent request headers with Perl program?
Message-Id: <97ndd7$lqv$1@news.chatlink.com>
How can I see the request headers from a request sent by my browser using
Perl? I'd like to recreate a POST request in a Perl program, but seem to be
missing something (cookie info., hidden fields, ...).
Thanks!
------------------------------
Date: Fri, 02 Mar 2001 07:29:42 GMT
From: wyzelli@yahoo.com (Wyzelli)
Subject: Re: Look at browser-sent request headers with Perl program?
Message-Id: <Xns9058A51DBwyzelliyahoocom@203.39.3.131>
"Scuttlebutt" <jbailey@cyberconnect.com> wrote in
<97ndd7$lqv$1@news.chatlink.com>:
>How can I see the request headers from a request sent by my browser
>using Perl? I'd like to recreate a POST request in a Perl program, but
>seem to be missing something (cookie info., hidden fields, ...).
>
>Thanks!
>
>
>
Here's something I was playing with recently which may be of help to you.
#!/usr/bin/perl -w
use strict;
use HTTP::Request::Common;
use LWP::UserAgent;
my $url = 'http://www.url.goes.here/cgi-bin/script.cgi';
my $proxy = ''; # null for no proxy
my $proxy_port = ''; # check local settings
my $force = '0'; #set to 1 to force new load (via proxy)
## get the page
my $ua = new LWP::UserAgent;
if ($proxy){
$ua->proxy('http', "http://$proxy:$proxy_port/");
}
# a post
my $req = POST "$url",
[ name1 => 'value1',
name2 => 'value2' ];
# a get
#my $req = new HTTP::Request('GET', "$url");
if ($force){
$req->header('pragma' => 'no-cache',
'max-age' => '0');
}
#view the request
print $req->as_string();
#view the result
my $html = $ua->request($req)->as_string;
print $html;
exit;
Wyzelli
--
#beer v2
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Fri, 02 Mar 2001 08:53:09 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Look at browser-sent request headers with Perl program?
Message-Id: <slrn99unr1.6pa.rgarciasuarez@rafael.kazibao.net>
Scuttlebutt wrote in comp.lang.perl.misc:
> How can I see the request headers from a request sent by my browser using
> Perl? I'd like to recreate a POST request in a Perl program, but seem to be
> missing something (cookie info., hidden fields, ...).
I've made a small HTTP proxy that enables (among other things) to trace
requests sent by / to the browser.
http://rgarciasuarez.free.fr/perl/biscuit.html
I believe it works only on Unix systems : it uses fork(). (For Windows,
you should be able to find equivalent software on the web).
--
Rafael Garcia-Suarez
------------------------------
Date: 2 Mar 2001 10:14:27 GMT
From: mfischer-news@josefine.ben.tuwien.ac.at (Fischer Markus)
Subject: mod_perl and conventional perl scripts simultaniously ?
Message-Id: <slrn99usk3.hj4.mfischer-news@josefine.ben.tuwien.ac.at>
Hello,
I hope this question is appropriate to this newsgroup and
apologize if not.
I've a bunch of perl scripts running normally as CGI scripts
currently. Due performance problems switching to mod_perl seems
to be the best option. Neverthless to say, those scripts were
never written in mind to work unter mod_perl ( mostly no variable
initialisation, no -w or use strict) and what I've read from the
mod_perl documentation and which seems reasonable for me such
things are necessary and highly recommended. Currently all
scripts are in one /cgi-bin/ directory. Many, many html documents
are linked to this fixed path.
Is it possible to have normal perl scripts and mod_perl rewritten
scripts in one and the same /cgi-bin/ path under apache and with
the current perl versions ?
thanks for any information ,
Markus
--
Markus Fischer, http://josefine.ben.tuwien.ac.at/~mfischer/
EMail: mfischer@josefine.ben.tuwien.ac.at
PGP Public Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0
- Free Software For A Free World -
------------------------------
Date: Fri, 02 Mar 2001 09:13:53 GMT
From: Ted Fiedler <tfiedler@zen.moldsandwich.com>
Subject: more regex
Message-Id: <Pine.LNX.4.21.0103020412100.12760-100000@zen.moldsandwich.com>
I know the values of $line_one ond $line_sixteen are uninitialized, but
how do I initialize them - I cant use while($line_one=<WEATHERFILE>) {
so i am curious to see how I would do this - im trying to remove the first
16 lines of a file...
!/usr/bin/perl -w
use strict;
my ($info);
my ($line);
my ($line_one);
my ($line_sixteen);
open (WEATHERFILE, "+<weather.dat")
|| die "cannot open weather.dat\n";
while ($line=<WEATHERFILE>) {
$line =~ s/\*|-//g;
$line_one =~ m/welcome to the weather/i;
$line_sixteen =~ m/press return for menu/i;
if ($line_one .. $line_sixteen) {
$line =~ s/$line_one .. $line_sixteen//;
}
print $line;
}
close WEATHERFILE;
Thanks in advance
Ted
------------------------------
Date: Fri, 02 Mar 2001 09:42:38 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: more regex
Message-Id: <slrn99uqoc.6ko.tjla@thislove.dyndns.org>
I was shocked! How could Ted Fiedler <tfiedler@zen.moldsandwich.com>
say such a terrible thing:
>I know the values of $line_one ond $line_sixteen are uninitialized, but
>how do I initialize them - I cant use while($line_one=<WEATHERFILE>) {
>so i am curious to see how I would do this - im trying to remove the first
>16 lines of a file...
How about:
while (<WEATHERFILE>)
{
next if (1..16);
# do whatever
}
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
You can bear anything if it isn't your own fault.
-- Katharine Fullerton Gerould
------------------------------
Date: 2 Mar 2001 07:25:02 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Opening STDERR for input
Message-Id: <97nhse$3mj$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Bernard Cosell
<bernie@fantasyfarm.com>],
who wrote in article <bi2u9t035rfuia67hg0ia4a3ucn39qrn16@4ax.com>:
> It is not passing data around inside the program -- it is a relatively
> standard Unix hack [that I've used before, just never before from
> Perl] for getting user input when you have a program that is running
> as a proper filter. you can't print out prompts and read responses
> using stdin/stdout else you'll mess up the pipeline, so it was always
> SOP to use stderr.
This is what Term::ReadLine is for. At least you can use it (or just
the ::Stub part) to get the i/o handles to the TTY.
Ilya
------------------------------
Date: 2 Mar 2001 08:26:45 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Opening STDERR for input
Message-Id: <slrn99uma5.l12.vek@pharmnl.ohout.pharmapartners.nl>
On Thu, 01 Mar 2001 21:49:47 -0500,
Bernard Cosell <bernie@fantasyfarm.com> wrote:
>On Thu, 01 Mar 2001 00:27:27 GMT, "John W. Krahn" <krahnj@acm.org>
>wrote:
>
>} Bernie Cosell wrote:
>} >
>} > On Unix, STDERR is standardly open for both reading and writing [try it
>} > from a shell script, for example].
>}
>} You'll have to provide an example to substantiate this claim!
>
>Well, I misspoke, it isn't default read/write in Unix, but it is
>readable/writable, viz:
>=============================
>/* Read from STDERR */
>
>#include <stdio.h>
>
>char line[1000] ;
>FILE * ERRBOTH ;
>
>main()
>{
> ERRBOTH = fdopen(2, "r+") ;
> fprintf(ERRBOTH, "Please type: ") ;
> fgets (line, 1000, ERRBOTH)
> printf ("You typed %s\n", line) ;
>}
>===================================
>
The file descriptor 1, 2, and 3 on unix is usualy dup() from the same
file descriptor which is open read-write. This does not mean that stderr
as an stdio stream or STDERR as a Perl file handle is opened for both
read and write.
Villy
------------------------------
Date: Thu, 01 Mar 2001 21:27:26 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <3A9F2F3E.B45A3CE4@stomp.stomp.tokyo>
BUCK NAKED1 wrote:
> No Luck from Lincoln :) All he did was send me the
> $query->defaults('button') paragraph from cgi.pm
(snipped)
Well within sixty minutes you could write your own
read and parse routine and arrange for your script
to print your html, as needed. Your problems would
be immediately resolved.
You have been playing a guessing game with this for
days and, could have had your program up and running
quickly on the first day, if you had stop using CGI.pm
in your program.
Godzilla!
--
@©=(a .. z);@®=qw(7 15 4 26 9 12 12 1 18 15 3 11 19);
$Ñ="\n";srand(time()^($$+($$<<15)));for($§=$®[$®[0]];
$§<$®[2];$§++){sub G{rand($®[8])<$®[4]?"\u$1":"\l$1";}
foreach$¿(@®){$¢=$©[$¿-1];$¢=~s¡([a-z])¡G($1)¡gie;
$Ø="$Ø$¢";}$Ø="$Ø! ";$ø=substr($Ø,$®[12]-$®[11],0," ");
$Ø=~s¯(a)(r)¯$1 $2¯i;push (@Ø,$Ø);}print"$Ñ$ÑC:\\>",
"$©[22]$©[$®[0]]$©[14] $©[$®[8]-$®[7]]o$©[$®[2]/2]ks",
" $©[24]o?$©[$®[8]]";undef$z;$Ø="\b";select$z,$z,$z,.5;
print$Ø;select$z,$z,$z,.5;print$Ø;select$z,$z,$z,.75;
print"$©[$®[12]+$®[7]]";select$z,$z,$z,.75;print"?";
select$z,$z,$z,1;print"$Ñ$Ñ";$Ø=.05;foreach$¡(@Ø)
{@©=split(//,$¡);foreach$§(@©){print$§;select$z,$z,$z,
$Ø;}print$Ñ;}@¶=reverse(@Ø);foreach$¶(@¶){@®=split(//,$¶);
foreach$¢(@®){print$¢;select$z,$z,$z,$Ø;}print $Ñ;}exit;
------------------------------
Date: Fri, 2 Mar 2001 01:12:34 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <97ndve$21e$1@slb0.atl.mindspring.net>
I have a solution. I'm not sure how happy I am with it, but it is a
solution. Assuming that the script is called in the following way:
<A HREF="../cgi-bin/scriptname?first_time=1">
The following will give you the desired effect:
print start_html;
if (param('first_time')) {
make_form($ENV{HTTP_REFERER});
} else {
make_form();
}
sub make_form {
print start_multipart_form,
textfield(-name=>'url',
-value=>"$_[0]",
-size=>60,
-maxlength=>300),
br,
submit(-name=>'submit',-value=>'SUBMIT'),
defaults('RESET'),
end_form,
end_html;
}
I can't think of anything better at the moment without using JavaScript. Of
course, you'll need to look carefully at the effects this will have on
submit (which I haven't). Good luck.
Joe
BUCK NAKED1 <dennis100@webtv.net> wrote in message
news:21681-3A9F20DF-3@storefull-246.iap.bryant.webtv.net...
> No Luck from Lincoln :) All he did was send me the
> $query->defaults('button') paragraph from cgi.pm that I had already read
> and tried numerous times. Looks like I need to clear the script's URL
> from an environmental variable, but don't know how... $ENV{'SCRIPT_URL'}
> = ""; doesn't work.
>
> --Dennis
>
------------------------------
Date: Fri, 2 Mar 2001 01:16:20 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <97ndvf$21e$2@slb0.atl.mindspring.net>
I have a solution. I'm not sure how happy I am with it, but it is a
solution. Assuming that the script is called in the following way:
<A HREF="../cgi-bin/scriptname?first_time=1">
The following will give you the desired effect:
print start_html;
if (param('first_time')) {
make_form($ENV{HTTP_REFERER});
} else {
make_form();
}
sub make_form {
print header,
start_html,
start_multipart_form,
textfield(-name=>'url',
-value=>"$_[0]",
-size=>60,
-maxlength=>300),
br,
submit(-name=>'submit',-value=>'SUBMIT'),
defaults('RESET'),
end_form,
end_html;
}
I can't think of anything better at the moment without using JavaScript. Of
course, you'll need to look carefully at the effects this will have on
submit (which I haven't). Good luck.
Joe
BUCK NAKED1 <dennis100@webtv.net> wrote in message
news:21681-3A9F20DF-3@storefull-246.iap.bryant.webtv.net...
> No Luck from Lincoln :) All he did was send me the
> $query->defaults('button') paragraph from cgi.pm that I had already read
> and tried numerous times. Looks like I need to clear the script's URL
> from an environmental variable, but don't know how... $ENV{'SCRIPT_URL'}
> = ""; doesn't work.
>
> --Dennis
>
------------------------------
Date: Fri, 2 Mar 2001 01:34:49 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <16792-3A9F4D19-9@storefull-241.iap.bryant.webtv.net>
Thanks, Joe. I dare to say this, but looks like Godzilla may be right
about cgi.pm. It seems to conflict with raw perl in places, and doesn't
appear to be very flexible. Maybe good for many CGI applications, but
not all... or maybe it's just me.:-{ Anyhow, I'll check out your
suggestions. I appreciate it.
I just didn't want to have to use a JS onClick event handler. Why? not
all browsers have JS or implemented it the same way, and some folks keep
JS turned off to prevent pop-ups, etc. Besides, I don't have any other
JS in this particular script and didn't want to start now... lol
[more than u wanted to know, I know]
Regards,
-Dennis
------------------------------
Date: Fri, 02 Mar 2001 00:24:45 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <3A9F58CD.74A768D4@stomp.stomp.tokyo>
BUCK NAKED1 wrote:
> Thanks, Joe. I dare to say this, but looks like Godzilla may be right
> about cgi.pm. It seems to conflict with raw perl in places, and doesn't
> appear to be very flexible. Maybe good for many CGI applications, but
> not all... or maybe it's just me.:-{ Anyhow, I'll check out your
> suggestions. I appreciate it.
Actually you could use CGI.pm and meet your needs. However,
you will have to jump through a lot of hoops and write code
which should not be needed. Writing custom code will save you
time and effort, in the long run. Use of CGI.pm is ok but it
is extremely restrictive and when you want to do something
fancy, you rarely can with CGI.pm in use. As you know, my
attitude is one of discouraging use of CGI.pm to retain ample
flexibility and options for cgi programming, with ease.
Being quite sincere, you never stood a chance on this. A reset
form button interacts with a browser only. When a reset button
is pressed, a browser restores default values stored within
cached memory. There is nothing you can do to change this
with Perl. However, a change in approach, a change in presented
format, allows you a work around. Try my test script and you
will quickly realize this work around.
> I just didn't want to have to use a JS onClick event handler. Why?
Because Java totally sucks.
Godzilla!
--
Name this test script, "reset.cgi"
#!perl
&Parse;
sub Parse
{ # Parse #
if ($ENV{'CONTENT_LENGTH'} > 131072)
{ print "Location: file:///%43|%2f"; exit; }
else
{
local (*in) = @_ if @_;
my ($input, $key, $value);
read(STDIN, $in, $ENV{CONTENT_LENGTH});
@in = split(/&/, $in);
foreach $input (0 .. $#in)
{
$in[$input] =~ s/\+/ /g;
($key, $value) = split (/=/, $in[$input], 2);
($value eq "") && next;
$key =~ s/%(..)/pack("c",hex($1))/ge;
$value =~ s/%(..)/pack("c",hex($1))/ge;
## Kill Metacharacters Here##
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $value;
}
return 1;
}
} # Parse #
print "Content-type: text/html\n\n
<HTML><BODY>
<BR><BR><BR>
<FORM METHOD=\"post\" ACTION=\"reset.cgi\">
<INPUT TYPE=\"submit\" NAME=\"Test\" VALUE=\"Reset Test\">
<P>
Your Browser Is: $ENV{HTTP_USER_AGENT}
<BR>
Change Your Browser:
<INPUT TYPE=\"text\" SIZE = \"30\" NAME=\"User_Agent\" VALUE=\"\">
<P>
Your IP Address Is: $ENV{REMOTE_ADDR}
<BR>
Change Your IP Address:
<INPUT TYPE=\"text\" SIZE = \"30\" NAME=\"Remote_Addr\" VALUE=\"\">
<P>
<INPUT TYPE=\"reset\" VALUE=\"Reset Form\">
</FORM>
<P>\n\n";
if (!($in{User_Agent}))
{ $in{User_Agent} = $ENV{HTTP_USER_AGENT}; }
if (!($in{Remote_Addr}))
{ $in{Remote_Addr} = $ENV{REMOTE_ADDR}; }
print "
<HR SIZE=\"5\">
Value For Browser: $in{User_Agent}
<BR>
Value For IP Address: $in{Remote_Addr}
<BR>
</BODY></HTML>";
exit;
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 394
**************************************