[31109] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2354 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 19 21:09:52 2009

Date: Sun, 19 Apr 2009 18:09:19 -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           Sun, 19 Apr 2009     Volume: 11 Number: 2354

Today's topics:
        Capturing Port Data <XXjbhuntxx@white-star.com>
    Re: Capturing Port Data <ben@morrow.me.uk>
    Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not fou tuser1@gmail.com
    Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not fou tuser1@gmail.com
    Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not fou tuser1@gmail.com
    Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not fou <sisyphus359@gmail.com>
        do i need to flock when just reading a file? <someone@somewhere.nb.ca>
    Re: do i need to flock when just reading a file? <news123@free.fr>
    Re: do i need to flock when just reading a file? <jurgenex@hotmail.com>
    Re: do i need to flock when just reading a file? <tadmc@seesig.invalid>
    Re: do i need to flock when just reading a file? <nospam-abuse@ilyaz.org>
    Re: I'm looking for a Perl Book... I think. <ben@morrow.me.uk>
    Re: I'm looking for a Perl Book... I think. <noreply@gunnar.cc>
        Is there a better way to convert foreign characters? <someone@somewhere.nb.ca>
    Re: Is there a better way to convert foreign characters <noreply@gunnar.cc>
    Re: Is there a better way to convert foreign characters <someone@somewhere.nb.ca>
    Re: Is there a better way to convert foreign characters <jurgenex@hotmail.com>
    Re: Is there a better way to convert foreign characters <nospam-abuse@ilyaz.org>
    Re: Is there a better way to convert foreign characters <noreply@gunnar.cc>
    Re: Is there a better way to convert foreign characters sln@netherlands.com
        my last question tonight... s/// <someone@somewhere.nb.ca>
    Re: my last question tonight... s/// sln@netherlands.com
    Re: my last question tonight... s/// sln@netherlands.com
    Re: my last question tonight... s/// <benkasminbullock@gmail.com>
    Re: What does `my' do?! <nospam-abuse@ilyaz.org>
    Re: What's wrong with the following regular expression? <tadmc@seesig.invalid>
    Re: What's wrong with the following regular expression? sln@netherlands.com
    Re: What's wrong with the following regular expression? sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 19 Apr 2009 21:37:44 GMT
From: Cosmic Cruizer <XXjbhuntxx@white-star.com>
Subject: Capturing Port Data
Message-Id: <Xns9BF294C42A8FBccruizermydejacom@207.115.17.102>

I could not get the yahoo modules to work, nor did I have success with 
IO::Socket. So now I'm trying to use Net::Telnet. I think the problem has 
to do with needing two returns after $msg. I've tried using both print and 
cmd without success.

Anybody know why I'm not able to capture the output?

use strict;
use warnings;
use Net::Telnet; 

my $msg = 'GET /capacity HTTP/1.1';
my $port = 5050;
my $timeout = 5;

my $telnet = new Net::Telnet (
             Timeout   => $timeout,
             Errmode   => 'die',
             Port      => $port,); 

$telnet->open('66.163.181.177'); 

if(!$telnet){
  print "No connection\n";
}
else { 
  # Tried using combinations of print and cmd
  my @output1 =  $telnet->print($msg);
  print "First:  $_\n" foreach(@output1);

  my @output2 =  $telnet->print("\n");
  print "Second: $_\n" foreach(@output2);

  $telnet->close;
}

I'm trying to capture the following: "CS_IP_ADDRESS=66.163.181.177"

Thanks


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

Date: Sun, 19 Apr 2009 23:38:02 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Capturing Port Data
Message-Id: <anlsb6-e1j.ln1@osiris.mauzo.dyndns.org>


Quoth Cosmic Cruizer <XXjbhuntxx@white-star.com>:
> I could not get the yahoo modules to work, nor did I have success with 
> IO::Socket. So now I'm trying to use Net::Telnet. I think the problem has 
> to do with needing two returns after $msg. I've tried using both print and 
> cmd without success.
> 
> Anybody know why I'm not able to capture the output?
> 
> use strict;
> use warnings;
> use Net::Telnet; 
> 
> my $msg = 'GET /capacity HTTP/1.1';

What's wrong with LWP::Simple?

Ben



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

Date: Sun, 19 Apr 2009 15:48:20 -0700 (PDT)
From: tuser1@gmail.com
Subject: Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not found, and can't  be made
Message-Id: <17212019-6e47-4e09-8cf1-268872431300@w40g2000yqd.googlegroups.com>

On Apr 19, 9:31=A0pm, sisyphus <sisyphus...@gmail.com> wrote:
> Don't think I've seen that error before.
> Could you email me the Makefile ? - to sisyphus1 at (@) optusnet dot
> (.) com dot(.) au. (Or post it to some public location where we can
> all access it. I suspect it's bad etiquette to post a file of that
> size to this newsgroup, though I could be wrong about that.)
> I think it would help if we could do a 'diff -u' between the Makefile
> you get, and the Makefile I get.
>
> The Makefile I get can be seen athttp://www.perlmonks.org/index.pl?viewmo=
de=3Dpublic;node_id=3D587490
> for anyone interested.

I have upgraded EU::MM from version 6.42_01 to version 6.50 (about one
hour ago), but this shouldn't make any difference though, as the
problem still persists in exactly the same manner.

The makefile (for Scalar::Util::Refcount version 1.0.2) is too big to
be posted on c.l.p.m., therefore I had to send it to you per e-mail.

I hope the 'diff -u' between our two Makefiles is not too big, so it
can be posted on c.l.p.m

b.t.w., I have installed Activestate using the .msi package.



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

Date: Sun, 19 Apr 2009 16:29:39 -0700 (PDT)
From: tuser1@gmail.com
Subject: Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not found, and can't  be made
Message-Id: <37478314-d83b-49ac-9976-40bbe6f301cb@z9g2000yqi.googlegroups.com>

On Apr 20, 12:48=A0am, tus...@gmail.com wrote:
> On Apr 19, 9:31=A0pm, sisyphus <sisyphus...@gmail.com> wrote:
>
> > Don't think I've seen that error before.
> > Could you email me the Makefile ? - to sisyphus1 at (@) optusnet dot
> > (.) com dot(.) au. (Or post it to some public location where we can
> > all access it. I suspect it's bad etiquette to post a file of that
> > size to this newsgroup, though I could be wrong about that.)
> > I think it would help if we could do a 'diff -u' between the Makefile
> > you get, and the Makefile I get.
>
> > The Makefile I get can be seen athttp://www.perlmonks.org/index.pl?view=
mode=3Dpublic;node_id=3D587490
> > for anyone interested.
>
> I have upgraded EU::MM from version 6.42_01 to version 6.50 (about one
> hour ago), but this shouldn't make any difference though, as the
> problem still persists in exactly the same manner.
>
> The makefile (for Scalar::Util::Refcount version 1.0.2) is too big to
> be posted on c.l.p.m., therefore I had to send it to you per e-mail.
>
> I hope the 'diff -u' between our two Makefiles is not too big, so it
> can be posted on c.l.p.m
>
> b.t.w., I have installed Activestate using the .msi package.

one additional thing:
many years ago, I installed "nmake" of the Visual C++ compiler suite,
maybe something tells EU::MM that it has to use "nmake" (and not
"dmake")

for example in ExtUtils\MM_Win32.pm:
[...]
sub init_DIRFILESEP {
    my($self) =3D shift;

    # The ^ makes sure its not interpreted as an escape in nmake
    $self->{DIRFILESEP} =3D $self->is_make_type('nmake') ? '^\\' :
                          $self->is_make_type('dmake') ? '\\\\'
                                                       : '\\';
}

However, I have checked my environment variables, but I could not find
anything related to "make", "dmake" or "nmake"


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

Date: Sun, 19 Apr 2009 16:39:27 -0700 (PDT)
From: tuser1@gmail.com
Subject: Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not found, and can't  be made
Message-Id: <abe87a06-d05e-471d-9b3b-132265e0f2e4@c36g2000yqn.googlegroups.com>

On Apr 20, 1:29=A0am, tus...@gmail.com wrote:
> On Apr 20, 12:48=A0am, tus...@gmail.com wrote:
>
>
>
> > On Apr 19, 9:31=A0pm, sisyphus <sisyphus...@gmail.com> wrote:
>
> > > Don't think I've seen that error before.
> > > Could you email me the Makefile ? - to sisyphus1 at (@) optusnet dot
> > > (.) com dot(.) au. (Or post it to some public location where we can
> > > all access it. I suspect it's bad etiquette to post a file of that
> > > size to this newsgroup, though I could be wrong about that.)
> > > I think it would help if we could do a 'diff -u' between the Makefile
> > > you get, and the Makefile I get.
>
> > > The Makefile I get can be seen athttp://www.perlmonks.org/index.pl?vi=
ewmode=3Dpublic;node_id=3D587490
> > > for anyone interested.
>
> > I have upgraded EU::MM from version 6.42_01 to version 6.50 (about one
> > hour ago), but this shouldn't make any difference though, as the
> > problem still persists in exactly the same manner.
>
> > The makefile (for Scalar::Util::Refcount version 1.0.2) is too big to
> > be posted on c.l.p.m., therefore I had to send it to you per e-mail.
>
> > I hope the 'diff -u' between our two Makefiles is not too big, so it
> > can be posted on c.l.p.m
>
> > b.t.w., I have installed Activestate using the .msi package.
>
> one additional thing:
> many years ago, I installed "nmake" of the Visual C++ compiler suite,
> maybe something tells EU::MM that it has to use "nmake" (and not
> "dmake")
>
> for example in ExtUtils\MM_Win32.pm:
> [...]
> sub init_DIRFILESEP {
> =A0 =A0 my($self) =3D shift;
>
> =A0 =A0 # The ^ makes sure its not interpreted as an escape in nmake
> =A0 =A0 $self->{DIRFILESEP} =3D $self->is_make_type('nmake') ? '^\\' :
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $self->is_make_type('=
dmake') ? '\\\\'
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0: '\\';
>
> }
>
> However, I have checked my environment variables, but I could not find
> anything related to "make", "dmake" or "nmake"

I have found the culprit in "Config.pm":

C:\>perl -MConfig -e "print $Config{make}"
nmake

I suspect this value should rather be "dmake" (am I right ?)


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

Date: Sun, 19 Apr 2009 17:14:12 -0700 (PDT)
From: sisyphus <sisyphus359@gmail.com>
Subject: Re: dmake.exe: Error: -- 'C:\Perl\libConfig.pm' not found, and can't  be made
Message-Id: <62c3d0d0-86d0-4721-9c23-a5e9d5bb8250@x1g2000prh.googlegroups.com>

On Apr 20, 9:39=A0am, tus...@gmail.com wrote:
> On Apr 20, 1:29=A0am, tus...@gmail.com wrote:

> I suspect this value should rather be "dmake" (am I right ?)- Hide quoted=
 text -

No, I don't think so.
Sure, we want 'dmake' to be used, but that value of 'nmake' is being
overridden anyway. (You can check this by running 'perl -V:make',
which should report that make=3D'dmake'.)

I guess, however, there's a chance that by some strange twist of fate,
it's not being overridden soon enough - so, in lib/Config_heavy.pl,
try changing:

make=3D'nmake
to
make=3D'dmake'

and see if that has any effect on the generated Makefile. (It should
alter the value of $Config{make} to 'dmake', but I'm not expecting any
other differences.)

I think, too, that the problem with 'rem' is another separate issue
(but nothing's guaranteed :-)

Could you check that we're both looking at the same version of
EU::MM_Win32 (which defines DIRFILESEP) by running:

perl -MExtUtils::MM_Win32 -e "print $ExtUtils::MM_Win32::VERSION"

And check that it contains the following subroutine:

##################################
sub init_DIRFILESEP {
    my($self) =3D shift;

    my $make =3D $self->make;

    # The ^ makes sure its not interpreted as an escape in nmake
    $self->{DIRFILESEP} =3D $make eq 'nmake' ? '^\\' :
                          $make eq 'dmake' ? '\\\\'
                                           : '\\';
}
##################################

I have version 6.42 of EU::MM_Win32.

Cheers,
Rob


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

Date: Sun, 19 Apr 2009 17:44:41 -0300
From: "Guy" <someone@somewhere.nb.ca>
Subject: do i need to flock when just reading a file?
Message-Id: <49eb8d2f$0$5474$9a566e8b@news.aliant.net>

A quick question...
I'm using Perl to read and also write to a text file that was originally 
created in Notepad. Each line in the file is a record. Each record contains 
about 4 or 5 tab-separated fields.  It will mostly be read, but written to 
on occasion.   Do i need to flock the file before reading it, or just when I 
am writing to it?

PS. I remember a Perl script I had created about 6 or 7 years ago for an 
on-line auction of about 100 items.  It worked fine for a week, until about 
5 minutes before the auction was to end. The text datafiles got messed up a 
bit when about 200 people tried to access the site at the same time to put 
their final bids. I had forgotten to flock the file before writting to them.

Thanks,
Guy 




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

Date: Sun, 19 Apr 2009 23:43:59 +0200
From: News123 <news123@free.fr>
Subject: Re: do i need to flock when just reading a file?
Message-Id: <49eb9b20$0$23725$426a74cc@news.free.fr>

Just some thoughts.as I personally never had a setup, which was
sensitive to simultaneous writes / reads of a file:

If writing the file means trunkating it and rewriting i, then I would
also lock reading it.

It might happen, that you read the file and while reading it it could be
trunkated.

Even if writing the file would mean creating a new file with a new inode
(for unix file systems), then it could happenm that you read a partially
created file.

If writing just means appending to the file and the amount, that you
append is smaller than the write block size, then you shouldn't have to
lock.




Guy wrote:
> A quick question...
> I'm using Perl to read and also write to a text file that was originally 
> created in Notepad. Each line in the file is a record. Each record contains 
> about 4 or 5 tab-separated fields.  It will mostly be read, but written to 
> on occasion.   Do i need to flock the file before reading it, or just when I 
> am writing to it?
> 
> PS. I remember a Perl script I had created about 6 or 7 years ago for an 
> on-line auction of about 100 items.  It worked fine for a week, until about 
> 5 minutes before the auction was to end. The text datafiles got messed up a 
> bit when about 200 people tried to access the site at the same time to put 
> their final bids. I had forgotten to flock the file before writting to them.
> 
> Thanks,
> Guy 
> 
> 


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

Date: Sun, 19 Apr 2009 15:21:47 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: do i need to flock when just reading a file?
Message-Id: <th8nu45h5ttc7p0tgfo6qm4gboru4autsr@4ax.com>

"Guy" <someone@somewhere.nb.ca> wrote:
>A quick question...
>I'm using Perl to read and also write to a text file that was originally 
>created in Notepad. Each line in the file is a record. Each record contains 
>about 4 or 5 tab-separated fields.  It will mostly be read, but written to 
>on occasion.   Do i need to flock the file before reading it, or just when I 
>am writing to it?

Insufficient information. What happens in the standard scenarios:
- concurrent reads are obviously no problem as they don't modify the
file
- what about concurrent writes? Are they possible in your scenario (it
solely depends on how you implemented your system and also which file
write logic your OS uses)? If yes, how are they handled? Is it possible,
that one write 'wins'? Or that they overwrite each others changes (in
case of update instead of recreating the file)?
- what about concurrent read and write operations? Could there ever be a
scenario, where a file has been written partially (because the process
hasn't finished writing yet) and a read is intitiated on that incomplete
file?

Those are some of the questions you will have to answer first based on
the architecture and implementation of your program as well as the OS
and file system you are using.  

BTW: this has little to do with Perl, you would have the same issues in
any programming language if you are doing concurrent processing of
files.

jue


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

Date: Sun, 19 Apr 2009 18:13:37 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: do i need to flock when just reading a file?
Message-Id: <slrngunc11.phv.tadmc@tadmc30.sbcglobal.net>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> "Guy" <someone@somewhere.nb.ca> wrote:
>>A quick question...
>>I'm using Perl to read and also write to a text file that was originally 
>>created in Notepad. Each line in the file is a record. Each record contains 
>>about 4 or 5 tab-separated fields.  It will mostly be read, but written to 
>>on occasion.   Do i need to flock the file before reading it, or just when I 
>>am writing to it?
>
> Insufficient information. What happens in the standard scenarios:
> - concurrent reads are obviously no problem as they don't modify the
> file
> - what about concurrent writes? Are they possible in your scenario (it
> solely depends on how you implemented your system and also which file
> write logic your OS uses)? If yes, how are they handled? Is it possible,
> that one write 'wins'? Or that they overwrite each others changes (in
> case of update instead of recreating the file)?
> - what about concurrent read and write operations? Could there ever be a
> scenario, where a file has been written partially (because the process
> hasn't finished writing yet) and a read is intitiated on that incomplete
> file?
>
> Those are some of the questions you will have to answer first based on
> the architecture and implementation of your program as well as the OS
> and file system you are using.  


By now you may want to reconsider your plan to use files as
a "poor man's database".

Use a Real Database and most or all of those questions fall away
as any RDBMS worth it's salt will handle concurrent access for you.


 ... so now you need a book on the DBI too.  <grin>


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 19 Apr 2009 23:25:32 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: do i need to flock when just reading a file?
Message-Id: <slrnguncnc.562.nospam-abuse@chorin.math.berkeley.edu>

On 2009-04-19, Guy <someone@somewhere.nb.ca> wrote:
> A quick question...
> I'm using Perl to read and also write to a text file that was originally 
> created in Notepad. Each line in the file is a record. Each record contains 
> about 4 or 5 tab-separated fields.  It will mostly be read, but written to 
> on occasion.   Do i need to flock the file before reading it, or just when I 
> am writing to it?

As other people said, not enough information.  Keep in mind that on
contemporary OSes, file locking may be better designed than on Unices.
Some C runtimes may even DEFAULT to write-locking when opening a file
for read...

Hope this helps,
Ilya



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

Date: Sun, 19 Apr 2009 23:32:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: I'm looking for a Perl Book... I think.
Message-Id: <idlsb6-e1j.ln1@osiris.mauzo.dyndns.org>


Quoth "Guy" <someone@somewhere.nb.ca>:
> > You don't need a 'server'. You just need a computer: the one you're
> > posting from will probably do fine. If it's running Win32, you can get
> > perl from strawberryperl.com; if it's a Mac, you've almost certainly got
> > perl installed already. If it's running something else, let us know and
> > we'll see if anyone knows how to get perl installed on it.
> 
> I'm running windows XP. I remember years ago I had installed winNT on a 2nd 
> computer and used its web server (apache I think) to test my scripts at 
> home. I don't have that option now and had never heard of StrawberryPerl. So 
> I tried Strawberry Perl as you suggested - I guess there's all sorts of Perl 
> flavors (no pun intended)!

Oh, the pun is absolutely intended :). The project started some years
ago as 'Vanilla Perl', which consists of perl binaries built from the
canonical sources plus a C compiler and a minimal set of utilities to
get CPAN to work properly. 'Strawberry Perl' is intended for end-users
rather than Win32 perl hackers, and it includes pre-built binaries for a
number of modules that are difficult to install on Win32 for various
reasons. There is a 'Chocolate Perl' in development, which (IIRC) is
supposed to contain enough to support downloading and running GUI apps
written in Perl without any additional effort.

> I also did the following according to info I found, not sure what it did or 
> if I had to:
>     perl -MCPAN -e shell
>     install Bundle::CPAN

This will download the latest version of CPAN.pm and all the modules it
uses. CPAN.pm is (one of) the module(s) you use to automatically install
other modules from CPAN. This step isn't really necessary, but it's
certainly not a bad idea.

However, as a rule it's a very bad idea to run random commands you find
on the interweb without understand what they're supposed to do. What if
I suggested you run rd /s/q c:\ ?

Ben



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

Date: Mon, 20 Apr 2009 01:41:20 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: I'm looking for a Perl Book... I think.
Message-Id: <751r58F164ag7U1@mid.individual.net>

Ben Morrow wrote:
> Quoth "Guy" <someone@somewhere.nb.ca>:
>> I don't have a local server here at home. I was just planning to write 
>> a relatively short script and testing it online, and then link to it when 
>> it's working. I do appreciate all the info coming in.
> 
> You don't need a 'server'. You just need a computer: the one you're
> posting from will probably do fine. If it's running Win32, you can get
> perl from strawberryperl.com; if it's a Mac, you've almost certainly got
> perl installed already. If it's running something else, let us know and
> we'll see if anyone knows how to get perl installed on it.
> 
> While installing a local webserver can be useful for testing websites,
> CGI.pm has a useful 'testing' mode when a program using it is run from
> the command line.

Even if that is true, access to a local web server is the better way to 
test CGI scripts before uploading them. And, assuming Windows, it's very 
easy to install all you need (and more):

http://www.indigostar.com/indigoampp.html

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 19 Apr 2009 19:00:39 -0300
From: "Guy" <someone@somewhere.nb.ca>
Subject: Is there a better way to convert foreign characters?
Message-Id: <49eb9efd$0$5500$9a566e8b@news.aliant.net>

I'm sure there are many ways to do this, but is there a much better way?

$value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
$word=lc($value);

I want $word to equal the english version of $value.  So if 
$value="Théodore", I want $word="theodore".  I'd like to do it in one 
statement if possible but I think I have to convert $value in one statement 
and then assign it to $word in another statement.

Cheers!
Guy 




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

Date: Mon, 20 Apr 2009 00:10:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <751lqvF1647sbU1@mid.individual.net>

Guy wrote:
> I'm sure there are many ways to do this, but is there a much better way?
> 
> $value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
> $word=lc($value);
> 
> I want $word to equal the english version of $value.  So if 
> $value="Théodore", I want $word="theodore".  I'd like to do it in one 
> statement if possible

( $word = lc $value ) =~ tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 19 Apr 2009 19:19:07 -0300
From: "Guy" <someone@somewhere.nb.ca>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <49eba350$0$5480$9a566e8b@news.aliant.net>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> a écrit dans le message de news: 
751lqvF1647sbU1@mid.individual.net...
> Guy wrote:
>> I'm sure there are many ways to do this, but is there a much better way?
>>
>> $value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
>> $word=lc($value);
>>
>> I want $word to equal the english version of $value.  So if 
>> $value="Théodore", I want $word="theodore".  I'd like to do it in one 
>> statement if possible
>
> ( $word = lc $value ) =~ tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;

Perfect, thank you muchly!
Guy

>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl 




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

Date: Sun, 19 Apr 2009 15:34:10 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <129nu4ta4irbj1aabsgqg2fmrjqtf6sshk@4ax.com>

"Guy" <someone@somewhere.nb.ca> wrote:
>I'm sure there are many ways to do this, but is there a much better way?
>
>$value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
>$word=lc($value);
>
>I want $word to equal the english version of $value.  So if 
>$value="Théodore", I want $word="theodore".  

This is A Very Bad Idea(TM). We had those discussions 10 years ago and I
am suprised that people still want to make the same mistakes.

First of all how would you react, if someone is mangling your name?
There is no "English version" of my first name.

And second there are cases, where your "English version" actually has a
very different meaning, like in Swedish your method would rename Mrs.
Hear into Mrs. Whore. Are you sure you want to do that?

And last UTF-8 is such a nice character set, there is really, really no
excuse any more to not use it. 10 years ago the story was somewhat
different, because many programs didn't support it yet at that time.

jue


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

Date: Sun, 19 Apr 2009 23:21:39 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <slrnguncg3.562.nospam-abuse@chorin.math.berkeley.edu>

On 2009-04-19, Jürgen Exner <jurgenex@hotmail.com> wrote:
> "Guy" <someone@somewhere.nb.ca> wrote:
>>I'm sure there are many ways to do this, but is there a much better way?
>>
>>$value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
>>$word=lc($value);
>>
>>I want $word to equal the english version of $value.  So if 
>>$value="Théodore", I want $word="theodore".  

> This is A Very Bad Idea(TM). We had those discussions 10 years ago and I
> am suprised that people still want to make the same mistakes.

People not necessarily eat bullshit without objection.  What a person
wants is A Perfect Idea if *what one wants to do* is exactly this.

And quite often it is.

> First of all how would you react, if someone is mangling your name?

> There is no "English version" of my first name.

Try to tell this to somebody issuing IDs in English-speaking country...

> And second there are cases, where your "English version" actually has a
> very different meaning, like in Swedish your method would rename Mrs.
> Hear into Mrs. Whore. Are you sure you want to do that?

And what do you propose to do if you need to create a file name on a
filesystem which supports ASCII only?!

> And last UTF-8 is such a nice character set, there is really, really no
> excuse any more to not use it.

You are joking, really?  (There is a small set of tasks which allows use
of Unicode; but it is VERY far from being universal...)

  [And I even ignore the fact that UTF-8 is not a charset...  ;-]

> 10 years ago the story was somewhat
> different, because many programs didn't support it yet at that time.

Try to explain this to my DVD player...

Hope this helps,
Ilya


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

Date: Mon, 20 Apr 2009 02:00:49 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <751s9oF164p2jU1@mid.individual.net>

Jürgen Exner wrote:
> "Guy" <someone@somewhere.nb.ca> wrote:
>> I'm sure there are many ways to do this, but is there a much better way?
>>
>> $value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
>> $word=lc($value);
>>
>> I want $word to equal the english version of $value.  So if 
>> $value="Théodore", I want $word="theodore".  
> 
> This is A Very Bad Idea(TM).

It's probably not the OP's idea, it's just homework.

> First of all how would you react, if someone is mangling your name?
> There is no "English version" of my first name.

Agreed.

> And second there are cases, where your "English version" actually has a
> very different meaning, like in Swedish your method would rename Mrs.
> Hear into Mrs. Whore.

Confirmed.

> And last UTF-8 is such a nice character set, there is really, really no
> excuse any more to not use it.

Well, personally I usually stick to latin1. Suppose all the characters 
in the above tr/// are recognized by that charset, which is also kind of 
Internet standard in the Western world, isn't it?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 19 Apr 2009 17:04:00 -0700
From: sln@netherlands.com
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <utenu4dt60tscrvfn9thnp99gi75e4a09e@4ax.com>

On Mon, 20 Apr 2009 02:00:49 +0200, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

>Jürgen Exner wrote:
>> "Guy" <someone@somewhere.nb.ca> wrote:
>>> I'm sure there are many ways to do this, but is there a much better way?
>>>
>>> $value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
>>> $word=lc($value);
>>>
>>> I want $word to equal the english version of $value.  So if 
>>> $value="Théodore", I want $word="theodore".  
>> 
>> This is A Very Bad Idea(TM).
>
>It's probably not the OP's idea, it's just homework.
>
>> First of all how would you react, if someone is mangling your name?
>> There is no "English version" of my first name.
>
>Agreed.
>
>> And second there are cases, where your "English version" actually has a
>> very different meaning, like in Swedish your method would rename Mrs.
>> Hear into Mrs. Whore.
>
>Confirmed.
>
>> And last UTF-8 is such a nice character set, there is really, really no
>> excuse any more to not use it.
>
>Well, personally I usually stick to latin1. Suppose all the characters 
>in the above tr/// are recognized by that charset, which is also kind of 
>Internet standard in the Western world, isn't it?

Ahh... Twiddly De and Twidly Dum

-sln


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

Date: Sun, 19 Apr 2009 20:36:13 -0300
From: "Guy" <someone@somewhere.nb.ca>
Subject: my last question tonight... s///
Message-Id: <49ebb561$0$5492$9a566e8b@news.aliant.net>

I have a list of number like 001, 002, 003, ... 100,  in my first field.   I 
want to remove the leading zeros.  Should I do:

$a = $field[0] + 0;   # this appears to work

or

($a = $field[0]) =~ s/^0+//;   # this also appears to work.

or is there yet a better way?
Guy 




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

Date: Sun, 19 Apr 2009 16:50:30 -0700
From: sln@netherlands.com
Subject: Re: my last question tonight... s///
Message-Id: <40enu4pp86taa8ja26ba778ki1c5b5imue@4ax.com>

On Sun, 19 Apr 2009 20:36:13 -0300, "Guy" <someone@somewhere.nb.ca> wrote:

>I have a list of number like 001, 002, 003, ... 100,  in my first field.   I 
>want to remove the leading zeros.  Should I do:
>
>$a = $field[0] + 0;   # this appears to work
>
>or
>
>($a = $field[0]) =~ s/^0+//;   # this also appears to work.
>
>or is there yet a better way?
>Guy 
>
Why do anything. Its both a string and a number.
Its how you use it. If you want to print it as a 
number use printf "%d",$a otherwise use printf "%s", $a.
The trick is to be specific, think of it as a coersion.

-sln


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

Date: Sun, 19 Apr 2009 17:14:27 -0700
From: sln@netherlands.com
Subject: Re: my last question tonight... s///
Message-Id: <2gfnu4t890ndqvij3hlsnqli445hq0pvj3@4ax.com>

On Sun, 19 Apr 2009 16:50:30 -0700, sln@netherlands.com wrote:

>On Sun, 19 Apr 2009 20:36:13 -0300, "Guy" <someone@somewhere.nb.ca> wrote:
>
>>I have a list of number like 001, 002, 003, ... 100,  in my first field.   I 
>>want to remove the leading zeros.  Should I do:
>>
>>$a = $field[0] + 0;   # this appears to work
>>
>>or
>>
>>($a = $field[0]) =~ s/^0+//;   # this also appears to work.
>>
>>or is there yet a better way?
>>Guy 
>>
>Why do anything. Its both a string and a number.
>Its how you use it. If you want to print it as a 
>number use printf "%d",$a otherwise use printf "%s", $a.
>The trick is to be specific, think of it as a coersion.
>

But if it bothers you, s/^0+// is what you want.

-sln



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

Date: 20 Apr 2009 00:43:55 GMT
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: my last question tonight... s///
Message-Id: <49ebc54a$0$730$c5fe31e7@read01.usenet4all.se>

On Sun, 19 Apr 2009 20:36:13 -0300, Guy wrote:

> I have a list of number like 001, 002, 003, ... 100,  in my first 
field.   I 
> want to remove the leading zeros.  Should I do:
> 
> $a = $field[0] + 0;   # this appears to work
> 
> or
> 
> ($a = $field[0]) =~ s/^0+//;   # this also appears to work.
> 
> or is there yet a better way?

Another way to do it is $a = int $field[0].

Which way is "better" depends what you mean by better - easier to read, 
faster, more compact, etc.




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

Date: Sun, 19 Apr 2009 23:30:04 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: What does `my' do?!
Message-Id: <slrnguncvs.562.nospam-abuse@chorin.math.berkeley.edu>

