[26852] in Perl-Users-Digest
Perl-Users Digest, Issue: 8871 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 20 14:05:28 2006
Date: Fri, 20 Jan 2006 11:05:04 -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 Fri, 20 Jan 2006 Volume: 10 Number: 8871
Today's topics:
Re: Maybe difficult for English Users - but I ask anywa <eing@uni-muenster.de>
Re: Maybe difficult for English Users - but I ask anywa <kigar@gmx.net>
Re: Maybe difficult for English Users - but I ask anywa <flavell@ph.gla.ac.uk>
Re: Maybe difficult for English Users - but I ask anywa <eing@uni-muenster.de>
Re: traversing a hash two using serveral conditions <tadmc@augustmail.com>
Re: traversing a hash two using serveral conditions (Anno Siegel)
Updating @BO_FO_Emails from a web page widget <wh2leung@student.cs.uwaterloo.ca>
Re: Updating @BO_FO_Emails from a web page widget <glex_no-spam@qwest-spam-no.invalid>
Re: Updating @BO_FO_Emails from a web page widget <wh2leung@student.cs.uwaterloo.ca>
Re: Updating @BO_FO_Emails from a web page widget <xx087@freenet.carleton.ca>
Re: Updating @BO_FO_Emails from a web page widget <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Jan 2006 12:42:41 +0100
From: Bodo Eing <eing@uni-muenster.de>
Subject: Re: Maybe difficult for English Users - but I ask anyway
Message-Id: <dqqibb$bff$1@sagnix.uni-muenster.de>
Reinhard Glauber wrote:
>
> I fetch an HTML Site, through out all the <> TAGS, so that I get plain text, search for some words and
> save them to a MYSQL Database
>
> That all seems to work except the correct display of "ä" "ö" "ü"
>
> Wörl is saved as Wörl
^^ looks like utf8, but displayed by software set
to display iso-8859-1. *Where* does it look wrong: in your browser, in
your text editor ...?
[ snip]
Bodo
------------------------------
Date: Fri, 20 Jan 2006 13:16:26 +0100
From: "Reinhard Glauber" <kigar@gmx.net>
Subject: Re: Maybe difficult for English Users - but I ask anyway
Message-Id: <43d0d499$0$21025$9b4e6d93@newsread2.arcor-online.net>
DQoiQm9kbyBFaW5nIiA8ZWluZ0B1bmktbXVlbnN0ZXIuZGU+IHNjaHJpZWIgaW0gTmV3c2JlaXRy
YWcgbmV3czpkcXFpYmIkYmZmJDFAc2Fnbml4LnVuaS1tdWVuc3Rlci5kZS4uLg0KPiBSZWluaGFy
ZCBHbGF1YmVyIHdyb3RlOg0KDQo+ID4gV/ZybCBpcyBzYXZlZCBhcyBXw7ZybA0KDQoNCj4gICAg
ICAgICAgICAgICAgICAgICAgXl4gbG9va3MgbGlrZSB1dGY4LCBidXQgZGlzcGxheWVkIGJ5IHNv
ZnR3YXJlIHNldCANCj4gdG8gZGlzcGxheSBpc28tODg1OS0xLiAqV2hlcmUqIGRvZXMgaXQgbG9v
ayB3cm9uZzogaW4geW91ciBicm93c2VyLCBpbiANCj4geW91ciB0ZXh0IGVkaXRvciAuLi4/DQoN
Ci0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0NCg0Kb2ssIHRoZSBQcm9ibGVtIGlzIG5vdCB0aGUgZGF0YWJhc2UsIGFzIGkgZm91bmQgb3V0
Lg0KaWYgaSBtYWtlIGFuIGluc2VydCBzdGF0ZW1lbnQgcmlnaHQgZnJvbSB0aGUgIGxpbnV4LXNo
ZWxsIGl0IHdvcmtzDQoNCmlmIGkgZG93bmxvYWQgdGhlIGh0bWwgc2l0ZSBpbnRvIGEgZmlsZSBh
bmQgbG9vayBhdCBpdCB3aXRoIGRyZWFtd2VhdmVyIEkgYWxzbyBzZWUgV8O2cmwgLg0KDQp0aGF0
IG1lYW5zLi4uLi4uLi4uID8/DQoNCkkgc29sdmVkIHRoZSBQcm9ibGVtICB3aXRoICRodG1sID1+
IHMvw7Yv9i9nczsgDQoNCklzIGl0IHBvc3NpYmxlIHRoYXQgdGhpcyBvY2N1cmVzIGJlY2F1c2Ug
dGhlIFdlYnNpdGUgaGFzIG5vIA0KTUVUQSBIVFRQLUVRVUlWIGNoYXJzZXQgbGluZSBpbiBhbGwg
b2YgdGhlIGh0bWwgcGFnZXM/VGhhbmtz
------------------------------
Date: Fri, 20 Jan 2006 12:54:25 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Maybe difficult for English Users - but I ask anyway
Message-Id: <Pine.LNX.4.62.0601201234130.26103@ppepc55.ph.gla.ac.uk>
On Fri, 20 Jan 2006, Reinhard Glauber wrote:
(in a usenet posting advertised as Content-Type: text/plain;
charset="iso-8859-1")
> "Bodo Eing" <eing@uni-muenster.de> schrieb im Newsbeitrag news:dqqibb$bff$1@sagnix.uni-muenster.de...
> > Reinhard Glauber wrote:
>
> > > Wörl is saved as Wörl
>
>
> > ^^ looks like utf8, but displayed by software set
> > to display iso-8859-1. *Where* does it look wrong: in your browser, in
> > your text editor ...?
>
> ----------------------------------------------------------
>
> ok, the Problem is not the database, as i found out.
> if i make an insert statement right from the linux-shell it works
>
> if i download the html site into a file and look at it with
> dreamweaver I also see Wörl .
>
> that means......... ??
It means you don't appear to have a Perl problem as such.
It also means your "problem space partitioning" skills could use
some tuning...
> I solved the Problem with $html =~ s/ö/ö/gs;
I wouldn't call that a "solution". It's hardly even a decent
workaround. "Kludge", as we say.
> Is it possible that this occures because the Website has no
> META HTTP-EQUIV charset line in all of the html pages?Thanks
You seem to have a question about the WWW.
There's a useful briefing here:
http://www.w3.org/International/O-charset.html
This is off-topic for Perl, but the best solution (if this is an HTTP
context) is to serve documents out with the correct character encoding
specified on their real HTTP Content-type header.
If and only if there is no such specification on the real HTTP header,
then, provided we're talking about text/html content type, it's
permissible to supply it on a meta http-equiv. It's not so simple for
XHTML, however.
Unfortunately there isn't a usenet group dedicated to HTTP protocol,
so the topic gets scattered around in discussions on
comp.infosystems.www.authoring.html, comp.infosystems.www.servers.*
and various other groups in the hierarchy.
In general terms, when you're discussing character encoding problems
on usenet, there are too many things that *can* go wrong when merely
copy/pasting from examples. It's generally useful also to *describe
in words" what you were seeing, and where, e.g "my browser displayed
A-tilde followed by a pilcrow sign" (ideally, staying close to the
reference names of the characters in the unicode database). As it
happens, in this case I think you've managed to get the message over
without that, but I've seen too many cases where it went wrong (take a
look at some of the i18n discussions in the Mozilla bugzilla to see
just how horribly wrong this can get, when different people are
posting differently-encoded Chinese, Russian, whatever, into the same
bug report page).
And I'd have to recommend putting the subject of your posting in the
"Subject:" of your posting. As recommended in the posting guidelines
for this group.
good luck.
------------------------------
Date: Fri, 20 Jan 2006 14:42:06 +0100
From: Bodo Eing <eing@uni-muenster.de>
Subject: Re: Maybe difficult for English Users - but I ask anyway
Message-Id: <dqqpb2$fg2$1@sagnix.uni-muenster.de>
Reinhard Glauber wrote:
> "Bodo Eing" <eing@uni-muenster.de> schrieb im Newsbeitrag news:dqqibb$bff$1@sagnix.uni-muenster.de...
>
>>Reinhard Glauber wrote:
>
>
>>>Wörl is saved as Wörl
>
>
>
>> ^^ looks like utf8, but displayed by software set
>>to display iso-8859-1. *Where* does it look wrong: in your browser, in
>>your text editor ...?
>
>
> ----------------------------------------------------------
>
> ok, the Problem is not the database, as i found out.
> if i make an insert statement right from the linux-shell it works
>
> if i download the html site into a file and look at it with dreamweaver I also see Wörl .
>
> that means......... ??
That your Dreamweaver is set to assume iso-8859-1 as html source
>
> I solved the Problem with $html =~ s/ö/ö/gs;
>
Since you seem to be trying to convert utf-8 to iso-8859-1, don't do it
with self-written regexes because
- you most probably don't need to at all
- if you are sure you know why you want to do it, use the Encode module(s)
> Is it possible that this occures because the Website has no
> META HTTP-EQUIV charset line in all of the html pages?Thanks
No need for more typing here, please read Alan's reply.
Bodo
------------------------------
Date: Fri, 20 Jan 2006 06:19:10 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: traversing a hash two using serveral conditions
Message-Id: <slrndt1l9u.cb6.tadmc@magna.augustmail.com>
Me <me@invalid.domain> wrote:
> Snippet of what I have so far:
If you say so.
> if ($day == $) {
^^
^^ what's that?
Post real code if you want real help.
Have you seen the Posting Guidelines that are posted here frequently?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Jan 2006 12:37:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: traversing a hash two using serveral conditions
Message-Id: <dqqlj6$54p$1@mamenchi.zrz.TU-Berlin.DE>
Me <me@invalid.domain> wrote in comp.lang.perl.misc:
> I have an array of hash with the contains some of the following data:
> Direction
> Name
> Usage
> Day
> Month
> Year
> Protocol
>
>
> From this, I need to get an array of a"Usage" data for a given
> "Protocol" for a x number of "Day"(s), two direcions.
>
> Protocol1 = [45, 67 ,87, 76, 75] : Would be usage for
This would all be much clearer if you had provided a few lines of
example data.
> Snippet of what I have so far:
Please don't post a snippet, post code that we can run and test.
Your code references variables that are nowhere set. How, do you
suppose, should we tell if what you do is right when we don't know
what you are doing?
> ################
> foreach my $p(@$protocols) {
What is in @$protocols? In fact, since you are never using $p in the
code, why is the loop there at all?
>
> foreach my $c ($day1..$day2) {
You are making a lot of passes over @usage: The number of protocols
times the number of days. You should make one pass and extract the
data you need as they come by.
> foreach my $ref (@usage) { #the array with the data
> my $day = $ref->{Day};
> if ($day == $) {
^
Is this supposed to be $c? As it stands, it is a syntax error.
> push(@in_proto,$ref->{Usage})
> if ($ref->{direction} eq "In");
> push(@out_proto,$ref->{Usage})
> if ($ref->{direction} eq "Out");
>
> }
>
> }
>
> }
>
> }
> ################
>
>
> Am I going in the right direction?
I don't know, since neither your prose nor your code make entirely
clear what it is you want. It looks terribly inefficient, but that
may not be a problem.
If I understand your intention, this is one way to do it:
# Set up raw data
my @usage;
while ( <DATA> ) {
@{ $usage[ @usage]}{ qw(
Direction
Name
Usage
Day
Month
Year
Protocol)
} = split;
}
# This hash points to the two possible output arrays
my %inout = (
In => \ my @in_proto,
Out => \ my @out_proto,
);
# Define protocols to watch
my %proto = (
Protocol1 => 1,
Protocol2 => 1,
);
# Define days to watch
my ( $day1, $day2) = ( 1, 14);
# Extract usage data
push @{ $inout{ $_->{ Direction}} }, $_->{ Usage} for
grep $proto{ $_->{ Protocol}},
grep +( $day1 <= $_->{ Day} and $_->{ Day} <= $day2),
@usage;
print "In: (@in_proto)\n";
print "Out: (@out_proto)\n";
__DATA__
In Donald 45 12 6 2000 Protocol1
In Susy 67 12 6 2000 Protocol1
In Gerald 87 12 7 2000 Protocol1
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Fri, 20 Jan 2006 10:35:07 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: Updating @BO_FO_Emails from a web page widget
Message-Id: <Pine.GSO.4.64.0601201023010.22138@cpu02.student.cs.uwaterloo.ca>
The webpage is produced with the following CGI object:
print $query->td(
$query->textarea(-name=>'BOFOEmails',
-onChange=>"saveText( this.form.bo_fo_emails,
this.form.BOFOEmails, this.form.bo_fo_emails )"),
$query->p,
$query->button(-name=>'ADD',
-value=>'Confirm Modifications',
-onClick=>"move(index, this.form.BOFOEmails,
this.form.bo_fo_emails)"),
$query->button(-name=>'REMOVE',
-value=>'Edit Selected Entry',
-onClick=>"edit( this.form.bo_fo_emails,
this.form.BOFOEmails)"));
saveText() is as follows:
function saveText( scroll_list, t_area, listToBeUpdated ) {
alert( listToBeUpdated.name );
// need to know which list to add the value in textarea back into
for(var i = 0; i < scroll_list.options.length; i++) {
if( scroll_list.options[i].selected == true ) {
scroll_list.options[i].text = t_area.value;
break;
}
}
// push new value to the corresponding scrolling_list
// then use this scrolling_list to update the dummylist
if ( listToBeUpdated.name == "bo_fo_emails" ) {
// push ( \@BO_FO_EMAILS, t_area.value );
}
}
Basically, I am trying to remove scroll_list.options[i].text from
@BO_FO_EMAILS and replace it with t_area.value.
Order of elements does matter in BO_FO_EMails. ie.
scroll_list.options[i].text must be in the same relative position as
t_area.value in @BO_FO_EMAILS.
Problem:
push ( \@BO_FO_EMAILS, t_area.value );
gives a javascript error "Error on Page". How do I update @BO_FO_EMAILS
within the javascript function saveText()?
------------------------------
Date: Fri, 20 Jan 2006 10:53:12 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Updating @BO_FO_Emails from a web page widget
Message-Id: <Yz8Af.14$PO5.160@news.uswest.net>
William wrote:
> The webpage is produced with the following CGI object:
WTF is a 'web page widget'?
>
>
> print $query->td(
> $query->textarea(-name=>'BOFOEmails',
> -onChange=>"saveText( this.form.bo_fo_emails,
> this.form.BOFOEmails, this.form.bo_fo_emails )"),
>
>
> saveText() is as follows:
>
> function saveText( scroll_list, t_area, listToBeUpdated ) {
> if ( listToBeUpdated.name == "bo_fo_emails" ) {
> // push ( \@BO_FO_EMAILS, t_area.value );
> }
> }
>
>
> Basically, I am trying to remove scroll_list.options[i].text from
> @BO_FO_EMAILS and replace it with t_area.value.
Basically, your saveText is Javascript, and you are trying to use
perl in your Javascript, which doesn't work, as you have discovered.
>
> Order of elements does matter in BO_FO_EMails. ie.
> scroll_list.options[i].text must be in the same relative position as
> t_area.value in @BO_FO_EMAILS.
BO_FO_EMAILS is a perl structure, scroll_list is a Javascript method,
they're not at all related or accessible from each other.
>
>
> Problem:
> push ( \@BO_FO_EMAILS, t_area.value );
Bigger problem: using perl in Javascript. Write Javascript in your
Javascript, and perl on the server side.
>
> gives a javascript error "Error on Page". How do I update @BO_FO_EMAILS
> within the javascript function saveText()?
You don't. I'm guessing, but it looks like you want to know the
values of the BOFOEmails form element, that's set in your Web page,
in your CGI. That's handled by your CGI, not by the Javascript.
Possibly:
my @values = $query->param( 'BOFOEmails' );
I'd suggest reading up on CGI and Javascript and learning when and
why each is useful. There's obviously a lot of confusion here, which
makes it difficult to provide an answer.
------------------------------
Date: Fri, 20 Jan 2006 12:25:22 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: Re: Updating @BO_FO_Emails from a web page widget
Message-Id: <Pine.GSO.4.64.0601201221100.22138@cpu02.student.cs.uwaterloo.ca>
On Fri, 20 Jan 2006, J. Gleixner wrote:
> William wrote:
>> The webpage is produced with the following CGI object:
>
> WTF is a 'web page widget'?
a form element.
>>
>> print $query->td(
>> $query->textarea(-name=>'BOFOEmails',
>> -onChange=>"saveText( this.form.bo_fo_emails,
>> this.form.BOFOEmails, this.form.bo_fo_emails )"),
>
>>
>>
>> saveText() is as follows:
>>
>> function saveText( scroll_list, t_area, listToBeUpdated ) {
>
>> if ( listToBeUpdated.name == "bo_fo_emails" ) {
>> // push ( \@BO_FO_EMAILS, t_area.value );
>> }
>> }
>>
>>
>> Basically, I am trying to remove scroll_list.options[i].text from
>> @BO_FO_EMAILS and replace it with t_area.value.
>
> Basically, your saveText is Javascript, and you are trying to use
> perl in your Javascript, which doesn't work, as you have discovered.
>
>>
>> Order of elements does matter in BO_FO_EMails. ie.
>> scroll_list.options[i].text must be in the same relative position as
>> t_area.value in @BO_FO_EMAILS.
>
> BO_FO_EMAILS is a perl structure, scroll_list is a Javascript method,
> they're not at all related or accessible from each other.
>
>>
>>
>> Problem:
>> push ( \@BO_FO_EMAILS, t_area.value );
>
> Bigger problem: using perl in Javascript. Write Javascript in your
> Javascript, and perl on the server side.
>
>>
>> gives a javascript error "Error on Page". How do I update @BO_FO_EMAILS
>> within the javascript function saveText()?
>
> You don't. I'm guessing, but it looks like you want to know the
> values of the BOFOEmails form element, that's set in your Web page,
> in your CGI. That's handled by your CGI, not by the Javascript.
>
> Possibly:
>
> my @values = $query->param( 'BOFOEmails' );
>
> I'd suggest reading up on CGI and Javascript and learning when and
> why each is useful. There's obviously a lot of confusion here, which
> makes it difficult to provide an answer.
I have tried my @values = $query->param( 'BOFOEmails' );
before my first post. Unfortunately, I only got the outdated values
before the perl script was run. When the Perl script had finished
running, the user makes an update on the form elements using client-side
javascript; but the updated values needs to be reflected on a server-side
text file.
i.e. the newest values need to be input to @BO_FO_EMAILS.
How do I pick up the updated client-side values, and use such values to
update the server side text file?
------------------------------
Date: 20 Jan 2006 18:34:14 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Updating @BO_FO_Emails from a web page widget
Message-Id: <slrndt2b96.lha.xx087@smeagol.ncf.ca>
At 2006-01-20 12:25PM, William <wh2leung@student.cs.uwaterloo.ca> wrote:
> I have tried my @values = $query->param( 'BOFOEmails' );
>
> before my first post. Unfortunately, I only got the outdated values
> before the perl script was run. When the Perl script had finished
> running, the user makes an update on the form elements using client-side
> javascript; but the updated values needs to be reflected on a server-side
> text file.
>
> i.e. the newest values need to be input to @BO_FO_EMAILS.
>
> How do I pick up the updated client-side values, and use such values to
> update the server side text file?
The user has to submit the form. Until then, the server (i.e. your cgi)
will not have any knowledge about values changed by javascript.
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: Fri, 20 Jan 2006 12:44:29 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Updating @BO_FO_Emails from a web page widget
Message-Id: <icaAf.1$Ap5.169@news.uswest.net>
William wrote:
> I have tried my @values = $query->param( 'BOFOEmails' );
>
> before my first post. Unfortunately, I only got the outdated values
> before the perl script was run. When the Perl script had finished
> running, the user makes an update on the form elements using client-side
> javascript; but the updated values needs to be reflected on a
> server-side text file.
>
> i.e. the newest values need to be input to @BO_FO_EMAILS.
>
> How do I pick up the updated client-side values, and use such values to
> update the server side text file?
The client has to send information to the server.
This has nothing to do with perl though.
To simplify things a bit, the interaction goes roughly like this:
1. Client submits information to your URL and the Web
server executes your CGI.
2. Your CGI reads/processes input, and returns the HTML, which is
displayed by the client.
3. Go to step 1.
The CGI knows nothing about the client, until the client sends
information. The client knows nothing about the CGI until the
CGI sends information.
I suppose you could look at using AJAX, for something more dynamic,
however, again, I strongly suggest that you learn about client vs
server-side applications before posting. Once you understand
how they interact, you should be able to code it correctly and you
could post your perl code if you're having problems getting it to
do what you want.
------------------------------
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 8871
***************************************