[21918] in Perl-Users-Digest
Perl-Users Digest, Issue: 4122 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 14 21:06:23 2002
Date: Thu, 14 Nov 2002 18:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 14 Nov 2002 Volume: 10 Number: 4122
Today's topics:
Re: Binary Deployment for Perl? <pkent77tea@yahoo.com.tea>
Checking whether a block of tcp ports/sockets are in us (Gudolf)
Re: Checking whether a block of tcp ports/sockets are i (Walter Roberson)
Re: Checking whether a block of tcp ports/sockets are i <mgjv@tradingpost.com.au>
Re: code comprehension tools <pkent77tea@yahoo.com.tea>
Re: Copy *.o to a different directory grazz@nyc.rr.com
Creating a pop up HTML page in perl <g0khaasa@cdf.toronto.edu>
Re: Creating a pop up HTML page in perl <tk@WINDOZEdigiserv.net>
Re: Creating a pop up HTML page in perl <tk@WINDOZEdigiserv.net>
Re: Creating a pop up HTML page in perl <jurgenex@hotmail.com>
Re: Fields in /etc/passwd (Alan Barclay)
Re: Help Using Crypt() <matthew.garrish@sympatico.ca>
Re: how do I turn off unicode on file I/O? (Jamie Zawinski)
Re: How to get rid of <p> and <br> displayed in textare <nobody@noplace.com>
Re: How to get rid of <p> and <br> displayed in textare <tassilo.parseval@post.rwth-aachen.de>
Is Perl capable to write and read Word file or Excel fi (Colin Smith)
Re: Is Perl capable to write and read Word file or Exce <comdog@panix.com>
Re: Is Perl capable to write and read Word file or Exce <trh411@earthlink.net>
Re: Multiple calls to pl script (Jay Tilton)
Re: newbie to perl: printing literals(constants). <bongie@gmx.net>
Partial matching of keys in a hash: Would this code wor <dragnet@internalysis.com>
perl and js <g-preston1@ti.com>
Perl Regular Expression esantosa@student.bond.edu.au
Re: Possible solution for too long list problem request <bongie@gmx.net>
Re: Possible solution for too long list problem request <bongie@gmx.net>
Re: Sending veriables to pl script using hyperlinks (Jay Tilton)
Socket dropping packets <jeff@jeffs-place.org>
Re: write to file <tassilo.parseval@post.rwth-aachen.de>
Re: write to file (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Nov 2002 00:02:21 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Binary Deployment for Perl?
Message-Id: <pkent77tea-7B5195.00021615112002@news-text.blueyonder.co.uk>
In article <9acc2ac1.0211132139.7f7ab07@posting.google.com>,
peterwu@hotmail.com (Peter Wu) wrote:
> pkent <pkent77tea@yahoo.com.tea> wrote:
> > In article <9acc2ac1.0211130136.3fa250ce@posting.google.com>,
> > peterwu@hotmail.com (Peter Wu) wrote:
> I work with ASP for many years and also play with ASP.NET for now.
Right, so you're not trying to learn programming _and_ perl _and_ a new
business all at the same time - good stuff :-)
<stuff about legalities and licences>
> Well, you are talking about legal license issue. Currently, I don't
> think we're involving any legal issue yet. I wanted to know how
> _technically_ we can wrap up our source code into a binary format so
> that we can deploy the binary to customers' site and have Perl call
> the binary then.
yeah it can be done, by a few tools, but you don't have to make
something binary to protect it. Maybe we have 2 separate issues (maybe
not)
1) You want to ensure your work is used only by your customers, within
the licence, and they don't try to steal your intellectual property
2) You want to hide your source from the customer
Making a binary object would help with both, potentially, whereas a
properly written licence would only help with the first. Do note that
many large and rich-ish organizations release human-readable source code
that is NOT open source in any way. Examples would be the header files
on Solaris, headers from Apple, and the Oracle developer sources, for
example.
In any case perl can indeed be squidged in an assortment of way but as I
have no experience, personally, of these things I hope other posters can
give you pointers and help with exact tools.
> However, your response reminds me of some questions:
> Can a Perl program call a binary C lib or something like that?
Sure, many of Perl's most fab modules have a heart written in C: the
XML::Parser stuff, GD, Storable, Data::Dumper, to name a few. You can
use a tool like SWIG to make the joining of Perl and C even easier
(beware, it can be non-trivial to do it sometimes). Your perl script
calls 'My::Module::foo()' which is really a call to a routine in a C
library.
It's really a very cool thing that allows you to write stuff in C or C++
for speed or linking with existing libraries etc, but you can still use
a nice clever perl script over the top.
> Can you please post the link to the FAQ? I'm pretty new to Perl
> programming. Thanks again! :)
Try this at your command line:
perldoc -q hide
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 14 Nov 2002 16:33:32 -0800
From: a_skoe@hotmail.com (Gudolf)
Subject: Checking whether a block of tcp ports/sockets are in use
Message-Id: <d9e62d23.0211141633.6c3df98a@posting.google.com>
in perl, how do i detect whether a specific tcp socket/port is in use?
i know i can invoke 'netstat' and parse the output, but i'm hoping for
a more elegant solution.
i'm looking for a way to find 100 consecutive ports that are not
currently in use on my localhost.
------------------------------
Date: 15 Nov 2002 01:29:07 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: Checking whether a block of tcp ports/sockets are in use
Message-Id: <ar1il3$4g1$1@canopus.cc.umanitoba.ca>
In article <d9e62d23.0211141633.6c3df98a@posting.google.com>,
Gudolf <a_skoe@hotmail.com> wrote:
:in perl, how do i detect whether a specific tcp socket/port is in use?
:i know i can invoke 'netstat' and parse the output, but i'm hoping for
:a more elegant solution.
:i'm looking for a way to find 100 consecutive ports that are not
:currently in use on my localhost.
For each port in the range, create a socket and bind the port; if the
bind failed, then the port was already in use.
Unfortunately, you then need to pass all the sockets down to the
rest of your program: if you release them at this point, then
another process might grab them. There's no way to lock a port
other than holding it open.
netstat itself works by magic. For example on SGI IRIX, it runs
an IRIX-specific system call to return the kernel address of
netstat-specific kernel structures, and then it opens /dev/kmem
and reads through that part of kernel memory, "just knowing" how
to interpret what's there. Linux probably does things completely
differently. You are unlikely to find a portable netstat-equivilent.
(Vic's "lsof" C tool tries hard to be portable, but there's just too much
behind-the-scenes details to work without co-operation from the
kernel-writers.)
Note that even if you had a perl way of finding out if the ports were
available -now-, because of the lack of locking, they might not be available
a few jiffies from now.
--
Would you buy a used bit from this man??
------------------------------
Date: Fri, 15 Nov 2002 01:29:24 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Checking whether a block of tcp ports/sockets are in use
Message-Id: <slrnat8jjp.6u4.mgjv@verbruggen.comdyn.com.au>
On 14 Nov 2002 16:33:32 -0800,
Gudolf <a_skoe@hotmail.com> wrote:
> in perl, how do i detect whether a specific tcp socket/port is in use?
>
> i know i can invoke 'netstat' and parse the output, but i'm hoping for
> a more elegant solution.
I don't know of any module that would do this, but I would advise you
to check for yourself, on search.cpan.org.
It would be a highly system specific activity, and is isn't too likely
that someone has written a module.
I'd probably just accept that my code would be unportable, and either
parse lsof or netstat output.
> i'm looking for a way to find 100 consecutive ports that are not
> currently in use on my localhost.
Why do you want to do that? It seems a rather useless thing to do. If
you are planning to get this information, and then start using those
ports, you are opening yourself up to a race condition: By the time
you have finished finding a range like that, something else could have
used one of them.
Why do you care? Why not start at some point, and open the following
100 free ports, whether or not they are consecutive?
Are you sure you even need 100 ports?
Martien
--
|
Martien Verbruggen | That's funny, that plane's dustin' crops
Trading Post Australia | where there ain't no crops.
|
------------------------------
Date: Fri, 15 Nov 2002 00:16:28 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: code comprehension tools
Message-Id: <pkent77tea-3CFBD4.00162715112002@news-text.blueyonder.co.uk>
In article <bNIA9.819016$Ag2.27694866@news2.calgary.shaw.ca>,
"NKarun" <ntk00@hotmail.com> wrote:
> I have a relatively large Linux web application written in C, Perl and shell
> scripts. Are there any tools/techniques/methodologies that can help me
> understand this application?
eww, sounds like fun :-)
Use existing documentation and source code to work out what the public
APIs are between things. Try building a big, high-level block diagram of
the system so you get a vague idea that 'foo.pl' is in the 'data
validation' part of the systems and 'bar.pl' is in 'database updates' or
something. It's probably going to be hard work, so document as you go.
Lots of A4 (or your local equivalent) paper and a pencil would be good.
Then you can work into more specific stuff like:
this shell script runs at 2am as a cron job and invokes this program
with these options, then renames some files.
this perl file is never referenced from anywhere else
this API call assumes that $Foo::bar has already been set to an active
database handle
etc etc
etc
I personally have found that, generally, getting the big idea about a
system is the best thing to do first, working into more and more detail
as I get familiar with the files. Sometimes though it works as a a
bottom-up or middle-out approach :-/
I'd also recommend that you shove all the files into CVS. You might want
to update the code, you see. Writing unit tests and the like would
proabably help you in keeping the code working and in understanding it.
In _every_ single .pl and .pm file make sure 'use strict;' is at the
top. Make sure all C compiles with -Wall, etc. It probably does already,
but it's best to start with the best quality code you can get. Don't get
tripped up by buggy code from the outset.
If you can, try to get info from the author, the maintainer or the
people who comissioned the software. get any docs or specifications you
can lay your hands on - they'll tell you _why_ the software was written
and its intended usage, and that could be a useful insight.
A good text editor with 'Find string across many files' will come in
handy too.
I am nowhere near cynical enough to suggest that you have been given
100,000 lines of badly commented non-ANSI C and highly idiomatic perl,
with no tech specs, no functional specs, no API docs, no profiling data,
no optimization data, no unit tests, and no Makefile.
I can't say a lot more without more details about the application, but I
hope there's a bit of food for thought there.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Fri, 15 Nov 2002 00:14:16 GMT
From: grazz@nyc.rr.com
Subject: Re: Copy *.o to a different directory
Message-Id: <s%WA9.126915$gB.25659333@twister.nyc.rr.com>
Ed Doyle <doyleed@sprynet.com> wrote:
> Is there an easy way inside a perl script to copy all .o
> files from one directory to another?
> I tried something like:
> use File::Copy;
> copy("$DIR1\*\.o" , "$DIR2\*\.o"); which compiled an ran
> but didn't copy any files.
>
Sooner or later you'll have to break down and do:
$ perldoc File::Copy
Which will tell you that copy() doesn't do wildcard
expansion or operate on lists of files.
So find the list of files with glob() and copy each
member of that list in a loop.
And put in some error-checking so the next time
something goes wrong you'll know what happened:
#!/usr/bin/perl
use strict;
use warnings;
my $src = '/home/grazz/perl';
my $dst = '/tmp';
use File::Copy;
for my $file (glob "$src/*.pl") {
copy $file, $dst
or warn "couldn't copy '$file' to '$dst': $!";
}
HTH
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: Fri, 15 Nov 2002 00:52:10 GMT
From: Asad <g0khaasa@cdf.toronto.edu>
Subject: Creating a pop up HTML page in perl
Message-Id: <Pine.LNX.4.30.0211141951590.26842-100000@b375-15.cdf>
How do I make a new HTML page using a perl script. I want it to be a pop
up age. Actually, I have a script, and I am making an HTML page thorough
it. On this page, I have a link checkout, which when clicked opens up a
new pop up HTML page (existing page remains intact as it is) containing
some information.
So my question is, how do I create a pop up HTML page. In Javascript we
can go:
DisplayOrder = window.open("", "_blank", "toolbar=yes, status=no,
width=600, height=800");
How can I do the same in perl?
------------------------------
Date: Fri, 15 Nov 2002 01:43:32 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Creating a pop up HTML page in perl
Message-Id: <hbk8tuc4i7qrm4ngjt0f587q06185skglg@4ax.com>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Fri, 15 Nov 2002 00:52:10 GMT, Asad
<g0khaasa@cdf.toronto.edu> managed to scribble:
| How do I make a new HTML page using a perl script. I want it to be a
| pop up age. Actually, I have a script, and I am making an HTML page
| thorough it. On this page, I have a link checkout, which when clicked
| opens up a new pop up HTML page (existing page remains intact as it
| is) containing some information.
|
| So my question is, how do I create a pop up HTML page. In Javascript
| we can go:
|
| DisplayOrder = window.open("", "_blank", "toolbar=yes, status=no,
| width=600, height=800");
|
| How can I do the same in perl?
|
You can't.
Per's server side, not client side.
Regards,
tk
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPdRRhSjNZg8h4REKEQJWIgCgpFh9MiNNgPo0xEI5nPVxRyaJEy4AoPJv
0mzCxoMhJIKVz3+hiKkoM/mw
=q6la
-----END PGP SIGNATURE-----
--
+--------------------------+
| digiServ Network |
| Web solutions | Remove WINDOZE to reply.
| http://www.digiserv.net/ |
+--------------------------+
------------------------------
Date: Fri, 15 Nov 2002 01:46:57 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Creating a pop up HTML page in perl
Message-Id: <mhk8tu4fu2lr406ainngee4qt331f2lmvm@4ax.com>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Fri, 15 Nov 2002 01:43:32 GMT, tk
<tk@WINDOZEdigiserv.net> managed to scribble:
[snip]
| | So my question is, how do I create a pop up HTML page. In
| | Javascript we can go:
| |
| | DisplayOrder = window.open("", "_blank", "toolbar=yes, status=no,
| | width=600, height=800");
| |
| | How can I do the same in perl?
| |
|
| You can't.
|
| Per's server side, not client side.
Or Perl even =)
tk
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPdRSUyjNZg8h4REKEQLxrwCg6chFmD166IhmsqCLXQ0RrfGBKU0AoLVK
0WE0nEEztPqdjNg3QtchIhVB
=QGqK
-----END PGP SIGNATURE-----
--
+--------------------------+
| digiServ Network |
| Web solutions | Remove WINDOZE to reply.
| http://www.digiserv.net/ |
+--------------------------+
------------------------------
Date: Fri, 15 Nov 2002 01:58:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Creating a pop up HTML page in perl
Message-Id: <RwYA9.25068$6Z.15820@nwrddc01.gnilink.net>
Asad wrote:
> How do I make a new HTML page using a perl script.
You would use the 'print' command or if you are talking about CGI
server-side scripting the CGI module.
> I want it to be a
> pop up age. Actually, I have a script, and I am making an HTML page
> thorough it. On this page, I have a link checkout, which when clicked
> opens up a new pop up HTML page (existing page remains intact as it
> is) containing some information.
>
> So my question is, how do I create a pop up HTML page. In Javascript
> we can go:
>
> DisplayOrder = window.open("", "_blank", "toolbar=yes, status=no,
> width=600, height=800");
>
> How can I do the same in perl?
You could use PerlScript. However this is available for Windows only.
jue
------------------------------
Date: 14 Nov 2002 23:22:27 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Fields in /etc/passwd
Message-Id: <1037316147.65176@elaine.furryape.com>
In article <3DD35512.D03A2E54@earthlink.net>,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>Walter Roberson wrote:
>[snip]
>> UID 11 to 99 Commonly used for uucp logins and 'famous users'.
>
>What's considered a famous user? Folks like Larry Wall, Linus Torvalds,
>Brian Kernighan, Dennis Ritchie, etc.?
Probably only the latter two.
When all of Unix came from Bell labs, it was normal to include certain
users in the passwd file. login accounts like bfk and dmr would therefore
be well known.
Larry & Linus came along far too late for their accounts to be included
in the example file.
------------------------------
Date: Thu, 14 Nov 2002 18:50:36 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Help Using Crypt()
Message-Id: <PFWA9.14690$md7.1235143@news20.bellglobal.com>
"Paanwa" <paanwa@hotmail.com> wrote in message
news:ut7lgu3n189sbb@corp.supernews.com...
> In the Permission denied section I trap the two variables so that I can
> verify their values - each time the two are identical. So, what rule am I
> missing here that prevents "Permission Granted" condition when the two
> variable are indeed equal?
>
Are you absolutely sure they are identical? No trailing white space or
carriage returns being pulled in with the stored password?
Matt
------------------------------
Date: 14 Nov 2002 17:13:37 -0800
From: jwz@jwz.org (Jamie Zawinski)
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <8ef0bdd0.0211141713.59cd260a@posting.google.com>
Benjamin Goldberg wrote:
>
> What happens with the following script:
It does this:
!! imode bytes, omode bytes
## 102 111 246 98 97 114
<< foöbar
!! imode utf8, omode bytes
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately
after start byte 0xf6) in ord at /tmp/c.pl line 14, <FH> line 2 (#1)
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xf6) in ord at /tmp/c.pl line 14, <FH>
line 2.
## 102 111 0
Wide character in print at /tmp/c.pl line 15, <FH> line 2 (#2)
(W utf8) Perl met a wide character (>255) when it wasn't expecting
one. This warning is by default on for I/O (like print) but can
be
turned off by no warnings 'utf8';. You are supposed to explicitly
mark the filehandle with an encoding, see open and
perlfunc/binmode.
<< foöbar
!! imode bytes, omode utf8
## 102 111 246 98 97 114
<< foöbar
!! imode utf8, omode utf8
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately
after start byte 0xf6) in ord at /tmp/c.pl line 14, <FH> line 4 (#1)
## 102 111 0
<< foöbar
------------------------------
Date: Thu, 14 Nov 2002 23:06:18 GMT
From: "Gregory Toomey" <nobody@noplace.com>
Subject: Re: How to get rid of <p> and <br> displayed in textarea after being submitted in a form
Message-Id: <01c28c33$ea159960$b1498a90@gmtoomey>
kjc <kevin@kjcrowley.com> wrote in article
<1fa921fe.0211141304.5e50977f@posting.google.com>...
> I have a form that uses a textarea for input and when the user has
> completed the form the script displays a new page showing them their
> responses.
Try a alt.html. This is Perl newsgroup.
gtoomey
------------------------------
Date: 14 Nov 2002 23:17:15 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: How to get rid of <p> and <br> displayed in textarea after being submitted in a form
Message-Id: <ar1atr$9rb$1@nets3.rz.RWTH-Aachen.DE>
Also sprach kjc:
> I have a form that uses a textarea for input and when the user has
> completed the form the script displays a new page showing them their
> responses. The textarea on this displayed page shows the <br> and <p>
> used on the page. I do have a code that searches and replaces the
><br> and <p> from the variable, and when displayed using "print" it
> works fine. The only time it looks wrong is when displayed in a text
> area. Here is an example of what I am talking about:
>
> http://kjcrowley.com/drforum/example.html
What does the code that - according to you - 'searches and replaces the
<br> and <p> from the variable' actually do? As your example shows, the
tags still show up so obviously it does the wrong thing.
The fact that it seemingly works when you just print it only
demonstrates that both <p> and <br> lead to newlines in the rendered
HTML. In a textarea however things get printed rather literally.
Solution: Get rid of these tags before letting the content of your
variable show up in a textarea. A naive approach for that would be:
$variable =~ s/<br>|<p>//gi;
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: 14 Nov 2002 16:04:34 -0800
From: peibing@hotmail.com (Colin Smith)
Subject: Is Perl capable to write and read Word file or Excel file?
Message-Id: <5a1cd92b.0211141604.7e186977@posting.google.com>
Hi all:
Currently I am using VBscript and ASP to generate a txt file as the
packing slip and attach that txt file to the e-mail purchase order.
But I would like to generate a Word file instead. Is it possible to
use Perl to read and write a Word file?
TIA.
Colin
------------------------------
Date: Thu, 14 Nov 2002 18:17:30 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: Is Perl capable to write and read Word file or Excel file?
Message-Id: <141120021817305591%comdog@panix.com>
In article <5a1cd92b.0211141604.7e186977@posting.google.com>, Colin Smith <peibing@hotmail.com> wrote:
> Currently I am using VBscript and ASP to generate a txt file as the
> packing slip and attach that txt file to the e-mail purchase order.
> But I would like to generate a Word file instead. Is it possible to
> use Perl to read and write a Word file?
http://search.cpan.org
--
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl
<http://www.theperlreview.com>
------------------------------
Date: Fri, 15 Nov 2002 00:18:26 GMT
From: "Tom Hoffmann" <trh411@earthlink.net>
Subject: Re: Is Perl capable to write and read Word file or Excel file?
Message-Id: <m3XA9.117$%a.13422@newsread1.prod.itd.earthlink.net>
On Thu, 14 Nov 2002 16:04:34 +0000, Colin Smith wrote:
> Hi all:
>
> Currently I am using VBscript and ASP to generate a txt file as the
> packing slip and attach that txt file to the e-mail purchase order. But
> I would like to generate a Word file instead. Is it possible to use Perl
> to read and write a Word file?
Not sure about Word, but there's a perl module for creating cross
platform excel binary files. Look for it on CPAN.
------------------------------
Date: Fri, 15 Nov 2002 00:24:46 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Multiple calls to pl script
Message-Id: <3dd43d74.186528048@news.erols.com>
Asad <g0khaasa@cdf.toronto.edu> wrote:
: I am calling this line in my fetchPosters.pl
:
: print "Content-type: text/html\n\n";
:
: It was included in the sample code and seemed to work fine and all before.
:
: Now, that I am calling fetchPosters.pl from another perl script using:
:
: exec 'fetchPosters.pl';
:
: everything works fine (the page is displayed properly) except that I get
: the following text on top of my page (page generated by fetchPosters.pl)
:
: Content-type: text/html
:
: The reason is that the server has already got a header from the first CGI
: script and is faithfully printing out the second "content-type" to STDOUT.
:
: Is there a way I can stop this from happening.
Eliminate one of the statements that is emitting the header.
: That is have it ignore the second "content-type" to STDOUT?
That's just broken thinking.
Don't turn the redundant operation into a do-nothing. Eliminate it.
------------------------------
Date: Fri, 15 Nov 2002 02:26:19 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: newbie to perl: printing literals(constants).
Message-Id: <1909099.tohtuibV4E@nyoga.dubu.de>
seb bean wrote:
> so: perl -e 'print "The price is \$", 100, ., "\n";' will work
> notice commas: ^ ^ ^
It won't work, and it can't work. If you want to print a period, you
must enclude it within (single or double) quotes, like everything else
what is to be printed verbatim.
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
That's our advantage at Microsoft; we set the standards and we can
change them. -- Karen Hargrove, Microsoft, Feb 1993
------------------------------
Date: Fri, 15 Nov 2002 01:32:52 GMT
From: Marc Bissonnette <dragnet@internalysis.com>
Subject: Partial matching of keys in a hash: Would this code work?
Message-Id: <Xns92C6D10907BD9dragnetinternalysisc@206.172.150.14>
Hi all;
I'm just asking out of curiosity here, since I'm almost certain my sample
code below would be waaay too CPU intensive to actually be viable, but
I'm curious to know if it would actually work to match partial keys.
I wrote the example below just for the heck of it in another NG when
someone asked why I couldn't compare submitted city names to a master
list and then present mis-spelled city names back to the user for
correction. Given that the total number of cities in any country is
probably huge, I only wrote this for curiosity's sake and am interested
in opinions from those more knowledgeable than I.
I'm just looking to see if I've got the idea right, not necessarily
whether or not the code is 100% usable, since I do not intend to actually
implement it (mental excercise, I guess)
# get comma separated list of cities from form
$city = $q->param('cities');
# stick em all in an array
@cities = split /\,/,$city;
# cycle through each city to test
for (@cities) {
# set a default of "no match"
$citymatch='nomatch';
while ($citymatch ne 'match') {
# cycle through the master city list to compare against the
# current city in the loop
foreach $key (keys %mastercities) {
# if the current city has had the last char lopped
# off to check for a partial match, use the lopped
# city name instead of the originally submitted
if ($usetempcity==1) {
$citytomatch=$tempcity;
# otherwise use the current full city name in the loop
} else {
$citytomatch=$_;
}
# if it matches, check to see if this is the original
# city name, or if it's been chopped for a partial match
if ($key =~ $citytomatch) {
if ($usetempcity ==1) {
# push the city name into an array to be sent
# back to the user
push @partialmatches,$_;
# reset these two flags to undef to avoid
# false matches
$usetempcity=();
$tempcity=();
} else {
# this city matches the master list
push @matchedcities,$citytomatch;
}
$citymatch = 'match';
} else {
# if there's no match, chop the last character off
# the city name and try again
$tempcity = $_;
chop $tempcity;
# set a flag to let us know to use the modified
# city name in the next matching loop
$usetempcity=1;
}
}
}
}
I didn't put anything in there to deal with the names once all the
content has been chopped out, but I'm sure another couple of lines would
handle that; As mentioned, this is just for my own edification;
Appreciative for any insights offered.
--
-----------------------------
Marc Bissonnette
Internalysis - Intelligence in Internet Communications
http://www.internalysis.com
------------------------------
Date: Thu, 14 Nov 2002 17:33:42 -0600
From: "Jerry Preston" <g-preston1@ti.com>
Subject: perl and js
Message-Id: <ar1brr$iho$1@tilde.itg.ti.com>
Hi!,
I need to use the -onchange in a popup_menu and textfield::
print $query->textfield( -name => 'lot_number',
-default => '',
-size => '7',
-length => '7',
-maxlength => '7',
);
print $query->textfield( -name => 'wafer',
-size => '2',
-length => '2',
-maxlength => '2',
-justificaton => 'right',
);
print $query->popup_menu( -name => 'test_group',
-values => \@{$TABLES::T_TEST_AREAS{
"_\L$fab"."L" }},
-default => "",
-onchange => "
alert(update_form.test_group.options[update_form.test_group.selectedIndex].v
alue);
var lot_number=update_form.lot_number.options[
update_form.lot_number.selectedIndex ].value;
var wafer=update_form.wafer.options[
update_form.wafer.selectedIndex ].value;
var test_group=update_form.test_group.options[
update_form.test_group.selectedIndex ].value;
var engineer=update_form.engineer.options[
update_form.engineer.selectedIndex ].value;
var reg_engineer=update_form.reg_engineer.options[
update_form.reg_engineer.selectedIndex ].value;
var
newLocation='$script?pgm_op=open_job&test_group='+test_group+'&lot_number='+
lot_number+'&wafer='+wafer+'&engineer='+engineer+'®_engineer='+reg_engine
er;
top.location=newLocation;"
);
I am unable to get my lot_number and wafer values to pass. I am sure that
my js code is missing something:
var lot_number=update_form.lot_number.options[
update_form.lot_number.selectedIndex ].value;
var wafer=update_form.wafer.options[
update_form.wafer.selectedIndex ].value;
but I donot know what? Any Ideas??
Thanks,
Jerry
------------------------------
Date: 14 Nov 2002 18:00:39 -0800
From: esantosa@student.bond.edu.au
Subject: Perl Regular Expression
Message-Id: <894a4768.0211141800.796c0c60@posting.google.com>
I am looking for context free grammar defined for Perl Regular Expression.
------------------------------
Date: Fri, 15 Nov 2002 01:24:47 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Possible solution for too long list problem requested.
Message-Id: <2899703.078BfkaQxH@nyoga.dubu.de>
Jan Fure wrote:
> I recently wrote a script which requires user input to pick a
> directory in which to process files. The way to pick one or more
> directories is by inputing a matching string through standard input.
>
> The problem with my script is that if @dirs contains more elements
> than can be displayed on the output terminal (~25-50), the user will
> be required to scroll back (may or may not work depending on terminal
> definition) or know in advance which directory to choose based on
> looking at the directory list.
One suggestion for a text-only solution:
- Show the list page by page (maybe you could find out the number of
lines in the current terminal, or else just show them by blocks of 10
or so, which should be small enough);
- Enumerate the list items;
- Ask the user to enter a corresponding number or 'r' to redisplay, if
s/he didn't remember the right number.
This way, the user need not find a "unique string" for the right entry
and can back up within the list. You can also combine the paging and
the selection:
my $selection = 0;
# one of the rare occasions a C-like for-loop is useful in Perl ;)
DIRLIST: for (my $i=1; $i<=@dirs; $i++) {
printf "%3d) %s\n", $i, $dirs[$i-1];
while ($i % 10 == 0) { # every 10th item, expect a valid input
print ($i == @dirs ?
'[End of list] ' : '<Enter> to continue list, ');
print '<r> to resume or <number> to select a dir: ';
chomp(my $in = <>);
$in =~ s/^\s+//; $in =~ s/\s+$//; # strip whitespace
next DIRLIST if !length($in); # <Enter> -> continnue
if ($in =~ /(\d+)/ && $1 >= 1 && $1 <= @dirs) {
$selection = $1;
last DIRLIST; # dir selected
} elsif (lc $in eq 'r') {
$i = 0;
next DIRLIST; # <r> -> resume
}
}
}
if ($selection >= 0) {
....
> The ideal solution would be some output similar to lynx (the original
> web browser)
Hm-hm. I still think the "original web browser" is NCSA Mosaic. :)
> where the user can browse through the @dirs elements and
> pick one or more elements.
Sounds like an ncurses interface.
> Another solution would be using the
> WIN32::GUI module, and create a dialog where the user picks one or
> more elements.
Or Perl/Tk, or Perl/Qt, ...
> I don't know how to do either, but would be grateful for any
> suggestions.
HTH,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Time is the best teacher; unfortunately it kills all of it's students.
------------------------------
Date: Fri, 15 Nov 2002 02:05:52 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Possible solution for too long list problem requested.
Message-Id: <103734465.Qqyop6cvbt@nyoga.dubu.de>
Harald H.-J. Bongartz wrote:
> if ($in =~ /(\d+)/ && $1 >= 1 && $1 <= @dirs) {
> $selection = $1;
^^^^^ = $1 - 1;
Sorry, classic off-by-one error. ;-)
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"The Law of Self Sacrifice"
When you starve with a tiger, the tiger starves last.
------------------------------
Date: Fri, 15 Nov 2002 00:30:21 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Sending veriables to pl script using hyperlinks
Message-Id: <3dd43efd.186921193@news.erols.com>
Asad <g0khaasa@cdf.toronto.edu> wrote:
: I have the following line in my html file:
:
: <a href="cgi-bin/fetchPosters.pl?var1='music'"
: target="content">Music</a><br/>
:
: and the following in my fetchPosters.pl script
:
: my $userinput = = $cgi->param('var1');
^^^
^^^
What's that?
: However, it doesn't work.
That's a shame.
Change the program so that part that "doesn't work" becomes more like
the part that "does work."
------------------------------
Date: Thu, 14 Nov 2002 23:27:06 GMT
From: "Jeff Walter" <jeff@jeffs-place.org>
Subject: Socket dropping packets
Message-Id: <ejWA9.2066$__1.644@rwcrnsc51.ops.asp.att.net>
I have a Perl program that uses a UDP socket to send and recieve data.
I recieve a list of servers (approx. 1300) that I then query. I have
verified the following with Network Monitor: All the queries go out, about
90% are replied to. However, my Perl program only gets like 20-30 of the
replies. I am getting some errors about $peeraddr being empty, although
there are not enough of the errors to make up for the dropped packets.
Below is my recieve code loop:
do {
$rin = '';
vec($rin, fileno($sock), 1) = 1;
$change = select($rin, undef, undef, 2);
if ($change > 0) {
$peeraddr = recv $sock, $buffer, 65507, 0;
if ((length($buffer) > 0) && (length($peeraddr) == 16)){
($port, $addr) = unpack_sockaddr_in($peeraddr);
$addr = nettoip($addr);
if (isoob($buffer)) {
$buffer = stripoob($buffer);
if (lc(substr($buffer,0,9)) =~ "heartbeat") {
updateserverhash($addr,$port,1);
getserverinfo($peeraddr);
}
if (lc(substr($buffer,0,12)) =~ "inforesponse") {
updateserverhash($addr,$port,2);
}
if (lc(substr($buffer,0,10)) =~ "getservers") {
sendserverhash($peeraddr);
}
if (lc(substr($buffer,0,18)) =~ "getserversresponse") {
$buffer = substr($buffer,18);
rawtoaddrarray($buffer);
}
if (lc(substr($buffer,0,5)) =~ "getid") {
querymaster("192.246.40.56", 27950, "68 empty full demo");
}
}
}
}
} while (1 == 1);
Thanks,
Jeff Walter
jeff@jeffs-place.org
------------------------------
Date: 14 Nov 2002 23:05:18 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: write to file
Message-Id: <ar1a7e$950$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Linux.ie:
> okay thanks all. i got it. By the way Tassilo v. Parseval iam 14 years old,
^^^^^^^^
> dont know much about perl and wanting to learn it so i need to talk to
> people who allready no it.Iam very sorry if i ve done something wrong on the
> is newgroup but i didnt mean it
What did you get? My point was quite simple and should be understood by
a native speaker such as you probably are (as I understand you are from
Ireland). Then 'you didnt mean it' but did it again. How hard can it be
to properly quote? Quoting is a technique of citing what others said by
providing the original wording along with its source. In usenet the
quoted material is commonly prefixed with certain characters, for
instance - and as it can be seen in this article - with these odd
'greater than' signs ('>').
This whining story about being only 14 years old is hardly an excuse.
You feel ready to tackle Perl but fail with the most basic things
imaginable.
Not to mention the more than thoughless typography of yours and the
occasional malfunction of your space key. None of this is necessary but
just leads to a less than non-satisfactory experience of your postings by
others. Read: By those who are supposed to read them and provide
assistance with your problems.
Am I just waisting my time here? Mewonders...
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Thu, 14 Nov 2002 23:17:49 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: write to file
Message-Id: <3dd42d0e.182329254@news.erols.com>
"Linux.ie" <mail@eircom.net> wrote:
: okay thanks all. i got it. By the way Tassilo v. Parseval iam 14 years old,
: dont know much about perl and wanting to learn it so i need to talk to
: people who allready no it.
Get acquainted with the bundled documentation before spraying more
questions on the group.
: Iam very sorry if i ve done something wrong on the
: is newgroup but i didnt mean it
But you're _still_ doing it.
Read the posting guidlines, pronto.
http://mail.augustmail.com/~tadmc/clpmisc.shtml
Pay close attention to the "Use an effective followup style"
subsection.
------------------------------
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 4122
***************************************