[27989] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9353 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 23 09:05:44 2006

Date: Fri, 23 Jun 2006 06:05:06 -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           Fri, 23 Jun 2006     Volume: 10 Number: 9353

Today's topics:
        Construction of a non-regexable subset of the set of al <dominic.zypen@gmail.com>
    Re: Construction of a non-regexable subset of the set o <someone@example.com>
    Re: Database Connection Problem fred@fredthomas.co.uk
    Re: extracting regular expressions <nospam@home.com>
    Re: extracting regular expressions <David.Squire@no.spam.from.here.au>
    Re: extracting regular expressions <David.Squire@no.spam.from.here.au>
        Help Required !!!! <vandana@sadhanasoft.com>
    Re: Help Required !!!! <David.Squire@no.spam.from.here.au>
    Re: Help Required !!!! cartercc@gmail.com
    Re: Help Required !!!! <someone@example.com>
    Re: Help with worthy project ? <hooper1@optonline.net>
    Re: Help with worthy project ? <someone@example.com>
    Re: Saying "latently-typed language" is making a catego <pats@acm.org>
    Re: Saying "latently-typed language" is making a catego <anton@appsolutions.com>
    Re: Saying "latently-typed language" is making a catego <pc@p-cos.net>
    Re: Saying "latently-typed language" is making a catego <pc@p-cos.net>
        service name package <me@invalid.domain>
    Re: Unwanted character "^@" in perl output <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 23 Jun 2006 05:45:44 -0700
From: "Dominic van der Zypen" <dominic.zypen@gmail.com>
Subject: Construction of a non-regexable subset of the set of all strings
Message-Id: <1151066744.131474.280600@y41g2000cwy.googlegroups.com>

Hello,

I have a question which I am afraid might seem "overly scientific" (not
to say nutty), but which I find is quite natural after all.

If we look at the set S of all finite strings, then each regex
represents some subset of S. For instance, h(a|e)ndel is the set
consisting of handel and hendel; and the regex .+ represents the set
of all non-empty strings not containing \n.

I wondered whether there is a "non-regexable" subset N of S (i.e. a
subset N for which there is no regex representing N) and came up with
a (non-constructive) positive answer from set theory: there are
uncountably many subsets of S, but there are only countably many
regular expressions, so there are non-regexable subsets.

What I would like to know is whether one can construct a subset N of S
which is non-regexable (and whether it is hard to prove that N has the
desired property).

Many thanks in advance and best wishes, Dominic



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

Date: Fri, 23 Jun 2006 12:53:48 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Construction of a non-regexable subset of the set of all strings
Message-Id: <wvRmg.84820$771.80395@edtnps89>

Dominic van der Zypen wrote:
> 
> I have a question which I am afraid might seem "overly scientific" (not
> to say nutty), but which I find is quite natural after all.
> 
> If we look at the set S of all finite strings, then each regex
> represents some subset of S. For instance, h(a|e)ndel is the set
> consisting of handel and hendel; and the regex .+ represents the set
> of all non-empty strings not containing \n.
> 
> I wondered whether there is a "non-regexable" subset N of S (i.e. a
> subset N for which there is no regex representing N) and came up with
> a (non-constructive) positive answer from set theory: there are
> uncountably many subsets of S, but there are only countably many
> regular expressions, so there are non-regexable subsets.
> 
> What I would like to know is whether one can construct a subset N of S
> which is non-regexable (and whether it is hard to prove that N has the
> desired property).

Are you talking about regular expressions in general or only Perl's regular
expressions?  If this is a generic regular expression question you may want to
ask in a group like comp.programming instead.


John
-- 
use Perl;
program
fulfillment


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

Date: 23 Jun 2006 04:58:02 -0700
From: fred@fredthomas.co.uk
Subject: Re: Database Connection Problem
Message-Id: <1151063882.394700.155980@u72g2000cwu.googlegroups.com>


fred@fredthomas.co.uk wrote:
> Hi,
>
> I im trying to install an intranet onto a new build server and while it
> works fine in the development environment i get this error on the new
> test server:
>
> DBI connect('Driver={SQL
> Server};Server=172.16.99.1;Database=ffcommon;','sa',...) failed:
> [Microsoft][ODBC SQL Server Driver][Named Pipes]Access denied.
> (SQL-08001)
> [Microsoft][ODBC SQL Server Driver][Named Pipes]ConnectionOpen
> (CreateFile()). (SQL-01000)(DBD: db_login/SQLConnect err=-1) at
> FF_Config.pm line 112
>
>
> I dont want to use named pipes but cannot see where to change it.  In
> development it uses TCP IP so why on the new sever would it be trying
> to use named pipes?
>
> (I am a complete novice when it comes to perl!)
>
> Thanks for any help
>
> Fred

