[27980] in Perl-Users-Digest
Perl-Users Digest, Issue: 9344 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 22 14:05:52 2006
Date: Thu, 22 Jun 2006 11:05:08 -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 Thu, 22 Jun 2006 Volume: 10 Number: 9344
Today's topics:
coderwiki.com is starting and needs you! <da404lewzer@gmail.com>
Re: extracting regular expressions <xicheng@gmail.com>
Re: extraction of multiple extensions of a file path na <tzz@lifelogs.com>
Re: extraction of multiple extensions of a file path na <corff@zedat.fu-berlin.de>
Re: List context versus list context <tadmc@augustmail.com>
Re: Native language versions <corff@zedat.fu-berlin.de>
Re: Native language versions <tzz@lifelogs.com>
Re: Native language versions <hjp-usenet2@hjp.at>
Re: Native language versions <hjp-usenet2@hjp.at>
Re: Native language versions <corff@zedat.fu-berlin.de>
Re: Native language versions <tadmc@augustmail.com>
question on Net::LPR / Unix::Login <"v.niekerk at hccnet.nl">
Re: question on Net::LPR / Unix::Login <benmorrow@tiscali.co.uk>
Re: question on Net::LPR / Unix::Login <"v.niekerk at hccnet.nl">
Re: question on Net::LPR / Unix::Login <glex_no-spam@qwest-spam-no.invalid>
Re: Unset $1 <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jun 2006 10:44:01 -0700
From: "da404LewZer" <da404lewzer@gmail.com>
Subject: coderwiki.com is starting and needs you!
Message-Id: <1150998241.432378.55400@c74g2000cwc.googlegroups.com>
i'm starting a wiki on coding, keeping everything seperate. anyone who
wants to help check out the site. i want to document every function for
every language ever
www.coderwiki.com
------------------------------
Date: 22 Jun 2006 08:18:36 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: extracting regular expressions
Message-Id: <1150989516.405088.240780@i40g2000cwc.googlegroups.com>
Anno Siegel wrote:
> In article <1150907933.364748.49710@i40g2000cwc.googlegroups.com>,
> "Xicheng Jia" <xicheng@gmail.com> writes:
> > 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:
>
> [...]
>
> >> 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
>
> It will, but I don't see why you would use a substitution to extract a bit
> of text when a pattern match will do.
>
> my ( $var2) = $var1 =~ /(.*)@/;
>
> It isn't exactly equivalent in the presence of more than one "@", but
> that can be modified. The OP hasn't been specified that case anyway.
>
> As a principle, use the simplest tool that does the job.
There are too many ways to do this, the only difference is just which
one happens to come up in one's mind at a special time.
my ( $var2) = $var1 =~ /([^@]*)/;
my $var2 = (split "@", $str)[0];
......
Not a big deal though.
Xicheng
------------------------------
Date: Thu, 22 Jun 2006 11:31:10 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: extraction of multiple extensions of a file path name ...
Message-Id: <g69hd2dtdfl.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 22 Jun 2006, corff@zedat.fu-berlin.de wrote:
> Let $filename contain your full path and file, then
> $filename=~s/\.[^.]+$/;
>
> will contain your new filename stripped off last extension and dot.
You forgot the last '/'
$filename=~s/\.[^.]+$//;
Ted
------------------------------
Date: 22 Jun 2006 15:32:59 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: extraction of multiple extensions of a file path name ...
Message-Id: <4fvrhbF1kk8cvU4@uni-berlin.de>
Ted Zlatanov <tzz@lifelogs.com> wrote:
: On 22 Jun 2006, corff@zedat.fu-berlin.de wrote:
: > $filename=~s/\.[^.]+$/;
: >
: You forgot the last '/'
: $filename=~s/\.[^.]+$//;
Thank you.
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
Date: Thu, 22 Jun 2006 11:18:31 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: List context versus list context
Message-Id: <slrne9lgmn.3ui.tadmc@magna.augustmail.com>
Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:
> Tad McClellan wrote:
>> Bo Lindbergh <blgl@stacken.kth.se> wrote:
>>
>>>Consider this snippet:
>>>{
>>> sub foo {
>>> print scalar(@_)," arguments\n";
>>> }
>>>
>>> foo((17)[2,1]);
>>> foo(my @foo=(17)[2,1]);
>>>}
>>>
>>>When run by my perl 5.8.8, it produces these two lines of output:
>>>2 arguments
>>>0 arguments
[snip my explanation of why you get the "0 arguments" output]
> I thought the context question was, why in this case
> foo((17)[2,1]);
> the expression (17)[2,1] evaluates to (undef,undef) ??
Ah ha.
The OP didn't say which of the two he understood and I ended up
picking the wrong one.
The real question here is why we're getting the "2 arguments" output.
> Maybe it has something to do with aliasing of function arguments...
I believe you are onto something there, since the only place I
can get "2" is with the 4 things (are there more?) that do aliasing:
map, grep, foreach and sub arguments.
perl -le 'push @a, map $_, (17)[2,1]; print scalar @a'
perl -le 'push @a, grep 1, (17)[2,1]; print scalar @a'
perl -le 'foreach ( (17)[2,1] ) {push @a, $_} print scalar @a'
perl -le 'push @a, sub {return @_}->( (17)[2,1] ); print scalar @a'
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Jun 2006 15:38:32 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: Native language versions
Message-Id: <4fvrroF1kk8cvU5@uni-berlin.de>
Tad McClellan <tadmc@augustmail.com> wrote:
: > Has anyone tried translating the command set of Perl into other
: > languages (French, Japanese, Arabic etc.)
: How do you say "grep" in French or Japanese?
grep in French could be ierg (imprimer expression rationelle globale), while
in Japanese I'd expect shdi (seikihyougen wo dokodemo insatsu suru), but more
idiomatical would be gureppu, of course.
scnr,
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
Date: Thu, 22 Jun 2006 11:40:44 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Native language versions
Message-Id: <g69d5d1tczn.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 22 Jun 2006, nisbeti@googlemail.com wrote:
> Has anyone tried translating the command set of Perl into other
> languages (French, Japanese, Arabic etc.), so that native speakers do
> not need to learn any English in order to program, then writing a
> suitable compiler?
I don't think the former would engender the latter. In particular,
you'd need to translate and correct all the documentation
appropriately for that language, and all your programs would require
that special version of Perl. I don't think the effort is worth the
loss of compatibility, considering the incremental effort of learning
a few keywords is negligible compared to learning Perl as a language.
Ted
------------------------------
Date: Thu, 22 Jun 2006 18:13:36 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Native language versions
Message-Id: <gjfe7e.j6r.ln@teal.hjp.at>
corff@zedat.fu-berlin.de wrote:
> Ian <nisbeti@googlemail.com> wrote:
> : Has anyone tried translating the command set of Perl into other
> : languages (French, Japanese, Arabic etc.), so that native speakers do
> : not need to learn any English in order to program, then writing a
> : suitable compiler?
In perl you don't need a separate compiler for that: You can write a
filter module. See Lingua::Romana::Perligata for a filter module which
implements Latin syntax (including declensions and
position-independence) for Perl.
> Many years ago I as in Japan for the first time and had access to a
> computer. At that time, computers still came with built-in ROM with
> BASIC, which I could try after starting the machine. I was astonished
> and disappointed to see that print statements still were named print,
> and not insatsu (in whichever writing system that would be rendered
> doesn't really matter). Naively, I asked myself why the advanced
> technology of Japan had not brought forth a computer that would natively
> "work in Japanese".
>
> Years and many languages later I understood that such an endeavour is
> of little meaning. Any given language consists of more than words, there
> is also grammar. While you could replace "print" by "insatsu", you
> would also have to transform
[examples where Japanese grammar differs from English grammar]
> Worse with Arab which modifies the vowel structure of a consonantal skeleton
> in order to arrive at new meanings.
>
> No, this approach is completely impractical and not even of any academic
> interest.
I don't think this would be impractical at all. I don't know Japanese or
Arabic, but I don't think parsing a computer language based on Japanese
or Arabic grammar would be harder than parsing Perl (indeed parsing Perl
is quite hard - "only perl can parse Perl" as the saying goes). At least
your examples don't look hard to me.
> The German-, French-, ... ized versions of MS Excel macro language and
> friends show how utterly useless the approach is. You gain ease of talking
> while loosing your complete audience. What a trade-off.
There are probably a lot more people who program Excel than any other
programming language. There are of course other factors which make Excel
attractive to non-programmers (not least that it doesn't *look* like a
programming language), but I wonder whether translating the function
names doesn't contribute to its popularity. There is a surprising number
of people who don't understand basic English (even though they learned
it in school).
To you and me and other members of the Open Source community who are
used to sharing our programs with other people all over the world, the
mere thought of a localized programming language is a nightmare
(debugging a program with Portuguese comments in it is hard enough, at
least you understand the code), but there are people who don't speak
English and who want to write programs only for themselves and their
colleagues and friends. (and BTW, if you do it right, you can make such
programs translatable - unlike human languages, the semantics of a
programming language is known)
hp
--
_ | 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: Thu, 22 Jun 2006 18:21:00 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Native language versions
Message-Id: <d1ge7e.48r.ln@teal.hjp.at>
Josef Moellers wrote:
> Ian wrote:
>> Has anyone tried translating the command set of Perl into other
>> languages (French, Japanese, Arabic etc.), so that native speakers do
>> not need to learn any English in order to program, then writing a
>> suitable compiler?
>>
>
> ... and loose the possibility to use CPAN modules?
If you do it via a source filter (like Lingua::Romana::Perligata) you
don't lose the CPAN modules. What you may lose is some of the usefulness
of the documentation that comes with those modules since the examples
may not work if you change for example the way functions are called or
assignments are done. So you need somebody to translate the docs. But if
you aim at programmers who don't speak English, you need to translate
the docs anyway.
hp
--
_ | 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: 22 Jun 2006 16:37:49 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: Native language versions
Message-Id: <4fvvatF1i97viU1@uni-berlin.de>
Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
: > Ian <nisbeti@googlemail.com> wrote:
: > : Has anyone tried translating the command set of Perl into other
: > : languages (French, Japanese, Arabic etc.), so that native speakers do
: > : not need to learn any English in order to program, then writing a
: > : suitable compiler?
: In perl you don't need a separate compiler for that: You can write a
: filter module. See Lingua::Romana::Perligata for a filter module which
: implements Latin syntax (including declensions and
: position-independence) for Perl.
Which is a nice thing to have, but have we ever heard that the Vatican
uses this module extensively?
: > No, this approach is completely impractical and not even of any academic
: > interest.
: I don't think this would be impractical at all. I don't know Japanese or
: Arabic, but I don't think parsing a computer language based on Japanese
: or Arabic grammar would be harder than parsing Perl (indeed parsing Perl
: is quite hard - "only perl can parse Perl" as the saying goes). At least
: your examples don't look hard to me.
No, that's right. You _can_ do it, but is it practical? Is it still Perl?
I wonder how to maintain a claim that two languages are equal (perhaps
better: equivalent) if both their grammars and lexica differ substantially?
: There are probably a lot more people who program Excel than any other
: programming language. There are of course other factors which make Excel
: attractive to non-programmers (not least that it doesn't *look* like a
: programming language), but I wonder whether translating the function
: names doesn't contribute to its popularity. There is a surprising number
: of people who don't understand basic English (even though they learned
: it in school).
While I stay with you that this feature may have contributed to the popularity
of Excel, I've seen a number of cases where a file with scripts written in the
German version wouldn't execute on the English version Excel. This was quite
a few years ago, though, maybe things have changed.
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
Date: Thu, 22 Jun 2006 11:39:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Native language versions
Message-Id: <slrne9lhtt.42f.tadmc@magna.augustmail.com>
<corff@zedat.fu-berlin.de> <corff@zedat.fu-berlin.de> wrote:
> Tad McClellan <tadmc@augustmail.com> wrote:
>
>: > Has anyone tried translating the command set of Perl into other
>: > languages (French, Japanese, Arabic etc.)
>
>
>: How do you say "grep" in French or Japanese?
>
>
> grep in French could be ierg (imprimer expression rationelle globale), while
> in Japanese I'd expect shdi (seikihyougen wo dokodemo insatsu suru), but more
> idiomatical would be gureppu, of course.
>
> scnr,
That was fun.
I suppose we'd need some character other than "m" for m// then too?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Jun 2006 17:15:57 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: question on Net::LPR / Unix::Login
Message-Id: <449aaf83$0$31408$e4fe514c@dreader25.news.xs4all.nl>
Hi,
Running FC5, I'm not sure if this is the right place to ask, but I'm
trying Net::LPR to print to a remote printerserver. On CPAN I found nice
examples, but I get permission errors on the printer when I run my code.
Can I somehow 'su' to root from within Perl? Unix::Login only seems to
be for validating an existing login.
Thanks,
Huub
------------------------------
Date: Thu, 22 Jun 2006 16:28:51 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: question on Net::LPR / Unix::Login
Message-Id: <jipqm3-mma.ln1@osiris.mauzo.dyndns.org>
Quoth Huub <"v.niekerk at hccnet.nl">:
>
> Running FC5, I'm not sure if this is the right place to ask, but I'm
> trying Net::LPR to print to a remote printerserver. On CPAN I found nice
> examples, but I get permission errors on the printer when I run my code.
> Can I somehow 'su' to root from within Perl? Unix::Login only seems to
> be for validating an existing login.
No, you can't. The only way is to run 'su' or 'sudo' with system.
Why do you think this is necessary? You are probably better off invoking
lpr(1) directly, and sendign the job as yourself.
Ben
--
#!/bin/sh
quine="echo 'eval \$quine' >> \$0; echo quined"
eval $quine
# [benmorrow@tiscali.co.uk]
------------------------------
Date: Thu, 22 Jun 2006 18:11:53 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question on Net::LPR / Unix::Login
Message-Id: <449ac148$0$12069$e4fe514c@dreader27.news.xs4all.nl>
>
> No, you can't. The only way is to run 'su' or 'sudo' with system.
>
Ok.
> Why do you think this is necessary? You are probably better off invoking
> lpr(1) directly, and sendign the job as yourself.
>
If I want to send the job as myself, access is denied. Unless I print by
using the printmanager.
The script should print data from a 900 record database on paper. So if
I have to invoke lpr myself, I would have to print everything into a
file, and then print that file. This sounds like doing the print job
twice. Unless I can come up with another way to do it.
------------------------------
Date: Thu, 22 Jun 2006 12:26:01 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: question on Net::LPR / Unix::Login
Message-Id: <7mAmg.31$2z1.1325@news.uswest.net>
Huub wrote:
>
>> Why do you think this is necessary? You are probably better off invoking
>> lpr(1) directly, and sendign the job as yourself.
>>
>
> If I want to send the job as myself, access is denied. Unless I print by
> using the printmanager.
> The script should print data from a 900 record database on paper. So if
> I have to invoke lpr myself, I would have to print everything into a
> file, and then print that file. This sounds like doing the print job
> twice. Unless I can come up with another way to do it.
Show us how you're sending the information to lpr.
------------------------------
Date: Thu, 22 Jun 2006 10:27:23 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Unset $1
Message-Id: <slrne9ldmr.3ah.tadmc@magna.augustmail.com>
Martin D. <mndr@snafu.de> wrote:
> Ho to unset $1 afer a regexp match?
/^/;
But I cannot conceive of a real need to do that.
Why do you think that you need to unset $1 after a regexp match?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 9344
***************************************