[31938] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3201 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 8 18:09:29 2010

Date: Mon, 8 Nov 2010 15:09:10 -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           Mon, 8 Nov 2010     Volume: 11 Number: 3201

Today's topics:
        My perl does not support transliteration? <rxjwg98@gmail.com>
    Re: My perl does not support transliteration? <sbryce@scottbryce.com>
    Re: My perl does not support transliteration? <sherm.pendley@gmail.com>
        Puzzling DTD parsing error with XML::Checker <news@lawshouse.org>
    Re: Puzzling DTD parsing error with XML::Checker <skye.shaw@gmail.com>
    Re: Puzzling DTD parsing error with XML::Checker <tadmc@seesig.invalid>
    Re: Puzzling DTD parsing error with XML::Checker <skye.shaw@gmail.com>
    Re: Puzzling DTD parsing error with XML::Checker sln@netherlands.com
    Re: Puzzling DTD parsing error with XML::Checker <news@lawshouse.org>
        Using Perl to find what address bar says <jwcarlton@gmail.com>
    Re: Using Perl to find what address bar says <sherm.pendley@gmail.com>
    Re: Using Perl to find what address bar says <jurgenex@hotmail.com>
    Re: Using Perl to find what address bar says <sbryce@scottbryce.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 7 Nov 2010 06:54:49 -0800 (PST)
From: fl <rxjwg98@gmail.com>
Subject: My perl does not support transliteration?
Message-Id: <4760a9d1-e1c8-400b-afc9-154728768077@z20g2000pra.googlegroups.com>

Hi,
I am new to perl. I try to use transliteration with the lines:

#!/usr/bin/perl
# matchtest2.plx
use warnings;
use strict;

$_ = '1: A silly sentence (495,a) *BUT* one which will be useful.
(3)';

my $string =~ tr/0123456789/abcdefghij/;

But it respondes back:

Use of uninitialized value in transliteration (tr///) at
matchtest21.plx line 9.


What is wrong with my code? I run perl on WinXP. Thanks.



------------------------------

Date: Sun, 07 Nov 2010 08:05:58 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: My perl does not support transliteration?
Message-Id: <ib6f8r$p0j$1@news.eternal-september.org>

On 11/7/2010 7:54 AM, fl wrote:
> Hi,
> I am new to perl. I try to use transliteration with the lines:
>
> #!/usr/bin/perl
> # matchtest2.plx
> use warnings;
> use strict;
>
> $_ = '1: A silly sentence (495,a) *BUT* one which will be useful.
> (3)';
>
> my $string =~ tr/0123456789/abcdefghij/;
>
> But it respondes back:
>
> Use of uninitialized value in transliteration (tr///) at
> matchtest21.plx line 9.
>
>
> What is wrong with my code? I run perl on WinXP. Thanks.


You are trying to do the transliteration on $string, which does not 
contain a value.


#!/usr/bin/perl
# matchtest2.plx
use warnings;
use strict;

my $string = '1: A silly sentence (495,a) *BUT* one which will be useful.
(3)';

$string =~ tr/0123456789/abcdefghij/;

print $string;



------------------------------

Date: Sun, 07 Nov 2010 10:10:56 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: My perl does not support transliteration?
Message-Id: <m239rdtbi7.fsf@sherm.shermpendley.com>

fl <rxjwg98@gmail.com> writes:

> Hi,
> I am new to perl. I try to use transliteration with the lines:
>
> #!/usr/bin/perl
> # matchtest2.plx
> use warnings;
> use strict;
>
> $_ = '1: A silly sentence (495,a) *BUT* one which will be useful.
> (3)';
>
> my $string =~ tr/0123456789/abcdefghij/;
>
> But it respondes back:
>
> Use of uninitialized value in transliteration (tr///) at
> matchtest21.plx line 9.
>
> What is wrong with my code?

Tr/// only uses $_ when you haven't bound it to a variable with =~.

Since you *have* bound it to $string, the value you've assigned to $_
is irrelevant, and since you haven't assigned a value to $string, you
get the above warning.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Sun, 07 Nov 2010 13:12:22 +0000
From: Henry Law <news@lawshouse.org>
Subject: Puzzling DTD parsing error with XML::Checker
Message-Id: <bIKdnUrQvJIpOEvRnZ2dnUVZ8jOdnZ2d@giganews.com>

I am using XML::Checker to parse a DTD and I'm getting the error that 
means that there are extraneous characters before the XML declaration, 
except that there aren't.  I've searched for this error message and can 
find no cause other than the extraneous characters that I'm sure I don't 
have: I've even looked at the DTD in hex and there's definitely nothing 
there.  Can someone suggest where else to look?

XML::Checker has a date of 2002-07-07 (no version that I can see) and 
here are the XML file, the DTD and a simple test program.

# Test xml file ---------------
henry@eris $ cat tryit.xml
<?xml version="1.0"?>
<!DOCTYPE build SYSTEM "tryit.dtd">

<build name="tryit">
</build>
# Test DTD, showing (as far as I can see) no extraneous characters
henry@eris $ cat tryit.dtd
<?xml version='1.0' encoding='UTF-8'?>
<!ELEMENT build EMPTY>
   <!ATTLIST build name ID #REQUIRED>
# Test Perl program for the above
henry@eris $ cat tryit
#! /usr/bin/perl
use strict;
use warnings;

use XML::Checker::Parser;

my $parser = new XML::Checker::Parser ();
eval {
   local $XML::Checker::FAIL = \&my_fail;
   $parser->parsefile ("tryit.xml");
};
warn "Some problem.  Errors are ...\n", join("\n",$@),"\n" and exit if $@;

sub my_fail {
   my $code = shift;
   XML::Checker::print_error ($code, @_);
}

The resulting error message from "tryit" is:
henry@eris $ ./tryit
Some problem.  Errors are ...
Couldn't parse contents of external DTD <tryit.dtd> :
XML or text declaration not at start of entity at line 2, column 0, byte 
37 at /usr/lib/perl5/XML/Parser.pm line 187


-- 

Henry Law            Manchester, England


------------------------------

Date: Sun, 7 Nov 2010 09:46:58 -0800 (PST)
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: Puzzling DTD parsing error with XML::Checker
Message-Id: <b2c67767-a7a2-4963-9ee8-9cae62846301@z20g2000pra.googlegroups.com>

On Nov 7, 6:12=A0am, Henry Law <n...@lawshouse.org> wrote:
> henry@eris $ cat tryit.dtd
> <?xml version=3D'1.0' encoding=3D'UTF-8'?>
> <!ELEMENT build EMPTY>

That's a DTD not an XML document.


------------------------------

Date: Sun, 07 Nov 2010 12:04:13 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Puzzling DTD parsing error with XML::Checker
Message-Id: <slrniddqud.3s7.tadmc@tadbox.sbcglobal.net>

Skye Shaw!@#$ <skye.shaw@gmail.com> wrote:
> On Nov 7, 6:12 am, Henry Law <n...@lawshouse.org> wrote:
>> henry@eris $ cat tryit.dtd
>> <?xml version='1.0' encoding='UTF-8'?>
>> <!ELEMENT build EMPTY>
>
> That's a DTD not an XML document.


Yes it is.

Is your comment related in any way to the OP's problem?

If so, in what way?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Sun, 7 Nov 2010 16:27:03 -0800 (PST)
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: Puzzling DTD parsing error with XML::Checker
Message-Id: <b8f959d7-37f9-4db7-a3a5-35830227b41e@35g2000prt.googlegroups.com>

On Nov 7, 10:04=A0am, Tad McClellan <ta...@seesig.invalid> wrote:
> Skye Shaw!@#$ <skye.s...@gmail.com> wrote:
> > On Nov 7, 6:12=A0am, Henry Law <n...@lawshouse.org> wrote:
> >> henry@eris $ cat tryit.dtd
> >> <?xml version=3D'1.0' encoding=3D'UTF-8'?>
> >> <!ELEMENT build EMPTY>
>
> > That's a DTD not an XML document.
>
>
> Is your comment related in any way to the OP's problem?

Is an external subset also a XML file? The XML declaration in his DTD
is probably confusing XML::Checker.


------------------------------

Date: Mon, 08 Nov 2010 08:26:17 -0800
From: sln@netherlands.com
Subject: Re: Puzzling DTD parsing error with XML::Checker
Message-Id: <s88gd6dmgtjt1h9i88feckneni7m92upvi@4ax.com>

On Sun, 07 Nov 2010 13:12:22 +0000, Henry Law <news@lawshouse.org> wrote:

>I am using XML::Checker to parse a DTD and I'm getting the error that 
>means that there are extraneous characters before the XML declaration, 
>except that there aren't.  I've searched for this error message and can 
>find no cause other than the extraneous characters that I'm sure I don't 
>have: I've even looked at the DTD in hex and there's definitely nothing 
>there.  Can someone suggest where else to look?
>
>XML::Checker has a date of 2002-07-07 (no version that I can see) and 
>here are the XML file, the DTD and a simple test program.

Try local declarations instead, then move the block to an external
declaration. What you see is that there is only one xml declaration.

<?xml version="1.0"?>
<!DOCTYPE build [
   <!ELEMENT build EMPTY>
   <!ATTLIST build name ID #REQUIRED>
]>
<build name="tryit"></build>
                   ^^
and EMPTY means no line feeds in the content.
(ANY if you want a lf).

Take a look at  DOCTYPE in the 1.1 specs:
http://www.w3.org/TR/xml11/#sec-prolog-dtd

-sln


------------------------------

Date: Mon, 08 Nov 2010 22:13:18 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Puzzling DTD parsing error with XML::Checker
Message-Id: <ufGdnb81SvGd60XRnZ2dnUVZ7sGdnZ2d@giganews.com>

On 08/11/10 00:27, Skye Shaw!@#$ wrote:
>
> Is an external subset also a XML file? The XML declaration in his DTD
> is probably confusing XML::Checker.

This turned out to be the solution.  An external DTD isn't an XML 
document, in the sense that it needs an <?xml line.  I took it out and 
all worked correctly.  A perfect example of the error message being 
correct, but not fitting in with the user's prejudices.

Thank you to all.

-- 

Henry Law            Manchester, England


------------------------------

Date: Sun, 7 Nov 2010 22:53:18 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Using Perl to find what address bar says
Message-Id: <153d9170-d76f-4244-8708-0b9f31ef9cd7@l17g2000yqe.googlegroups.com>

Can you guys think of a way, in Perl, to find what the address bar
actually says? I don't think that $ENV{'SCRIPT_NAME'} is quite the
same, because it's only going to show me what it's SUPPOSED to be.

I'm trying to find if a user is using something like anonymizer.com or
hidemyass.com, and it seems like the easiest method is to compare
$ENV{'SCRIPT_NAME'} to the address bar. I can do it in Javascript, but
I'm hoping there's a way to do it in Perl.


------------------------------

Date: Mon, 08 Nov 2010 06:37:40 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Using Perl to find what address bar says
Message-Id: <m2y694qc57.fsf@sherm.shermpendley.com>

jwcarlton <jwcarlton@gmail.com> writes:

> Can you guys think of a way, in Perl, to find what the address bar
> actually says?

"The address bar?" What address bar? I use Perl to write GUI apps, many
of which don't have such a thing, and command-line admin tools, none
of which do.

> I don't think that $ENV{'SCRIPT_NAME'} is quite the same

Oh, I see now - you're writing a web app. You might want to say so,
rather than assuming that it's a given, since Perl is used for a great
many things in addition to that. :-)

> I'm trying to find if a user is using something like anonymizer.com or
> hidemyass.com

Seems to me that will be quite difficult, given that keeping you from
finding such things out is precisely the intent of such services. One
has to wonder, since the user obviously wishes to remain anonymous,
why not simply let him do so?

> and it seems like the easiest method is to compare
> $ENV{'SCRIPT_NAME'} to the address bar.

The address bar (if there is one) is part of the browser that's running
on the client. Your server-side script has no access to it whatsoever.

> I can do it in Javascript

 ... because said Javascript is running on the client, not on the server.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Mon, 08 Nov 2010 04:04:16 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Using Perl to find what address bar says
Message-Id: <lnpfd6hai7tq3r6i63s0rk9m4t8du4svcv@4ax.com>

jwcarlton <jwcarlton@gmail.com> wrote:
>Can you guys think of a way, in Perl, to find what the address bar
>actually says?

Address bar? What address bar? There ain't no address bar where you run
Perl programs.

jue


------------------------------

Date: Mon, 08 Nov 2010 11:27:27 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Using Perl to find what address bar says
Message-Id: <ib9fel$4i8$1@news.eternal-september.org>

On 11/7/2010 11:53 PM, jwcarlton wrote:
> Can you guys think of a way, in Perl, to find what the address bar
> actually says? I don't think that $ENV{'SCRIPT_NAME'} is quite the
> same, because it's only going to show me what it's SUPPOSED to be.
>
> I'm trying to find if a user is using something like anonymizer.com
> or hidemyass.com, and it seems like the easiest method is to compare
> $ENV{'SCRIPT_NAME'} to the address bar. I can do it in Javascript,
> but I'm hoping there's a way to do it in Perl.


I am assuming that we are talking about a Perl CGI script communicating
with a browser. As Sherm already pointed out, a script running on the
server has no way of knowing what is happening in the browser. In fact,
there does not even have to be a browser involved in the transaction.
Your script can be called in any number of different ways, not all of
which involve a browser.


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 3201
***************************************


home help back first fref pref prev next nref lref last post