No worries all sorted.  Turns out it was just a corrupt install of the
DBD-ODBC package.



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

Date: Fri, 23 Jun 2006 11:02:43 GMT
From: "Nospam" <nospam@home.com>
Subject: Re: extracting regular expressions
Message-Id: <nTPmg.56497$uP.29791@newsfe2-gui.ntli.net>


"Xicheng Jia" <xicheng@gmail.com> wrote in message
news:1150907933.364748.49710@i40g2000cwc.googlegroups.com...
> Nospam wrote:
> > I am wondering say I had a string, en email address sample@example.com
and I
> > wanted to ignore everything from the @ and place in a variable, would
> > something like this suffice:
> >
> > #! usr/bin/perl
> > use warnings;
> > use strict;
> > my $var1= sample@example.com;
> >
> > my $var2 = $var !=~ m/(\@*.$)(.*)/s;
> >
> > however I am not making any progress and looking at perltut I am unable
to
> > find a regular expression to do just this
>
> (my $var2 = $var1) = ~s/\@.*//;
>
> this will assign 'sample' to $var2
>
> Xicheng
>

Tried to print out $var2 all I received was a number and not the actual
text:

#! usr/bin/perl
use warnings;
use strict;
my $var1= "sample\@example.com";

(my $var2 = $var1) = ~s/\@.*//;

print "$var2 \n";

output is:

