[22531] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4752 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 24 06:05:52 2003

Date: Mon, 24 Mar 2003 03:05:06 -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, 24 Mar 2003     Volume: 10 Number: 4752

Today's topics:
    Re: currency number to text conversion <please@no.spam>
    Re: getOpenFile with -initialdir <pzerwetz@yaccom.com>
    Re: getOpenFile with -initialdir (Anno Siegel)
        Help with for loops and array iteration <imarine@bigpond.net.au>
    Re: Help with for loops and array iteration <grazz@nyc.rr.com>
    Re: Help with for loops and array iteration <jurgenex@hotmail.com>
    Re: Help with for loops and array iteration <please@no.spam>
    Re: Help with for loops and array iteration <bigj@kamelfreund.de>
    Re: How stable is 'Magic'? <im_not_giving_it_here@i_hate_spam.com>
    Re: Memory used by hashes <mhunter@celeste.net.berkeley.edu>
        Need help with regular expression <D'oh@null.com>
    Re: Need help with regular expression <tassilo.parseval@rwth-aachen.de>
    Re: Need help with regular expression <fxn@hashref.com>
    Re: nms formmail with file upload <please@no.spam>
        perl's expat.so <xiaojun@netscape.com>
        print here-documents question <bht@actrix.gen.nz>
    Re: print here-documents question <please@no.spam>
    Re: print here-documents question <notreal@null.com>
    Re: Problem with Getopt::Std and getopts().... <bik.mido@tiscalinet.it>
    Re: Really weird?!? <please@no.spam>
        UTF-8 Woes <lefty@goedel.ih-intranet>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Mar 2003 08:58:36 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: currency number to text conversion
Message-Id: <rOzfa.64$3j5.38536@newsfep1-win.server.ntli.net>

Michael Budash wrote:

> In article <3trfa.16086$pK4.1449944@newsread1.prod.itd.earthlink.net>,
>  "Jodyman" <Jodyman@hotmail.com> wrote:
> 
>  .. etc ..

Is all the world American? What about some internationalisation?

Chris
-- 
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
 -- OpenSource (free) e-mail virus protection


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

Date: Mon, 24 Mar 2003 09:59:31 +0100
From: "Pascal Zerwetz" <pzerwetz@yaccom.com>
Subject: Re: getOpenFile with -initialdir
Message-Id: <b5mhda$304v$1@biggoron.nerim.net>

Thanks for your answer, but it doesn't help me.
In fact I used:
use Cwd;
[...]
-initialdir => cwd
(it was only a typing shortcut for me....)
printing cwd gives the right directory: the one of my last chdir() call.
The initial path really used is the one of the last opened file.
It is kept, even after a PC reboot.

I used a path with a single well-identified word, like foobarismyway:
W2k: C:\foobarismyway
Cygwin: /cygdrive/c/foobarismyway/hello.txt
And after opened a file, I have not found "foobarismyway" in the registry,
nor in any file.
Have you any further idea ?
(for the moment, I think rewrite a "browsing files" box in perl/Tk....)

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> a ιcrit dans le message de
news: b5g3l3$gf0$1@mamenchi.zrz.TU-Berlin.DE...
> Pascal Zerwetz <pzerwetz@yaccom.com> wrote in comp.lang.perl.misc:
> > Hello
> > First many thanks to Christian Winter!
> > I am using perl/Tk in Cygwin, on W2k.
> > When I open the getOpenFile dialog, even with use of Cwd and -initialdir
=
> > Cwd,
>
> Your syntax is wrong, this can't be your actual code.  It should be
> "-initialdir => getcwd".  However, this would have no visible effect
> because it is also the default.  Are you confused about what your
> current directory is?
>
> Anno




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

Date: 24 Mar 2003 09:28:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getOpenFile with -initialdir
Message-Id: <b5mj4n$ra7$1@mamenchi.zrz.TU-Berlin.DE>

