[23557] in Perl-Users-Digest
Perl-Users Digest, Issue: 5765 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 7 21:06:04 2003
Date: Fri, 7 Nov 2003 18:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 7 Nov 2003 Volume: 10 Number: 5765
Today's topics:
Re: binary dist calculation <kalinaubears@iinet.net.au>
Re: binary dist calculation <kalinaubears@iinet.net.au>
Re: bit sequence match <edady2002@yahoo.com>
calling XS(function) from C <peter@nospam.calweb.com>
CGI parameter question <j.g.karssenberg@student.utwente.nl>
Re: CGI parameter question <usenet@expires12.2003.tinita.de>
Re: Checking environment variable existence (David Efflandt)
Re: Checking environment variable existence (Malcolm Dew-Jones)
Re: Checking environment variable existence <uri@stemsystems.com>
Re: Checking environment variable existence (Tad McClellan)
Re: Help a non-Perl user update an older program... (Steve)
Re: How to remove javascript tag by perl <jurgenex@hotmail.com>
Re: Perl features <usenet@morrow.me.uk>
Re: Perl features <bobx@linuxmail.org>
Re: Perl Module DBD::ORACLE (polarbear)
Problem with changes to referrenced object rosenthd@yahoo.com
Re: Problem with changes to referrenced object <noreply@gunnar.cc>
Re: Problem with changes to referrenced object <pinyaj@rpi.edu>
Re: searching for null in pattern <no@email.com>
Re: searching for null in pattern (Brian Andrus)
Re: searching for null in pattern <bmb@ginger.libs.uga.edu>
Re: searching for null in pattern <usenet@morrow.me.uk>
Re: searching for null in pattern <usenet@morrow.me.uk>
Style question: map versus foreach <go@away.spam>
Re: Style question: map versus foreach <tassilo.parseval@rwth-aachen.de>
Re: Style question: map versus foreach (Roy Johnson)
Re: Style question: map versus foreach (Anno Siegel)
Upgrading perl and module use <b_duke@octa4.net.invalid>
Re: Upgrading perl and module use (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 08 Nov 2003 11:05:54 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: binary dist calculation
Message-Id: <3fac3421$0$1753$5a62ac22@freenews.iinet.net.au>
Fred wrote:
> Hello
> I am trying to calculate the distance between 2 binary data arrays
> it is puting out errors but I don't know why or how to fix it.
> I guss if I spend a day or 2 reading I may know why and fix it but after
> 1/2 hr or trail and error I gave up.
>
>
> thanks
>
> my @bit1 = qw /01 10 01 01 01/;
> my @bit2 = qw /01 00 11 01 00/;
> print (dist(\@bit1, \@bit2), "\n"); pass array ref to sub
>
> sub dist {
> my $fst = shift; #grab the first array
> my $x = join("", @{$fst}); #de-ref into a string
my $X = oct("0b$x"); #concate "0b" infront for the "^" xOR operator
> my $scd = shift;
> my $y = join("", @{$scd});
my $Y = oct("0b$y");
> my $answer = sprintf "%b", $X ^ $Y; #xOR($X, $Y)
> return ($answer =~ tr/1//); #grab how many 1s
> }
>
I've made minimal changes to that script so that it will work. (Hope
that helps.)
As Brian hinted:
$x = 0b101; # $x is a number (= 3).
$x = "0b101"; # $x is not a number, just a string of chars.
$x = oct("0b101"); # $x is a number (= 3)
Both Brian and Tassilo have shown you some other ways to go about it.
Perl is like that - and I regard your approach to the solution as quite
acceptable.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sat, 08 Nov 2003 11:14:25 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: binary dist calculation
Message-Id: <3fac3620$0$1753$5a62ac22@freenews.iinet.net.au>
Sisyphus wrote:
>
> As Brian hinted:
> $x = 0b101; # $x is a number (= 3).
> $x = "0b101"; # $x is not a number, just a string of chars.
> $x = oct("0b101"); # $x is a number (= 3)
>
Ummm ... I wasn't wearing my glasses, and couldn't see my fingers
properly. I think '101' is actually binary representation of '5', not
'3'. Time to visit the optometrist .... or maybe the neurosurgeon.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sat, 08 Nov 2003 07:59:50 +1100
From: Edo <edady2002@yahoo.com>
Subject: Re: bit sequence match
Message-Id: <3FAC07C6.7060106@yahoo.com>
Jay Tilton wrote:
> Edo <edady2002@yahoo.com> wrote:
>
> : my @a1 = qw (1 000001 2 000010 3 000100);
> : my @a2 = qw (1 110001 2 110011 3 000001 4 000010 5 000100 6 111000 7
> : 111110 8 000000 9 111111 10 111011);
> :
> : my (%h1, %h2) = (@a1, @a2); #convert array to hash
>
> Because the RHS is flattened into one list, that doesn't do what you
> think it does.
>
> my %h1 = @a1;
> my %h2 = @a2;
>
> Are the hash keys really going to be numeric? Using arrays may be a
> more sensible choice than using hashes.
the hash keys are going to be numeric, in the @a1 above example, the
real keys are 369 444 885 with irregular incrementation, thats why I
thought it'd be better to use a hash with 1 2 3 ... keys for ease of
coding and debugging.
>
> : after sorting keys in both hashes,
>
> What is the sorted order? I'm guessing it's a plain numeric sort.
yes, it is plain numeric sort.
>
> : I need to seach %h2 for the sequence
> : of keys which match a sorted-key %h1. e.g. seach the %h2 for 000001
> : followed by 00010 followed by 000100.
>
> The hash values appear to be binary representations of numbers. The
> task could be done with pack() and index().
>
> my @k1 = sort {$a <=> $b} keys %h1;
> my @k2 = sort {$a <=> $b} keys %h2;
>
> my $i = index(
> pack('(B6)*' => @h2{ @k2 }), # Perl 5.8.0 required
> pack('(B6)*' => @h1{ @k1 })
> );
> if( $i >= 0 ) {
> printf "%%h1: %s\n%%h2: %s\n",
> join(', ' => map "$_ => $h1{$_}" => @k1),
> join(', ' => map "$_ => $h2{$_}" => @k2[$i .. $i+@k1-1])
> } else {
> print "The sequence of values in %h1 was not found in %h2\n";
> }
>
> : once found place the results in
> : another %h3 which is then a hoh with the first result taking the number
> : 1 and the second result 2 ... in that new %h3.
>
> That part needs more explanation. With the %h1 and %h2 shown above,
> what exactly would you like the data structure in %h3 to look like?
>
%h3 which I think it could be an array @a3 instead, needs to contain the
list of all matched sequences, therefore it would be array of hash refs
IF hashs are still the more sensible way from question 1 above.
------------------------------
Date: Fri, 07 Nov 2003 15:08:53 -0800
From: Penguinista <peter@nospam.calweb.com>
Subject: calling XS(function) from C
Message-Id: <3fac25e8$0$22655$d368eab@news.calweb.com>
I'm embeding perl in a C program and using swig to generate an
interface. One of the generated functions is XS(boot_module) to
initialize the extension functions in perl, and intended to be called
from perl in a module bootstrap operation. In my case I want to call it
from C code. I've gotten a kludge that to works on my system, but
breaks on a different system. Is there a 'proper' way to make this call?
------------------------------
Date: Sat, 8 Nov 2003 01:44:41 +0100
From: Jaap Karssenberg <j.g.karssenberg@student.utwente.nl>
Subject: CGI parameter question
Message-Id: <20031108014441.5843c6ac.j.g.karssenberg@student.utwente.nl>
I have a script cgi-bin/test.pl that uses the CGI module and takes named
parameters, now I also want it to be able to be called with the
cgi-bin/test.pl/foo syntax, but I didn't succeed getting the value
"foo". I tried various things with CGI::param and also tried @ARGV but
no luck :(. Can anyone tell me how to get this value ?
--
) ( Jaap Karssenberg || Pardus [Larus] | |0| |
: : http://pardus-larus.student.utwente.nl/~pardus | | |0|
) \ / ( |0|0|0|
",.*'*.," Proud owner of "Perl6 Essentials" 1st edition :)
------------------------------
Date: 8 Nov 2003 00:44:10 GMT
From: Tina Mueller <usenet@expires12.2003.tinita.de>
Subject: Re: CGI parameter question
Message-Id: <bohe8q$1euek8$1@ID-24002.news.uni-berlin.de>
Jaap Karssenberg wrote:
> I have a script cgi-bin/test.pl that uses the CGI module and takes named
> parameters, now I also want it to be able to be called with the
> cgi-bin/test.pl/foo syntax, but I didn't succeed getting the value
> "foo". I tried various things with CGI::param and also tried @ARGV but
> no luck :(. Can anyone tell me how to get this value ?
CGI.pm provides the method path_info() which contains the value
of the environment variable PATH_INFO.
find details in
perldoc CGI
hth, tina
--
http://www.tinita.de/ http://www.perlquotes.de/ http://www.darkdance.net/
Enter the Doors of P e r c e p t i o n
-my address is currently unreachable due to the Swen.A virus-
------------------------------
Date: Fri, 7 Nov 2003 19:20:28 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Checking environment variable existence
Message-Id: <slrnbqns3s.37u.efflandt@typhoon.xnet.com>
On Fri, 7 Nov 2003, Andreas Kahari <ak+usenet@freeshell.org> wrote:
> In article <boggp9$q9$1@news.kodak.com>, Victor Hannak wrote:
>> Is there an >easy< way to tell if an environment variable exists without
>> getting a "use of uninitialized variable" error in Perl?
>>
>> I know I could probably cycle through the entire %ENV array and look for a
>> match, but I was hoping there was a better way...
>
> %ENV is a hash, not an array.
>
>
> if (exists $ENV{MYVAR} && defined $ENV{MYVAR}) {
> # The MYVAR environment variable exists and is not undef
> }
If the point is just to do something if it has a value (other than zero),
then 'exists' or 'defined' are not even needed:
#!/usr/bin/perl -w
use strict;
my ($evar) = shift;
if ($ENV{$evar}) {
print "$evar = $ENV{$evar}\n";
} else {
print "$evar is zero or not set\n";
print "however, ".uc($evar)." = $ENV{uc($evar)}\n" if $ENV{uc($evar)};
}
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: 7 Nov 2003 15:22:45 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Checking environment variable existence
Message-Id: <3fac2945@news.victoria.tc.ca>
Uri Guttman (uri@stemsystems.com) wrote:
: >>>>> "AK" == Andreas Kahari <ak+usenet@freeshell.org> writes:
: AK> if (exists $ENV{MYVAR} && defined $ENV{MYVAR}) { # The MYVAR
: AK> environment variable exists and is not undef
: AK> }
: if the environment is set from the outside and not modified in the perl
: script, then you can't get undefined entries.
well only sort of
# try.pl
my $thing = $ENV{'THIS_MIGHT_NOT_BE_DEFINED'} ;
if ($thing == 1)
{
print "$thing\n";
}
C:\> perl -w try.pl
Use of uninitialized value at try.pl line 5.
------------------------------
Date: Fri, 07 Nov 2003 23:48:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Checking environment variable existence
Message-Id: <x7k76b4u6i.fsf@mail.sysarch.com>
>>>>> "MD" == Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> writes:
MD> Uri Guttman (uri@stemsystems.com) wrote: : >>>>> "AK" == Andreas
MD> Kahari <ak+usenet@freeshell.org> writes:
MD> : AK> if (exists $ENV{MYVAR} && defined $ENV{MYVAR}) { # The MYVAR
MD> : AK> environment variable exists and is not undef : AK> }
MD> : if the environment is set from the outside and not modified in
^^^^^^^
MD> the perl : script, then you can't get undefined entries.
MD> well only sort of
MD> my $thing = $ENV{'THIS_MIGHT_NOT_BE_DEFINED'} ;
hmm, that looks like code INSIDE the script.
MD> if ($thing == 1) { print "$thing\n";
MD> }
MD> C:\> perl -w try.pl Use of uninitialized value at try.pl line 5.
the point is that if an %ENV entry exists and was set from the outside
it can't be undefined. your code didn't cover that situation.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 7 Nov 2003 18:19:22 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Checking environment variable existence
Message-Id: <slrnbqodka.5kg.tadmc@magna.augustmail.com>
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
> Uri Guttman (uri@stemsystems.com) wrote:
>: >>>>> "AK" == Andreas Kahari <ak+usenet@freeshell.org> writes:
>
>: AK> if (exists $ENV{MYVAR} && defined $ENV{MYVAR}) { # The MYVAR
>: AK> environment variable exists and is not undef
>: AK> }
>
>: if the environment is set from the outside and not modified in the perl
>: script, then you can't get undefined entries.
^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^
> well only sort of
^^^^^^^
No, exactly.
> # try.pl
>
> my $thing = $ENV{'THIS_MIGHT_NOT_BE_DEFINED'} ;
There is no undefined entry in your example.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Nov 2003 15:08:03 -0800
From: gomek@onvoymail.com (Steve)
Subject: Re: Help a non-Perl user update an older program...
Message-Id: <b1e7c6d6.0311071508.722506b7@posting.google.com>
Hi - I also use this program and am interested in a fix.
Unfortunately, I know nothing of Perl...
I was wondering if the suggestion above helped? I may be able to
enlist some help from some Perl friends...
Thanks,
Steve
------------------------------
Date: Sat, 08 Nov 2003 01:27:56 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to remove javascript tag by perl
Message-Id: <wEXqb.19721$p9.14167@nwrddc02.gnilink.net>
jjl wrote:
[...]
What a coincidence: A namesake of yours just posted exactly the same
question at clp.
You may want to check the replies he got.
jue
------------------------------
Date: Fri, 7 Nov 2003 21:03:56 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl features
Message-Id: <boh1bs$cs4$1@wisteria.csv.warwick.ac.uk>
James Willmore <jwillmore@remove.adelphia.net> wrote:
> One of Perl's shortcomings, IMHO, is the *need* for the programer to
> make sure that OOP is enforced.
One of Perl's advantages, IMHO, is that OOP is not enforced. If your
program is not going to be maintained by monkeys, a note in the
documentation to the effect that 'so-and-so is a private
method/variable, don't use it' is quite adequate protection; if your
code is going to be maintained by monkeys, you're screwed anyway :).
> In other words, there's more you need
> to code for in Perl versus langauges like C, C++, or Java. However,
> the facility is there to OOP in Perl. Modules are an example of OOP
> in Perl.
A correction: Classes are an example of OOP in Perl. *Some* modules
make use of classes.
The class/module/package/file distinction, although often convenient
to ignore, *is* important to understand.
> One last "rant" on this topic - Perl is the one of the only languages
> that can easily provide what you need to extend your applications
> *without* the need to recompile the base interpreter or jump through
> hoops to get what you want. You want to send email via SMTP, just
> install the Net::SMTP module. You want a GUI, install the Tk module.
>
> Languages like PHP have, for example, database support *compiled* as
> part of the base language and the drivers need to be defined during
> the install in order to get them
I don't think this is true of PHP any more. I know it is not true of
Python.
> Of course, this all could lead to a "holy" type discussion ("My
> language is better than your language" thread) :-)
Yes. As such, it is completely pointless. My response to language
advocates is usually 'Well, if you want to spend your time fighting
PHP/Python/whatever then good luck to you' :).
WRT Python in particular, the only things (IMHO) Perl has over python
are
1. A sensible block structure not relying on indentation.
2. Closures.
3. Larry's obsession with correctly 'Huffman coding' the language:
viz. that commonly used operations should be short to code.
Plus I *strongly* object to the apparent sentiment in the Python
community that their aim is to 'supplant Perl'. If Python is a
language worth having, and it seems to me that it is, then it is quite
capable of finding its own uses without it needing to be set up in
opposition to Perl.
Just my 2d.
Ben
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
------------------------------
Date: Fri, 07 Nov 2003 21:30:50 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Perl features
Message-Id: <eaUqb.265$9l4.173370@news2.news.adelphia.net>
"The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than they
could ever be in a language that attempts to enforce cleanliness. The
potential for greater good goes right along with the potential for greater
evil." -- Larry Wall
------------------------------
Date: 7 Nov 2003 15:13:16 -0800
From: mp34ken@hotmail.com (polarbear)
Subject: Re: Perl Module DBD::ORACLE
Message-Id: <1fd7a467.0311071513.17bfb0b4@posting.google.com>
I would like to follow up and let anyone who has this issue know what
the fix was:
EDIT Makefile.PL
Change Line 95 from:
my $is_me = (-d "/home/timbo/dbi" && ($ENV{LOGNAME}||'') eq 'timbo');
# a reasonable guess
to:
my $is_me = 0;
Ron Reidy <r_reidy@comcast.net> wrote in message news:<3FAAD466.3040405@comcast.net>...
> See below ...
>
> polarbear wrote:
> > Friends.
> >
> > When I attempt to install the DBD::ORACLE modual it hangs after one
> > line of output.
>
> What does this mean? One line of output from 'perl Makefile.PL'? Or ?
> Did you read the README* docs?
When I said one line the output looked like:
[logger] DBD-Oracle-1.14> perl Makefile.PL
Multiple copies of Driver.xst found Using DBI 1.38 installed in
/usr/local/lib/perl5/site_perl/5.8.1/sun4-solaris/auto/DBI
That is it. Untill Ctrl+c.
> >
> > I have installed several other modules including DBI with out
> > problems. Has anyone seen this.
> >
> > -Ken
>
------------------------------
Date: Fri, 07 Nov 2003 21:54:37 GMT
From: rosenthd@yahoo.com
Subject: Problem with changes to referrenced object
Message-Id: <lq4oqvc1hgsm0j73c2q6tnt17qs9tp6mia@4ax.com>
Hi,
I'd like to use a copy of my "test" object below without it being
changed. However, all of my attempts so far to copy it don't seem
to succeed. As the example shows below changing newarray affects the
test object. How Can I copy values from the test array into a new
array without changing the original test array.
$test[0]{'A'} = 1;
$test[1]{'A'} = 1;
$test[2]{'A'} = 2;
$test[2]{'C'} = 3;
$test[3]{'B'} = 3;
@newarray = @test;
$testref = \@test;
for ($x=0;$x<=$#{$testref};$x++)
{
#print "$x\n";
foreach $elem (keys %{${$testref}[$x]})
{
print "$x: $elem, ${$testref}[$x]{$elem}\n";
}
}
print "Setting G to 3\n";
$newarray[0]{'G'}=3;
for ($x=0;$x<=$#{$testref};$x++)
{
#print "$x\n";
foreach $elem (keys %{${$testref}[$x]})
{
print "$x: $elem, ${$testref}[$x]{$elem}\n";
}
}
Here's my output:
0: A, 1
1: A, 1
2: A, 2
2: C, 3
3: B, 3
Setting G to 3
0: A, 1
0: G, 3
1: A, 1
2: A, 2
2: C, 3
3: B, 3
------------------------------
Date: Sat, 08 Nov 2003 00:19:18 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem with changes to referrenced object
Message-Id: <boh9ur$1efgkt$1@ID-184292.news.uni-berlin.de>
rosenthd@yahoo.com wrote:
> I'd like to use a copy of my "test" object below without it being
> changed. However, all of my attempts so far to copy it don't
> seem to succeed. As the example shows below changing newarray
> affects the test object. How Can I copy values from the test
> array into a new array without changing the original test array.
>
> $test[0]{'A'} = 1;
> $test[1]{'A'} = 1;
> $test[2]{'A'} = 2;
> $test[2]{'C'} = 3;
> $test[3]{'B'} = 3;
>
> @newarray = @test;
@test contains references to anonymous hashes, so @newarray is
assigned references to just those anonymous hashes.
Instead of
@newarray = @test;
you need to do something like
for my $i (0..$#test) {
for my $key ( keys %{ $test[$i] } ) {
$newarray[$i]{$key} = $test[$i]->{$key};
}
}
@newarray now contains references to _copies_ of the anonymous hashes
instead of references to the original ditto.
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 7 Nov 2003 18:51:19 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: rosenthd@yahoo.com
Subject: Re: Problem with changes to referrenced object
Message-Id: <Pine.SGI.3.96.1031107184916.75825A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On Fri, 7 Nov 2003 rosenthd@yahoo.com wrote:
>I'd like to use a copy of my "test" object below without it being
>changed. However, all of my attempts so far to copy it don't seem
>to succeed. As the example shows below changing newarray affects the
>test object. How Can I copy values from the test array into a new
>array without changing the original test array.
You want to make a "deep copy", not a "shallow copy". A shallow copy only
goes one level deep, whereas a deep copy is thorough, and copies EACH
level of reference.
You might want to use the Storable module's dclone() function.
Also, I suggest reading
http://www.stonehenge.com/merlyn/UnixReview/col30.html
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Fri, 07 Nov 2003 19:13:36 +0000
From: Brian Wakem <no@email.com>
Subject: Re: searching for null in pattern
Message-Id: <bogqt2$1dvreg$1@ID-112158.news.uni-berlin.de>
Brian Andrus wrote:
> I am trying to parse an html line that contains lots of noise. I have
> gotten it down mostly, but am having trouble with exact matches.
>
> The part I am looking at will be
> *align="right"><b>##.###</b></td>*
>
> where * is much useless stuff and ##.### is the part I am trying to
> extract.
> The issue:
>
> examples of what ##.### might be:
> 9.31
> 0.17
> 8.345
> 12.72
>
> So I need to get something that will return the value whethere there
> is 1 or 2 digits before the decimal and 2 or 3 digits after.
>
> I have
>
> /^*align="right"><b>*([0-9]\.[0-9][0-9])/
>
> which will work for #.##, but not the other possibilities. How do I
> get all the possibilities in a single search? When I try using *
> inside the parentheses, I get an error.
>
> Brian Andrus
\d{1,2}\.\d{2,3}
--
Brian Wakem
------------------------------
Date: 7 Nov 2003 16:50:55 -0800
From: batman@thundermail.com (Brian Andrus)
Subject: Re: searching for null in pattern
Message-Id: <ae9a7893.0311071650.12d360b7@posting.google.com>
Brian Wakem <no@email.com> wrote in message news:<bogqt2$1dvreg$1@ID-112158.news.uni-berlin.de>...
>
>
> \d{1,2}\.\d{2,3}
Perfect! Thanks.. Now for the learning part..heh.
I can figure d{x,y} must mean x or y digits.
what to the backslashes do in this case?
Brian Andrus
------------------------------
Date: Fri, 7 Nov 2003 20:09:30 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: searching for null in pattern
Message-Id: <Pine.A41.4.58.0311071957560.16502@ginger.libs.uga.edu>
On Fri, 7 Nov 2003, Brian Andrus wrote:
> Brian Wakem <no@email.com> wrote in message news:<bogqt2$1dvreg$1@ID-112158.news.uni-berlin.de>...
> > \d{1,2}\.\d{2,3}
> Perfect! Thanks.. Now for the learning part..heh.
>
> I can figure d{x,y} must mean x or y digits.
> what to the backslashes do in this case?
\d (including the backslash) means [0-9], i.e., digits
{x,y} means at least x and no more than y of what immediately precedes,
i.e., it's a range
. is a metacharacter that matches any character (with some
qualifications).
\. escapes that metacharacter to match the literal character '.'
See also perldoc perlre
Regards,
Brad
------------------------------
Date: Sat, 8 Nov 2003 01:16:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: searching for null in pattern
Message-Id: <bohg5n$i8s$1@wisteria.csv.warwick.ac.uk>
batman@thundermail.com (Brian Andrus) wrote:
> Brian Wakem <no@email.com> wrote in message
> news:<bogqt2$1dvreg$1@ID-112158.news.uni-berlin.de>...
> >
> >
> > \d{1,2}\.\d{2,3}
>
> I can figure d{x,y} must mean x or y digits.
> what to the backslashes do in this case?
Have you read perldoc perlre? Why not?
'\d' means 'match a digit'. '{x,y}' means 'match the preceding atom
(in this case '\d') between x and y times'.
/d{2,3}/ would match 'dd' or 'ddd', but not '123'.
Ben
--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: ben@morrow.me.uk
------------------------------
Date: Sat, 8 Nov 2003 01:23:11 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: searching for null in pattern
Message-Id: <bohghv$i8s$2@wisteria.csv.warwick.ac.uk>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> \d (including the backslash) means [0-9], i.e., digits
As someone pointed out before wrt [[:lower:]], \d is different from
[0-9]. Try
% perl -Mcharnames=viacode -le'for(0x0..0xffff) { print \
charnames::viacode $_ if chr =~ /\d/ }'
with 5.8. (The above should be all on one line.)
Ben
--
. | .
\ / The clueometer is reading zero.
. .
__ <-----@ __ ben@morrow.me.uk
------------------------------
Date: Fri, 07 Nov 2003 19:05:35 GMT
From: "LaDainian Tomlinson" <go@away.spam>
Subject: Style question: map versus foreach
Message-Id: <32Sqb.90992$IA2.3116886@twister.southeast.rr.com>
Hi,
I wrote a short script the other night to search for C errno definitions by
their integer values. It works fine, but I was originally using map() in
void context and figured that was bad practice. Is this true at all, or are
there any advantages to using map() (speed-wise or otherwise) rather than a
foreach loop even in void context? The script follows:
--- BEGIN CODE ---
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
my @errnos;
my $errnum = 21;
find(\&wanted, qw(/usr/include));
$\ = "\n";
foreach (@errnos){
open ERRNO, "<", $_ or die "Couldn't open $_: $!";
#map { chomp && print if /\b$errnum\b/ } <ERRNO>; #this?
foreach (<ERRNO>){ chomp && print if /\b$errnum\b/ }; #or this?
close ERRNO or die "Couldn't close $_: $!";
}
sub wanted { push(@errnos, $File::Find::name) if /errno.h$/ }
--- END CODE ---
Thanks,
Brandan L.
--
bclennox AT eos DOT ncsu DOT edu
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 10/27/2003
------------------------------
Date: 7 Nov 2003 19:20:17 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Style question: map versus foreach
Message-Id: <bogr9h$9si$1@nets3.rz.RWTH-Aachen.DE>
Also sprach LaDainian Tomlinson:
> I wrote a short script the other night to search for C errno definitions by
> their integer values. It works fine, but I was originally using map() in
> void context and figured that was bad practice. Is this true at all, or are
> there any advantages to using map() (speed-wise or otherwise) rather than a
> foreach loop even in void context? The script follows:
[...]
Depends on the version of perl you employ. When you are using 5.8.1
map() no longer bothers to return a list in void context which makes it
almost (but not quite, as I remember) fast as a foreach-loop.
For older perls, there is a measurable difference in speed favouring
foreach. If in doubt, use the Benchmark module to get some figures for
your machine.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 7 Nov 2003 14:07:37 -0800
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Style question: map versus foreach
Message-Id: <3ee08638.0311071407.3ef4961b@posting.google.com>
"LaDainian Tomlinson" <go@away.spam> wrote in message news:<32Sqb.90992$IA2.3116886@twister.southeast.rr.com>...
> #map { chomp && print if /\b$errnum\b/ } <ERRNO>; #this?
> foreach (<ERRNO>){ chomp && print if /\b$errnum\b/ }; #or this?
Or maybe
print grep (chomp && /\b$errnum\b/) <ERRNO>;
?
------------------------------
Date: 8 Nov 2003 01:21:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Style question: map versus foreach
Message-Id: <bohgei$i2v$1@mamenchi.zrz.TU-Berlin.DE>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach LaDainian Tomlinson:
>
> > I wrote a short script the other night to search for C errno definitions by
> > their integer values. It works fine, but I was originally using map() in
> > void context and figured that was bad practice. Is this true at all, or are
> > there any advantages to using map() (speed-wise or otherwise) rather than a
> > foreach loop even in void context? The script follows:
>
> [...]
>
> Depends on the version of perl you employ. When you are using 5.8.1
> map() no longer bothers to return a list in void context which makes it
> almost (but not quite, as I remember) fast as a foreach-loop.
>
> For older perls, there is a measurable difference in speed favouring
> foreach. If in doubt, use the Benchmark module to get some figures for
> your machine.
That's efficiency. As for style, that depends very much upon whom
you ask. Some want to ban map in void context entirely, others say
there's nothing wrong with it. I tend to avoid it since (namely 5.1.1
or so) the statement-modifying "for" does the same thing.
Anno
------------------------------
Date: Fri, 07 Nov 2003 22:50:54 GMT
From: Brian Salter-Duke <b_duke@octa4.net.invalid>
Subject: Upgrading perl and module use
Message-Id: <ilVqb.35$z31.1413@news.optus.net.au>
When I upgraded perl, it could not find my installed modules (the ones I
had installed). Is there a way to get perl to use modules that are under a
different version tree structure, or do I have to reinstall the modules?
--
Brian Salter-Duke Humpty Doo, Nr Darwin, Australia
My real address is b_duke(AT)octa4(DOT)net(DOT)au
Use this for reply or followup
Perl user for eight years - the way to go.
------------------------------
Date: Fri, 7 Nov 2003 17:18:50 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Upgrading perl and module use
Message-Id: <slrnbqoa2q.5h8.tadmc@magna.augustmail.com>
Brian Salter-Duke <b_duke@octa4.net.invalid> wrote:
> When I upgraded perl,
From what version to what version?
> it could not find my installed modules (the ones I
> had installed). Is there a way to get perl to use modules that are under a
> different version tree structure,
Yes, the way given in the Perl FAQ no less!
perldoc -q module
How do I keep my own module/library directory?
> or do I have to reinstall the modules?
Maybe.
Are they pure Perl modules or do they use XS?
Some versions of Perl are not binary-compatible with other versions.
--
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.
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 5765
***************************************