[13433] in Perl-Users-Digest
Perl-Users Digest, Issue: 843 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 18 16:07:18 1999
Date: Sat, 18 Sep 1999 13:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937685109-v9-i843@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 18 Sep 1999 Volume: 9 Number: 843
Today's topics:
A Search Engine <pawanbhati@hotmail.com>
Re: An Array of Collumns <meridamx@enol.com>
Re: backref problem <rick.delaney@home.com>
Can I call a compiled C program from Perl? <MrETS@inconnect.com>
Re: CGI in PERL <flavell@mail.cern.ch>
Re: CGI in PERL <jcreed@cyclone.jprc.com>
Re: CONTEST: Range Searching (Chris Nandor)
Re: Converting time() to real date (Abigail)
I need a persistent XML server in Perl davesmall@my-deja.com
Re: Perl Challenge <tlb@algonet.se>
Re: Perl Challenge <jcreed@cyclone.jprc.com>
Re: Problem with XS and MakeMaker (Win98) <tlb@algonet.se>
Re: regexp odity with (?s-x:) <bwalton@rochester.rr.com>
Search Engine <pawanbhati@hotmail.com>
Re: transform / in \/ (Larry Rosler)
Re: transform / in \/ (Larry Rosler)
Re: transform / in \/ <tlb@algonet.se>
Using a period as a delimiter in the split() function <geedawgster@hotmail.com>
Re: Using a period as a delimiter in the split() functi <bwalton@rochester.rr.com>
Re: Using a period as a delimiter in the split() functi (Larry Rosler)
Re: Using a period as a delimiter in the split() functi <rick.delaney@home.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 19 Sep 1999 01:18:24 +0530
From: "Pawan Bhati" <pawanbhati@hotmail.com>
Subject: A Search Engine
Message-Id: <7s1uqo$1gp$1@news.vsnl.net.in>
Can anyone please help me build a small search engine for my site in perl.
My website is on Webjump & I have tried many free search scripts but all
fail to work.
Somebady pleaze help me !!
Pawan
pawanbhati@hotmail.com
------------------------------
Date: Sat, 18 Sep 1999 13:30:28 -0600
From: "Chuck Burgess" <meridamx@enol.com>
Subject: Re: An Array of Collumns
Message-Id: <7s0pkt$jiq$1@news.inquo.net>
Thanks so much for such a quick response. I also appreciate the tips for
cleaning up my code.
I attempted to incorporate the sample you provided, and it didn't work. It's
almost as though nothing is being passed into the array.
I do need to have the arrays organized in collumns so the first example is
not what I am looking for:
i.e.
-> open (dfile, "data.dat");
-> while (<dbfile>) {
-> @row = split //;
-> push @testans, \@row;
-> }
I attempted the second example:
-> open (dfile, "data.dat");
-> while (<dbfile>) {
-> @row = split //;
-> for $col (0..$#row) {
-> push @{$testans[$col]}, $row[$col];
-> }
-> }
But when I:
print "Content-type: text/html\n\n";
print "@{$testans[1]} ";
nothing shows up.
I need to be able to pass the @{$testans[1]} to a statistics pm as follows.
$stat = Statistics::Descriptive::Full->new();
$stat->add_data(@{$testans[$cols]});
$mean = $stat->mean();
because the $stat->add_data( ); expects numbers added like
$stat->add_data(1,2,3,4,5,6);
I know I can pass an array to the add_data because the following code works.
@array = (1,2,3,4,5,6);
$stat = Statistics::Descriptive::Full->new();
$stat->add_data(@array);
$mean = $stat->mean();
So, again, I propose:
How can I take a line by line file such as:
12345
12345
12345
12345
and get all of the numbers from each collumn in separate arrays?
i.e.
@array1 = (1,1,1,1)
@array2 = (2,2,2,2) etc.
------------------------------
Date: Sat, 18 Sep 1999 18:40:15 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: backref problem
Message-Id: <37E3DC88.C8107279@home.com>
[posted & mailed]
[why is $2 eq 'foo' in "foobar' =~ /((foo)|bar)+/ ?
lt lindley wrote:
>
> Eric Bohlman <ebohlman@netcom.com> wrote:
>
> :>Nope. Regex memory variables are *not* altered by unsuccessful matches.
>
> But this is a successful match. In this case $1 and $2 are set
> during the same match. The concept of "the last time ((foo)|bar)
> matches" is misleading because it is "((foo|bar)+" and it is only one
> successful match, not two. There is only one "time" of the regexp
> evaluation. It just matched multiple substrings at the same time.
> Hmmm. That doesn't sound very satisfying. Maybe someone else will
> step in with a clearer explanation.
Well, here's an attempt.
In 'foobar' =~ /((foo)|bar)+/, the REx engine will first try to match
foo which is successful. It then reaches the closing paren for the
group and sets the pos for $2 to 0 (the start of the string where it was
found). It will also set the pos for $1 to 0 since it reaches the
closing paren for that group too.
Because of the + modifier, it will try again. 'foo' doesn't match this
time so the closing parenthesis for $2 is never reached and pos for $2
is not reset. The REx engine then tries the alternative, 'bar', which
succeeds. The close of group 1 is reached and its position is set to 3.
REx engine tries again and cannot match either foo or bar. Neither
closing paren is reached, so the positions for $1 and $2 remain 3 and 0,
respectively.
This can all be seen using
perl -Mre=debug -e '"foobar"=~/((foo)|bar)+/'
My only question is, in the lines
restoring \1 to 3(3)..6
restoring \2 to 0(3)..3
from the output below, I think that
restoring \i to n(k)..m
means \i matches at pos n and contains all characters up to but not
including m, but what does k represent? I thought it might mean the
length of the string but when I changed the test to
perl -Mre=debug -e '"foozbar"=~/((fooz)|bar)+/'
these lines become
restoring \1 to 4(4)..7
restoring \2 to 0(4)..4
and the length of \1 is 3, not 4.
Anyway, here's the output from the original problem:
compiling RE `((foo)|bar)+'
size 21 first at 5
1: CURLYX {1,32767}(20)
3: OPEN1(5)
5: BRANCH(13)
6: OPEN2(8)
8: EXACT <foo>(11)
11: CLOSE2(17)
13: BRANCH(17)
14: EXACT <bar>(17)
17: CLOSE1(19)
19: WHILEM(0)
20: NOTHING(21)
21: END(0)
minlen 3
Omitting $` $& $' support.
EXECUTING...
Matching `((foo)|bar)+' against `foobar'
Setting an EVAL scope, savestack=3
0 <> <foobar> | 1: CURLYX {1,32767}
0 <> <foobar> | 19: WHILEM
0 out of 1..32767 cc=bffff40c
0 <> <foobar> | 3: OPEN1
0 <> <foobar> | 5: BRANCH
Setting an EVAL scope, savestack=3
0 <> <foobar> | 6: OPEN2
0 <> <foobar> | 8: EXACT <foo>
3 <foo> <bar> | 11: CLOSE2
3 <foo> <bar> | 17: CLOSE1
3 <foo> <bar> | 19: WHILEM
1 out of 1..32767 cc=bffff40c
Setting an EVAL scope, savestack=16
3 <foo> <bar> | 3: OPEN1
3 <foo> <bar> | 5: BRANCH
Setting an EVAL scope, savestack=16
3 <foo> <bar> | 6: OPEN2
3 <foo> <bar> | 8: EXACT <foo>
3 <foo> <bar> | 14: EXACT <bar>
6 <foobar> <> | 17: CLOSE1
6 <foobar> <> | 19: WHILEM
2 out of 1..32767 cc=bffff40c
Setting an EVAL scope, savestack=29
6 <foobar> <> | 3: OPEN1
6 <foobar> <> | 5: BRANCH
Setting an EVAL scope, savestack=29
6 <foobar> <> | 6: OPEN2
6 <foobar> <> | 8: EXACT <foo>
6 <foobar> <> | 14: EXACT <bar>
restoring \1 to 3(3)..6
restoring \2 to 0(3)..3
failed, try continuation...
6 <foobar> <> | 20: NOTHING
6 <foobar> <> | 21: END
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sat, 18 Sep 1999 12:34:23 -0600
From: "Rocky" <MrETS@inconnect.com>
Subject: Can I call a compiled C program from Perl?
Message-Id: <7s0lsd$dts$1@news.inconnect.com>
Does anyone know how to call a compiled C executable
from within a Perl program on a UNIX server.
My executable C is in the same directory as my Perl Script.
I have tried extensions . .out .exe and (no extension)
I have "chmod" executable files to 755
The executables run just fine if I telnet to the directory
and just type their names from the command line...
What Gives? - Val Patterson, SLC UT
------------------------------
Date: Sat, 18 Sep 1999 19:13:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI in PERL
Message-Id: <Pine.HPP.3.95a.990918190959.1726F-100000@hpplus03.cern.ch>
On Sat, 18 Sep 1999, Kragen Sitaker wrote:
> BTW, COBOL really is spelled with all caps. So is FORTRAN. Indeed,
> most languages from the 1950-1970 era were.
Arrrr, back then we didn't have the luxury of lower-case letters, and we
'ad to punch the 'oles in 't cards with our teeth, those of us who still
'ad any, and shovel coal on 't CPU ourselves an' all...
You youngsters 'ave it easy, arrrr...
;-)
------------------------------
Date: 18 Sep 1999 15:47:04 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: CGI in PERL
Message-Id: <a14sgsxarr.fsf@cyclone.jprc.com>
"Alan J. Flavell" <flavell@mail.cern.ch> writes:
> On Sat, 18 Sep 1999, Kragen Sitaker wrote:
>
> > BTW, COBOL really is spelled with all caps. So is FORTRAN. Indeed,
> > most languages from the 1950-1970 era were.
>
> Arrrr, back then we didn't have the luxury of lower-case letters, and we
> 'ad to punch the 'oles in 't cards with our teeth, those of us who still
> 'ad any, and shovel coal on 't CPU ourselves an' all...
>
> You youngsters 'ave it easy, arrrr...
May favorite 'you-whippersnappers-have-it-too-easy' joke
has long been the one along the lines of
'Back in my day, we didn't have no pansy-assed *binary* system.
Why, we had it so hard, we couldn't even afford ones ---
Why, I once wrote an entire operating system with nothing
but zeros! And damn few of them, too, since memory was expensive
back then.'
---Jason
(getting back to snapping whippers, and playing music too loud)
------------------------------
Date: Sat, 18 Sep 1999 16:00:53 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: CONTEST: Range Searching
Message-Id: <pudge-1809991201010001@192.168.0.77>
In article <37E3AFC7.9D9BB420@mediaone.net>, Steven Tolkin
<tolkin@mediaone.net> wrote:
# The contest is fun, produces a lot of creative output, and solves a real
# need (an improved version of the old cgrep (context grep) from the first
# Camel that I still use). But I am concerned that it still seems to
# emphasize the mentality of cleverness (which seems to cause obscurity).
Why is that bad? It is an exercise. Consider it research.
# I suggest that these subjective criteria miss a few that are more
# important:
I disagree.
# * extensibility: How easy is it to add functionality, or add robustness.
This is not an exercise to write complete programs for distribution to the
world to use. Note that Tom did not even ask for documentation, which is
essential for finished code for such distribution. Adding to it is not
important here.
# * reusability: Does the code reuse existing modules? Presumably these
See above.
# What am I belaboring the obvious? Because I believe the Perl community
# must try hard to overcome Perl's reputation of being hard to
# understand.
I don't. I think we shouldn't give a damn. I sure don't. Of course,
many here will disagree with me. But I don't give a damn. :)
# I love Perl; it is the highest level language available for solving
# practical programming problems, is truly portable, etc. But "image"
# *is* important in the real world.
I am in the real world, and it does not matter to me. Are you saying that
I am not in the real world, or that it does matter to me, and I am lying
to myself (or to you)? :)
# Perl is not being used in some
# projects due to its reputation. That is a fact.
It is also a fact with every other language in existence, from C to Python
to AppleScript to Ada. In light of that, I consider your fact
irrelevant. Also, consider that Perl is easily one of the top five
languages in demand these days (most likely in the top three with Java and
C, and apparently gaining in popularity, still), and I just don't see
cause for worry.
Of course, it is your right to worry about such things. But it is my
right to respond. :)
# We should be
# emphasizing Perl's suitability for quickly writing programs
# that are correct and efficient.
We should be emphasizing whatever we feel like emphasizing at the moment
we emphasize it. This newsgroup is not comp.lang.perl.advocacy.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 18 Sep 1999 14:37:22 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Converting time() to real date
Message-Id: <slrn7u7qkf.2an.abigail@alexandra.delanet.com>
Craig Vincent (2bunnyhop@home.com) wrote on MMCCIX September MCMXCIII in
<URL:news:EXNE3.42790$kL1.516589@news2.rdc1.on.home.com>:
() I'm sure this is an incredibly easy function to do...but how do you convert
() the return of a time() function to be the actual corresponding date/time?
Make a large lookup table. Or RTFM.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 18 Sep 1999 19:28:17 GMT
From: davesmall@my-deja.com
Subject: I need a persistent XML server in Perl
Message-Id: <7s0p49$er2$1@nnrp1.deja.com>
Hi all.
Not too sure if this is possible, but it's interesting. It's
also very important to me, so if you could help I'd be v v v
grateful.
I started out writing a server-side ASP that opens a number of
MS XML DOM objects:
$resCat = $Server->CreateObject("Microsoft.XMLDOM");
I create a load of these in a very big Perl ASP. But some
of the XML files are so large that they take a long time to spark
into life, and (I think) they vanish after they've been used
in the one ASP. I'm creating an application that uses a
number of these server objects every time the ASP is called,
and I was wondering if there's any way to make some of them
persistent, so they don't take as long to spark up each time.
Ideally I'd like to start 4 permanent parser objects up on the
server, and have them accessible from ASP scripts as they're
called. Does anyone know if this is possible, and if so, how?
I'm hoping that these 4 server objects will be faster to access
if they don't have to load up *each time* an ASP is called. I
don't mind the overhead of these objects running permanently.
As I said, this is very important to me (to complete my PhD).
All help received with thanks.
Pls email me at daves@scs.nospam.leeds.ac.uk (taking the .nospam out)
TIA
Dave Small
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sat, 18 Sep 1999 19:38:56 +0200
From: Andreas Hagelberg <tlb@algonet.se>
Subject: Re: Perl Challenge
Message-Id: <37E3CE30.57B6D38@algonet.se>
makau@multimania.com wrote:
>
> I challenge you to tell me what this piece of cde does :-)
>
> $text=~s/('|")/${{"'"=>"\\'",'"'=>'\\"'}}{$1}/eg;
>
> I doubt you'll find out easily :)
Looks like it backslashes all single and double-quotes in variable
$text.
Took about 10 seconds to figure it out =)
A better way to do it would be:
$text=~s/(['"])/\\$1/g;
Best regards
/Andreas
--
______________________________________________________________________
ANDREAS HAGELBERG - Student at "Högskolan i Karlskrona/Ronneby"
- IT-consultant at Ericsson Software Technology AB
- Webmaster at AllGlobal (http://allglobal.com)
+ E-mail: tlb@algonet.se or di97aha@student.hk-r.se
+ Web: http://www.algonet.se/~tlb - Visual Systems Check
+ Address: Stenbocksvägen 6, SE-372 37 Ronneby, SWEDEN
+ ICQ UIN: 128240
+ Tel: +46-(0)457-19141 ________________________________________
------------------------------
Date: 18 Sep 1999 15:12:07 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: Perl Challenge
Message-Id: <a16718xce0.fsf@cyclone.jprc.com>
elephant@squirrelgroup.com (elephant) writes:
> makau@multimania.com writes ..
> >I challenge you to tell me what this piece of cde does :-)
> >
> >$text=~s/('|")/${{"'"=>"\\'",'"'=>'\\"'}}{$1}/eg;
>
> btw - the following does the same thing - only three times quicker
>
> $text =~ s/['"]/\\$&/g;
And, as an extra bonus feature, possibly slows down the rest of your
program. Yay $&!
---Jason
------------------------------
Date: Sat, 18 Sep 1999 20:22:36 +0200
From: Andreas Hagelberg <tlb@algonet.se>
Subject: Re: Problem with XS and MakeMaker (Win98)
Message-Id: <37E3D86C.EBC37703@algonet.se>
> For me, it was enough to change libpth and incpath. Before
> building the module, did you run a script called Vcvars32.bat,
> in something like \Vstudio\VC98\Bin? That sets up some
> environment variables VC++ likes.
Hi once again,
Of course I forgot to do that as well... Anyway, when I tried again for
some reason it couldn't find the file PerlCRT.lib, but I just wanted it
to work so I simple copied it into VC5's lib-directory and, behold my
astonishment, it actually work!!!
For some obscure reason the .pm-file wasn't copied into Perl/site/lib
when installing, but I did it manually and it worked perfectly (or at
least it worked!)
Thank ever so much. I don't know for how long I've been trying to do
this and I wouldn't have been able to do it without your help.
Thanks once more!
Have a great day!
/Andreas
--
______________________________________________________________________
ANDREAS HAGELBERG - Student at "Högskolan i Karlskrona/Ronneby"
- IT-consultant at Ericsson Software Technology AB
- Webmaster at AllGlobal (http://allglobal.com)
+ E-mail: tlb@algonet.se or di97aha@student.hk-r.se
+ Web: http://www.algonet.se/~tlb - Visual Systems Check
+ Address: Stenbocksvägen 6, SE-372 37 Ronneby, SWEDEN
+ ICQ UIN: 128240
+ Tel: +46-(0)457-19141 ________________________________________
------------------------------
Date: Sat, 18 Sep 1999 15:29:43 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: regexp odity with (?s-x:)
Message-Id: <37E3E827.63BDDE81@rochester.rr.com>
Rick Delaney wrote:
>
> [posted & mailed]
>
> Bob Walton wrote:
> >
> > lt lindley wrote:
> > >
> > > $pattern_dont = qr{
> > > (
> > > (?s-x:$pattern)
> > > )}xo;
> > >
> >
> > lt, in the pattern above, you have turned off the "x" option with
> > (?s-x for the rest of the pattern.
>
> No, it should not apply for the rest of the pattern. From perlre:
>
> These modifiers are localized inside an enclosing group (if any).
>
> (?:) looks like an enclosing group to me.
>
> This is a bug which has been fixed in devel perls (it is in 5005_61
> anyway).
>
Thanks for the clarification. I guess I just assumed the paren set
in which the "-x" was defined didn't count as an "enclosing" paren set.
It isn't clear to me from perlre that this isn't actually the case,
given the examples with (?i), in which the effect of the (?i)
clearly proceeds until the end of the paren group surrounding the (?i).
In the example case above, the "enclosing group" would be the first
( to its matching ), not the (?s-x to its ), which would mean that
the whitespace following the ) from the (?s-x would be included in
the pattern. Which way does the documentation actually indicate
it should be? Thanks.
> --
> Rick Delaney
> rick.delaney@home.com
--
Bob Walton
------------------------------
Date: Sun, 19 Sep 1999 01:25:40 +0530
From: "Pawan Bhati" <pawanbhati@hotmail.com>
Subject: Search Engine
Message-Id: <7s1v8e$1ks$1@news.vsnl.net.in>
Can anyone please help me build a small search engine for my site in perl.
My website is on Webjump & I have tried many free search scripts but all
fail to work.
Somebady pleaze help me !!
Pawan
pawanbhati@hotmail.com
------------------------------
Date: Sat, 18 Sep 1999 09:59:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: transform / in \/
Message-Id: <MPG.124d64d07bec17dc989f9d@nntp.hpl.hp.com>
In article <37e36c57.0@212.7.64.37> on Sat, 18 Sep 1999 12:44:12 +0200,
Mattia <mattiac@alinet.it> says...
> I need to have a variable (let's say $foo) that points to a directory. I
> need to put this var both in string and in regular expression, so I need
> another var for regular expressions. In regular expression the / char must
> be preceded by the \ char. Let's say:
Why do you think that? '/' is not a regex metacharacter, so it need not
be escaped when interpolated into a regex.
I think you are confused between the standard regex delimiter '/' and
the contents of the interpolated variable. The regex is parsed before
the contents of an interpolated variable are known. Apparent delimiters
within the interpolation are irrelevant.
> #main var
> $foo = "/usr/bin/mattia";
>
> #var for regexp
> $regfoo="\/usr\/bin\/mattia";
Had you printed $regfoo, you would have discovered that it is identical
to $foo, because of the double-quotes. To get backslashes within
double-quotes, you must double them. But, as I said above, none of this
is necessary.
> I would like get the $regfoo variable out of $fo, instead of typing it.
$regfoo = $foo; # :-)
But if you are really concerned about metacharacters in $foo, the
suggestions posted ($regfoo = quotemeta($foo), or /\Q$foo/) are correct.
> I tried with tr///\// but it doesn't work.
> Can anyone suggest a solution?
> (please try it before posting)
Amusing that you should ask people to try their solutions before
posting, because the two responders so far didn't!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 18 Sep 1999 10:37:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: transform / in \/
Message-Id: <MPG.124d6da670ac5497989fa0@nntp.hpl.hp.com>
In article <37E3AC8B.FAE590C3@one.net> on Sat, 18 Sep 1999 11:15:23 -
0400, Joe Kline <jkline@one.net> says...
+ Mattia wrote:
+ >
+ > I need to have a variable (let's say $foo) that points to a
+ > directory. I need to put this var both in string and in regular
+ > expression, so I need another var for regular expressions. In
+ > regular expression the / char must be preceded by the \ char.
+ > Let's say:
+ >
+ > #main var
+ > $foo = "/usr/bin/mattia";
+ >
+ > #var for regexp
+ > $regfoo="\/usr\/bin\/mattia";
+ >
+ > I would like get the $regfoo variable out of $fo, instead of typing
+ > it.
+ >
+ > I tried with tr///\// but it doesn't work.
...
+ Your tr is wildly wrong as well:
+
+ tr///\//
+ ^^^you're transposing nothing to nothing the remaing characters are
+ rather meaningless.
+
+ You'll need:
+
+ tr/\//\\\/;
Did you try that before posting it?
Transliteration replacement not terminated at ...
+ This gives your regex ,"leaning-toothpick syndrome". That is, you need
+ to escape the special characters and choose different delimiters. To
+ make this more readable you might try:
+
+ tr!/!\\/!;
Did you try that before posting it?
All it does is convert every '/' into a backslash. To prepend a
backslash to each '/', you need this:
s!/!\\/!g;
And I did try that before posting it, as a matter of policy.
Sheesh!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 18 Sep 1999 20:37:13 +0200
From: Andreas Hagelberg <tlb@algonet.se>
Subject: Re: transform / in \/
Message-Id: <37E3DBD9.D4EE6B95@algonet.se>
Joe Kline wrote:
>
> tr/\//\\\/;
>
Hmmm... I actually think you missed a / at the end... It's definitely a
good idea to use some other quote-character in this case...
--
______________________________________________________________________
ANDREAS HAGELBERG - Student at "Högskolan i Karlskrona/Ronneby"
- IT-consultant at Ericsson Software Technology AB
- Webmaster at AllGlobal (http://allglobal.com)
+ E-mail: tlb@algonet.se or di97aha@student.hk-r.se
+ Web: http://www.algonet.se/~tlb - Visual Systems Check
+ Address: Stenbocksvägen 6, SE-372 37 Ronneby, SWEDEN
+ ICQ UIN: 128240
+ Tel: +46-(0)457-19141 ________________________________________
------------------------------
Date: Sat, 18 Sep 1999 20:22:38 +0100
From: "Gareth" <geedawgster@hotmail.com>
Subject: Using a period as a delimiter in the split() function
Message-Id: <7s0ota$brr$1@uranium.btinternet.com>
Hi people,
I am currently having a problem with using a period as a delimiter in the
split function. I am attempting to separate segments of a domain name into
elements of an array, using the period(s) in the domain name as the
delimiter. The offending line of code is as follows:
@array=split('.',$domain);
At the moment a null value is passed to the array. If any of you have any
suggestions for a way to get around this I would be very grateful.
TIA,
Gareth
------------------------------
Date: Sat, 18 Sep 1999 15:45:05 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Using a period as a delimiter in the split() function
Message-Id: <37E3EBC1.DF258935@rochester.rr.com>
Gareth wrote:
>
> Hi people,
>
> I am currently having a problem with using a period as a delimiter in the
> split function. I am attempting to separate segments of a domain name into
> elements of an array, using the period(s) in the domain name as the
> delimiter. The offending line of code is as follows:
>
> @array=split('.',$domain);
Gareth, the first argument to split is treated as a regular expression.
A . is a regular expression metacharacter, and thus must be quoted if
it is to be considered a literal period. Try:
@array=split(/\./,$domain);
>
> At the moment a null value is passed to the array. If any of you have any
> suggestions for a way to get around this I would be very grateful.
>
> TIA,
> Gareth
--
Bob Walton
------------------------------
Date: Sat, 18 Sep 1999 12:48:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Using a period as a delimiter in the split() function
Message-Id: <MPG.124d8c68a4c2f3e6989fa1@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7s0ota$brr$1@uranium.btinternet.com> on Sat, 18 Sep 1999
20:22:38 +0100, Gareth <geedawgster@hotmail.com> says...
> I am currently having a problem with using a period as a delimiter in the
> split function. I am attempting to separate segments of a domain name into
> elements of an array, using the period(s) in the domain name as the
> delimiter. The offending line of code is as follows:
>
> @array=split('.',$domain);
>
> At the moment a null value is passed to the array. If any of you have any
> suggestions for a way to get around this I would be very grateful.
Yes. Instead of writing the argument for split() as a string, write it
as what it really is, a regex. Then you will see that '.' is a regex
metacharacter, which needs to be escaped to have its literal meaning.
@array = split(/\./, $domain);
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 18 Sep 1999 19:56:53 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Using a period as a delimiter in the split() function
Message-Id: <37E3EE80.5FE7F445@home.com>
[posted & mailed]
[removed ancient, defunct comp.lang.perl]
Gareth wrote:
>
> The offending line of code is as follows:
>
> @array=split('.',$domain);
Whenever a funtion is giving you results you don't expect you should
ALWAYS look it up in the manual.
perldoc -f split
Once you look this up you will see that the first argument to split is a
pattern, not a string and so special pattern matching characters like
'.' must be escaped (unless you want their special meaning).
perldoc perlre
@array = split /\./, $domain;
Of course, when presented with the code
split ':', $passwd;
it's no wonder people think split works on strings. Please go smack the
person that showed you code like that when
split /:/, $passwd;
would be clearer.
It's getting to the point where I'd like to see
split ''
deprecated in favour of
split m''
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 843
*************************************