[27904] in Perl-Users-Digest
Perl-Users Digest, Issue: 9268 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 8 18:05:47 2006
Date: Thu, 8 Jun 2006 15:05:08 -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 Thu, 8 Jun 2006 Volume: 10 Number: 9268
Today's topics:
Re: Active Perl Package Installation razmaspaz@gmail.com
filename charset and internal Perl utf8 <ynleder@nspark.org>
Re: filename charset and internal Perl utf8 <jl_post@hotmail.com>
Help with PDK benjamin.m.morley@gmail.com
How to mark UTF-8 string as being UTF-8 <ynleder@nspark.org>
Merging a blank hash <dbasch@yahoo.com>
Re: Merging a blank hash <simon.chao@fmr.com>
Re: Merging a blank hash <dbasch@yahoo.com>
Re: Merging a blank hash <simon.chao@fmr.com>
Re: Multiple Line output using Win32::Printer <veatchla@yahoo.com>
Re: Multiple Line output using Win32::Printer <goodcall1@hotmail.dot.com>
Need help <antwonmedford@hotmail.com>
Re: PerlIO omission <blgl@stacken.kth.se>
Re: PerlIO omission <blgl@stacken.kth.se>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Jun 2006 12:41:59 -0700
From: razmaspaz@gmail.com
Subject: Re: Active Perl Package Installation
Message-Id: <1149795718.958780.29780@u72g2000cwu.googlegroups.com>
For anyone who cares, the problem was that I did not have the http://
at the beginning of my proxy address. This prevented ppm from knowing
how to connect to my proxy server
razmaspaz@gmail.com wrote:
> Thank you all for the help to this point. The problem was threefold.
> First I did not have the theoryx5 in my repository list. Second I did
> not have the proxy configured for ppm.
>
> Third, and this is still a problem, I get this error message:
>
> Error: Failed to download URL http://theoryx5.uwinnipeg.ca/ppms/Crypt-
> SSLeay.ppd: 501 Protocol scheme '' is not supported
>
> I looked at the file that comes down, and I don't know what the scheme
> is. Any thoughts on what this might be?
>
> Thanks,
> Michael
>
>
> Bart Lateur wrote:
> > razmaspaz@gmail.com wrote:
> >
> > >I get the following error:
> > >Error: No valid repositories: Error: 500 Can't connect to
> > >ppm.ActiveState.com:80 (connect: Unknown error)
> > >
> > >I can ping theoryx5 and I can get the url to appear in the browser. Am
> > >I missing something?
> >
> > The fact that that repositiory probably isn't in your list of
> > repositories? Activestate and theoryx5 are different repositories.
> >
> > Use "rep add" in the PPM shell to add it. Something like
> >
> > rep add theoryx5 http://theoryx5.uwinnipeg.ca/ppms/
> >
> > --
> > Bart.
------------------------------
Date: Thu, 8 Jun 2006 20:48:14 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: filename charset and internal Perl utf8
Message-Id: <MPG.1ef28f5a42827f3b989881@news.tiscali.fr>
Hi. I'm under Win with ActivePerl 5.8.8, working on a script to add UTF-
8 support. So, the script is generating an html page with charset=utf-8
and containing a form with an upload file field. The script (the same)
which receives the form submission (POST of multipart/form-data) proceed
with a raw STDIN read, then parsing of the content and decoding to
internal utf8 about all name and value text fields, including the one
containing the filename. Something like this about this code part :
binmode STDIN;
read(STDIN, $data, $ENV{'CONTENT_LENGTH'});
... parsing code here ...
For each name/value pair gathered in a hash :
decode("utf8", $name);
decode("utf8", $value);
Well, it works for every pair except the filename one when ther's an
acccentuated character in the file name.
For example,
- In the form, I select (under Win) : "c:\â.bin"
- I clic sending button
- I receive "c:\â.bin" whatever be the decoding stage.
This is the same with or without decode() :-(
What does it means exactly ?
Does it means that this filename as to be decoded from the current
operating-system's charset ; decode('iso-8859-1', $value) ?
If yes, how to know the client os's charset ?
If no, what to do ?
And, same question but on server-side : do I have to take care of the
current server operating-system's charset for the purpose to create
files with filename in this same charset ?
------------------------------
Date: 8 Jun 2006 14:43:46 -0700
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: filename charset and internal Perl utf8
Message-Id: <1149803026.432616.125610@u72g2000cwu.googlegroups.com>
Yohan N. Leder wrote:
>
> binmode STDIN;
> read(STDIN, $data, $ENV{'CONTENT_LENGTH'});
> ... parsing code here ...
> For each name/value pair gathered in a hash :
> decode("utf8", $name);
> decode("utf8", $value);
Dear Yohan,
I'll offer some input, but please be warned that I am not too
familiar with different encodings and how they work. Therefore, some
of the advice I'll give you might have errors. (Keep that in mind if
someone else offers you advice that contradicts mine.)
That having been said:
After reading through "perldoc Encode" I see that the decode()
function returns a string encoded in Perl's internal form. From what
you posted, it looks like you're doing nothing with the return value.
You may have wanted to modify $name and $value by transforming them
into Perl's internal form. If so, you can do that with this code:
$name = decode("utf8", $name);
$value = decode("utf8", $value);
In your old code, you never actually modified $name and $value.
This might explain why you had the same results with and without
decode().
I don't know if my advice will help, but you may want to consider
trying it anyway. If it works, great! (If it doesn't, well...)
I hope this helps, Yohan.
-- Jean-Luc
------------------------------
Date: 8 Jun 2006 13:22:04 -0700
From: benjamin.m.morley@gmail.com
Subject: Help with PDK
Message-Id: <1149798124.330207.302600@u72g2000cwu.googlegroups.com>
I've recently suffered through a windows meltdown. All of my
programming projects were backed up -- but my perl directory was not.
This, of course, meant I had to reinstall all of my perl packages -- as
well as Perl Development Kit. I updgraded my Perl in the process.
The project I'm working on involves Web Sessioning using CGI-Sessions.
It was working on my old version of Perl. Now, when I run the perl
script (.pl) it appears the CGI Sessioning works (it generates the ID
in the MySQL table) -- but after I compile it using PDK (Perlapp) it
does not work. Any suggestions?
I get no errors when compiling the pl.
Here's the relevant code.
use DBI;
use Time::localtime;
use Carp::Heavy;
use DBD::mysql;
use CGI;
use Apache::DBI;
use CGI::Session;
use CGI::Session::MySQL;
use CGI::Session::ID::md5;
use CGI::Session::Serialize::default;
#database connection handle
my $dbh = DBI->connect("dbi:$dbms:$db:$server",
$username,
$pword,
{
PrintError => 0,
RaiseError => 1,
AutoCommit => 0
}
);
my $cgi = new CGI;
## cgi object
my $sid = $cgi->param('CGISESSID') || undef; ## get the
session ID
my $session = new CGI::Session("driver:mysql", undef,
{Handle=>$dbh});
------------------------------
Date: Fri, 2 Jun 2006 19:44:39 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: How to mark UTF-8 string as being UTF-8
Message-Id: <MPG.1eea976e246b0b15989872@news.tiscali.fr>
Hi,
In a script I'm reviewing to support UTF-8 everywhere ("use utf8",
"binmode STDOUT, ':utf8'", generated html's content-type as utf8), I'm
parsing STDIN containing form data (urlencoded or multipart ones). This
part of code is starting with the usual :
binmode STDIN; # raw while it may, eventually, contain binary data
read (STDIN, $data, $ENV{CONTENT_LENGTH});
... here parsing code ...
But, the text fields values pairs are not recognized as being UTF-8
after parsing (a print show two chars rathers than one accentuated char)
even if they are. So, how to do to mark these string as being UTF-8 (not
any conversion to do, since they already are UTF-8 catched from raw
read)?
And, of course, I can't do a "binmode STDIN, ':utf8'" due to the
presence of binary/text mixing in STDIN.
------------------------------
Date: 8 Jun 2006 13:03:06 -0700
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Merging a blank hash
Message-Id: <1149796986.065783.162550@j55g2000cwa.googlegroups.com>
If I am merging a blank hash into a populated hash how do I prevent
blank key/value pairs from being created?
This:
my %hash1 = ();
my %hash2 = (
key1 => 'cat',
key2 => 'dog'
);
my %hash3 = (%hash1, %hash2);
while (my ($key, $value) = each(%hash3)) {
print "$key: $value\n\n";
}
outputs:
-----------------
key2: dog
key1: cat
------------------
Thanks Everyone,
Derek Basch
------------------------------
Date: 8 Jun 2006 13:07:43 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: Merging a blank hash
Message-Id: <1149797263.484761.10460@h76g2000cwa.googlegroups.com>
Derek Basch wrote:
> If I am merging a blank hash into a populated hash how do I prevent
> blank key/value pairs from being created?
>
> This:
>
> my %hash1 = ();
> my %hash2 = (
> key1 => 'cat',
> key2 => 'dog'
> );
>
> my %hash3 = (%hash1, %hash2);
>
> while (my ($key, $value) = each(%hash3)) {
> print "$key: $value\n\n";
> }
>
> outputs:
> -----------------
> key2: dog
>
> key1: cat
>
> ------------------
Are you sure the newlines aren't from the extra newline you are
printing out after the value?
------------------------------
Date: 8 Jun 2006 13:14:07 -0700
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Re: Merging a blank hash
Message-Id: <1149797647.676843.312990@y43g2000cwc.googlegroups.com>
it_says_BALLS_on_your forehead wrote:
> Derek Basch wrote:
> > If I am merging a blank hash into a populated hash how do I prevent
> > blank key/value pairs from being created?
> >
> > This:
> >
> > my %hash1 = ();
> > my %hash2 = (
> > key1 => 'cat',
> > key2 => 'dog'
> > );
> >
> > my %hash3 = (%hash1, %hash2);
> >
> > while (my ($key, $value) = each(%hash3)) {
> > print "$key: $value\n\n";
> > }
> >
> > outputs:
> > -----------------
> > key2: dog
> >
> > key1: cat
> >
> > ------------------
>
> Are you sure the newlines aren't from the extra newline you are
> printing out after the value?
OMG. Sulks away in idiocy. Thanks. Sorry.
------------------------------
Date: 8 Jun 2006 13:30:31 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: Merging a blank hash
Message-Id: <1149798631.120971.109450@i40g2000cwc.googlegroups.com>
Derek Basch wrote:
> it_says_BALLS_on_your forehead wrote:
> > Derek Basch wrote:
> > > If I am merging a blank hash into a populated hash how do I prevent
> > > blank key/value pairs from being created?
> > >
> > > This:
> > >
> > > my %hash1 = ();
> > > my %hash2 = (
> > > key1 => 'cat',
> > > key2 => 'dog'
> > > );
> > >
> > > my %hash3 = (%hash1, %hash2);
> > >
> > > while (my ($key, $value) = each(%hash3)) {
> > > print "$key: $value\n\n";
> > > }
> > >
> > > outputs:
> > > -----------------
> > > key2: dog
> > >
> > > key1: cat
> > >
> > > ------------------
> >
> > Are you sure the newlines aren't from the extra newline you are
> > printing out after the value?
>
> OMG. Sulks away in idiocy. Thanks. Sorry.
Are you sure you don't mean "skulks"? ;-).
No worries. I've done LOTS of idiotic things, and I've only been in the
business for 2 years.
------------------------------
Date: 8 Jun 2006 14:00:27 -0700
From: "l v" <veatchla@yahoo.com>
Subject: Re: Multiple Line output using Win32::Printer
Message-Id: <1149800427.838297.218040@u72g2000cwu.googlegroups.com>
Jack D wrote:
> I'm trying to output mutilple lines to a printer using Win32::Printer. I
> have only suceeded in printing one line so far. Does anyone know how force
> it to print multiple lines? The output is shows rectangles in between each
> word.
>
> Sample code below
>
> use strict;
> use Win32::Printer;
> my @array = keys %ENV;
>
> printMultiple();
>
> sub printMultiple {
> my $dc = new Win32::Printer( papersize => A4,
> description => 'Test,
> unit => 'mm') or die "Failed to
> create printer object";
> if ($dc) {
> my $textToPrint = join("\r\n",@oldarray);
> my $font = $dc->Font('Times New Roman', 12);
> $dc->Font($font);
> $dc->Color(0, 0, 0);
> $dc->Write($textToPrint, 10, 10);
> $dc->Close;
> }
> }
> __END__
>
> Jack
>
>
What does you print show when you change the "\r\n" in the join to ':'?
my $textToPrint = join(':',@oldarray);
--
Len
------------------------------
Date: Thu, 08 Jun 2006 21:37:37 GMT
From: "Jack D" <goodcall1@hotmail.dot.com>
Subject: Re: Multiple Line output using Win32::Printer
Message-Id: <BM0ig.24616$771.22206@edtnps89>
"l v" <veatchla@yahoo.com> wrote in message
news:1149800427.838297.218040@u72g2000cwu.googlegroups.com...
> Jack D wrote:
> > I'm trying to output mutilple lines to a printer using Win32::Printer. I
> > have only suceeded in printing one line so far. Does anyone know how
force
> > it to print multiple lines? The output is shows rectangles in between
each
> > word.
> >
> > Sample code below
> >
> > use strict;
> > use Win32::Printer;
> > my @array = keys %ENV;
> >
> > printMultiple();
> >
> > sub printMultiple {
> > my $dc = new Win32::Printer( papersize => A4,
> > description => 'Test,
> > unit => 'mm') or die "Failed
to
> > create printer object";
> > if ($dc) {
> > my $textToPrint = join("\r\n",@oldarray);
> > my $font = $dc->Font('Times New Roman', 12);
> > $dc->Font($font);
> > $dc->Color(0, 0, 0);
> > $dc->Write($textToPrint, 10, 10);
> > $dc->Close;
> > }
> > }
> > __END__
> >
> > Jack
> >
> >
>
> What does you print show when you change the "\r\n" in the join to ':'?
> my $textToPrint = join(':',@oldarray);
Is this a trick question? It prints the colon of course.
Jack
------------------------------
Date: 8 Jun 2006 13:33:53 -0700
From: "perl newbie" <antwonmedford@hotmail.com>
Subject: Need help
Message-Id: <1149798833.544921.327520@g10g2000cwb.googlegroups.com>
Hello, I am attempting to build a page that uses a cgi script to
extract info from
a delimited text file database and then place it into an html file for
viewing (see files below.) The database will contain "tips for the
day" and is
arranged in four fields containing the month, day, year, and tip or
event
info (I have "dummy data" in it now.). The script gets the current
date and compares it to the date listed for the tip. If they match it
extracts that record and prints it. I
compare the month and the date but not the year. There is a foreach
loop
used for iteration. My script works well with the sample data that I
have
when the cgi script is run.
I use a WYSIWYG web program called "Webpagemaker." I can draw a box
then
click in it and paste my html content or script in it. I have a
limited
knowledge of cgi and html and I don't know how to properly insert the
cgi
script into my html page. On my html page listed below, I simply typed
in
the result in the box but I want that info generated by the cgi instead
so
that it will change daily. In other words, I need to "marry" the cgi
script
to my html page.
Questions:
1) How might I achieve the aforementioned task? I have tried both
<!--#include virtual="/cgi-bin/tips.cgi"--> and <!--#exec
cgi="/cgi-bin/tips.cgi" -->
With both I get "[an error occurred while processing this directive]"
The only thing I can come up with is maybe lycos/tripod doesn't suport
SSI. When the site is finally finished, it will be hosted on
doteasy.com using a plan that does support SSI..
2) As a second option, I tried to put the html in the cgi page itself
and do everything from it. I get it to output on the page but I don't
knoe how to place the outputted text where I want (see cgi file below).
Also, when I get this to work, I will have to redirect my users form
the index/html page to the cgi page. Does anyone know the proper perl
syntax to place text where you want on a page and constain it to a
selected area?
3) Also, A hard return must be used after each record in the data text
file
according to my understanding of cgi. Using my file, what if I wanted
my
last field (the tips or event field) to contain let's say a recipe for
the
day instead of a tip for the day. The recipe would consist of more
than one
line. How could all of that be grouped together as one unit since
there
would be a hard return for each line of the recipe?
These are my files:
Html page http://dailytips.tripod.com/index.html
Datbase http://dailytips.tripod.com/cgi-bin/data.txt
Cgi file http://dailytips.tripod.com/cgi-bin/tips.cgi
Thank you in advance for any assistance you might offer me.
------------------------------
Date: Thu, 08 Jun 2006 20:43:11 +0200
From: Bo Lindbergh <blgl@stacken.kth.se>
Subject: Re: PerlIO omission
Message-Id: <e69r3v$1fu$1@news.su.se>
In article <J0Jvn7.988@news.boeing.com>,
Charles DeRykus <ced@blv-sam-01.ca.boeing.com> wrote:
> Bo Lindbergh wrote:
> > Why is there no truncate operation in PerlIO?
> >
>
> There is though: perldoc -f truncate
"PerlIO", not "Perl I/O". There's a difference.
/Bo Lindbergh
------------------------------
Date: Thu, 08 Jun 2006 20:55:49 +0200
From: Bo Lindbergh <blgl@stacken.kth.se>
Subject: Re: PerlIO omission
Message-Id: <e69rrl$1lk$1@news.su.se>
In article <orill3-3dl.ln1@osiris.mauzo.dyndns.org>,
Ben Morrow <benmorrow@tiscali.co.uk> wrote:
> Quoth Bo Lindbergh <blgl@stacken.kth.se>:
> > Why is there no truncate operation in PerlIO?
>
> Err...cos PerlIO's broken? :)
> There seems to be some sort of abstraction of the operation, but systems
> with ftruncate(2) always end up calling it on fileno($FH). :(
And so truncate fails with EBADF in the example below.
{
open(my $fh,">",\my $buffer)
or die "open: $!";
print $fh "Hello, World!\n"
or die "print: $!";
truncate($fh,5)
or die "truncate: $!";
}
This is sad, because truncating a Perl scalar is a perfectly
reasonable thing to want to do.
/Bo Lindbergh
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 9268
***************************************