[18091] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 251 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 8 21:15:49 2001

Date: Thu, 8 Feb 2001 18:15:24 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981684924-v10-i251@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 8 Feb 2001     Volume: 10 Number: 251

Today's topics:
    Re: splitting a string on the / character <mischief@velma.motion.net>
    Re: splitting a string on the / character <mischief@velma.motion.net>
    Re: splitting a string on the / character (Randal L. Schwartz)
    Re: splitting a string on the / character <flavell@mail.cern.ch>
    Re: splitting a string on the / character (Gary E. Ansok)
    Re: This is driving me nuts and I need a guru (Tad McClellan)
    Re: Using regex to match numbers (not digits)? (Brandon Metcalf)
    Re: Using regex to match numbers (not digits)? <godzilla@stomp.stomp.tokyo>
    Re: Using regex to match numbers (not digits)? (Tad McClellan)
    Re: Using regex to match numbers (not digits)? (Tad McClellan)
    Re: Using regex to match numbers (not digits)? <ccx138@coventry.ac.uk>
    Re: When is an array @f allowed in a string? (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 08 Feb 2001 23:28:33 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: splitting a string on the / character
Message-Id: <t86at11ug87p8b@corp.supernews.com>

Studio 51 <leekembel@hotmail.com> wrote:
> "mgj1" <mgj1@ukc.ac.uk> wrote in message news:3A81C776.1C7C@ukc.ac.uk...
>> obviously will work.
>> Is there a way of splitting on the / character?

> Jesus people, it was a simple question, yet out of 3 posts no one could
> state the obvious simple solution! Did you not know the answer that you need
> to respond with "read the man pages"?

> It's simple: /// should be /\//

> I look forward to the day when you need help with something regarding Perl,
> and some smart ass responds with "read the man pages".

The people who referred this to the man pages have read the man pages.
That's how they know where in the man pages to look, why they themselves
won't ask questions answered by the man pages, and why others will know
their questions are not answered in the man pages so that no one will
have to refer them to the manual.

Ever heard the proverb about giving a fish and teaching someone to
fish? Search Deja. It's a common thread here. While you're at it,
take a look at this post's randomized signature. It fits this
discussion pretty well I think.

Chris

-- 
Christopher E. Stith

Get real!  This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental. -- nobull, clp.misc



------------------------------

Date: Thu, 08 Feb 2001 23:40:24 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: splitting a string on the / character
Message-Id: <t86bj87f02p880@corp.supernews.com>

Studio 51 <leekembel@hotmail.com> wrote:
> "Uri Guttman" <uri@sysarch.com> wrote in message
> news:x7wvb2nhey.fsf@home.sysarch.com...
>> and that is a lousy way to do it. leaning toothpick syndrome. typical of
>> a simple but poor answer.

> It's one character, who gives a damn if it looks like a stack of toothpicks.
> I agree that a mess of slashes looks horrible, but we're talking about ONE
> character. It is not hard to read, it is simple, it does EXACTLY what is
> needed, and I would be surprised if there were an alternate way that takes
> less code or is easier to understand. Besides, if you REALLY don't like
> slashes, use this:

> my @temp = split "\/", $direntry;

You can do the same thing without the escape, since you use different
delimeters.

my @temp = split[/], $direntry;

>> and you should probably read them yourself. someone else posted the
>> better way of using alternate delimiters.

> Better way? Besides the fact that it's more code to type compared to adding
> a simple \, you now have to worry about whether or not your alternate
> delimiter was used in your original string. Besides, there is no "better
> way". If you think that way is "better" then use it. I think my way is
> "better" for me so that's how I'll do it, and how I'll recommend to others
> to do it. Neither one is any better, they both do the same thing.

What with the more code? I just showed you the same thing you did without
the EXTRA character you added unecessarily. Come back from the Cargo Cult,
it's not a good way to live.

>> someone throw this guy a stinking fish. he will never become a fisherman.

> My point is that a lot of "helpful" replies seem to just be "read the man
> pages". That is not helpful, and if that's all you have to add then why
> bother posting it? When people ask simple questions give a simple answer,
> that's all I'm trying to say. It seemed like everyone knew the answer, but
> no one wanted to come out and say "This is how you do it and why".

The man pages do tell you how to do it and why. Telling someone the
man page to read gives them more info about it, too. Of course, if
someone didn't know about TFM, then teaching them that they need to
RTFM and maybe how to RTFM can be of a lot more help to them than
waiting for someone else to answer the question.

Anyone ever notice that the least polite people are the ones with the
least identifying info in their headers? Like a psuedonym and a free
email service that doesn't verify who you are? ;)  Of course you have.
It's been discussed for a long time that anonymity is adouble-edged
sword.

Chris

-- 
Christopher E. Stith

Parking for people we like only. All other vehicles will be vandalized.



------------------------------

Date: 08 Feb 2001 15:53:40 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: splitting a string on the / character
Message-Id: <m11yt8k9yz.fsf@halfdome.holdit.com>

>>>>> "Chris" == Chris Stith <mischief@velma.motion.net> writes:

Chris> Ever heard the proverb about giving a fish and teaching someone to
Chris> fish? Search Deja. It's a common thread here. While you're at it,
Chris> take a look at this post's randomized signature. It fits this
Chris> discussion pretty well I think.

        GIVE A MAN A FIRE, he's warm for an hour
        SET A MAN ON FIRE, he's warm for the rest of his life

Chris> Get real!  This is a discussion group, not a helpdesk. You post
Chris> something, we discuss its implications. If the discussion happens to
Chris> answer a question you've asked, that's incidental. -- nobull, clp.misc

That's great.  I've got to remember that.  Thanks nobull!

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Fri, 9 Feb 2001 01:01:57 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: splitting a string on the / character
Message-Id: <Pine.LNX.4.30.0102090054230.22440-100000@lxplus003.cern.ch>

On Thu, 8 Feb 2001, Studio 51 wrote:

> My point is that a lot of "helpful" replies seem to just be "read the man
> pages". That is not helpful,

If it's there, and the reader has failed to look for it, then
ultimately it _is_ the most helpful answer they could be given, even
if it seems to be lacking in short-term gratification.

Being misled to believe that posting here and waiting around until
someone can be bothered to read the man page over to them is _not_
helpful, neither to questioners nor to would-be helpers.

Now, if their question had cited the man page (or perldoc or whatever)
and indicated difficulty in understanding what it said, then I'm
confident they'd have been most welcome to post here, and I reckon
they'd have got a genuinely helpful answer.

> When people ask simple questions give a simple answer,

You're telling them not to get out of diapers yet?  I would find that
insulting.



------------------------------

Date: 9 Feb 2001 02:02:56 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: splitting a string on the / character
Message-Id: <95vj4g$2ol@gap.cco.caltech.edu>

In article <t86bj87f02p880@corp.supernews.com>,
Chris Stith  <mischief@velma.motion.net> wrote:
>Studio 51 <leekembel@hotmail.com> wrote:
>> my @temp = split "\/", $direntry;
>
>You can do the same thing without the escape, since you use different
>delimeters.
>
>my @temp = split[/], $direntry;

Are you sure about that?

perl -e 'my @temp = split[/], $direntry;'
Search pattern not terminated at -e line 1.

That's one thing that has been bothering me about this whole
discussion -- it's NOT obvious how to use alternate delimiters
with split, so don't be too hard on the OP.

The documentation on split mention no alternate delimiters 
other than ' ' (which is identified as a special case) and 
?? (which force a split into @_).  perlre doesn't cover
delimiters, though it does refer you to perlop.  Buried in
there you can probably come up with the syntax to use:

my @temp = split qr[/], $direntry;

I'm not sure what the "official" solution would be in pre-5.005
Perls.  As it happens, both of these work:

my @temp = split m[/], $direntry;
my @temp = split "/", $direntry;

but I can't find anything in the 5.6.0 documentation that indicates
either of these are guaranteed.

-- Gary Ansok


------------------------------

Date: Thu, 08 Feb 2001 23:51:52 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <slrn9864jb.ckg.tadmc@tadmc26.august.net>

Peter L. Berghold <peter@uboat.berghold.net> wrote:
>On Mon, 5 Feb 2001 17:39:32 -0500, John W <jwgws@hotZEROSPAMmail.com> wrote:
>>run across (of many I've participated in) where "Jeopardy-style" was such an
>
>As much as I admire and respect the denizens of this NG I have noted 
>before that they tend to be a rather sensitive lot. 


Manners are a means of avoiding conflict. The more densely packed
the people, the more opportunity for conflict, so even more
manners are required. Japan is an example of that.

comp.lang.perl.misc is another example. It has very high traffic.
It is not a "typical" newsgroup. It is a high traffic newsgroup.

Manners matter more here than they do elsewhere. It's crowd control.


>Newbies (not that 
>you are one) get kicked rather resoundly here. 


Here we have the Most Classic Example of misunderstanding what
is expected here.

The use of an unqualified "newbie" is a disservice to everyone involved.

I do not at all agree that Perl Newbies are treated harshly here,
and I've been watching here for a good deal of time.

All that is expected is that you make a good faith attempt to
find the answer yourself first. Posting to Usenet is a Last Resort.

Newsgroup Newbies, OTOH, are flamed roundly for breaches of netiquette.
All that is required is that you learn how to play nice on Usenet
if you want to join the fun.


   You don't (or shouldn't anyway) get flamed here for being
   new to Perl. You get flamed here for being new to Usenet.


If you lurk for a few weeks and pay attention, you won't be flamed here.


>Makes me wonder 
>if they aren't trying for a "us 4 no more" news group. 


We have mailing lists for that, and no, you can't join  (heh heh)


>Now.. hopefully being honest in my assesment won't get me killfiled....


No, but crossposting to a newsgroup that has been defunct for over
*five years* gets your article scored down into the invisible range 
anyway, you should avoid doing that.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 8 Feb 2001 23:09:56 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: Using regex to match numbers (not digits)?
Message-Id: <95v904$i2c$1@nrchh45.us.nortel.com>

nukes666@my-deja.com writes:

 > I apologize if this question is elementary, which I suspect it is.
 > However, I am struggling with it and have searched the web and also
 > checked the regex section of Learning Perl.
 > 
 > I need to search a file which has, let's say, 2000 numbers in it
 > between 1 & 2000, each on it's own line. I want to only print numbers
 > 700 through 900 and 1200 through 1500.
 > 
 > I need something which would do something that in my "mind" might look
 > like this:
 > 
 > while (<FILE>) {
 >       print if /[700-900][1200-1500]/;
 >       }

Why use a regexp at all?

while (<FILE>) {
   next unless /^\d+$/;
   print if (($_ >= 700 && $_ <= 900) || ($_ >= 1200 && $_ <= 1500));
}

Brandon


------------------------------

Date: Thu, 08 Feb 2001 15:36:13 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Using regex to match numbers (not digits)?
Message-Id: <3A832D6D.D11FCD36@stomp.stomp.tokyo>

nukes666@my-deja.com wrote:

(snipped obvious language use idioms)


> I need something which would do something that in my 
> "mind" might look like this:
 
> while (<FILE>) {
>       print if /[700-900][1200-1500]/;
>       }
 

My $lo and $hi variables represent user input.

Godzilla!
--

TEST SCRIPT:
------------

#!perl

print "Content-type: text/plain\n\n";

$lo_1 = 761;
$hi_1 = 932;

$lo_2 = 1423;
$hi_2 = 1587;

open (INPUT, "test.txt");

while (<INPUT>)
 {
  if (($_ >= $lo_1) & ($_ <= $hi_1) ||
      ($_ >= $lo_2) & ($_ <= $hi_2))
   { print $_; }
 }

close (INPUT);

exit;


CONTENTS OF TEST.TXT:
---------------------

1499
1586
760
761
933
957
1423
772
932
1422
1587
1600


PRINTED RESULTS:
----------------

1499
1586
761
1423
772
932
1587


------------------------------

Date: Thu, 08 Feb 2001 23:51:53 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using regex to match numbers (not digits)?
Message-Id: <slrn986549.ckg.tadmc@tadmc26.august.net>

nukes666@my-deja.com <nukes666@my-deja.com> wrote:
>
>I apologize if this question is elementary, which I suspect it is.
>However, I am struggling with it and have searched the web and also
>checked the regex section of Learning Perl.


You are not working smart then, as those are 3rd or 4th level
resources to check.

The First Place to check are the Perl FAQs.

The Second Place to check are the other standard Perl docs.

The Third Place to check is a Usenet archive, like the one
you are posting from.

If all of those fail, _then_ you resort to search engines and books.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Thu, 08 Feb 2001 23:51:54 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using regex to match numbers (not digits)?
Message-Id: <slrn9865dk.ckg.tadmc@tadmc26.august.net>

nukes666@my-deja.com <nukes666@my-deja.com> wrote:

> Subject: Using regex to match numbers (not digits)?


regexs work on character strings, not numbers.

Don't use a pattern match, use numeric operators.


>I need to search a file which has, let's say, 2000 numbers in it
>between 1 & 2000, each on it's own line. I want to only print numbers
>700 through 900 and 1200 through 1500.
>
>while (<FILE>) {


   print if ($_ >=  700 and $_ <=  900) or
            ($_ >= 1200 and $_ <= 1500);

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Thu, 08 Feb 2001 23:46:25 +0000
From: JMT <ccx138@coventry.ac.uk>
Subject: Re: Using regex to match numbers (not digits)?
Message-Id: <3A832FD1.5243473F@coventry.ac.uk>



Tad McClellan wrote:

> nukes666@my-deja.com <nukes666@my-deja.com> wrote:
> >
> >I apologize if this question is elementary, which I suspect it is.
> >However, I am struggling with it and have searched the web and also
> >checked the regex section of Learning Perl.
>
> You are not working smart then, as those are 3rd or 4th level
> resources to check.
>
> The First Place to check are the Perl FAQs.
>
> The Second Place to check are the other standard Perl docs.
>
> The Third Place to check is a Usenet archive, like the one
> you are posting from.
>
> If all of those fail, _then_ you resort to search engines and books.
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

I go for books first because you can take them on the bus or to the
toilet with you. ;)
John



------------------------------

Date: Thu, 08 Feb 2001 23:51:53 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: When is an array @f allowed in a string?
Message-Id: <slrn9864o9.ckg.tadmc@tadmc26.august.net>

Philip Hirschhorn <psh@math.mit.edu> wrote:

>Thanks also to those who suggested "use diagnostics" and "use strict";
>I should probably get into that habit.
   ^^^^^^

No "should" about it.

You *must* get into the habit of "use strict".

I have seen people lose jobs for lack of it...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

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 V10 Issue 251
**************************************


home help back first fref pref prev next nref lref last post