[22751] in Perl-Users-Digest
Perl-Users Digest, Issue: 4972 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 11 21:06:20 2003
Date: Sun, 11 May 2003 18:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 11 May 2003 Volume: 10 Number: 4972
Today's topics:
"Premature end of script headers" Error <null@null.com>
Re: "Premature end of script headers" Error <abuse@mweb.co.za>
Re: "Premature end of script headers" Error <bob@nowhere.com>
Re: "Premature end of script headers" Error <jurgenex@hotmail.com>
Re: "Premature end of script headers" Error <abigail@abigail.nl>
8255A Chip (Herbert Andress)
Re: 8255A Chip <palaste@cc.helsinki.fi>
check IP address <farmers@ihug.com.au>
Re: check IP address <dorward@yahoo.com>
Re: check IP address (Sam Holden)
Re: check IP address <farmers@ihug.com.au>
Re: check IP address (James E Keenan)
command interface (not a shell) <samj@austarmetro.com.au>
Re: File pointers, EOF, +< (Sam Holden)
Re: File pointers, EOF, +< <abigail@abigail.nl>
Re: IO:Select module Help! <dmn@box43.pl>
Re: Newbie - packing Perl application for distribution <ctrueman@wavesoftware.com>
Not able to build perl5.8.0 on Solaris 9 <ewagar@yahoo.com>
Re: Open With? <taariqq@yahoo.com>
Re: Open With? <taariqq@yahoo.com>
Re: Open With? <taariqq@yahoo.com>
Re: perl -pe "s/<er>/<er>\n"/g": memory efficient versi (Peter J. Acklam)
Re: perl -pe "s/<er>/<er>\n"/g": memory efficient versi (Peter J. Acklam)
Re: RegExp Question <noreply@gunnar.cc>
Re: Splitting, Sorting, then Rebuilding an Array <bigj@kamelfreund.de>
Re: stat and underscore in file name (Jay Tilton)
Try to find a hash element but no luck <DavidG997@yahoo.com>
Re: Try to find a hash element but no luck <DavidG997@yahoo.com>
Re: Why is POE idle most of the time? <troc@netrus.net>
Re: Why Perl is so difficult to learn? (Randal L. Schwartz)
Re: Why Perl is so difficult to learn? <ddl76@singnet.com.sg>
Re: Why Perl is so difficult to learn? <galen@alumni.utexas.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 May 2003 17:39:15 +0200
From: "fernando" <null@null.com>
Subject: "Premature end of script headers" Error
Message-Id: <3ebe6eaf$1_4@news.arrakis.es>
Hi all!
I have just copied and pasted an script example that uses GD, from:
http://shawn.apocabilly.org/pwg/examples/4ex.html
And when i execute it on my apache server, under red hat 8, it throws a 500
error, and prints:
Server error!
Premature end of script headers: sample2.pl
Error 500
Does any one know whats happening, and how to fix it?
Thanks a lot
Fernando
Madrid, Spain
------------------------------
Date: Sun, 11 May 2003 17:46:37 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: Re: "Premature end of script headers" Error
Message-Id: <pan.2003.05.11.15.46.36.725194@mweb.co.za>
What does /var/log/httpd/access_log and /var/log/httpd/ssl_error_log say?
What happens if you run the script from the command line? Try:
$ perl -w /path/to/script.pl
Do this, and maybe we can help you better.
Cheers
On Sun, 11 May 2003 17:39:15 +0200, fernando wrote:
> Hi all!
>
> I have just copied and pasted an script example that uses GD, from:
> http://shawn.apocabilly.org/pwg/examples/4ex.html
>
> And when i execute it on my apache server, under red hat 8, it throws a 500
> error, and prints:
>
> Server error!
> Premature end of script headers: sample2.pl
>
> Error 500
>
> Does any one know whats happening, and how to fix it?
>
> Thanks a lot
>
> Fernando
> Madrid, Spain
--
Nico Coetzee
http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/
To the systems programmer, users and applications serve only to provide a
test load.
------------------------------
Date: Sun, 11 May 2003 15:05:03 -0500
From: bob <bob@nowhere.com>
Subject: Re: "Premature end of script headers" Error
Message-Id: <3ebeacd6_1@127.0.0.1>
Often there is more useful information in the apache error_log file.
On Sun, 11 May 2003 10:39:15 -0500, fernando wrote:
> http://shawn.apocabilly.org/pwg/examples/4ex.html
>
> And when i execute it on my apache server, under red hat 8, it throws a
> 500 error, and prints:
>
> Server error!
> Premature end of script headers: sample2.pl
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sun, 11 May 2003 21:54:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: "Premature end of script headers" Error
Message-Id: <wEzva.10516$TM6.7806@nwrddc02.gnilink.net>
fernando wrote:
[...]
> And when i execute it on my apache server, under red hat 8, it throws
> a 500 error, and prints:
>
> Server error!
> Premature end of script headers: sample2.pl
>
> Error 500
>
> Does any one know whats happening, and how to fix it?
Read The Fine Manual: "perldoc -q 500"
jue
------------------------------
Date: 11 May 2003 23:10:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: "Premature end of script headers" Error
Message-Id: <slrnbbtm2c.2vd.abigail@alexandra.abigail.nl>
fernando (null@null.com) wrote on MMMDXL September MCMXCIII in
<URL:news:3ebe6eaf$1_4@news.arrakis.es>:
,, Hi all!
,,
,, I have just copied and pasted an script example that uses GD, from:
,, http://shawn.apocabilly.org/pwg/examples/4ex.html
,,
,, And when i execute it on my apache server, under red hat 8, it throws a 500
,, error, and prints:
,,
,, Server error!
,, Premature end of script headers: sample2.pl
,,
,, Error 500
,,
,, Does any one know whats happening, and how to fix it?
It means you have a bug in your program.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Sat, 10 May 2003 18:01:20 GMT
From: handress@spam.blokcck (Herbert Andress)
Subject: 8255A Chip
Message-Id: <3ecf3e58.66639322@decaxp.HARVARD.EDU>
Is it likely that a small picoJava II embedded system would include an
8255 chip?
------------------------------
Date: 11 May 2003 18:06:08 GMT
From: Joona I Palaste <palaste@cc.helsinki.fi>
Subject: Re: 8255A Chip
Message-Id: <b9m3eg$e26$1@oravannahka.helsinki.fi>
Herbert Andress <handress@spam.blokcck> scribbled the following
on comp.lang.c:
> Is it likely that a small picoJava II embedded system would include an
> 8255 chip?
What was... <looks at the crosspost list> oh, never mind.
--
/-- Joona Palaste (palaste@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Parthenogenetic procreation in humans will result in the founding of a new
religion."
- John Nordberg
------------------------------
Date: Mon, 12 May 2003 04:58:23 +1000
From: "Hugo" <farmers@ihug.com.au>
Subject: check IP address
Message-Id: <b9m6go$l1c$1@lust.ihug.co.nz>
Hi,
I am trying to write a perl script to check if the ip address is match the
one in a file.txt e.g. 192.12.2.1. The code I use is:
if ($ARGV[0] != $newhash{$hostname}) {print "something here"}
However, the code checks anything up to 192.1 and it doesn't matter what you
type after that i.e. it says 192.12sadasdsadb is the same as 192.12.2.1
??????
Can anyone fix this?
------------------------------
Date: Sun, 11 May 2003 20:07:27 +0100
From: David Dorward <dorward@yahoo.com>
Subject: Re: check IP address
Message-Id: <b9m6vs$s7v$1$8302bc10@news.demon.co.uk>
Hugo wrote:
> if ($ARGV[0] != $newhash{$hostname}) {print "something here"}
>
> However, the code checks anything up to 192.1 and it doesn't matter what
> you type after that i.e. it says 192.12sadasdsadb is the same as
> 192.12.2.1 ??????
!= is a numeric test, not a string test.
See the section Equality Operators in perldoc perlop
--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
2 and 5 are objects, as opposed to Java, where they are primitive thingies.
------------------------------
Date: 11 May 2003 19:09:44 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: check IP address
Message-Id: <slrnbbt7vo.kua.sholden@flexal.cs.usyd.edu.au>
On Mon, 12 May 2003 04:58:23 +1000, Hugo <farmers@ihug.com.au> wrote:
> Hi,
>
> I am trying to write a perl script to check if the ip address is match the
> one in a file.txt e.g. 192.12.2.1. The code I use is:
>
> if ($ARGV[0] != $newhash{$hostname}) {print "something here"}
>
> However, the code checks anything up to 192.1 and it doesn't matter what you
> type after that i.e. it says 192.12sadasdsadb is the same as 192.12.2.1
> ??????
If you want to compare strings use the string comparison ops ('ne' in
this case).
Read the perlop documentation (perldoc perlop).
--
Sam Holden
------------------------------
Date: Mon, 12 May 2003 08:32:23 +1000
From: "Hugo" <farmers@ihug.com.au>
Subject: Re: check IP address
Message-Id: <b9mj1v$u20$1@lust.ihug.co.nz>
umm.....I don't think it is the problem with ne, eq, ==, !=.......etc As I
can successfully check the so called hostname <----"string" (with "eq"). If
use ne or eq my script even can't recognize any ip address.
Is it necessary to "split" the "." ? The dot is char. or number?
thanks
"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnbbt7vo.kua.sholden@flexal.cs.usyd.edu.au...
> On Mon, 12 May 2003 04:58:23 +1000, Hugo <farmers@ihug.com.au> wrote:
> > Hi,
> >
> > I am trying to write a perl script to check if the ip address is match
the
> > one in a file.txt e.g. 192.12.2.1. The code I use is:
> >
> > if ($ARGV[0] != $newhash{$hostname}) {print "something here"}
> >
> > However, the code checks anything up to 192.1 and it doesn't matter what
you
> > type after that i.e. it says 192.12sadasdsadb is the same as 192.12.2.1
> > ??????
>
> If you want to compare strings use the string comparison ops ('ne' in
> this case).
>
> Read the perlop documentation (perldoc perlop).
>
> --
> Sam Holden
>
------------------------------
Date: 11 May 2003 17:49:50 -0700
From: jkeen@concentric.net (James E Keenan)
Subject: Re: check IP address
Message-Id: <b955da04.0305111649.2af0317d@posting.google.com>
"Hugo" <farmers@ihug.com.au> wrote in message news:<b9m6go$l1c$1@lust.ihug.co.nz>...
> Hi,
>
> I am trying to write a perl script to check if the ip address is match the
> one in a file.txt e.g. 192.12.2.1. The code I use is:
>
> if ($ARGV[0] != $newhash{$hostname}) {print "something here"}
>
> However, the code checks anything up to 192.1
because != is the operator for numerical inequality: "is not equal
to". It expects a number on the right hand side. You want a regular
expression.
What you want is probably something like this:
if ($ARGV[0] !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {print
"something here"}
(Of the top of my head I don't know the exact spec for an ip address,
but this is close enough to get you started.
------------------------------
Date: Sun, 11 May 2003 22:08:44 GMT
From: "Sam Jesse" <samj@austarmetro.com.au>
Subject: command interface (not a shell)
Message-Id: <3ebec9eb$1@news.comindico.com.au>
Hello
I was reading the Description of cpan - easily interact with CPAN from the
command line. it says This "script provides a command interface (not a
shell) to CPAN.pm." sorry for the novice question. what is the differenc
between a comand interface and a shell? is he talking about command
interface on a C: prompt vs. shell on unix? I am very green in this thing
Sam
------------------------------
Date: 11 May 2003 13:25:44 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: File pointers, EOF, +<
Message-Id: <slrnbbsjqo.goe.sholden@flexal.cs.usyd.edu.au>
On Sun, 11 May 2003 18:08:16 +0930, Henry <urael@zrgebcbyvf.arg.nh> wrote:
> In article <slrnbbrsvg.crr.sholden@flexal.cs.usyd.edu.au>,
> sholden@flexal.cs.usyd.edu.au (Sam Holden) wrote:
>
>> >> || Are writes _inserted_ at the current pointer position, or do they
>> >> || _overwrite_ the contents (starting) at the current pointer position?
>> >>
>> >> They are overwritten. Files are just a stream of bytes in the file
>> >> system, and disks are rigid structures. You can't easily insert something
>> >> in a file.
>> >
>> > In which case "+<" will place the pointer at the start of the file and,
>> > providing you don't read anything, overwrite from that point onwards.
>> > Got it.
>> >
>> > If that's the case, what happens when you close the file? Where does
>> > the EOF marker go? Does it stay where it is, or does it get placed at
>> > the current pointer position?
>>
>> It stays where it is.
>
> Ok, so if "+<" overwrites data at the current pointer position and
> "close" does _not_ modify the position of the EOF, then what happens if
> you _overwrite_ the EOF?
The EOF is not a byte and hence can't be overwritten. It indicates the
end of a file. Granted some OS use an EOF byte in character files, but that
is done behind the scenes and automatically created by the OS (or libc I guess).
>
> Scenario 1: Write 1000 bytes into a file which previously held 999
> bytes.
>
> Assuming blocks of 512 bytes, the filesystem has still allocated only 2
> blocks to the file. The next time you try to read the file, would you
> get the first, predictable 1000 bytes, then an unpredictable 24 bytes
> (the rest of the block)?
What do you think happens if you create a 1000 byte file normally.
You get a 1000 byte file. The Operating System (assuming a normal
run of the mill sane one) presents files as a stream of bytes, not as
a bunch of 512 byte blocks.
>
> Does Perl keep reading until it encounters the first EOF? If so, and if
> no EOF is encountered in the trailing 24 bytes, what happens next? Does
> Perl generate an "EOF Not Found"-type error? The file-system presumably
> knows that the file being read doesn't span more than two blocks and
> thus will generate its own error and pass that to Perl (which will
> presumably pass it to the script being run).
>
> Scenario 2: Write 128 KB into a file which previously only held 999
> bytes.
>
> Will more blocks be allocated by the filesystem if a "+<" write exceeds
> the original number of blocks assigned to the original file?
Of course. When you write past the EOF the OS allocates the file more space,
unless there is no space in which case you can catch the error (print or close
is going to fail...)
--
Sam Holden
------------------------------
Date: 11 May 2003 23:08:49 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: File pointers, EOF, +<
Message-Id: <slrnbbtm01.2vd.abigail@alexandra.abigail.nl>
Henry (urael@zrgebcbyvf.arg.nh) wrote on MMMDXL September MCMXCIII in
<URL:news:urael-EFBB32.13272911052003@nswpull.telstra.net>:
:} In article <slrnbbr41q.2vd.abigail@alexandra.abigail.nl>,
:} Abigail <abigail@abigail.nl> wrote:
:}
:} > || Are writes _inserted_ at the current pointer position, or do they
:} > || _overwrite_ the contents (starting) at the current pointer position?
:} >
:} > They are overwritten. Files are just a stream of bytes in the file
:} > system, and disks are rigid structures. You can't easily insert something
:} > in a file.
:}
:} In which case "+<" will place the pointer at the start of the file and,
:} providing you don't read anything, overwrite from that point onwards.
:} Got it.
:}
:} If that's the case, what happens when you close the file? Where does
:} the EOF marker go? Does it stay where it is, or does it get placed at
:} the current pointer position?
What EOF marker? Sane operating systems don't use EOF markers - why
sacrifice a character which you then cannot have anywhere else in your
file? Sane OS just record the size of the file, and that's it.
:} Scenario 1: EOF stays where it is. If "+<" overwrites data at the
:} current pointer position and "close" does _not_ modify the position of
:} the EOF, then what happens if you overwrite the EOF? (By, for example,
:} writing 1025 bytes into a file which previously held 1024 bytes.)
:}
:} Scenario 2: EOF placed at the current pointer position. What happens
:} with the "+<" approach if the file spans multiple blocks, and writing
:} terminates (for example) in the penultimate block? (Now you have an EOF
:} in block n-1 as well as block n.)
:}
:} Basically, I'm wondering what logic deals with the EOF when the "+<"
:} approach is used.
Files grow on demand - if you write after the end of the file, the file
is increased. But a file isn't decreased in size automatically - you'd
need to call truncate for that.
Abigail
--
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];
------------------------------
Date: Sun, 11 May 2003 15:19:44 +0200
From: "Dariusz Nowak" <dmn@box43.pl>
Subject: Re: IO:Select module Help!
Message-Id: <b9lig5$oan$1@atlantis.news.tpi.pl>
>I have setup to listening sockets, one a UDP one and another TCP one. I
need to use the
>Select method to listen for data on each of these. I have the following so
far:
>
>#!/usr/bin/perl -w
>
>use IO::Socket;
>use IO::Select;
>
>
># Read config file and store in array
>my @config;
>open (CONFIG, "config.txt") or die "I couldn't open server config file";
>@config = <CONFIG>;
>close CONFIG;
>
>
>my $wb_server_port = $config[0];
>my $lc_server_port = $config[1];
>my $ig_host_name = $config[4];
>my $ig_port = $config[5];
>my $ig_username = $config[6];
>my $ig_password = $config[7];
>
>my $wb_listener = IO::Socket::INET->new(LocalPort => $wb_server_port,
> Proto => "tcp",
> Listen => 250 )
> or die "Couldn't be a web server on port
$wb_server_port : $@\n";
>
>
>my $lc_listener = IO::Socket::INET->new(LocalPort => $lc_server_port,
> Proto =>
"udp")
> or die "Couldn't be a log client server on port
$lc_server_port : $@\n";
>
>
>my $select = IO::Select->new($wb_listener);
>$select->add($lc_listener);
>
>
>I would like to know how I now go about testing for and handling the
incoming data for
>each of the listeners.
>
>Cheers
I would start with changing last few lines into:
my @listen_socket = ($wb_listener, $lc_listener);
my $read_socket_set = new IO::Select();
$read_socket_set->add(@listen_socket);
while(1) {
($ref_to_read_ready_sockets, undef, undef) =
IO::Select->select($read_socket_set,
undef, undef, 30);
foreach $socket (@$ref_to_read_ready_sockets) {
if ($socket == $wb_listener) {
my $client1 = $socket->accept();
# ..... do something on accepted soket
$read_socket_set->add($client);
} elsif ($socket == $lc_listener)
my $client2 = $socket->accept();
# ..... do something on accepted soket
$read_socket_set->add($client);
} else {
#message from already connected client
# .... read, write from $socket
}
} #end foreach loop
}#end while loop
This is the main scheme for socket handling.
Regards
Dariusz
}
------------------------------
Date: Sun, 11 May 2003 20:38:28 +0000 (UTC)
From: Chris Trueman <ctrueman@wavesoftware.com>
Subject: Re: Newbie - packing Perl application for distribution
Message-Id: <Xns9378DCBA4CA82ctruemanwavesoftware@217.32.252.50>
> Yep. Take a look at the PAR module. They don't even need perl
> installed if you use the pp utility.
Thanks Simon. PAR certainly looks like a good option.
Chris.
------------------------------
Date: Sun, 11 May 2003 23:14:37 GMT
From: "Eric Wagar" <ewagar@yahoo.com>
Subject: Not able to build perl5.8.0 on Solaris 9
Message-Id: <xPAva.808774$3D1.453262@sccrnsc01>
When I try to 'make test' on my Sun Netra running Solaris 9 (fully patched),
I get errors like this:
fatal: relocation error: file ../lib/auto/Socket/Socket.so: symbol
inet_aton: referenced symbol not found
Of course, this doesn't stop perl from installing, but it kinda hampers
stuff like CPAN (among other things I want to be doing.)
I haven't been able to find much of anything on the web, except that maybe
changing my LD_LIBRARY_PATH around, which I did. I added /usr/lib. My
./myconfig is at the end.
Any help is greatly enjoyed and appreciated.
thanks
eric
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=solaris, osvers=2.9, archname=sun4-solaris
uname='sunos guy 5.9 generic_112233-05 sun4u sparc
sunw,ultrasparc-iii-cengine '
config_args='-de -Ubincompat5005'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags
='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-fno-strict-aliasing'
ccversion='', gccversion='3.2.3', gccosandvers='solaris2.9'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib '
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lbind -lnsl -ldl -lm -lc
perllibs=-lsocket -lbind -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
------------------------------
Date: Sun, 11 May 2003 19:48:21 -0400
From: "Tariq" <taariqq@yahoo.com>
Subject: Re: Open With?
Message-Id: <b9mncv01e8m@enews1.newsguy.com>
"Helgi Briem" <helgi@decode.is> wrote in message
news:3eb8ccac.2312123858@news.cis.dfn.de...
> On Tue, 6 May 2003 21:13:01 -0400, "Tariq"
> <taariqq@yahoo.com> wrote:
>
> >> > are talked about as the necessary tools. Since
> >> > PHP is famous for server side scripting with MySQL, I thought if I
could
> >> > eliminate CGI from the mix, that would be one less technology to
learn
>
> PHP is basically a simplified subset of Perl, with a
> CGI module and DBI module built in. It is used
> only for Web programming. Perl is a general purpose
> language and can be used to solve any programming
> problem, although it may not be suitable for all.
That was to the point, thanks for clarifying.
> Perl programmers do most of their work
> with modules, plug in libraries that export
> functions and objects and extend the language.
True object orientation I guess?
> An especially useful set of modules for Bioinformatics
> work is Bioperl. See http://www.bioperl.org/
> for details, but not until you have a basic understanding
> of Perl itself.
This is very helpful.
> --
> Regards, Helgi Briem
> helgi DOT briem AT decode DOT is
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 5/6/2003
------------------------------
Date: Sun, 11 May 2003 19:51:48 -0400
From: "Tariq" <taariqq@yahoo.com>
Subject: Re: Open With?
Message-Id: <b9mnjc01em0@enews1.newsguy.com>
"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3eb8555a@news.victoria.tc.ca...
> Tariq (taariqq@yahoo.com) wrote:
> : Tad,
>
> : My feeble understanding is that CGI is a server side scripting language,
and
>
> No. CGI is the definition of how to pass data from a web server to a
> program running on the server. Any program, no matter what language it is
> written in, must use the CGI protocol if it wants to be able to run under
> the control, so to speak, of a web server. In some languages you must
> take explicit action to use the CGI protocols. In other languages it all
> happens automatically, you just see the results, such as the magical
> existence of a certain variable in your program. Some "languages"
> automatically provide additional useful functionality, such as "session
> variables", which might be useful to the programmer, but they are not CGI,
> just useful extra stuff.
Thank you for a very clear definition.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 5/6/2003
------------------------------
Date: Sun, 11 May 2003 19:56:01 -0400
From: "Tariq" <taariqq@yahoo.com>
Subject: Re: Open With?
Message-Id: <b9mp0d025bs@enews4.newsguy.com>
"Bill Smith" <wksmith@optonline.net> wrote in message
news:UVWta.15270$kV3.2846181@news4.srv.hcvlny.cv.net...
> There are several ways to run a perl script under WIN32 Ref:
> "What is the equivalent of the shebang ("#!") syntax for win32" in
> perlwin32faq4.
>
> You did not say how you tried to run it. I think that you clicked on
> the icon
> for your script. The message was from WIN32. It did not know what
> program (perl) to run to process your script. This would happen if your
> script file did not have the extension ".pl" or if the association was
> not set up
> during installation.
>
> I prefer to work from the DOS command line. Open a DOS window and
> use the syntax "perl myscript.pl". Both STDOUT and STDERR will be
> written
> to the DOS window. Other methods have advantages for production code,
> but this is the best way to be sure of getting your error messages.
>
> Good Luck,
> Bill
Thanks ... I know I will be back for more questions.
Tariq
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 5/6/2003
------------------------------
Date: Sun, 11 May 2003 13:38:28 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: perl -pe "s/<er>/<er>\n"/g": memory efficient version?
Message-Id: <of29btmz.fsf@online.no>
tiltonj@erols.com (Jay Tilton) wrote:
> I should have tested that first. I forgot about the
> auto-chomp() behavior with that combination of switches.
>
> perl -pe "BEGIN{$\=$/;$/='<er>'}" foo.txt
I'm not sure you tested it this time either. It converts
--------
aa<er>bb
--------
into
--------
aa<er>
bb
--------
which has one newline too many. Here are some that work:
perl -pe 'BEGIN{ $/ = "<er>" } $_ .= "\n" if /<er>/
perl -pe 'BEGIN{ $/ = "<er>" } s/<er>/<er>\n/' infile
perl -pe 'BEGIN{ $/ = "<er>" } $_ .= "\n" if substr($_, -4) eq $/'
Peter
--
I wish dialog boxes had a button saying "Whatever". I hate being
forced to answer "Yes" or "No" to a question I have no opinion on
whatsoever. There ought to be a button matching my indifference.
------------------------------
Date: Sun, 11 May 2003 13:42:40 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: perl -pe "s/<er>/<er>\n"/g": memory efficient version?
Message-Id: <isshbtfz.fsf@online.no>
"John W. Krahn" <krahnj@acm.org> wrote:
> perl -lpe'BEGIN{ $\=($/="<er>").$\ }' yourfile
That fails if the last field does not end with "<er>". The file
--------
aa<er>bb
--------
becomes
--------
aa<er>
bb
<er>
--------
which has one "<er>" too many. The simplest solution is just a
slight modification of the origial version:
perl -pe 'BEGIN{ $/ = "<er>" } s/<er>/<er>\n/'
Peter
--
I wish dialog boxes had a button saying "Whatever". I hate being
forced to answer "Yes" or "No" to a question I have no opinion on
whatsoever. There ought to be a button matching my indifference.
------------------------------
Date: Sun, 11 May 2003 12:11:48 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: RegExp Question
Message-Id: <b9l895$kbqfh$1@ID-184292.news.dfncis.de>
Janek Schleicher wrote:
> Gunnar Hjalmarsson wrote at Sat, 10 May 2003 00:19:23 +0200:
>>Anthony Saffer wrote:
>>
>>>Let's say I have an entry in a log file like this:
>>>
>>>1/13/03 "Joe Somebody"<joe@somewhere.com>
>>>
>>>How would I extract ONLY the email address from this line?
>>
>> $line = '1/13/03 "Joe Somebody"<joe@somewhere.com>';
>> ($address) = $line =~ /<([^>]+)>/;
>
> Or a bit shorter:
> ($address) = $line =~ /<(.+?)>/;
Yeah, two characters shorter.
However, I'm used to avoid playing with greediness when it isn't
necessary, since I have experienced that Perl may be confused by too
much use of it in more complex regexes. I'm not sure; maybe it's just
me who have made mistakes and blame Perl without deserving it. Would
be interested in comments from others.
Let me add, to avoid misunderstandings, that I don't think Janek's
suggestion in this particular case would be a problem. ;-)
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 11 May 2003 09:22:24 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Splitting, Sorting, then Rebuilding an Array
Message-Id: <pan.2003.05.11.06.59.50.673510@kamelfreund.de>
Brad Walton wrote at Sun, 11 May 2003 01:12:58 +0000:
> Ok I got it working, and much less code. Could probably still be better, but
> this is working:
Now it's already looking like good c-code.
Now, we only have to make it Perlish,
so let's shorten again :-)
>
> sub update_player_archive {
> #Grab session variables
> my (@newsess,$n);
> my @currentsess = split /\t/, $adddata;
> my @oldsess = split /\t/, $updatedata;
>
> #Increment archive data with new data
> for ($n = 0; $n < 6; $n++) {
> @newsess[$n] = @currentsess[$n];
^ ^
Please read
perldoc -q 'What is the difference between $array[1] and @array[1]'
> }
Simpler as:
@newsess = @currentsess;
if @currentsess could contain more than 6 elements, than you could use
@newsess = @currentsess[0..5];
> @newsess[6] = (@oldsess[6] + @currentsess[6]);
> @newsess[7] = @currentsess[7];
> for ($n = 8; $n < 32; $n++) {
> @newsess[$n] = (@oldsess[$n] + @currentsess[$n]);
> }
Working with array splices and the map function is really comfortable,
you could write the last lines also as:
@newsess[0..5,7] = @currentsess[0..5,7];
@newsess[6,8..31] = map {$oldsess[$_] + $currentsess[$_]} (6,8..31);
> for ($n = 32; $n < 34; $n++) {
> unless (!@currentsess[$n]) {
BTW, avoid double negation if you can. It's confusing!
if ($currentsess[$n]) {
says better what is going on
> @newsess[$n] = @currentsess[$n];
> }
> else {
> @newsess[$n] = @oldsess[$n];
> }
> }
Again there is a short way:
@newsess[32,33] = map {$currentsess[$_] || $oldsess[$_]} (32,33);
>
> #Format info for return to archive
> push @updatearchive, join "\t", @newsess[0..33];
> return;
> }
>
> Any problems or tips you see or have would be appreciated.
I would also suggest to rename the variables.
As the subroutine name explains that you are handling with player
archives, it's not really necessary to over emphasize it also with the
variables.
Just call them as
@new, @old and @current.
That's why we write subroutines,
to make code more compact and easier to understand.
(In fact, the other style is harder to read as there are so many confusing
characters looking all the same 'sess' and more harder to type, I mistyped
a lot when I wrote it)
>
> Thanks,
> Brad
Best Wishes,
Janek
------------------------------
Date: Sun, 11 May 2003 13:57:27 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: stat and underscore in file name
Message-Id: <3ebe5606.123201638@news.erols.com>
big__smile@hotmail.com (big__smile) wrote:
: i have a problem when i use stat($file) if $file has a filename with
: underscore it stuffs up and says use of uninitialized value
Not enough details. stat($file) should only cause uninitialized value
warnings if $file itself is undefined. Post a short sample that
exhibits the problem.
------------------------------
Date: Sun, 11 May 2003 15:58:45 +1000
From: "David G" <DavidG997@yahoo.com>
Subject: Try to find a hash element but no luck
Message-Id: <b9m3i8$kq6ut$1@ID-82947.news.dfncis.de>
I have a defined hash loaded as follows:
while($leng= sysread(F, $buf, 16))
{
($host, $ip,$ip1,$ip2,$ip3) = unpack("a12C4",$buf) ;
$hashhost =~ s/(^..*\b).*/$1/ ;
$value = "$ip.$ip1.$ip2.$ip3" ;
$hash{$host} = $value;
}
%database= %hash;
i'm using the following code to find a hash element but I can't get it to
find it - it's there alright
if (exists $database{$inphost})
{
print "\nfound hash element\n";
}
else
{
print "\nHash element not found\n";
}
Will using the large C and not the small c casue this ?
If not how to do I find it ?
TIA
------------------------------
Date: Sun, 11 May 2003 16:20:18 +1000
From: "David G" <DavidG997@yahoo.com>
Subject: Re: Try to find a hash element but no luck
Message-Id: <b9m46u$keblv$1@ID-82947.news.dfncis.de>
Don't worry I've fixed the mistake . .
: $hashhost =~ s/(^..*\b).*/$1/ ;
should have read
: $host =~ s/(^..*\b).*/$1/ ;
David G <DavidG997@yahoo.com> wrote in message
news:b9m3i8$kq6ut$1@ID-82947.news.dfncis.de...
: I have a defined hash loaded as follows:
:
: while($leng= sysread(F, $buf, 16))
: {
: ($host, $ip,$ip1,$ip2,$ip3) = unpack("a12C4",$buf) ;
: $hashhost =~ s/(^..*\b).*/$1/ ;
: $value = "$ip.$ip1.$ip2.$ip3" ;
: $hash{$host} = $value;
: }
: %database= %hash;
:
: i'm using the following code to find a hash element but I can't get it to
: find it - it's there alright
:
: if (exists $database{$inphost})
: {
: print "\nfound hash element\n";
: }
: else
: {
: print "\nHash element not found\n";
: }
: Will using the large C and not the small c casue this ?
: If not how to do I find it ?
:
: TIA
:
:
:
------------------------------
Date: Mon, 12 May 2003 00:52:15 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: Why is POE idle most of the time?
Message-Id: <slrnbbts1t.1hhb.troc@eyrie.homenet>
On 5 May 2003 21:39:03 -0700, jtd wrote:
> Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3EB6C298.A2624B35@earthlink.net>...
>> jtd wrote:
>> >
>> > I wrote a simple test script using POE that created a single session
>> > with a single handler that simply incremented a counter (0..1000) and
>> > then yielded to itself. The script took 10s to run. When I profiled
>> > it, dprofpp showed that the total user+system time was less than 0.8s.
>> >
>> > What is happening here? Shouldn't POE use as much CPU time as the OS
>> > scheduler allows?
>> >
>> > Jtd
>>
>> Maybe there were other things running on your computer?
>
> Nothing intensive, the CPU was mostly idle according to top. Could it
> be that POE's scheduler has fixed (time) resolution?
Chances are good you're running Linux. Before POE 0.26 (released
yesterday), there was a work-around for older Linux kernels that
incurred a heavy penalty on those systems.
Version 0.26 removes the work-around, increasing performance a lot on
Linux systems. Give it a try with the latest release. Thanks!
-- Rocco Caputo - troc@pobox.com - http://poe.perl.org/
------------------------------
Date: Sun, 11 May 2003 11:53:13 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "ldd" <ddl76@singnet.com.sg>
Subject: Re: Why Perl is so difficult to learn?
Message-Id: <c092104fc32c8cb0d15a0efe9d0547c7@TeraNews>
>>>>> "ldd" == ldd <ddl76@singnet.com.sg> writes:
ldd> 3) If I want to swap the positions of entire word ending with "ood" and
ldd> "uter", can anyone provide and example?
ldd> $line = "this is a good testing computer";
Given the subject line, and the other parts of this message, and
this particular "odd" request and requirement...
... I smell homework.
Please don't answer this, people.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 12 May 2003 01:14:09 +0800
From: "ldd" <ddl76@singnet.com.sg>
Subject: Re: Why Perl is so difficult to learn?
Message-Id: <b9lvpp$ccm$1@mawar.singnet.com.sg>
Yes u are right.. I was trying very hard to learn Perl and was figuring out
ways to swap words in a string.
Thanks for all your help. I am very grateful for it.
"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:c092104fc32c8cb0d15a0efe9d0547c7@TeraNews...
> >>>>> "ldd" == ldd <ddl76@singnet.com.sg> writes:
>
> ldd> 3) If I want to swap the positions of entire word ending with "ood"
and
> ldd> "uter", can anyone provide and example?
>
> ldd> $line = "this is a good testing computer";
>
> Given the subject line, and the other parts of this message, and
> this particular "odd" request and requirement...
>
> ... I smell homework.
>
> Please don't answer this, people.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!
------------------------------
Date: 11 May 2003 17:49:28 GMT
From: Galen Menzel <galen@alumni.utexas.net>
Subject: Re: Why Perl is so difficult to learn?
Message-Id: <slrnbbt3hi.sj.galen@localhost.localdomain>
In article <b9lvpp$ccm$1@mawar.singnet.com.sg>, ldd wrote:
> Yes u are right.. I was trying very hard to learn Perl and was figuring out
> ways to swap words in a string.
>
> Thanks for all your help. I am very grateful for it.
>
>
> "Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
> news:c092104fc32c8cb0d15a0efe9d0547c7@TeraNews...
>> >>>>> "ldd" == ldd <ddl76@singnet.com.sg> writes:
>>
>> ldd> 3) If I want to swap the positions of entire word ending with "ood"
> and
>> ldd> "uter", can anyone provide and example?
>>
>> ldd> $line = "this is a good testing computer";
>>
>> Given the subject line, and the other parts of this message, and
>> this particular "odd" request and requirement...
>>
>> ... I smell homework.
Hmm... I just smell confusion. And I think it's me.
galen
------------------------------
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 4972
***************************************