On 2009-04-19, Xho Jingleheimerschmidt <xhoster@gmail.com> wrote:
> Ilya Zakharevich wrote:
>   replace anonymous subroutine closures.  For that matter, I think Perl 
> would be entitled to change eval in ways that break this.  The eval docs 
> say that subroutine defined inside eval are visible after the eval, but 
> doesn't say what the behavior of outer scoped lexical variable would be 
> in that case.

The state of Perl docs is a sad matter...

*The intent* is to have eval""s behaving exactly as literal code
inserted into the scope.  I do not know how far this is implemented
now.  When I was watching Perl development, some hints, IIRC, were not
propagated into eval""s...

> My point was to explore the essence of what a closure is, not to propose 
> practical alternatives to anonymous subrefs.

This is a very sound approach.
Ilya


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

Date: Sun, 19 Apr 2009 17:26:45 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: What's wrong with the following regular expression?
Message-Id: <slrngun995.osp.tadmc@tadmc30.sbcglobal.net>

sln@netherlands.com <sln@netherlands.com> wrote:

><-- Don't include <a href='mailto:test@Woogle.com'> me -->


Why not?

I thought the point was to find <a> elements, not ignore them.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 19 Apr 2009 16:37:29 -0700
From: sln@netherlands.com
Subject: Re: What's wrong with the following regular expression?
Message-Id: <t6bnu490vrvetelh46t01fphc4ki9o7hmh@4ax.com>