Use of uninitialized value in substitution (s///) at varex1.pl line 6.
4294967295




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

Date: Fri, 23 Jun 2006 12:13:55 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: extracting regular expressions
Message-Id: <e7gidj$mfh$1@news.ox.ac.uk>

Nospam wrote:
> "Xicheng Jia" <xicheng@gmail.com> wrote in message
> news:1150907933.364748.49710@i40g2000cwc.googlegroups.com...
>> Nospam wrote:
>>> I am wondering say I had a string, en email address sample@example.com
> and I
>>> wanted to ignore everything from the @ and place in a variable, would
>>> something like this suffice:
>>>
>>> #! usr/bin/perl
>>> use warnings;
>>> use strict;
>>> my $var1= sample@example.com;
>>>
>>> my $var2 = $var !=~ m/(\@*.$)(.*)/s;
>>>
>>> however I am not making any progress and looking at perltut I am unable
> to
>>> find a regular expression to do just this
>> (my $var2 = $var1) = ~s/\@.*//;
>>
>> this will assign 'sample' to $var2
>>
>> Xicheng
>>
> 
> Tried to print out $var2 all I received was a number and not the actual
> text:
> 
> #! usr/bin/perl
----^

Broken path, but I guess that you must be on M$ Windows, since this 
apparently didn't hurt you.


> use warnings;
> use strict;
> my $var1= "sample\@example.com";
> 
> (my $var2 = $var1) = ~s/\@.*//;
-----------------------^

The =~ operator has been broken. You want:

----

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

my $var1 = "sample\@example.com";

(my $var2 = $var1) =~ s/\@.*//;

print "$var2\n";

----

Output:

sample


DS


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

Date: Fri, 23 Jun 2006 12:17:34 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: extracting regular expressions
Message-Id: <e7gike$mfh$2@news.ox.ac.uk>

David Squire wrote:
> Nospam wrote:
>> "Xicheng Jia" <xicheng@gmail.com> wrote in message
>> news:1150907933.364748.49710@i40g2000cwc.googlegroups.com...
>>> Nospam wrote:
>>>> I am wondering say I had a string, en email address sample@example.com
>> and I
>>>> wanted to ignore everything from the @ and place in a variable, would
>>>> something like this suffice:
>>>>
>>>> #! usr/bin/perl
>>>> use warnings;
>>>> use strict;
>>>> my $var1= sample@example.com;
>>>>
>>>> my $var2 = $var !=~ m/(\@*.$)(.*)/s;
>>>>
>>>> however I am not making any progress and looking at perltut I am unable
>> to
>>>> find a regular expression to do just this

[snip]

> The =~ operator has been broken. You want:
> 
> ----
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $var1 = "sample\@example.com";
> 
> (my $var2 = $var1) =~ s/\@.*//;
> 
> print "$var2\n";
> 
> ----
> 
> Output:
> 
> sample
> 

Though in fact this is how I would do it myself:

----

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

my $var1 = "sample\@example.com";

my ($var2) = $var1 =~ m/(.*?)\@/;

print "$var2\n";

----


DS


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

Date: 23 Jun 2006 03:53:24 -0700
From: "vandana" <vandana@sadhanasoft.com>
Subject: Help Required !!!!
Message-Id: <1151060004.367827.86320@m73g2000cwd.googlegroups.com>

Hello,

# strip (trailing) filename from path, leaving directory only

my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;

It removes trailing filename from path. Can anyone help me to
understand the working of
m|(^.*)\\|; in above command.

Regards
Vandana



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

Date: Fri, 23 Jun 2006 12:01:45 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Help Required !!!!
Message-Id: <e7ghmp$m92$1@news.ox.ac.uk>

vandana wrote:
> Hello,

Hello Vandana,

Welcome to this group. Might I suggest that a good starting point for 
you would be to read the posting guidelines that are posted here several 
times a week. In particular, they give advice on how to maximize your 
chances of getting a useful response, by doing such things are using a 
meaningful subject line for your post.


> 
> # strip (trailing) filename from path, leaving directory only
> 
> my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;
> 
> It removes trailing filename from path. Can anyone help me to
> understand the working of
> m|(^.*)\\|; in above command.

You need to read Perl's documentation on regular expressions, and the 
match and substitution operators that use them. Perl comes with its 
documentation included. You can access it using the perldoc command on 
the command line. Try "perldoc perlre", "perldoc perlop", and "perldoc 
perlretut". You can also read the documentation online at 
http://www.perl.com/pub/q/documentation

Regards,

DS


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

Date: 23 Jun 2006 04:16:16 -0700
From: cartercc@gmail.com
Subject: Re: Help Required !!!!
Message-Id: <1151061376.675509.217120@b68g2000cwa.googlegroups.com>

vandana wrote:
> Hello,
> It removes trailing filename from path. Can anyone help me to
> understand the working of
> m|(^.*)\\|; in above command.

m # matches the left value
| # the delimiter for the regular expression
( # beginning of whatever is saved
^ # matches the beginning of the line
 . # matches any character up to whatever follows
* # matches greedily any number of characters from zero upward
) # ends the recording of charachter - paired with the opening parens
\ # the escape character
\ # the character escaped, possibly a Windows path delimiter
| # the delimiter of the regular expression - paired with the opening
pipe
; # ends the expression

Suggest you sit down with the Perl documentation and read the pages on
regular expressions.

CC



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

Date: Fri, 23 Jun 2006 12:39:31 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help Required !!!!
Message-Id: <7iRmg.1633$B91.794@edtnps82>

vandana wrote:
> 
> # strip (trailing) filename from path, leaving directory only

You probably want to use the File::Basename::dirname function for that:

perldoc File::Basename


John
-- 
use Perl;
program
fulfillment


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

Date: 23 Jun 2006 04:08:37 -0700
From: "GHBoom" <hooper1@optonline.net>
Subject: Re: Help with worthy project ?
Message-Id: <1151060916.695213.243890@r2g2000cwb.googlegroups.com>


Juha,
It is a sourceforge project ;)

I understand about getting trust worthy delvelopers.

