[25723] in Perl-Users-Digest
Perl-Users Digest, Issue: 7963 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 11 18:05:30 2005
Date: Mon, 11 Apr 2005 15:05:12 -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 Mon, 11 Apr 2005 Volume: 10 Number: 7963
Today's topics:
C# regular expressions, HTML & removal of text between john.w.blair@gmail.com
Re: C# regular expressions, HTML & removal of text betw <postmaster@castleamber.com>
Re: C# regular expressions, HTML & removal of text betw <matternc@comcast.net>
Re: get mod_perl max memory usage <pilsl@goldfisch.at>
Re: get mod_perl max memory usage <alexj@floor.ch>
Re: get mod_perl max memory usage <pilsl@goldfisch.at>
Re: get mod_perl max memory usage <glex_nospam@qwest.invalid>
Re: if(wantarray){...}else{...} (Anno Siegel)
Re: if(wantarray){...}else{...} <1usa@llenroc.ude.invalid>
New Perl installation can't find module <jon.m.landenburger@verizon.com>
Re: New Perl installation can't find module <phaylon@dunkelheit.at>
Re: New Perl installation can't find module <glex_nospam@qwest.invalid>
Re: New Perl installation can't find module <matternc@comcast.net>
Re: New Perl installation can't find module <Jeff.Stampes@xilinx.com>
Re: New Perl installation can't find module <jon.m.landenburger@verizon.com>
Re: New Perl installation can't find module <glex_nospam@qwest.invalid>
Re: New Perl installation can't find module <matternc@comcast.net>
Re: New Perl installation can't find module <jon.m.landenburger@verizon.com>
Re: New Perl installation can't find module <kkeller-usenet@wombat.san-francisco.ca.us>
Re: New Perl installation can't find module <glex_nospam@qwest.invalid>
not $x respecting numeric 0 <pilsl@goldfisch.at>
Re: not $x respecting numeric 0 (Anno Siegel)
Re: not $x respecting numeric 0 <phaylon@dunkelheit.at>
Re: not $x respecting numeric 0 (Anno Siegel)
Re: Simple Encryption Script <hackeras@gmail.com>
Re: Simple Encryption Script <hackeras@gmail.com>
Re: Simple Encryption Script <matternc@comcast.net>
Re: Simple Encryption Script <someone@example.com>
Re: Simple Encryption Script <someone@example.com>
Re: Simple Encryption Script <hackeras@gmail.com>
Re: Simple Encryption Script <hackeras@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Apr 2005 12:20:30 -0700
From: john.w.blair@gmail.com
Subject: C# regular expressions, HTML & removal of text between <script> tags
Message-Id: <1113247230.195249.312840@l41g2000cwc.googlegroups.com>
Can someone help me out this this please? How does one remove content
between script tags and the script tags themselves using C# regular
expressions?
Thanks!
------------------------------
Date: 11 Apr 2005 19:35:30 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: C# regular expressions, HTML & removal of text between <script> tags
Message-Id: <Xns9635946611FABcastleamber@130.133.1.4>
wrote:
> Can someone help me out this this please? How does one remove content
> between script tags and the script tags themselves using C# regular
> expressions?
What's the name of the CPAN module you are using (to support C# regexp in
Perl)?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Mon, 11 Apr 2005 16:40:46 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: C# regular expressions, HTML & removal of text between <script> tags
Message-Id: <RO2dnTxGVotTfcffRVn-vA@comcast.com>
john.w.blair@gmail.com wrote:
> Can someone help me out this this please? How does one remove content
> between script tags and the script tags themselves using C# regular
> expressions?
>
One: You do *not* attempt to parse HTML with regexps. Parsing
HTML is a nontrivial task and regular expressions are not adequate.
Two: This is a Perl newgroups. Why would we be able to help you
with C#?
Three: Er, what's the difference between "script tags" and "the script
tags themselves"?
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Mon, 11 Apr 2005 16:47:12 +0200
From: peter pilsl <pilsl@goldfisch.at>
Subject: Re: get mod_perl max memory usage
Message-Id: <425a8df2$0$1956$79720d31@newsreader.inode.at>
Alexandre Jaquet wrote:
> Hi,
>
> I'm looking for the to get the maximum memory usage autorized for
> mod_perl is there any test script I can run
>
please clarify.
The amount of memory that a mod_perl-application can allocate in apache
is limited by your operating systems memory and settings.
You can take a look at you apache-processes and its mem-behaviour with
your standard monitoring tools (like ps under *nix).
But you can easily write a mod_perl-script that allocates as much memory
as you want on startup by simply creating a big datastructure or loading
the content of a file in memory.
best,
peter
--
http://www.goldfisch.at/know_list
------------------------------
Date: Mon, 11 Apr 2005 17:28:01 +0200
From: Alexandre Jaquet <alexj@floor.ch>
Subject: Re: get mod_perl max memory usage
Message-Id: <d3e51u$g9u$1@news.hispeed.ch>
peter pilsl a écrit :
> Alexandre Jaquet wrote:
>
>> Hi,
>>
>> I'm looking for the to get the maximum memory usage autorized for
>> mod_perl is there any test script I can run
>>
>
> please clarify.
>
> The amount of memory that a mod_perl-application can allocate in apache
> is limited by your operating systems memory and settings.
>
> You can take a look at you apache-processes and its mem-behaviour with
> your standard monitoring tools (like ps under *nix).
>
> But you can easily write a mod_perl-script that allocates as much memory
> as you want on startup by simply creating a big datastructure or loading
> the content of a file in memory.
>
> best,
> peter
>
>
>
in fact my questions was :
"how can /where can I settup mod_perl memory usage ?"
"where may I can found default settings ?"
"how much memory perl is allowed to use"
thans for your help :)
------------------------------
Date: Mon, 11 Apr 2005 18:51:16 +0200
From: peter pilsl <pilsl@goldfisch.at>
Subject: Re: get mod_perl max memory usage
Message-Id: <425aab05$0$1949$79720d31@newsreader.inode.at>
Alexandre Jaquet wrote:
>
> "how can /where can I settup mod_perl memory usage ?"
> "where may I can found default settings ?"
> "how much memory perl is allowed to use"
>
Please correct me if I'm wrong but imho there is no way to setup
mod_perl memory usage from outside. When I wrote memleaking
mod_perl-scripts there was obviously no limit catching in.
Like in normal perl, its up to the programmer to take care how much mem
its programm will take.
so the answers to your question by my experience, but not by my
knowledge are:
you cant
there are none
all your system gives you
best,
peter
--
http://www.goldfisch.at/know_list
------------------------------
Date: Mon, 11 Apr 2005 13:43:11 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: get mod_perl max memory usage
Message-Id: <4zz6e.16$Fe5.1501@news.uswest.net>
peter pilsl wrote:
> Alexandre Jaquet wrote:
>
>>
>> "how can /where can I settup mod_perl memory usage ?"
>> "where may I can found default settings ?"
>> "how much memory perl is allowed to use"
>>
>
> Please correct me if I'm wrong but imho there is no way to setup
> mod_perl memory usage from outside. When I wrote memleaking
> mod_perl-scripts there was obviously no limit catching in.
> Like in normal perl, its up to the programmer to take care how much mem
> its programm will take.
>
> so the answers to your question by my experience, but not by my
> knowledge are:
>
> you cant
> there are none
> all your system gives you
>
> best,
> peter
>
>
Correct, however to not allow memory usage to get above some limit there
are two modules that'll help: Apache::GTopLimit and Apache::SizeLimit.
There is a lot of documentation about mod_perl at: http://perl.apache.org/
------------------------------
Date: 11 Apr 2005 13:24:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: if(wantarray){...}else{...}
Message-Id: <d3dtqb$9sb$1@mamenchi.zrz.TU-Berlin.DE>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
> news:d3dlok$3iq$3@mamenchi.zrz.TU-Berlin.DE:
> > A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
[use of wantarray]
> The following is another convoluted example. If I am still failing, I'll
> just go learn APL or something :)
>
> #! /usr/bin/perl
>
> my @r = call_letters();
> my $r = call_letters();
>
> print "@r\n$r\n";
>
>
> sub call_letters {
> wantarray
> ? select_letters()
> : length(scalar select_letters());
^^^^^^
> }
>
>
> sub select_letters {
> my @letters;
>
> for my $letter ( 'A' .. 'Z' ) {
> if(rand(1) < 0.5) {
> push @letters, $letter;
> }
> }
> wantarray ? @letters : join('', @letters);
> }
>
> __END__
Yes, that's an example where wantarray does something useful. The
indicated "scalar" could go away since length() already provides scalar
context.
Anno
------------------------------
Date: Mon, 11 Apr 2005 14:06:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: if(wantarray){...}else{...}
Message-Id: <Xns963566C55DC1Dasu1cornelledu@127.0.0.1>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
news:d3dtqb$9sb$1@mamenchi.zrz.TU-Berlin.DE:
> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
>> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
>> news:d3dlok$3iq$3@mamenchi.zrz.TU-Berlin.DE:
>> > A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in
>> > comp.lang.perl.misc:
>
> [use of wantarray]
>
...
>> sub call_letters {
>> wantarray
>> ? select_letters()
>> : length(scalar select_letters());
> ^^^^^^
>> }
...
> Yes, that's an example where wantarray does something useful. The
> indicated "scalar" could go away since length() already provides
> scalar context.
Yes, absolutely. That was an editing error.
Now, where is that APL book ...
Joking aside, thank you very much for helping me better understand
wantarray.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 11 Apr 2005 11:10:06 -0700
From: "JONL" <jon.m.landenburger@verizon.com>
Subject: New Perl installation can't find module
Message-Id: <1113243006.514925.191450@f14g2000cwb.googlegroups.com>
Hi,
Please excuse me if this is an ignorant question. I have been slowly
backing my self up into the care and feeding of our perl subsystem.
I having been trying to get our new Perl (5.8.0) load to recognize the
ReadKey.pm module. What I did was to go to a directory in the @INC
array and add the file Term/ReadKey.pm. But still when I run the
program which has the statement use Term/ReadKey it comes back with
Can't locate loadable object for module Term::ReadKey in @INC
it then list the directories in INC, one of which is the directory
holding Term/ReadKey.pm
I have been pouring over man pages for PerlMod and PerlModLib and
thought I had it right but apparently I am missing something. Can
someone give me a clu? Thanks in advance
JonL
------------------------------
Date: Mon, 11 Apr 2005 20:13:54 +0200
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: New Perl installation can't find module
Message-Id: <pan.2005.04.11.18.13.54.376860@dunkelheit.at>
JONL wrote:
> Can someone give me a clu?
Hm. Would you mind giving us a bit more information? Like code, *exact*
(copy&paste) path's of the files and version information of perl would
help I guess.
You know, not all of us are wizzards ;)
--
http://www.dunkelheit.at/
Ordinary morality is only for ordinary people.
-- Aleister Crowley
------------------------------
Date: Mon, 11 Apr 2005 13:32:35 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: New Perl installation can't find module
Message-Id: <8pz6e.15$Fe5.1291@news.uswest.net>
JONL wrote:
> Hi,
> Please excuse me if this is an ignorant question. I have been slowly
> backing my self up into the care and feeding of our perl subsystem.
> I having been trying to get our new Perl (5.8.0) load to recognize the
> ReadKey.pm module. What I did was to go to a directory in the @INC
> array and add the file Term/ReadKey.pm. But still when I run the
> program which has the statement use Term/ReadKey it comes back with
> Can't locate loadable object for module Term::ReadKey in @INC
> it then list the directories in INC, one of which is the directory
> holding Term/ReadKey.pm
>
> I have been pouring over man pages for PerlMod and PerlModLib and
> thought I had it right but apparently I am missing something. Can
> someone give me a clu? Thanks in advance
> JonL
>
Copying ReadKey.pm isn't enough. Install it the "correct" way:
perl Makefile.PL
make
make test
make install
------------------------------
Date: Mon, 11 Apr 2005 14:34:35 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: New Perl installation can't find module
Message-Id: <1M6dnZToNIWmXsffRVn-qg@comcast.com>
JONL wrote:
> Hi,
> Please excuse me if this is an ignorant question. I have been slowly
> backing my self up into the care and feeding of our perl subsystem.
> I having been trying to get our new Perl (5.8.0) load to recognize the
> ReadKey.pm module. What I did was to go to a directory in the @INC
> array and add the file Term/ReadKey.pm. But still when I run the
> program which has the statement use Term/ReadKey it comes back with
> Can't locate loadable object for module Term::ReadKey in @INC
> it then list the directories in INC, one of which is the directory
> holding Term/ReadKey.pm
ReadKey has C code that must be compiled. Use CPAN to install it.
>
> I have been pouring over man pages for PerlMod and PerlModLib and
> thought I had it right but apparently I am missing something. Can
> someone give me a clu? Thanks in advance
> JonL
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Mon, 11 Apr 2005 12:44:51 -0600
From: Jeff Stampes <Jeff.Stampes@xilinx.com>
Subject: Re: New Perl installation can't find module
Message-Id: <d3egj4$g0k1@cliff.xsj.xilinx.com>
JONL wrote:
> What I did was to go to a directory in the @INC
> array and add the file Term/ReadKey.pm. But still when I run the
> program which has the statement use Term/ReadKey it comes back with
> Can't locate loadable object for module Term::ReadKey in @INC
> it then list the directories in INC, one of which is the directory
> holding Term/ReadKey.pm
(my terminology may be incorrect here, but I'm sure someone will correct me)
ReadKey is an XS module. The .pm file is simply a wrapper around a
compiled C module, ReadKey.so:
stampes@flux[41] lib > find . -name ReadKey.*
./site_perl/i686-linux-thread-multi/auto/Term/ReadKey/ReadKey.so
./site_perl/i686-linux-thread-multi/auto/Term/ReadKey/ReadKey.bs
./site_perl/i686-linux-thread-multi/Term/ReadKey.pm
Additionally, you need to be concerned about whether ReadKey is
autosplit or not.
Copying files around is a dangerous way to install modules. Use cpan,
or download the sources and recompile modules yourself for safety
~Jeff
------------------------------
Date: 11 Apr 2005 13:25:54 -0700
From: "JONL" <jon.m.landenburger@verizon.com>
Subject: Re: New Perl installation can't find module
Message-Id: <1113251154.906527.212720@z14g2000cwz.googlegroups.com>
Ok,
So I see I should have compiled it. I had run this route before but I
come up with so many obstacles. Remember I am new to this. I have been
pouring through the local man pages and through the internet. So this
takes me to my next ignorant question. I go to perl.org --> get perl
--> modules and extensions. I then search CPAN for ReadKey.pm and
follow the hyperlink for "source" code
-- http://search.cpan.org/~kjalb/TermReadKey-2.14/ReadKey.pm --
Frankly I was expecting a tar.gz file But I get a file which looks
like a lot of comments eventually coming up to some readable perl .
This, in fact, looks just like the ReadKey.pm that I had moved to the
area. So if there is a module that can be compiled I am not sure where
to go for it .
------------------------------
Date: Mon, 11 Apr 2005 15:35:57 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: New Perl installation can't find module
Message-Id: <NcB6e.21$Fe5.1874@news.uswest.net>
JONL wrote:
> Ok,
> So I see I should have compiled it. I had run this route before but I
> come up with so many obstacles. Remember I am new to this. I have been
> pouring through the local man pages and through the internet. So this
> takes me to my next ignorant question. I go to perl.org --> get perl
> --> modules and extensions. I then search CPAN for ReadKey.pm and
> follow the hyperlink for "source" code
> -- http://search.cpan.org/~kjalb/TermReadKey-2.14/ReadKey.pm --
> Frankly I was expecting a tar.gz file But I get a file which looks
> like a lot of comments eventually coming up to some readable perl .
> This, in fact, looks just like the ReadKey.pm that I had moved to the
> area. So if there is a module that can be compiled I am not sure where
> to go for it .
>
On this page:
http://search.cpan.org/~jstowe/TermReadKey-2.30/ReadKey.pm
select the 'TermReadKey-2.30' link at the top. From the page that
follows it, you'll see a 'download' link near the top of the page.
You may want to look at the CPAN module, which will go out and fetch,
compile, install modules for you:
http://search.cpan.org/~andk/CPAN-1.76/lib/CPAN.pm
------------------------------
Date: Mon, 11 Apr 2005 16:37:41 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: New Perl installation can't find module
Message-Id: <RO2dnT1GVouIfcffRVn-vA@comcast.com>
JONL wrote:
> Ok,
> So I see I should have compiled it. I had run this route before but I
> come up with so many obstacles. Remember I am new to this. I have been
> pouring through the local man pages and through the internet. So this
> takes me to my next ignorant question. I go to perl.org --> get perl
> --> modules and extensions. I then search CPAN for ReadKey.pm and
> follow the hyperlink for "source" code
> -- http://search.cpan.org/~kjalb/TermReadKey-2.14/ReadKey.pm --
> Frankly I was expecting a tar.gz file But I get a file which looks
> like a lot of comments eventually coming up to some readable perl .
> This, in fact, looks just like the ReadKey.pm that I had moved to the
> area. So if there is a module that can be compiled I am not sure where
> to go for it .
Use CPAN. CPAN will download everything you need, build it, and put it
where it belongs.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 11 Apr 2005 14:19:33 -0700
From: "JONL" <jon.m.landenburger@verizon.com>
Subject: Re: New Perl installation can't find module
Message-Id: <1113254373.575468.95520@g14g2000cwa.googlegroups.com>
J. G
When I go to the URL you provided-- which is the same one I went to in
the description above I do click on the TermReadKey-2.30 I get a page
with Module Version 2.30 SOURCE.
Followed by Name, Synopsis Discription , Author, I scroll that whole
thing and dont find a download.
Now if I click on Source I get a download dialog which will download
ReadKey.pm which I alreay have. Either I am downloading the wrong thing
r I need to know how to create the so files from that .pm file. Still
I am missing something .
------------------------------
Date: Mon, 11 Apr 2005 14:57:03 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: New Perl installation can't find module
Message-Id: <fe8ri2xka5.ln2@goaway.wombat.san-francisco.ca.us>
On 2005-04-11, JONL <jon.m.landenburger@verizon.com> wrote:
>
> When I go to the URL you provided-- which is the same one I went to in
> the description above I do click on the TermReadKey-2.30 I get a page
> with Module Version 2.30 SOURCE.
*Right above this* (which is exactly where J. Gleixner pointed you) is
the TermReadKey-2.30 that you should click to see a download link. It
says:
Jonathan Stowe > TermReadKey-2.30 > Term::ReadKey
Click the middle thing!
> Still I am missing something .
You missed his advice (and the advice of others) to use CPAN to install
modules. If you use CPAN then you don't even need to download
TermReadKey manually, as CPAN will do it for you. I think it's been
posted, but if it hasn't, here's the CPAN documentation:
http://search.cpan.org/~andk/CPAN-1.76/lib/CPAN.pm
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information
------------------------------
Date: Mon, 11 Apr 2005 17:03:47 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: New Perl installation can't find module
Message-Id: <7vC6e.62$Ua4.863@news.uswest.net>
JONL wrote:
> J. G
>
> When I go to the URL you provided-- which is the same one I went to in
> the description above I do click on the TermReadKey-2.30 I get a page
> with Module Version 2.30 SOURCE.
> Followed by Name, Synopsis Discription , Author, I scroll that whole
> thing and dont find a download.
> Now if I click on Source I get a download dialog which will download
> ReadKey.pm which I alreay have. Either I am downloading the wrong thing
> r I need to know how to create the so files from that .pm file. Still
> I am missing something .
>
Hmmm.. The link at the top just after the author's name?.. It should
take you to:
http://search.cpan.org/~jstowe/TermReadKey-2.30/
That should do it.
I thought it'd be more informative to show how to get to the download
page, in case you want to do this with other modules.
See ya
------------------------------
Date: Mon, 11 Apr 2005 16:40:29 +0200
From: peter pilsl <pilsl@goldfisch.at>
Subject: not $x respecting numeric 0
Message-Id: <425a8c5f$0$1947$79720d31@newsreader.inode.at>
I look for an shorter version of for:
if (defined $x and $x ne '') { ...}
One of my most frequent programm-bugs is that I often include statements
like:
if ($x) { ...}
which skips the block, if $x is undefined, empty or has the value 0.
And the latter is my problem: I would like to have a
as-simple-as-possible-statment that checks if $x is undefined or '' but
returns true if the value is 0, cause 0 is a perfect normal value in
most of my applications. Is there kind of a "numeric-aware" not-operator?
thnx,
peter
--
http://www.goldfisch.at/know_list
------------------------------
Date: 11 Apr 2005 15:29:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: not $x respecting numeric 0
Message-Id: <d3e55g$f3e$1@mamenchi.zrz.TU-Berlin.DE>
peter pilsl <pilsl@goldfisch.at> wrote in comp.lang.perl.misc:
>
>
> I look for an shorter version of for:
>
> if (defined $x and $x ne '') { ...}
>
>
> One of my most frequent programm-bugs is that I often include statements
> like:
>
> if ($x) { ...}
>
> which skips the block, if $x is undefined, empty or has the value 0.
>
> And the latter is my problem: I would like to have a
> as-simple-as-possible-statment that checks if $x is undefined or '' but
> returns true if the value is 0, cause 0 is a perfect normal value in
> most of my applications. Is there kind of a "numeric-aware" not-operator?
If $x happens to be in $_, "defined and length" is a bit shorter, otherwise
there isn't a whole lot you can do about it.
Anno
------------------------------
Date: Mon, 11 Apr 2005 17:37:20 +0200
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: not $x respecting numeric 0
Message-Id: <pan.2005.04.11.15.37.20.347558@dunkelheit.at>
peter pilsl wrote:
> I would like to have a as-simple-as-possible-statment that checks if $x
> is undefined or '' but returns true if the value is 0, cause 0 is a
> perfect normal value in most of my applications. Is there kind of a
> "numeric-aware" not-operator?
Hm. I would say: Make a function that does this. Sorry, don't know
anything else.
--
http://www.dunkelheit.at/
I want, therefore I can.
------------------------------
Date: 11 Apr 2005 17:09:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: not $x respecting numeric 0
Message-Id: <d3eb0m$ilh$1@mamenchi.zrz.TU-Berlin.DE>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in comp.lang.perl.misc:
> peter pilsl <pilsl@goldfisch.at> wrote in comp.lang.perl.misc:
> >
> > I look for an shorter version of for:
> >
> > if (defined $x and $x ne '') { ...}
[...]
> If $x happens to be in $_, "defined and length" is a bit shorter, otherwise
> there isn't a whole lot you can do about it.
Come to think of it, if we already had the err operator, this would do:
length( $x err '');
Anno
------------------------------
Date: Mon, 11 Apr 2005 17:55:44 +0000 (UTC)
From: Nikos <hackeras@gmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <Xns9635D4E98184Chackerasgmailcom@194.177.210.210>
"John W. Krahn" <someone@example.com> wrote in
news:x%r6e.15449$yV3.6992@clgrps12:
> Nikos wrote:
>> Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote in
>> news:d3dd5c $3qb$1@nntp.fujitsu-siemens.com:
>>
>>
>>>$_ is an alias for the currently selected element of @letters. Also,
>>>if $_ contains a letter, it contains a letter, not a number, so
>>>incrementing won't work:
>>>
>>>$_ = chr(ord($_) + 1);
>>
>>
>> thanks here it is now correct:
>>
>> #!/usr/bin/perl -w
>>
>> $i=0;
>>
>> print "Enter text to be encrypted: ";
>> $text = <>;
>> chomp($text);
>>
>> @letters = split //, $text;
>>
>> foreach (@letters) {
>> $letters[$i++] = chr( ord($_) + 1 );
>> }
>
> Could be written more simply as:
>
> foreach ( @letters ) {
> $_ = chr 1 + ord;
> }
Thank you but i cant understand how your example works.
whats chr 1 and ord by itslef gives?
>> print "\nEncrypted text now is: @letters\n";
>>
>>
>> The only proble now is that i get the encryptes text in @letters but
>> with spaces between each letter ie if encryptes etxt is "idfjs" i get
>> it as "i d f j s". Why?
>
> perldoc -q "Why do I get weird spaces when I print an array of lines"
Yes i saw that another thing is
print @letters ; #Gives the elements joined together.
and another is
print "@letters; # Gives the elements joined together but with a
space bettwen them.
Until now i thoughs that if we ommited the doubles quotes in a print it
would be tha same as haveing it, meaning that the $variable or @array
would still be interpolated.
But why is that difference?
--
Just because I didnt doesnt mean I dont want to.
Just because I wouldnt doesnt mean I cant.
------------------------------
Date: Mon, 11 Apr 2005 18:02:16 +0000 (UTC)
From: Nikos <hackeras@gmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <Xns9635D60491385hackerasgmailcom@194.177.210.210>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in news:d3djrj$3iq$1
@mamenchi.zrz.TU-Berlin.DE:
> foreach ( @letters ) {
> $_ = 1 + chr ord $_;
> }
Yes but this wont change the value of its element. i mean the new value of
every element will not be stored it will just change.
--
Just because I didnt doesnt mean I dont want to.
Just because I wouldnt doesnt mean I cant.
------------------------------
Date: Mon, 11 Apr 2005 14:07:56 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Simple Encryption Script
Message-Id: <MZ-dnbSdpNBhIcffRVn-hQ@comcast.com>
Nikos wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in news:d3djrj$3iq$1
> @mamenchi.zrz.TU-Berlin.DE:
>
>> foreach ( @letters ) {
>> $_ = 1 + chr ord $_;
>> }
>
> Yes but this wont change the value of its element. i mean the new value of
> every element will not be stored it will just change.
>
You might want to actually, y'know, try it before you state it doesn't
work. Or you could read the documentation for foreach.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Mon, 11 Apr 2005 20:14:29 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Simple Encryption Script
Message-Id: <FUA6e.21152$VF5.18312@edtnps89>
Nikos wrote:
> "John W. Krahn" <someone@example.com> wrote in
> news:x%r6e.15449$yV3.6992@clgrps12:
>
>>Nikos wrote:
>>
>>>Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote in
>>>news:d3dd5c $3qb$1@nntp.fujitsu-siemens.com:
>>>
>>>@letters = split //, $text;
>>>
>>>foreach (@letters) {
>>> $letters[$i++] = chr( ord($_) + 1 );
>>>}
>>
>>Could be written more simply as:
>>
>>foreach ( @letters ) {
>> $_ = chr 1 + ord;
>>}
>
> Thank you but i cant understand how your example works.
>
> whats chr 1 and ord by itslef gives?
In a foreach loop the $_ variable is an alias to the elements of the array
@letters so modifying $_ actually modifies the contents of @letters.
The chr operator is passed the expression "1 + ord" and ord by default is
passed the contents of $_.
>>>The only proble now is that i get the encryptes text in @letters but
>>>with spaces between each letter ie if encryptes etxt is "idfjs" i get
>>>it as "i d f j s". Why?
>>
>>perldoc -q "Why do I get weird spaces when I print an array of lines"
>
> Yes i saw that another thing is
>
> print @letters ; #Gives the elements joined together.
> and another is
> print "@letters; # Gives the elements joined together but with a
> space bettwen them.
>
> Until now i thoughs that if we ommited the doubles quotes in a print it
> would be tha same as haveing it, meaning that the $variable or @array
> would still be interpolated.
>
> But why is that difference?
Because double quoted strings are affected by the contents of the $" variable
just as the print operator is affected by the contents of the $, and $\
variables (and sometimes even the $_ and $| variables.)
perldoc perlvar
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 11 Apr 2005 20:20:18 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Simple Encryption Script
Message-Id: <6_A6e.21154$VF5.4413@edtnps89>
Anno Siegel wrote:
>
> It works now, but it is still somewhat roundabout. You can change
> the array elements one by one in the foreach loop, there is no need to
> use an index ($i) to access them:
>
> foreach ( @letters ) {
> $_ = 1 + chr ord $_;
> }
You are adding one to the character returned from chr()?
$ perl -le'
@x = qw/ a b c 1 2 3 9 h x y z /;
for ( @x ) { $_ = 1 + chr ord }
print "@x"
'
1 1 1 2 3 4 10 1 1 1 1
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 11 Apr 2005 21:50:36 +0000 (UTC)
From: Nikos <hackeras@gmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <Xns9636896BC768hackerasgmailcom@194.177.210.210>
"John W. Krahn" <someone@example.com> wrote in
news:FUA6e.21152$VF5.18312@edtnps89:
> In a foreach loop the $_ variable is an alias to the elements of the
> array @letters so modifying $_ actually modifies the contents of
> @letters.
ah, i see. I thought so far that $_ just copied itself the current
element of array @letters but it was just a copy, meaning that if any
change were applied to $_ it wouldnt impact at all each of the elements.
for ie in the first iteration
$_ == $letters[0]
If a change happened to $_ it wooulsnt change the real elements value.
foreach ( @letters ) <-- this can also be writen as
foreach $_( $letters )
foreach ( $letters[0]..$letters[@letters] )
right?
> The chr operator is passed the expression "1 + ord" and ord by default
> is passed the contents of $_.
i see, thank you.
--
Just because I didnt doesnt mean I dont want to.
Just because I wouldnt doesnt mean I cant.
------------------------------
Date: Mon, 11 Apr 2005 21:55:39 +0000 (UTC)
From: Nikos <hackeras@gmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <Xns96369726EF9Fhackerasgmailcom@194.177.210.210>
Nikos <hackeras@gmail.com> wrote in news:Xns963582F265D5hackerasgmailcom@
194.177.210.210:
> @letters = split //, $text;
Iam also using this but i cant quite understab how it works:
i mean how split manages to split $text's each letter? what // really does?
letters in $text dont really have a space between them so split can use to
seperate one from the other. so how can it really manages it?
--
Just because I didnt doesnt mean I dont want to.
Just because I wouldnt doesnt mean I cant.
------------------------------
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 7963
***************************************