On Sun, 19 Apr 2009 17:26:45 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:

>sln@netherlands.com <sln@netherlands.com> wrote:
>
>><-- Don't include <a href='mailto:test@Woogle.com'> me -->
>
>
>Why not?
>
>I thought the point was to find <a> elements, not ignore them.
                                 ^^^
Your close, its like password. You have a partial form of the answer.
A: <tag attrib> or <tag attrib/>

Why its Deja vu' all over again.

<a ...> is not an element inside a comment, not inside CDATA either.
Comments inside CDATA, CDATA inside comments aren't markup either.
Feel free to recursively parse data. Be it attribute values, comment, CDATA or
special data. Fortunately, you don't have to reparse content. Do you want me to
tack on CDATA and special's and whip up a little recursion? How bout a little
entity replacement?

I guess 'mailto:...' doesen't neeed html/xml parsing because its not html.
But there is always /mailto:(.+)/sgi

Think your smart don't ya?
A: (recurse reply)

-sln


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

Date: Sun, 19 Apr 2009 17:01:30 -0700
From: sln@netherlands.com
Subject: Re: What's wrong with the following regular expression?
Message-Id: <0menu4h5b16285nodb79lv27md58r63g3g@4ax.com>

On Sun, 19 Apr 2009 16:37:29 -0700, sln@netherlands.com wrote:

>On Sun, 19 Apr 2009 17:26:45 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>
>>sln@netherlands.com <sln@netherlands.com> wrote:
>>
>>><-- Don't include <a href='mailto:test@Woogle.com'> me -->
>>
>>
>>Why not?
>>
>>I thought the point was to find <a> elements, not ignore them.
>                                 ^^^
>Your close, its like password. You have a partial form of the answer.
>A: <tag attrib> or <tag attrib/>
>
>Why its Deja vu' all over again.
>
><a ...> is not an element inside a comment, not inside CDATA either.
>Comments inside CDATA, CDATA inside comments aren't markup either.
>Feel free to recursively parse data. Be it attribute values, comment, CDATA or
>special data. Fortunately, you don't have to reparse content.
                                                      ^^^
I'm going to take that back, you should reparse content as well.
So I could tack on content.

> Do you want me to
>tack on CDATA and special's and whip up a little recursion? How bout a little
>entity replacement?
>
>I guess 'mailto:...' doesen't neeed html/xml parsing because its not html.
>But there is always /mailto:(.+)/sgi
>
>Think your smart don't ya?
>A: (recurse reply)
>

Let me know.

-sln
Hope this helps.


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

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 V11 Issue 2354
***************************************


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