Pascal Zerwetz <pzerwetz@yaccom.com> wrote in comp.lang.perl.misc:
> Thanks for your answer, but it doesn't help me.
> In fact I used:
> use Cwd;
> [...]
> -initialdir => cwd
> (it was only a typing shortcut for me....)
> printing cwd gives the right directory: the one of my last chdir() call.
> The initial path really used is the one of the last opened file.
> It is kept, even after a PC reboot.
> 
> I used a path with a single well-identified word, like foobarismyway:
> W2k: C:\foobarismyway
> Cygwin: /cygdrive/c/foobarismyway/hello.txt
> And after opened a file, I have not found "foobarismyway" in the registry,
> nor in any file.
> Have you any further idea ?
> (for the moment, I think rewrite a "browsing files" box in perl/Tk....)

[tofu snipped]

Then show your real code.  getOpenFile() works fine for me.  And don't
top-post.

Anno


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

Date: Mon, 24 Mar 2003 05:34:26 GMT
From: Justin <imarine@bigpond.net.au>
Subject: Help with for loops and array iteration
Message-Id: <nq5t7vga29b45jfq3ojf8oahfnd41ec0j3@4ax.com>

Hi,

Please refer to the following code:

$logins = <USERS>;

chomp $logins;
@users = split(/,/,$logins);

for ( $i=0 ; $i <= @users ; $i++) 
{
  if ($users[$i] eq $username) 
  {
   $loginstate = "true";
  }
  else 
  {
   $loginstate = "false";
  }
}


I have successfully loaded the data from the file into the array (@users), however the
line it is having a problem with is the if statement.  Whenever I try the script with a
valid username I get a false login state, however if I modify that line to read:

if ($users[0] eq $username)

assuming I know the first value in the array is what I'm looking for, I get the login
state to be true.   There seems to be a problem with the $users[$i] part.

I've searched high and low and cannot find the answer.

Any help would be much appreciated.

Cheers
Justin




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

Date: Mon, 24 Mar 2003 06:04:09 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Help with for loops and array iteration
Message-Id: <tdxfa.9135$iE4.2675227@twister.nyc.rr.com>

Justin <imarine@bigpond.net.au> wrote:
> 
> Please refer to the following code:
> 
> $logins = <USERS>;
> 
> chomp $logins;
> @users = split(/,/,$logins);
> 
> for ( $i=0 ; $i <= @users ; $i++) 
                  ^^^^
Off by one.