I had one reply to the help wanted post, but unfortunatly
it looks like the guy wanted to code without talking  ;(

Anyway my project is at,
http://sourceforge.net/projects/fzbfd/


> How about getting the project up onto one of the open source
> repositories, such as SourceForge?
>
> Of course, SourceForge doesn't automatically bring you any
> developers, but it forms a communication channel, and also
> provides the code up for anyone to see and comment upon.
>



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

Date: Fri, 23 Jun 2006 12:35:00 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help with worthy project ?
Message-Id: <UdRmg.69010$I61.18682@clgrps13>

GHBoom wrote:
> Juha,
> It is a sourceforge project ;)
> 
> I understand about getting trust worthy delvelopers.
> 
> I had one reply to the help wanted post, but unfortunatly
> it looks like the guy wanted to code without talking  ;(
> 
> Anyway my project is at,
> http://sourceforge.net/projects/fzbfd/

I suggest the first thing you do is to compile your code with warnings enabled
and fix all the warnings that appear (I got 17 when I did it.)  And after that
compile your code with warnings *AND* strict enabled and when it finally
compiles without producing any messages from warnings and strict then you may
find people taking your request more seriously.


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 23 Jun 2006 11:18:28 GMT
From: Patricia Shanahan <pats@acm.org>
Subject: Re: Saying "latently-typed language" is making a category mistake
Message-Id: <86Qmg.10725$o4.1907@newsread2.news.pas.earthlink.net>

Vesa Karvonen wrote:
 ...
> An example of a form of informal reasoning that (practically) every
> programmer does daily is termination analysis.  There are type systems
> that guarantee termination, but I think that is fair to say that it is not
> yet understood how to make a practical general purpose language, whose
> type system would guarantee termination (or at least I'm not aware of such
> a language).  It should also be clear that termination analysis need not
> be done informally.  Given a program, it may be possible to formally prove
> that it terminates.

To make the halting problem decidable one would have to do one of two
things: Depend on memory size limits, or have a language that really is
less expressive, at a very deep level, than any of the languages
mentioned in the newsgroups header for this message.

A language for which the halting problem is decidable must also be a
language in which it is impossible to simulate an arbitrary Turing
machine (TM). Otherwise, one could decide the notoriously undecidable TM
halting problem by generating a language X program that simulates the TM
and deciding whether the language X program halts.

One way out might be to depend on the boundedness of physical memory. A
language with a fixed maximum memory size cannot simulate an arbitrary
TM. However, the number of states for a program is so great that a
method that depends on its finiteness, but would not work for an
infinite memory model, is unlikely to be practical.

Patricia


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

Date: Fri, 23 Jun 2006 11:50:44 GMT
From: Anton van Straaten <anton@appsolutions.com>
Subject: Re: Saying "latently-typed language" is making a category mistake
Message-Id: <oAQmg.49060$fb2.24820@newssvr27.news.prodigy.net>

Vesa Karvonen wrote:
> I think that we're finally getting to the bottom of things.  While reading
> your reponses something became very clear to me: latent-typing and latent-
> types are not a property of languages.  Latent-typing, also known as
> informal reasoning, is something that all programmers do as a normal part
> of programming.  To say that a language is latently-typed is to make a
> category mistake, because latent-typing is not a property of languages.
> 
> A programmer, working in any language, whether typed or not, performs
> informal reasoning.  I think that is fair to say that there is a
> correspondence between type theory and such informal reasoning.  The
> correspondence is like the correspondence between informal and formal
> math.  *But* , informal reasoning (latent-typing) is not a property of
> languages.

Well, it's obviously the case that latent types as I've described them 
are not part of the usual semantics of dynamically typed languages.  In 
other messages, I've mentioned types like "number -> number" which have 
no meaning in a dynamically typed language.  You can only write them in 
comments (unless you implement some kind of type handling system), and 
language implementations aren't aware of such types.

OTOH, a programmer reasoning explicitly about such types, writing them 
in comments, and perhaps using assertions to check them has, in a sense, 
     defined a language.  Having done that, and reasoned about the types 
in his program, he manually erases them, "leaving" code written in the 
original dynamically-typed language.  You can think of it as though it 
were generated code, complete with comments describing types, injected 
during the erasure process.

So, to address your category error objection, I would say that latent 
typing is a property of latently-typed languages, which are typically 
informally-defined supersets of what we know as dynamically-typed languages.

I bet that doesn't make you happy, though.  :D

Still, if that sounds a bit far-fetched, let me start again at ground 
level, with a Haskell vs. Scheme example:

   let double x = x * 2

vs.:

   (define (double x) (* x 2))

Programmers in both languages do informal reasoning to figure out the 
type of 'double'.  I'm assuming that the average Haskell programmer 
doesn't write out a proof whenever he wants to know the type of a term, 
and doesn't have a compiler handy.

But the Haskell programmer's informal reasoning takes place in the 
context of a well-defined formal type system.  He knows what the "type 
of double" means: the language defines that for him.

The type-aware Scheme programmer doesn't have that luxury: before he can 
talk about types, he has to invent a type system, something to give 
meaning to an expression such as "number -> number".  Performing that 
invention gives him types -- albeit informal types, a.k.a. latent types.

In the Haskell case, the types are a property of the language.  If 
you're willing to acknowledge the existence of something like latent 
types, what are they a property of?  Just the amorphous informal cloud 
which surrounds dynamically-typed languages?  Is that a satisfactory 
explanation of these two quite similar examples?

I want to mention two other senses in which latent types become 
connected to real languages.  That doesn't make them properties of the 
formal semantics of the language, but the connection is a real one at a 
different level.

The first is that in a language without a rich formal type system, 
informal reasoning outside of the formal type system becomes much more 
important.  Conversely, in Haskell, even if you accept the existence of 
latent types, they're close enough to static types that it's hardly 
necessary to consider them.  This is why latent types are primarily 
associated with languages without rich formal type systems.

The second connection is via tags: these are part of the definition of a 
dynamically-typed language, and if the programmer is reasoning 
explicitly about latent types, tags are a useful tool to help ensure 
that assumptions about types aren't violated.  So this is a connection 
between a feature in the semantics of the language, and these 
extra-linguistic latent types.

> An example of a form of informal reasoning that (practically) every
> programmer does daily is termination analysis.  There are type systems
> that guarantee termination, but I think that is fair to say that it is not
> yet understood how to make a practical general purpose language, whose
> type system would guarantee termination (or at least I'm not aware of such
> a language).  It should also be clear that termination analysis need not
> be done informally.  Given a program, it may be possible to formally prove
> that it terminates.

Right.  And this is partly why talking about latent types, as opposed to 
the more general "informal reasoning", makes sense: because latent types 
are addressing the same kinds of things that static types can capture. 
Type-like things.

> I'm now more convinced than ever that "(latently|dynamically)-typed
> language" is an oxymoron.  The terminology really needs to be fixed.

I agree that fixing is needed.  The challenge is to do it in a way that 
accounts for, rather than simply ignores, the many informal correlations 
to formal type concepts that exist in dynamically-typed languages. 
Otherwise, the situation won't improve.

Anton


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

Date: Fri, 23 Jun 2006 14:24:20 +0200
From: Pascal Costanza <pc@p-cos.net>
Subject: Re: Saying "latently-typed language" is making a category mistake
Message-Id: <4g24rlF1l16viU1@individual.net>

Vesa Karvonen wrote:
> In comp.lang.functional Anton van Straaten <anton@appsolutions.com> wrote:
> [...]
>> I reject this comparison.  There's much more to it than that.  The point 
>> is that the reasoning which programmers perform when working with an 
>> program in a latently-typed language bears many close similiarities to 
>> the purpose and behavior of type systems.
> 
>> This isn't an attempt to jump on any bandwagons, it's an attempt to 
>> characterize what is actually happening in real programs and with real 
>> programmers.  I'm relating that activity to type systems because that is 
>> what it most closely relates to.
> [...]
> 
> I think that we're finally getting to the bottom of things.  While reading
> your reponses something became very clear to me: latent-typing and latent-
> types are not a property of languages.  Latent-typing, also known as
> informal reasoning, is something that all programmers do as a normal part
> of programming.  To say that a language is latently-typed is to make a
> category mistake, because latent-typing is not a property of languages.

I disagree with you and agree with Anton. Here, it is helpful to 
understand the history of Scheme a bit: parts of its design are a 
reaction to what Schemers perceived as having failed in Common Lisp (and 
other previous Lisp dialects).

One particularly illuminating example is the treatment of nil in Common 
Lisp. That value is a very strange beast in Common Lisp because it 
stands for several concepts at the same time: most importantly the empty 
list and the boolean false value. Its type is also "interesting": it is 
both a list and a symbol at the same time. It is also "interesting" that 
its quoted value is equivalent to the value nil itself. This means that 
the following two forms are equivalent:

(if nil 42 4711)
(if 'nil 42 4711)

Both forms evaluate to 4711.

It's also the case that taking the car or cdr (first or rest) of nil 
doesn't give you an error, but simply returns nil as well.

The advantage of this design is that it allows you to express a lot of 
code in a very compact way. See 
http://www.apl.jhu.edu/~hall/lisp/Scheme-Ballad.text for a nice 
illustration.

The disadvantage is that it is mostly impossible to have a typed view of 
nil, at least one that clearly disambiguates all the cases. There are 
also other examples where Common Lisp conflates different types, and 
sometimes only for special cases. [1]

Now compare this with the Scheme specification, especially this section: 
http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-6.html#%25_sec_3.2

This clearly deviates strongly from Common Lisp (and other Lisp 
dialects). The emphasis here is on a clear separation of all the types 
specified in the Scheme standard, without any exception. This is exactly 
what makes it straightforward in Scheme to have a latently typed view of 
programs, in the sense that Anton describes. So latent typing is a 
property that can at least be enabled / supported by a programming 
language, so it is reasonable to talk about this as a property of some 
dynamically typed languages.



Pascal

[1] Yet Common Lisp allows you to write beautiful code, more often than 
not especially _because_ of these "weird" conflations, but that's a 
different topic.

-- 
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/


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

Date: Fri, 23 Jun 2006 14:27:38 +0200
From: Pascal Costanza <pc@p-cos.net>
Subject: Re: Saying "latently-typed language" is making a category mistake
Message-Id: <4g251pF1knc6tU1@individual.net>

Patricia Shanahan wrote:
> Vesa Karvonen wrote:
> ...
>> An example of a form of informal reasoning that (practically) every
>> programmer does daily is termination analysis.  There are type systems
>> that guarantee termination, but I think that is fair to say that it is 
>> not
>> yet understood how to make a practical general purpose language, whose
>> type system would guarantee termination (or at least I'm not aware of 
>> such
>> a language).  It should also be clear that termination analysis need not
>> be done informally.  Given a program, it may be possible to formally 
>> prove
>> that it terminates.
> 
> To make the halting problem decidable one would have to do one of two
> things: Depend on memory size limits, or have a language that really is
> less expressive, at a very deep level, than any of the languages
> mentioned in the newsgroups header for this message.

Not quite. See http://en.wikipedia.org/wiki/ACL2


Pascal

-- 
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/


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

Date: Fri, 23 Jun 2006 14:19:28 +0200
From: Me <me@invalid.domain>
Subject: service name package
Message-Id: <QYWdnd-LWLbBQQbZnZ2dnUVZ_tGdnZ2d@is.co.za>

How can I get a service name using IANA assigned port numbers?
I want pass a port number and possibly the protocol (tcp,udp,etc)
and have the name returned.

One package that does this but I can't get to install via CPAN
is Net::IANA::PortNumbers.


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

Date: Fri, 23 Jun 2006 13:49:03 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Unwanted character "^@" in perl output
Message-Id: <ffkg7e.c06.ln@teal.hjp.at>

Captain 3-Putt wrote:
> My output has a bunch of unwanted "^@" characters after every valid
> character.  It looks like:
> 
> ^@F^@i^@r^@s^@t^@^M^@

Looks like there is a NUL character *before* every valid character, not
after.

> ----------------------------------
> 
> #!/usr/bin/perl
> open(BBOARD_DOWN, "<$ARGV[0]") or die ("Couldn't open $ARGV[0]");

Are the NUL characters in the file you are opening here? 

If they are (and I suspect, they are, because I don't see where they
could come from), the file is probably in UCS-2BE or UTF-16BE (the
difference only matters if the file contains characters outside of the
BMP, like ancient Sumeric cuneiform), so you should open it with the
appropriate input layer:

open(BBOARD_DOWN, "<:encoding(UTF-16BE)", $ARGV[0]) or die ("Couldn't open $ARGV[0]");

This will convert into perl's internal string representation. You should
also tell perl to which charset it should convert when printing to
stdout (by default it will assume iso-8859-1, but switch to UTF-8 for
strings containing characters beyond U+00FF). E.g.,

binmode STDOUT, ":encoding(cp1252)";

if you want the Western Windows charset (which Microsoft likes to call
"ANSI" for reasons only known to them).

        hp

PS: Does anybody know of a portable way to get the default charset from
    the environment? I find hardcoding charsets in scripts extremely
    unelegant.

-- 
   _  | Peter J. Holzer    | Man könnte sich [die Diskussion] auch
|_|_) | Sysadmin WSR/LUGA  | sparen, wenn man sie sich einfach sparen
| |   | hjp@hjp.at         | würde.
__/   | http://www.hjp.at/ |   -- Ralph Angenendt in dang 2006-04-15


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

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


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