[22766] in Perl-Users-Digest
Perl-Users Digest, Issue: 4987 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 15 14:06:13 2003
Date: Thu, 15 May 2003 11:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 15 May 2003 Volume: 10 Number: 4987
Today's topics:
Re: "ndbm store" error on Solaris (Richard L. Hamilton)
Re: <html> and reg. expressions (Kevin Collins)
Re: [The/My] trouble with Perl <geenspam@geenspam.biz>
Re: [The/My] trouble with Perl <geenspam@geenspam.biz>
Re: [The/My] trouble with Perl <bart.lateur@pandora.be>
Re: [The/My] trouble with Perl <bart.lateur@pandora.be>
Re: [The/My] trouble with Perl <geenspam@geenspam.biz>
Re: [The/My] trouble with Perl <bjm-nntp@vsca.ca>
Re: [The/My] trouble with Perl <ddunham@redwood.taos.com>
Re: [The/My] trouble with Perl <geenspam@geenspam.biz>
Re: [The/My] trouble with Perl <geenspam@geenspam.biz>
Re: [The/My] trouble with Perl <ddunham@redwood.taos.com>
building perl on Solaris 9 (lib/pm.pm error) <mn-nospam@cs.york.ac.uk>
Re: Can't locate sub.pl <noreply@gunnar.cc>
changing perl's manpath (shambolic)
compile error for Time-HoRes-1.47 using perl 5.8.0 (Eric)
English parser <mrojas@netrover.com>
Re: English parser <ubl@schaffhausen.de>
Re: grep-mediated autocreation: bug or feature? <jill_krugman@yahoo.com>
Guessing content-type from file <guettler@thomas-guettler.de>
Re: Guessing content-type from file <tassilo.parseval@rwth-aachen.de>
Re: How to query a Microsoft SQL Server with perl? <ThomasKratz@REMOVEwebCAPS.de>
I know it is a newbie dumb question but the answer is n <bigbadbob@yahoo.com>
Re: I know it is a newbie dumb question but the answer <tassilo.parseval@rwth-aachen.de>
Re: I know it is a newbie dumb question but the answer <bwalton@rochester.rr.com>
Re: I know it is a newbie dumb question but the answer <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 15 May 2003 11:44:56 -0000
From: rlhamil@smart.net (Richard L. Hamilton)
Subject: Re: "ndbm store" error on Solaris
Message-Id: <vc6vdom68mgp9c@corp.supernews.com>
In article <C7Fwa.16663$io.343810@iad-read.news.verio.net>,
inwap@inwap.com (Joe Smith) writes:
> In article <l2Lva.6$tA3.151@news.oracle.com>,
> Shehzaad Nakhoda <dontspamme@dontspam.com> wrote:
>>I've run into a problem with periodic errors with the following error
>>message that cause my perl program to exit abnormally:
>>
>>ndbm store returned -1, errno 27, key
>>"1052131392769|217.225.201.81|56:1052131056:156
>>948" at <perl file path> line <perl file name>, <INFILE> line 204057.
>>
>>I'm using a dbm backed hash, which does grow to about 345MB file size (as
>>seen by the 'du' command). Running repeatedly causes the exact same error
>>with the same key. I should also mention that the hash file size shown by
>>'ls' is quite humungous: 936187058176 (over 900 Gb). Disk space is plentiful
>>and close to half full only.
>
>>#define EFBIG 27 /* File too large */
>
> The ndbm database interface has arbitrary limits that cause errors
> of EFBIG or ENOSPC when too many keys hash to the same bucket.
>
> solaris% man ndbm
>
> The sum of the sizes of a key/content pair must not exceed
> the internal block size (currently 1024 bytes). Moreover all
> key/content pairs that hash together must fit on a single
> block. dbm_store() will return an error in the event that a
> disk block fills with inseparable data.
[...]
> I recommend switching to gdbm or Berkeley_DB instead of trying
> to program around the limitations of ndbm.
>
> -Joe
>
> P.S. I hit this problem years ago after dumping an ndbm database to
> a flat file and attempting re-import it. The failure depended on which
> order keys were added first.
I've hit this problem with large netgroups in an NIS map. :-)
--
mailto:rlhamil@mindwarp.smart.net http://www.smart.net/~rlhamil
------------------------------
Date: 15 May 2003 10:27:47 -0700
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: <html> and reg. expressions
Message-Id: <a6882f32.0305150927.34f798b3@posting.google.com>
"berndt.sommer" <berndt.sommer@gmx.de> wrote in message news:<b9tntr$lev$05$1@news.t-online.com>...
> Hi there,
>
> 1. with s/<[^>]+>// I can replace all html tags to nothing. I tried to do
> this with
> /<[.]+>/ but this does not work. I do not have any idea why.
--snip--
The second regex doesn't work because you are saying match 1 or more
of a character class containing a literal ".". Change your regex to
match 1 or more of ANY character ("."):
s/<.+>//g
However, this is a flawed approach compared to you 1st regex, because
it could grab multiple tags on a line:
<H2>Here is a header with a <B>bold</B>word </H2>
Would be
s/<[^>]+>//g : "Here is a header with a bold word "
s/<.+>//g : ""
Hope this helps explain the problem...
Kevin
------------------------------
Date: Thu, 15 May 2003 19:18:55 +0200
From: Henk van Bree <geenspam@geenspam.biz>
Subject: Re: [The/My] trouble with Perl
Message-Id: <3ec3bde5$0$49101$e4fe514c@news.xs4all.nl>
Malcolm Dew-Jones wrote:
> I can't point to a publicly available application that does this, but if
> you write your application in the form of a "private" web server where the
> user is expected to use a browser to interact with the application, which
> only responds, one page at a time, to a local client, then you have the
> basis for a simple, yet fairly GUI perl application which can run most
> anywhere.
True, this is an easy way to handle most applications. For the graphing
program I'm trying to write I have to update the graph in real-time. So
I can't use a web-interface without severely misusing the http protocol.
I might have to resort to using Visual Basic (or something like that) to
handle the data display and feeding that from Perl. Horrendous, yes...
Henk
------------------------------
Date: Thu, 15 May 2003 19:30:42 +0200
From: Henk van Bree <geenspam@geenspam.biz>
Subject: Re: [The/My] trouble with Perl
Message-Id: <3ec3c0a8$0$49098$e4fe514c@news.xs4all.nl>
Randal L. Schwartz wrote:
> (1) posts to comp.lang.perl, a dead newsgroup
A dead newsgroup which in my newsreader (KNode)
isn't flagged as such and gets its fair share of
posts a day, so how was I to know? Sure, I guess
I could have lurked this group for a while and maybe
picked up on it. If that is my crime, so be it.
> (2) sets the *followup* to said dead newsgroup
Didn't know it was dead, follows from there.
> (3) spamcodes his email address
True. I'm getting over a hundred (100) spams a day already,
I have no desire for more. If you have a solution to my
problem that you are not willing or able to post but are
willing and able to mail, please use the address below, your
input is greatly appreciated.
> (4) doesn't give despamming instructions
True. I figured that since I asked in a newsgroup and since
the answer might be of benefit to someone else I didn't need
to provide an e-mail address. If I offended you with this
I apologize, and you can reach me at: zinkput()hotmail.com
You have to replace the () with an @ to make it a valid
address. The address will be valid for a period of three months
or until it gets spammed to oblivion, whichever happens first.
> That's probably worthy of a >PLONK< right there for those
> with less time than I have to answer questions.
I think you judge me harshly, I'm really a nice guy!
Henk
------------------------------
Date: Thu, 15 May 2003 16:39:28 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: [The/My] trouble with Perl
Message-Id: <shg7cv431tir7as21q2ht46c42atig8an9@4ax.com>
Henk van Bree wrote:
>I might have to resort to using Visual Basic (or something like that) to
>handle the data display and feeding that from Perl. Horrendous, yes...
PC, huh? Have you seen The GUI Loft, RAD tool for Win32::GUI?
<http://www.bahnhof.se/~johanl/perl/Loft/>
--
Bart.
------------------------------
Date: Thu, 15 May 2003 16:41:06 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: [The/My] trouble with Perl
Message-Id: <hng7cvo54urs5ti39i708e44n5pmdu2ucg@4ax.com>
Henk van Bree wrote:
>I'm getting over a hundred (100) spams a day already,
>I have no desire for more.
Don't worry, it wouldn't get any worse if you were to post under your
real address. You're beyond hope already.
--
Bart.
------------------------------
Date: Thu, 15 May 2003 19:42:03 +0200
From: Henk van Bree <geenspam@geenspam.biz>
Subject: Re: [The/My] trouble with Perl
Message-Id: <3ec3c351$0$49106$e4fe514c@news.xs4all.nl>
Randal L. Schwartz wrote:
> Yeah, the graphics libs are the toughest. GD, Gtk, Tk, PerlMagick.
> All seem to require some sort of magical work to get working.
My problem (or rather, one of my problems) is that I need something that
works under Gnu/Linux *and* under Windows. That narrows down the options
to Tk (which is a pain to deploy under Windows) and possibly WxWindows.
> But it's not really Perl at fault here... the problem is the layering
> of libraries, and moving (weekly? :) interfaces.
The point I was trying to make, was that if Perl had a GUI widgetset
built-in all these problems would be over. I'm fairly sure I'm not the only
one stumbling in the dark to get a simple button on screen.
I really like Perl for the language itself. I've written numerous
cgi-scripts and database conversions and it never left me wanting, but the
whole GUI issue I'm now encountering is very messy.
Maybe I'm just stubborn that I want to use Perl for a GUI application?
Henk
zi nk put#ho tm ai l.c om (remove spaces and substitute @ for #)
------------------------------
Date: Thu, 15 May 2003 16:57:04 GMT
From: Brad Murray <bjm-nntp@vsca.ca>
Subject: Re: [The/My] trouble with Perl
Message-Id: <AFPwa.473$%J.58158@news2.telusplanet.net>
Henk van Bree <geenspam@geenspam.biz> wrote:
HvB> My problem (or rather, one of my problems) is that I need something that
HvB> works under Gnu/Linux *and* under Windows. That narrows down the options
HvB> to Tk (which is a pain to deploy under Windows) and possibly WxWindows.
I'm surprised at your problems with Tk under windows. I find that the
ActivePerl installation has done this properly and reliably for many
many versions now. Tk has always worked out of the box for me with
Perl on Windows.
--
Brad Murray * The trouble with troubleshooting is that trouble
VSCA Founder * sometimes shoots back -- <Rejo>
------------------------------
Date: Thu, 15 May 2003 17:08:59 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: [The/My] trouble with Perl
Message-Id: <LQPwa.612$CM3.61160615@newssvr14.news.prodigy.com>
Henk van Bree <geenspam@geenspam.biz> wrote:
> Randal L. Schwartz wrote:
>> Yeah, the graphics libs are the toughest. GD, Gtk, Tk, PerlMagick.
>> All seem to require some sort of magical work to get working.
> My problem (or rather, one of my problems) is that I need something that
> works under Gnu/Linux *and* under Windows. That narrows down the options
> to Tk (which is a pain to deploy under Windows) and possibly WxWindows.
What's wrong with Tk? Are you using ActivePerl on windows or something
else? It even works with perl2exe if you want to ease the pain of
installing perl on a windows box in the first place.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Thu, 15 May 2003 20:15:48 +0200
From: Henk van Bree <geenspam@geenspam.biz>
Subject: Re: [The/My] trouble with Perl
Message-Id: <3ec3cb3a$0$49104$e4fe514c@news.xs4all.nl>
Brad Murray wrote:
> I'm surprised at your problems with Tk under windows. I find that the
> ActivePerl installation has done this properly and reliably for many
> many versions now. Tk has always worked out of the box for me with
> Perl on Windows.
For development, yes, you are right. But I need to deploy the program
to 3500 client machines, and installing a complete ActiveState installation
on them is just not possible (outside my control). So I've been trying to
package Tk in a Windows installer script and so far it just isn't reliable.
It works on maybe 80% of machines (wildly differing hardware and/or
software) and fails on the rest for a variety of reasons.
Maybe I'm just in a weird environment (mixed Linux and Windows pc's) but
I really need to run the same Perl code on different platforms.
Henk
(Now if there was a Perl2Java converter... Haha, only serious... :-( )
------------------------------
Date: Thu, 15 May 2003 20:21:10 +0200
From: Henk van Bree <geenspam@geenspam.biz>
Subject: Re: [The/My] trouble with Perl
Message-Id: <3ec3cc7c$0$49101$e4fe514c@news.xs4all.nl>
Darren Dunham wrote:
> What's wrong with Tk?
Don't get me started... ;-)
There's nothing inherently wrong with Tk, apart from the
trouble that I'm having installing it (see other post).
I think it doesn't look too great, but if Tk is my only
option I'll gladly use it, even if I find the way you have
to code for it a bit 'noisy'.
Henk
Still, I think adding native GUI features to Perl would
make the world a better place.
------------------------------
Date: Thu, 15 May 2003 17:57:16 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: [The/My] trouble with Perl
Message-Id: <0yQwa.639$kX3.61779182@newssvr14.news.prodigy.com>
Henk van Bree <geenspam@geenspam.biz> wrote:
> Darren Dunham wrote:
>> What's wrong with Tk?
> Don't get me started... ;-)
> There's nothing inherently wrong with Tk, apart from the
> trouble that I'm having installing it (see other post).
If you don't otherwise need perl on your target machines, how about
perl2exe or PAR installlations?
> Still, I think adding native GUI features to Perl would
> make the world a better place.
It doesn't sound that that would help you with your perl installation
problems on the windows boxes.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Thu, 15 May 2003 13:44:07 +0100
From: "Mark Nelson" <mn-nospam@cs.york.ac.uk>
Subject: building perl on Solaris 9 (lib/pm.pm error)
Message-Id: <pan.2003.05.15.12.44.07.653738@cs.york.ac.uk>
Hi
I'm trying to build perl 5.8.0 on Solaris 9, using gcc-3.2.2, part of the
way through the build it, fails with the following error -
make: Warning: Both `makefile' and `Makefile' exist
./miniperl -Ilib configpm configpm.tmp
sh mv-if-diff configpm.tmp lib/Config.pm
File lib/Config.pm not changed.
AutoSplitting perl library
./miniperl -Ilib -e 'use AutoSplit; \
autosplit_lib_modules(@ARGV)' lib/*.pm
./miniperl -Ilib -e 'use AutoSplit; \
autosplit_lib_modules(@ARGV)' lib/*/*.pm
AutoSplit: Can't open lib/pm.pm: No such file or directory
*** Error code 2
make: Fatal error: Command failed for target `preplibrary'
Is there some additional packages required in order to build perl on
Solaris
Thanks in advance
Mark.
(mn@cs.york.ac.uk)
--------------------------------------------------------
Mark Nelson - mn@cs.york.ac.uk
White Rose Grid Project, Department of Computer Science,
University of York Heslington, York, YO10 5DD
Reception: +44 1904 432722, Direct Dial: +44 1904 432722
This mail is for the addressee only
------------------------------
Date: Thu, 15 May 2003 12:11:36 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Can't locate sub.pl
Message-Id: <b9vp47$mtdmk$1@ID-184292.news.dfncis.de>
Pierre Couderc wrote:
> I have a sporadic error in my mod_perl script:
<snip>
> main.pl
> -------
>
> require './sub.pl';
> ...
> mysub();
>
> Using Apache+mod_perl and the correct URL, I call main.pl, and all is
> fine : mysub() is correcly executed.
>
> But, later sporadicly, when repeating the execution, I got the message
> in error.log:
>
> [Wed May 14 07:23:43 2003] [error] Undefined subroutine mysub called at
> /var/www/perl/main.pl line xxx
>
> Adding traces, I got the message "can't locate ./sub.pl"
Relative paths should _never_ be relied on when running scripts under
mod_perl. One solution might be to change main.pl to:
(my $dir = $0) =~ s,/[^/]+$,,;
require "$dir/sub.pl";
...
mysub();
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 15 May 2003 09:28:57 -0700
From: johnston.jay@mtvne.com (shambolic)
Subject: changing perl's manpath
Message-Id: <f333df78.0305150828.32b8210d@posting.google.com>
Hi,
i seem to have a conflicting manpath for perl. when installing CPAN
modules, make tries to put the man pages in /usr/bin/man , which is
actually the man binary and not the manpath (which is /usr/local/man).
i've had a scour through the docs without much luck, though what i've
seen suggests i may need to recompile perl.
does anyone know the best way to change this?
many thanks
j
------------------------------
Date: 15 May 2003 06:07:56 -0700
From: eric.chin@pinnacle.co.uk (Eric)
Subject: compile error for Time-HoRes-1.47 using perl 5.8.0
Message-Id: <d8c847cd.0305150507.563e5069@posting.google.com>
Greetings,
I try to compile Time-HiRes-1.47 using perl 5.8.0 and gets:
"Makefile:91: *** missing separator. Stop."
I compiled the same version of Time-HiRes-1.47 on perl 5.6.0 and it
compiles fine.
Both Makefile was generated using perl Makefile.PL.
Is anyone know if there is a patch for perl 5.8.0 to fix the above
error or know what to modify to fix the error.
I using RedHat 9.0 and perl 5.8.0-88 come with the distribution. I
checked RH site and found no patch available.
Any pointer appreciated.
TIA
Eric
------------------------------
Date: Thu, 15 May 2003 14:14:46 +0200
From: "jfd" <mrojas@netrover.com>
Subject: English parser
Message-Id: <ba00ak$3mg$1@news-reader13.wanadoo.fr>
Is there a simple English parser in Perl ?
(sth with a modicum of recurrence + a reasonable dictionary,
to break down sentences, look for NPs, find named entities).
Thanks
JFD
(I have searched a bit and have not found anything existing. Should I write
one from scratch ?)
--
---
JF Delannoy, Ph.D.
Consultant: text/discussion analysis, info retrieval, reporting
Adjunct Professor, University of Ottawa
Translator (Eng Fra Esp Por)
(613) 237-8301
www.site.uottawa.ca/~delannoy
--
------------------------------
Date: Thu, 15 May 2003 17:29:44 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: English parser
Message-Id: <ba0eu2$9jb$1@news.dtag.de>
jfd wrote:
> Is there a simple English parser in Perl ?
There is a lot of stuff here:
http://search.cpan.org/search?query=lingua+en&mode=all
You'll have to see what fits your needs.
malte
------------------------------
Date: Thu, 15 May 2003 12:01:11 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: grep-mediated autocreation: bug or feature?
Message-Id: <b9vvi7$c13$1@reader1.panix.com>
In <x7n0i8xcwg.fsf@mail.sysarch.com> Uri Guttman <uri@stemsystems.com> writes:
>>>>>> "JK" == J Krugman <jill_krugman@yahoo.com> writes:
> JK> DB<1> $x = $s{'a'}
> JK> DB<2> x \%s
> JK> 0 HASH(0x8387220)
> JK> empty hash
> JK> DB<3> @x = @s{qw(a b c)}
>those elements don't exist so they return undef. the values are not
>autovivified as they are not ever accessed.
> JK> DB<4> x \%s
> JK> 0 HASH(0x8387220)
> JK> empty hash
> JK> DB<5> @x = grep $_, @s{qw(a b c)}
>$_ is aliased to the values of those hash keys. so they must have an
>actual value and so are autovivified to undef. that means the keys will
>be created too.
> JK> DB<6> x \%s
> JK> 0 HASH(0x8387220)
> JK> 'a' => undef
> JK> 'b' => undef
> JK> 'c' => undef
> JK> Bug or feature?
>it's a feature and an interesting example of autovivification. for more
>on this read my tutorial at:
> http://www.sysarch.com/perl/tutorials/autoviv.txt
Thanks, Uri. Your tutorial dispels some of the fog, but I still
find this situation deeply unsettling. For one thing, your tutorial
suggests that autovivification is something one should be aware of
in the case of references, particularly nested references. For
example, you write:
Autovivification of references only occurs when you dereference
an undefined value.
As far as I can tell there was no explicit dereferencing going on
in the example I gave (unless grep does something like it internally).
Likewise, you talk about how using exists or defined can sometimes
result in autovivification, but again, this is not the case here.
My code is rife with the following idioms, which I use whenever I
want to represent sets in Perl:
my %A = map { $_ => undef } qw(one two three alpha gamma);
my @B_list = qw(alpha beta gamma delta);
my %B; @B{@B_list} = undef;
my %A_intersection_B = map { $_ => undef } grep exists $B{$_}, keys %A;
In this case, at least according to PerlDB, nothing gets autovivified,
but in other innocuous cases, like the one I posted, they do.
Irrespective of the possible benefits of this alleged feature,
without a clearly stated policy, the potential for bugs is huge.
I know how to fix the code above to minimize the risks posed by
unwanted vivification:
my %A = map { $_ => 1 } qw(one two three alpha gamma);
my @B_list = qw(alpha beta gamma delta);
my %B; @B{@B_list} = (1) x @B_list;
my %A_intersection_B = map { $_ => 1 } grep $B{$_}, keys %A;
...but it would be much easier for me to fix only those parts of my
code where unwanted vivification is happening. Therefore I need
to find out exactly when Perl will "oblige" with autovivification.
Thanks,
-Jill
------------------------------
Date: Thu, 15 May 2003 13:50:56 +0200
From: Thomas =?ISO-8859-15?Q?G=FCttler?= <guettler@thomas-guettler.de>
Subject: Guessing content-type from file
Message-Id: <b9vv0o$mr7fj$1@ID-63505.news.dfncis.de>
Hi!
Is there a perl module which can guess
a content-type of a file by:
- extension (.txt, .pl, ...)
- by looking at it (like file)
The content-type should be a mime.type like
in /etc/mime.types: Example application/postscript.
I looked at CPAN but, didn't found it.
thomas
------------------------------
Date: 15 May 2003 13:02:20 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Guessing content-type from file
Message-Id: <ba034s$4ea$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Thomas Güttler:
> Is there a perl module which can guess
> a content-type of a file by:
> - extension (.txt, .pl, ...)
> - by looking at it (like file)
>
> The content-type should be a mime.type like
> in /etc/mime.types: Example application/postscript.
>
> I looked at CPAN but, didn't found it.
You probably want File::MMagic.
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: Thu, 15 May 2003 17:31:30 +0200
From: "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: How to query a Microsoft SQL Server with perl?
Message-Id: <3ec3bace.0@juno.wiesbaden.netsurf.de>
DQoiRGF2aWQgSy4gV2Fsb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zZXI7cHdkPXBhc3N3b3JkOyc7IG15ICRkYmggPQ0KICAgICAgICBEQkktPmNvbm5lY3Qo
ImRiaTpPREJDOiREU04iKSBvciBkaWUgIiREQkk6OmVycnN0clxuIjsNCg0KVGhvbWFzDQo=
------------------------------
Date: Thu, 15 May 2003 14:47:26 +1000
From: "Bob" <bigbadbob@yahoo.com>
Subject: I know it is a newbie dumb question but the answer is not in the camel
Message-Id: <ba0g92$nvnun$1@ID-82947.news.dfncis.de>
looked for it every where . . .
why does perl use "=~" for s/// and tr///
and not just a straight "=' for assign ?
BigBadBob
------------------------------
Date: 15 May 2003 17:10:46 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: I know it is a newbie dumb question but the answer is not in the camel
Message-Id: <ba0hmm$mer$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Bob:
> looked for it every where . . .
>
> why does perl use "=~" for s/// and tr///
> and not just a straight "=' for assign ?
That would be ambiguous. Consider this code:
my $suc = s/foo/bar/;
The above is not a syntax-error, it does do something. What it does is
actually something like:
my $suc;
if ($_ =~ s/foo/bar) {
$sec = 1;
}
A match or substitution in scalar context returns true if the
match/substitution was successful, false otherwise. If no variable is
bound to the operation (with =~), $_ is assumed. But you can also use
another variable which leads to the slightly peculiar looking:
my $suc = $var =~ s/foo/bar;
'=~' bind more tightly than '=', so this is parsed as:
my $suc = ($var =~ s/foo/bar/);
A match in list-context does something else. It returns the bits
captured by pair of parens:
$_ = "foo:bar";
my @list = /(.*):(.*)/;
print join "\n", @list;
__END__
foo
bar
It works identically for named variables:
my $var = "foo:bar";
my @list = $var =~ /(.*):(.*)/;
print join "\n", @list;
That should answer your question. A new operator was needed because the
eventually chosen '=~' has a return value: Either true/false in scalar
context or captured substrings in list context (for m//). And if
something has a return value, you need to be able to assign this return
value with '='.
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: Thu, 15 May 2003 17:25:30 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: I know it is a newbie dumb question but the answer is not in the camel
Message-Id: <3EC3CD84.8050800@rochester.rr.com>
Bob wrote:
> looked for it every where . . .
>
> why does perl use "=~" for s/// and tr///
> and not just a straight "=' for assign ?
>
> BigBadBob
Well, you can use the = operator with s/// or tr///:
$_='this is that string, or is this confusing?';
$number_of_subs=s/this/that/g;
$number_of_chars=y/abc/def/;
print "string:$_\n";
print "number_of_subs:$number_of_subs\n";
print "number_of_chars:$number_of_chars\n";
Note that the s/// and tr/// operators above used the default variable
of $_ for their lvalue. Ordinarily, one would use the =~ operator to
designate an lvalue for the s/// and tr///:
$number_of_subs=$string=~s/this/that/g;
for example. The = operator in conjunction with s/// assigns the number
of substitutions if any; if none, the empty string. The tr/// operator
returns the number of characters replaced or deleted. The =~ operator
designates an lvalue for the s/// or tr/// to use. It is a different
operator than = . For more info:
perldoc perlop
--
Bob Walton
------------------------------
Date: Thu, 15 May 2003 19:04:44 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: I know it is a newbie dumb question but the answer is not in the camel
Message-Id: <ba0hau$nve3c$1@ID-184292.news.dfncis.de>
Bob wrote:
> looked for it every where . . .
Is perlop included in your definition of "every where"? ;-)
http://www.perldoc.com/perl5.8.0/pod/perlop.html
> why does perl use "=~" for s/// and tr///
> and not just a straight "=' for assign ?
Because binding a string to a pattern match is not an assignment.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 4987
***************************************