It's more idiomatic to use the range operator and $#array 
to loop over array indexes.

  for my $i (0 .. $#array) {

But if what you really want is to iterate over the array
elements (and that's what you're doing here) Perl lets you
do it directly:

  foreach (@array) {

  for my $user (@users) {

> {
>   if ($users[$i] eq $username) 
>   {
>    $loginstate = "true";

You need to break out of the loop now; otherwise you'll 
set $loginstate to "false" on the next iteration.

And using the strings "true" and "false" seems dodgy.

>   }
>   else 
>   {
>    $loginstate = "false";
>   }
> }
> 

And that was mainly array/loop advice, but since you're
testing for membership in a set, you should probably just
use a hash.

  chomp(my $logins = <USERS>);

  my %users;
  @users{ split /,/, $logins } = ();

  $loginstate = exists $users{$username};

HTH
-- 
Steve


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

Date: Mon, 24 Mar 2003 06:49:16 GMT
From: "Jόrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help with for loops and array iteration
Message-Id: <MTxfa.17028$tO3.11505@nwrddc04.gnilink.net>

Justin wrote:
> @users = split(/,/,$logins);
> for ( $i=0 ; $i <= @users ; $i++)

Why not a simple
    for (@users) {

>   if ($users[$i] eq $username)

and then
        if ($_ eq $username) {

>    $loginstate = "true";
>   }
>   else
>   {
>    $loginstate = "false";
>   }
> }

jue




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

Date: Mon, 24 Mar 2003 07:36:14 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: Help with for loops and array iteration
Message-Id: <dByfa.32$3j5.20182@newsfep1-win.server.ntli.net>

Steve Grazzini wrote:

> Justin <imarine@bigpond.net.au> wrote:
>> 
>> Please refer to the following code:
>> 
>> $logins = <USERS>;
>> 
>> chomp $logins;
>> @users = split(/,/,$logins);
>> 
>> for ( $i=0 ; $i <= @users ; $i++)
>                   ^^^^
> Off by one.
> 
> It's more idiomatic to use the range operator and $#array
> to loop over array indexes.
> 
>   for my $i (0 .. $#array) {
> 
> But if what you really want is to iterate over the array
> elements (and that's what you're doing here) Perl lets you
> do it directly:
> 
>   foreach (@array) {
> 
>   for my $user (@users) {
> 
>> {
>>   if ($users[$i] eq $username)
>>   {
>>    $loginstate = "true";
> 
> You need to break out of the loop now; otherwise you'll
> set $loginstate to "false" on the next iteration.
> 
> And using the strings "true" and "false" seems dodgy.
> 
>>   }
>>   else
>>   {
>>    $loginstate = "false";
>>   }
>> }
>> 
> 
> And that was mainly array/loop advice, but since you're
> testing for membership in a set, you should probably just
> use a hash.
> 
>   chomp(my $logins = <USERS>);
> 
>   my %users;
>   @users{ split /,/, $logins } = ();
> 
>   $loginstate = exists $users{$username};
> 
> HTH

Also .. make sure that $username is "chomp"ed too - if it came from a file 
or STDIN (etc).

Chris

-- 
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
 -- OpenSource (free) e-mail virus protection


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

Date: Mon, 24 Mar 2003 10:50:25 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Help with for loops and array iteration
Message-Id: <pan.2003.03.24.09.50.23.401281@kamelfreund.de>

Justin wrote at Mon, 24 Mar 2003 05:34:26 +0000:

> Please refer to the following code:
> 
> $logins = <USERS>;
> 
> chomp $logins;
> @users = split(/,/,$logins);
> 
> for ( $i=0 ; $i <= @users ; $i++) 
> {
>   if ($users[$i] eq $username) 
>   {
>    $loginstate = "true";
>   }
>   else 
>   {
>    $loginstate = "false";
>   }
> }

The for loops are only a long version for:

$loginstate = (grep {$_ eq $username} @users) ? "true" : "false";

But please note also that
"false" is a true value in Perl!


Greetings,
Janek


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

Date: Mon, 24 Mar 2003 07:33:55 +0000
From: Asfand Yar Qazi <im_not_giving_it_here@i_hate_spam.com>
Subject: Re: How stable is 'Magic'?
Message-Id: <b5mcaj$3ev$1@news8.svr.pol.co.uk>

Benjamin Goldberg wrote:
> Abigail wrote:
> [snip]
> 
>>Is there a garantee the API will never change? Nope. But I don't think
>>it will ever be marked as "this is never going to change". If perl6
>>goes to production, both the language and the API will have changed
>>radically.
> 
> 
> Perl6 won't be written in C, as perl5 is.  To say "will have changed
> radically" is a ridiculous understatement.
> 
> 

Let me guess.. is it going to be written in 'Parrot'?



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

Date: Sat, 22 Mar 2003 00:26:24 +0000 (UTC)
From: Mike Hunter <mhunter@celeste.net.berkeley.edu>
Subject: Re: Memory used by hashes
Message-Id: <slrnb7nbma.14m.mhunter@celeste.net.berkeley.edu>

On Fri, 21 Mar 2003 23:29:43 GMT, Steve Grazzini wrote:
>  Fr€d <nospam@euro.com> wrote:
> > I am running a simple perl program that sums 5 variables 
> > over 100Gb of data.  I have 5 hashes that use the same 12 
> > character key.  There are about 4 million keys.  Basically 
> > the program is:
> > 
> > while (<INPUT>) {
> >   $key =substr($_,0,12);
> >   extract 5 numbers from $_;
> >   $sum1{$key} ++;
> >   $sum2{$key} += $val;
> >   ... (for all 5 sums)
> > }
> > 
> > The job is currently running and is using about 685Mb of 
> > memory at about 2/3 the way thru the data.  80% of the keys 
> > have appeared by now I'd expect.  
> > 
> > Can anyone explain why this is using so much memory?  
> > Even given that all variables are double precision [...]
> 
>  Scalars are bulkier than you think.
> 
>  On i686-linux 'ints' and 'doubles' take up 28 and 36 bytes.
 
Ugh.

I'm in a bit of a similar situation, in that I have a hash storing a lot
of scalar values and I end up using a lot of memory.  Regarding the
packing suggestion, one has to chose the data type to pack into, and thus
has to assert an upper limit on the data size.  32 bit integers aren't big
enough for me, and I don't want to lose precision with doubles.  Last but
not least, my perl install wasn't compiled with "Q", so I can't get 64 bit
ints.  Haven't been motivated enough to recompile perl, but somehow I am
motivated enough to mindlessly complain on the news group :)

Mike


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

Date: Mon, 24 Mar 2003 21:43:29 +1100
From: D'oh <D'oh@null.com>
Subject: Need help with regular expression
Message-Id: <3E7EE151.92D2A452@null.com>


--------------6DA1E17F309ECE5F2FB346EA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I'm trying to create a script that will change 4 consecutive characters
to a single character within a string.  Can someone enlighten me with a
better solution to the one I've got?  Thanks.

#!/bin/perl
use strict;
use warnings;

my $string = "It SEEMS that the ''''CCCCAAAATTTT'''' sat on the
mmmmaaaatttt";

$string =~ s/\'{4}/\'/g;
for("A".."Z", "a".."z", "0".."9") {
  $string =~ s/$_{4}/$_/g;
}
print("$string\n");  ## output: It SEEMS that the 'CAT' sat on the mat


--------------6DA1E17F309ECE5F2FB346EA
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt>Hi,</tt><tt></tt>
<p><tt>I'm trying to create a script that will change 4 consecutive characters
to a single character within a string.&nbsp; Can someone enlighten me with
a better solution to the one I've got?&nbsp; Thanks.</tt><tt></tt>
<p><tt>#!/bin/perl</tt>
<br><tt>use strict;</tt>
<br><tt>use warnings;</tt><tt></tt>
<p><tt>my $string = "It SEEMS that the ''''CCCCAAAATTTT'''' sat on the
mmmmaaaatttt";</tt><tt></tt>
<p><tt>$string =~ s/\'{4}/\'/g;</tt>
<br><tt>for("A".."Z", "a".."z", "0".."9") {</tt>
<br><tt>&nbsp; $string =~ s/$_{4}/$_/g;</tt>
<br><tt>}</tt>
<br><tt>print("$string\n");&nbsp; ## output: It SEEMS that the 'CAT' sat
on the mat</tt>
<br><tt></tt>&nbsp;</html>

--------------6DA1E17F309ECE5F2FB346EA--



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

Date: 24 Mar 2003 10:47:59 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Need help with regular expression
Message-Id: <b5mnov$gb5$1@nets3.rz.RWTH-Aachen.DE>

Also sprach D'oh:

> I'm trying to create a script that will change 4 consecutive characters
> to a single character within a string.  Can someone enlighten me with a
> better solution to the one I've got?  Thanks.
> 
> #!/bin/perl
> use strict;
> use warnings;
> 
> my $string = "It SEEMS that the ''''CCCCAAAATTTT'''' sat on the
> mmmmaaaatttt";
> 
> $string =~ s/\'{4}/\'/g;
> for("A".."Z", "a".."z", "0".."9") {
>   $string =~ s/$_{4}/$_/g;
> }
> print("$string\n");  ## output: It SEEMS that the 'CAT' sat on the mat

You can use back-references:

    $string =~ s/(.)\1{3}/$1/g;

For such a squeezing-task I'd usually have recommended this idiom:

    $string =~ tr/A-Za-z'//s;

However, it also squeezes sequences of two characters so you can't use
it here.
    
Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 24 Mar 2003 10:56:06 +0000 (UTC)
From: Xavier Noria <fxn@hashref.com>
Subject: Re: Need help with regular expression
Message-Id: <b5mo86$8na$1@news.ya.com>

In article <3E7EE151.92D2A452@null.com>, D'oh wrote:
: I'm trying to create a script that will change 4 consecutive characters
: to a single character within a string.  Can someone enlighten me with a
: better solution to the one I've got?  Thanks.
: 
: #!/bin/perl
: use strict;
: use warnings;
: 
: my $string = "It SEEMS that the ''''CCCCAAAATTTT'''' sat on the
: mmmmaaaatttt";

$string =~ s/(.)\1{3}/$1/sg;

-- fxn



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

Date: Mon, 24 Mar 2003 08:55:30 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: nms formmail with file upload
Message-Id: <wLzfa.62$3j5.37419@newsfep1-win.server.ntli.net>

Neil C wrote:

> TO All:
> ... lots of perl code ...

Neil - get real my friend! If you want a question answered on a group like 
this, then post one that doesnt take more than about 60 seconds to read.

Cut your problem down to no more than 50 lines, or part with some cash and 
pay someone!

Good luck.

-- 
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
 -- OpenSource (free) e-mail virus protection


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

Date: Sun, 23 Mar 2003 21:42:00 -0800
From: Xiaojun Ping <xiaojun@netscape.com>
Subject: perl's expat.so
Message-Id: <3E7E9AA8.70009@netscape.com>


There is no errors when I set LD_LIBRARY_PATH for libexpat.so before I 
run my perl program, but I always get the following errors when I set 
$ENV{LD_LIBRARY_PATH} to the same value inside my perl program, any idea ?

 ...perl5.6.0/sun4-solaris-thread-multi/auto/XML/Parser/Expat/Expat.so' 
for module XML::Parser::Expat: ld.so.1: /usr/bin/perl: fatal: 
libexpat.so.0: open failed: No such file or directory at 
 ...perl-5.6.0/SunOS5.6/lib/5.6.0/sun4-solaris-thread-multi/DynaLoader.pm 
line 200, <F> line 5.

Thanks
XJ



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

Date: Mon, 24 Mar 2003 19:10:37 +1200
From: Bernard <bht@actrix.gen.nz>
Subject: print here-documents question
Message-Id: <1fat7v0qrgnhouq2lsl5vk4d8f1dnlam1v@4ax.com>

Hi,

I am looking for a way to avoid escaping of HTM/JavaScript text in
perl here-documents.

In other words I am not interested in the perl parser scanning the
here-document for special characters e.g. backslash "\" and @.

The purpose of this is to cut and paste static text that works in the
browser without having to alter it to keep perl happy. For me such
alterations cause an undesired maintenance overhead.
External .js files are not an option for performance reasons.


The following example illustrates the dilemma. What is perfectly valid
in JavaScript as you see it here gets rejected and truncated by perl.

This version does not work but it illustrates what is required:

print <<"EOF"
<HTML>
<SCRIPT>
alert("The correct email format is : \nusername@domain.extension");
</SCRIPT>
</HTML>
EOF

Escaped version works (note the additional JavaScript code "var
newLine..." and "\@":

print <<"EOF"
<HTML>
<SCRIPT>
var newLine = unescape("%0A");
alert("The correct email format is : "  + newLine +
"username\@domain.extension");
</SCRIPT>
</HTML>
EOF

The escaped version still works standalone without perl, reflecting my
desire to maintain only a single version. But I don't like the result
as it is inefficient and bulky.


I am using more and more regular expressions in JavaScript routines.
Having to escape these just to keep perl happy is a lot of work and in
some cases forces me to keep 2 versions of the same code - you know
how bad that is.

I would be very grateful if someone could show me a way out of this.

Bernard
bht@actrix.gen.nz



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

Date: Mon, 24 Mar 2003 07:30:22 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: print here-documents question
Message-Id: <Jvyfa.29$3j5.19161@newsfep1-win.server.ntli.net>

Bernard wrote:

> Hi,
> 
> I am looking for a way to avoid escaping of HTM/JavaScript text in
> perl here-documents.
> 
> In other words I am not interested in the perl parser scanning the
> here-document for special characters e.g. backslash "\" and @.
> 
> The purpose of this is to cut and paste static text that works in the
> browser without having to alter it to keep perl happy. For me such
> alterations cause an undesired maintenance overhead.
> External .js files are not an option for performance reasons.
> 
> 
> The following example illustrates the dilemma. What is perfectly valid
> in JavaScript as you see it here gets rejected and truncated by perl.
> 
> This version does not work but it illustrates what is required:
> 
> print <<"EOF"
> <HTML>
> <SCRIPT>
> alert("The correct email format is : \nusername@domain.extension");
> </SCRIPT>
> </HTML>
> EOF
> 
> Escaped version works (note the additional JavaScript code "var
> newLine..." and "\@":
> 
> print <<"EOF"
> <HTML>
> <SCRIPT>
> var newLine = unescape("%0A");
> alert("The correct email format is : "  + newLine +
> "username\@domain.extension");
> </SCRIPT>
> </HTML>
> EOF
> 
> The escaped version still works standalone without perl, reflecting my
> desire to maintain only a single version. But I don't like the result
> as it is inefficient and bulky.
> 
> 
> I am using more and more regular expressions in JavaScript routines.
> Having to escape these just to keep perl happy is a lot of work and in
> some cases forces me to keep 2 versions of the same code - you know
> how bad that is.
> 
> I would be very grateful if someone could show me a way out of this.
> 
> Bernard
> bht@actrix.gen.nz

If you only have one such HTML fragment, then ...

print <DATA>
__DATA__
<HTML>
<SCRIPT>
var newLine = unescape("%0A");
alert("The correct email format is : "  + newLine +
username@domain.extension");
</SCRIPT>
</HTML>

Or, just use single quotes (provided you HTML contains no single quotes)..

print '<HTML>
<SCRIPT>
var newLine = unescape("%0A");
alert("The correct email format is : "  + newLine +
username@domain.extension");
</SCRIPT>
</HTML>
';

or use single quotes round your EOF rather than doubles..

print <<'EOF'
<HTML>
<SCRIPT>
var newLine = unescape("%0A");
alert("The correct email format is : "  + newLine +
username@domain.extension");
</SCRIPT>
</HTML>
EOF

Chris

-- 
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
 -- OpenSource (free) e-mail virus protection


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

Date: Mon, 24 Mar 2003 20:25:59 +1100
From: not real <notreal@null.com>
Subject: Re: print here-documents question
Message-Id: <3E7ECF27.485411A0@null.com>

Bernard wrote:

> Hi,
>
> In other words I am not interested in the perl parser scanning the
> here-document for special characters e.g. backslash "\" and @.
>
> print <<"EOF"
> <HTML>
> <SCRIPT>
> alert("The correct email format is : \nusername@domain.extension");
> </SCRIPT>
> </HTML>
> EOF
>

Have you tried using single quotes?

print <<'EOF';





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

Date: Mon, 24 Mar 2003 09:08:37 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Problem with Getopt::Std and getopts()....
Message-Id: <kfor7vkbrl9k8a5mb427duo6qm2o40nikl@4ax.com>

On Sat, 22 Mar 2003 15:15:19 GMT, "Jόrgen Exner"
<jurgenex@hotmail.com> wrote:

>Michele Dondi wrote:
>> On 20 Mar 2003 16:36:36 -0800, clearguy02@yahoo.com (John Smith)
>> wrote:
>>> C:\>test.pl 1
>>
>> BTW: can you really run it like this (on Win* - as it seems)?!?
>
>Why not?

Because on Windows (up to all of the versions I've been in contact
with), executability is based upon a _naming convention_, for what
regards the _command line_ interface.

>Just create the correct association for the extension 'pl' (but that's a
>Windows question, not a Perl question).

Agreed, it's a Windows question and in this respect the association
for any extension is set up for the GUI and has nothing to do with the
command line, AFAIK (but then I've not been "working" with the most
recent releases of the OS).

>BTW: ActiveState does that for you automatically when you install it and you
>check the right checkbox.

Yes it does, OTOH, it also adds, e.g., a pl2bat.bat program (I don't
know wether it's AS-specific or in the core distribuition) for the
creation of stand-alone executables.


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Mon, 24 Mar 2003 07:32:29 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: Really weird?!?
Message-Id: <Ixyfa.30$3j5.19161@newsfep1-win.server.ntli.net>

Michael Budash wrote:

> In article <FHmfa.48$%l1.240@news13-win.server.ntlworld.com>,
>  Chris Lowth <please@no.spam> wrote:
> 
>> Michael Budash wrote:
>> 
>> > In article <nh6fa.7$v6.24796@newsfep2-gui>,
>> >  Chris Lowth <please@no.spam> wrote:
>> > 
>> >> Ryan Ritten wrote:
>> >> 
>> >> > I don't get it... all I want is to check to see if the string $key
>> >> > contains the string of characters represented by table$table!
>> >> > 
>> >> > so for example... if $table was equal to 4 .... it would check $key
>> >> > and see if the string table4! was found within it... here is my
>> >> > code:
>> >> > 
>> >> > 
>> >> > print "key=$key\n";
>> >> > print "table=$table\n";
>> >> > if($key =~ /table$table!/)
>> >> > {
>> >> >         print "I'm in\n";
>> >> > }
>> >> > 
>> >> > if I run this... for example... I'd get :
>> >> > 
>> >> > key=blahtable4!
>> >> > table=4
>> >> > 
>> >> > the if statement doesn't validate to true .... any ideas why?  it
>> >> > should... I've tried chomping the data to remove any weird
>> >> > characters at the end... with no luck... am I missing something
>> >> > stupid?
>> >> > 
>> >> > thanx
>> >> > 
>> >> > -Ryan
>> >> 
>> >> Problem is syntax of the "if($key..." line.
>> >> 
>> >> Fix thus...
>> >> 
>> >> $key = "blahtable4";
>> >> $table = 4;
>> >> print "key=$key\n";
>> >> print "table=$table\n";
>> >> if($key =~ m{table$table})
>> >> {
>> >>         print "I'm in\n";
>> >> }
>> > 
>> > huh? there's nothing wrong with his syntax. these are equivalent:
>> > 
>> > /table$table!/
>> > 
>> > m{table$table!}
>> > 
>> > however, you changed his regex in the process - you left out the
>> > exclamation point at the end...
>> > 
>> 
>> You are right about the "!" but wrong about the syntax (at least, for
>> 5.6.1). Here's 5.6.1 at work....
>> 
>> [chris@jazz chris]$ cat x
>> $key = "blahtable4!";
>> $table = 4;
>> print "key=$key\n";
>> print "table=$table\n";
>> if($key =~  table$table! )
>              ^            ^
>              ^            ^
> 
> uh, notice anything missing above? somehow, the forward slashes
> surrounding the regex disappeared, causing the syntax error mentioned
> below. the code with forward slashes passes syntax check.
> 
> [snip]
> 

Correct! - and if you note, the posters original script was missing those 
slashes which is why I suggested correcting the syntax in the first place. 
:)

Chris

-- 
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
 -- OpenSource (free) e-mail virus protection


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

Date: Mon, 24 Mar 2003 08:52:57 +0000 (UTC)
From: "E. Lefty Kreouzis" <lefty@goedel.ih-intranet>
Subject: UTF-8 Woes
Message-Id: <slrnb7thqp.qqe.lefty@goedel.ih-intranet>

Hi to all,

I am trying to write a web based application that deals with 
unicode data. The application should run under redhat 7.3 
and redhat 8.0.
I have found a problem with the unicode handling in the main 
perl program and the same function called in a module.

---- Makefile ----
SDAT=greek.iso-8859-7
DAT=greek.utf8
PL=split.pl Split.pm

all : test


$(DAT) : $(SDAT)
    iconv -f iso-8859-7 -t utf-8 $(SDAT) >$(DAT)

test-out.$(HOSTNAME) : $(DAT) $(PL)
    cat /etc/redhat-release >test-out.$(HOSTNAME)
    perl -v  >>test-out.$(HOSTNAME)
    ./split.pl >>test-out.$(HOSTNAME)

test : test-out.$(HOSTNAME)
---- split.pl ----
#!/usr/bin/perl -w

use strict;
use utf8;
use Split;
use POSIX;


sub to_upper($)
{
    my $word = shift @_;
    use locale;
    POSIX::setlocale(&POSIX::LC_CTYPE, "el_GR.utf8");
    return uc($word);
}


sub split_it($)
{
    my ($fname) = @_;

    open FILE, "<$fname" or die "Can't open file:$fname,";

    print "word\tto_upper(word)\tSplit::to_upper(word)\n";
    while ( <FILE> )
    {
    for my $word ( split /\W+/ )
    {
        print $word, "\t", to_upper($word), "\t", Split::to_upper($word),"\n";
    }
    }
    close FILE;
}

print "split_it('greek.utf8')\n";
split_it("greek.utf8");
print "Split::split_it('greek.utf8')\n";
Split::split_it("greek.utf8");

---- Split.pm ----
#!/usr/bin/perl -w

use strict;
use utf8;
use POSIX;

package Split;

sub to_upper($)
{
    my $word = shift @_;
    use locale;
    POSIX::setlocale(&POSIX::LC_CTYPE, "el_GR.utf8");
    return uc($word);
}

sub split_it($)
{
    my ($fname) = @_;

    open FILE, "<$fname" or die "Can't open file:$fname,";

    print "word\tto_upper(word)\n";
    while ( <FILE> )
    {
    for my $word ( split /\W+/ )
    {
        print $word, "\t", to_upper($word),"\n";
    }
    }
    close FILE;
}


return 1;

and the output ( encoded in utf-8)

---- test-out.goedel.ih-intranet ----
Red Hat Linux release 7.3 (Valhalla)

This is perl, v5.6.1 built for i386-linux

Copyright 1987-2001, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

split_it('greek.utf8')
word    to_upper(word)    Split::to_upper(word)
Δοκιμή    Δοκιμή    Δοκιμή
δοκιμαστικά    δοκιμαστικά    δοκιμαστικά
πράγματα    πράγματα    πράγματα
καί    καί    καί
όλα    όλα    όλα
αυτά    αυτά    αυτά
είναι    είναι    είναι
καλά    καλά    καλά
testing    TESTING    TESTING
tested    TESTED    TESTED
testing    TESTING    TESTING
words    WORDS    WORDS
Split::split_it('greek.utf8')
word    to_upper(word)
Δοκιμή    Δοκιμή
δοκιμαστικά    δοκιμαστικά
πράγματα    πράγματα
καί    καί
όλα    όλα
αυτά    αυτά
είναι    είναι
καλά    καλά
testing    TESTING
tested    TESTED
testing    TESTING
words    WORDS
---- test-out.testrh8.ih-intranet ----
Red Hat Linux release 8.0 (Psyche)

This is perl, v5.8.0 built for i386-linux-thread-multi

Copyright 1987-2002, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

split_it('greek.utf8')
word    to_upper(word)    Split::to_upper(word)
Δοκιμή    ΔΟΚΙΜΉ    ΔΟΚΙΜΉ
δοκιμαστικά    ΔΟΚΙΜΑΣΤΙΚΆ    ΔΟΚΙΜΑΣΤΙΚΆ
πράγματα    ΠΡΆΓΜΑΤΑ    ΠΡΆΓΜΑΤΑ
καί    ΚΑΊ    ΚΑΊ
όλα    ΌΛΑ    ΌΛΑ
αυτά    ΑΥΤΆ    ΑΥΤΆ
είναι    ΕΊΝΑΙ    ΕΊΝΑΙ
καλά    ΚΑΛΆ    ΚΑΛΆ
testing    TESTING    TESTING
tested    TESTED    TESTED
testing    TESTING    TESTING
words    WORDS    WORDS
Split::split_it('greek.utf8')
word    to_upper(word)
testing    TESTING
tested    TESTED
testing    TESTING
words    WORDS
 ------------------------------

Please note the following:
under perl 5.6.1 the to_upper function doesn't transform 
to upper case either in the main program or in the module

under perl 5.8.0 the to_upper function works
but the split function works in the main program but not 
in the module (greek unicode letters aren't recognised as \w)!

Please please help me I am going crazy. I know that I can call 
binmode(FILE, ":utf8") in the module for perl 5.8.0 and probably
wrap it in an eval block for perl 5.6.1 but that still doesn't 
solve the problem of the to_upper function not working 
under perl 5.6.1

This is an example showing the problem (the real application is 
a CGI application working via DBI with a postgresql database)

Thank you in advance


E. Lefty Kreouzis




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

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 4752
***************************************


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