[18718] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 886 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 13 03:05:45 2001

Date: Sun, 13 May 2001 00:05:08 -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: <989737507-v10-i886@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 13 May 2001     Volume: 10 Number: 886

Today's topics:
        dbm vs. gdbm <cb8560@cnsvax.albany.edu>
    Re: Existing Script To Add Time <dodger@necrosoft.net>
        exiting a sub <Waarddebon@chello.nl>
    Re: exiting a sub (Logan Shaw)
    Re: Freaky hash <crud_alex@yahoo.com>
        Need Help: Pattern Matching Etc. <phookie@xmission.com>
    Re: Need Help: Pattern Matching Etc. <Jodyman@usa.net>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <andras@mortgagestats.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <andras@mortgagestats.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <pne-news-20010513@newton.digitalspace.net>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <pne-news-20010513@newton.digitalspace.net>
    Re: R: Price for work? (Tad McClellan)
    Re: R: Price for work? <benhopkins@Mindspring.com>
    Re: regex for html links <andras@mortgagestats.com>
    Re: regex for html links <godzilla@stomp.stomp.tokyo>
    Re: Removing blank lines at beginng/end of a file (Charles DeRykus)
        Taint <phookie@xmission.com>
    Re: Taint <gtoomey@usa.net>
    Re: Unicode character (was: Re: If statement question) <pne-news-20010513@newton.digitalspace.net>
        Wierd behavior from a Perl array in a function (Falc2199)
    Re: Wierd behavior from a Perl array in a function <krahnj@acm.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 12 May 2001 23:08:01 -0400
From: "Mr. B" <cb8560@cnsvax.albany.edu>
Subject: dbm vs. gdbm
Message-Id: <tfrul0q7u5vh42@corp.supernews.com>

> I wrote a cgi script that uses a dbm database on a Solaris machine.  I'm
> trying to move that script over to a linux box and was told that linux
uses
> a gdbm database instead.  Does anyone have any info on what changes I
would
> have to make to run this on the linux box.  Also how do I check if I have
> permission to use gdbm
>
> Charles Barnes
>
>




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

Date: Sun, 13 May 2001 01:51:45 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: Existing Script To Add Time
Message-Id: <RMlL6.6714$LJ4.2219328@news1.rdc2.pa.home.com>


"grasshopper" <grasshopper99[no-spam]@hotmail.com> wrote in message
news:bNJK6.22617$Hk4.384649@news1.rdc1.ab.home.com...
> Wondering if anyone has a script (bourne or perl) available which can
> calculate the elapsed time between two given times such as: 08:00 16:30
> which would be an elapsed time of  08:30.

#!/usr/bin/perl
# I could have stored vars in hashes and cut out a lot of reps with fors,
# but I did it this way to make it easy to see what's going on.

my $start = shift;
my $stop = shift;
my ($starth,$startm) = split /:/, $start;
my ($stoph,$stopm) = split /:/, $stop;
$stoph += 24 if $stoph < $starth or ($stoph == $starth and $stopm <
$startm);
$startm += $starth * 60;
$stopm += $stoph * 60;
my $diffm = $stopm - $startm;
my $diffh;
while ($diffm - 60 >= 0) {
    $diffm -= 60;
    $diffh++;}
printf "%02d:%02d\n", $diffh, $diffm;


# On the fly - Not tested, as usual.
--
Dodger
www.dodger.org
www.necrosoft.net
www.gothic-classifieds.com





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

Date: Sun, 13 May 2001 02:03:58 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: exiting a sub
Message-Id: <iYlL6.342220$eL4.36582737@Flipper>


I'm calling a sub at an external .pm file.
This sub must be exited when a variable meets a certain value. Problem
though this is in the middle
of that sub and I don't know how to exit the sub. Is there a command that
stops executing the sub and
continues with the main program ?




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

Date: 12 May 2001 21:15:32 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: exiting a sub
Message-Id: <9dkqo4$cq6$1@ahab.cs.utexas.edu>

In article <iYlL6.342220$eL4.36582737@Flipper>,
Waarddebon <Waarddebon@chello.nl> wrote:
>
>I'm calling a sub at an external .pm file.
>This sub must be exited when a variable meets a certain value. Problem
>though this is in the middle
>of that sub and I don't know how to exit the sub. Is there a command that
>stops executing the sub and
>continues with the main program ?

Like in C, C++, Java, and other languages, you use return:

    sub foo
    {
	# some code here

	if ($whatever)
	{
	    return;
	}

	# more code here
    }

Hope that helps.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Sun, 13 May 2001 11:20:11 +0800
From: "´Z©Ò¤ô@!¡±o^" <crud_alex@yahoo.com>
Subject: Re: Freaky hash
Message-Id: <9dku49$9g$1@taliesin.netcom.net.uk>

what do u mean the particular version of perl?
my perl is activeperl623 and what's the differnece?
"Ciaran McCreesh" <keesh@users.pleaseremovethisbit.sourceforge.net> ¼¶¼g©ó¶l
¥ó news:9djm7j$dop$1@news6.svr.pol.co.uk...
> In article <9djjh6$223$1@taliesin.netcom.net.uk>, "´Z©Ò¤ô@!¡±o^"
> <crud_alex@yahoo.com> wrote:
> > isn't it that the values order of the hashed are arbitary? so how come i
> > got ordered output like onetwothreefourfive......
>
> Because that's the order they happen to hash to with the particular
> version of perl you're using. You can't assume that the order won't
> change...
>
> --
> Ciaran McCreesh
> mail:    keesh@users.sourceforge.net
> web:     http://www.opensourcepan.com/




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

Date: Sat, 12 May 2001 20:48:07 -0600
From: phookie <phookie@xmission.com>
Subject: Need Help: Pattern Matching Etc.
Message-Id: <3AFDF5E5.289C253C@xmission.com>

I have a record which begins with  "<" (excluding quotes) contains
alphanumeric, = & etc. ends with ">" (excluding quotes) has a value
e.g., 1415.23 followed by a similar character string of   "<" (excluding
quotes) contains alphanumeric, = & etc. ends with ">" (excluding
quotes).

how can I check substitute all between the first set of "<" and ">" with
a character string such as "test" (excluding the quotes)

How can I parse the number 1415.23 out of the record (the number is
seldom the same)

how can I check substitute all between the last set of "<" and ">" with
a character string such as "test" (excluding the quotes)

How can I split the record and store that three parts into a array

I know Perl a little, but as this request for help shows, it is very
little.

running Perl 5_004 on Solaris 8
Thanks....




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

Date: Sat, 12 May 2001 23:23:24 -0400
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Need Help: Pattern Matching Etc.
Message-Id: <9dkupa$dt7$1@plonk.apk.net>

"phookie" <phookie@xmission.com> wrote in message
news:3AFDF5E5.289C253C@xmission.com...
> I have a record which begins with  "<" (excluding quotes) contains
> alphanumeric, = & etc. ends with ">" (excluding quotes) has a value
> e.g., 1415.23 followed by a similar character string of   "<" (excluding
> quotes) contains alphanumeric, = & etc. ends with ">" (excluding
> quotes).

Instead of explaining it, show us a few data lines.

> how can I check substitute all between the first set of "<" and ">" with
> a character string such as "test" (excluding the quotes)
>
> How can I parse the number 1415.23 out of the record (the number is
> seldom the same)

is the number alway in the format dddd.dd??

>
> how can I check substitute all between the last set of "<" and ">" with
> a character string such as "test" (excluding the quotes)

Jody





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

Date: Sun, 13 May 2001 00:36:15 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3AFE0F3F.1F1E8AED@mortgagestats.com>



Tad McClellan wrote:

> Andras Malatinszky <andras@mortgagestats.com> wrote:
> >
> >
> >tadmc@augustmail.com wrote:
> >
> >[snip]
> >
> >Tad, I think what you are doing is great and much needed.
>
> This is *not* what _I_ am doing. I am just the guy who is writing it down.
>

That is exactly why I think you deserve appreciation. Most everyone here has ideas
about what a post should be like. You are going one step further and organizing
those ideas into a document. That's a lot of work. Thank you.

>
> It is what _we_ (clpmisc-ers) are doing.
>
> >I hope you don't mind
> >some suggestions.
>
> This is supposed to be (as close as is practicable) the concensus
> of the group's participants, so your are _supposed_ to be
> making suggestions  :-)
>
> >> Outline
> >>    Before posting to comp.lang.perl.misc
> >>       Must
> >
> >Should.
>
> I cannot make the change you suggest.
>
> >You are talking to adults.
>
> Yes. I am trying to succinctly describe what is expected from the
> folks in this newsgroup.
>
> "Should" implies that it is OK to post without checking the docs.
> I do not believe that that is the concensus here, so changing it
> would be misinforming the audience.
>
> >If you start off on a bossy tone
>
> I'm open to suggestions of less offensive wording. Let's have them...
>
> I'm not open to suggestions that change the _meaning_ of what
> is currently there.
>
> Of course, it may be that the group _does_ think that posting without
> checking is OK.
>
> If that proves to be the case, then we^H^Hyou will need to get
> someone else to maintain the guidelines, as it should be maintained
> by someone who participates in the newsgroup.
>
> >you are going to
> >alienate your audience. That's not what we want.
>
> I do not want to alienate the audience, of course.
>
> I also do not want to misinform them.
>
> What change would accomplish both of those objectives?

This must vs. should thing is apparently the most widely misunderstood item in my
comments. Looks like I didn't do a very good job getting my point accross. Sorry.

Let me say explicitly that I am not advocating the idea that it's OK to post
without doing your homework first.

Still, I think you should try to avoid creating the impression that you are bossing
people around  rather than offering them helpful hints "to increase [their] chances
of getting an answer to [their] Perl question." How about simply expanding the
first  sentence in the "Must" along the lines of:

"This section describes things that you *must* do before posting to clpmisc, in
order to maximize your chances of getting meaningful replies to your inquiry and to
avoid getting flamed for being lazy and trying to have others do your work."

Maybe I'm unreasonably sensitive about this. It's just that I always preferred
rules that had a clear reason behind them to rules that I was supposed to obey
because some guy said so.

>
>
> >>        - Check the Perl Frequently Asked Questions (FAQ)
> >
> >You might want to include a URL here.
>
> No, not _here_ (in the Outline, as you have quoted above), in
> the corresponding section below here.

Right, my bad. I still think you might want to include a URL in the corresponding
section of the document.

>
>
> I feel it would be gratuitous to bother with a URL...
>
> >I know that theoretically you should be
> >able to find the FAQ on your own machine,
>
> ... for something with less restricted access (no need to be
> connected to the internet at all).
>
> And there already is a "find the FAQ" regular posting, no need
> to repeat all of that again.
>
> >but in practice this doesn't seem to
> >work for newbies.
>
> Yes, I see your point.
>

Good.

>
> As another followup pointed out, I should make some mention of
> _using_ perldoc. Right now, I mention it, but never "define" it.
>
> I will make some change mentioning that perldoc is for accessing
> the docs.
>
> >>        - Check the other standard Perl docs (*.pod)
> >
> >What is pod?
>
> Once I've told them what perldoc is, then
>
>    perldoc perlpod
>
> heh, heh.
>
> >Again, if I know, I probably don't need this piece of advice. If I
>                                          ^^^^^^^^^^
> >am new to the game, I may not know.
>
> I am unclear which piece you are commenting on. I see 2 "pieces" there:
>
>    1) Check the other standard Perl docs
>
>    2) (*.pod)
>
> If you mean 1) then I disagree.
>
> If you mean 2) then I agree that it could be left out, but I still
> don't want to leave it out.
>

Sorry, I meant neither 1) nor 2). What I mean is this:
I believe that a major segment of the intended audience of this document is
clueless about the documentation that perl distributions normally come with. If you
tell this lot to "check the other standard Perl docs (*.pod)" their response is
likely to be "what's that?" I think you should be a little more verbose here and
explain what these docs are (yes, despite the fact that it is also explained
elsewhere). If you follow my advice, you will increase the chance of people
actually finding and reading/perusing that documentation and you will decrease the
number of  "Does perl have a random function?" type postings -- which, to me at
least, is the main purpose of the document you are developing.

>
> >>     It is *not* required, or even expected, that you actually *read* all of
> >>     Perl's standard docs, only that you spend a few minutes searching them
> >>     before posting.
> >
> >Very good point.
>
> It is, in fact, not (supposed to be) required that you _find_ it in
> the docs, only that you have _looked_ there. The docs are awfully
> big, and (perhaps) not layed out optimally.
>
> If you "missed it", just say "oops" and move on. A more usual
> reaction is some whining about looking at the documentation for
> the software that you are using  :-(
>

Right. Like I said, very good point.

>
> >>     Lurk for a while before posting
>
> I, personally, would like this moved up to the bossy "Must" section,
> as it would render this entire guidelines thing moot. Folks would
> see for themselves how to conduct themselves before actually
> conducting themselves. (and some folks just will not lurk no
> matter what anyway)
>
> But these aren't my guidelines, so it goes down here.
>
> >>     Search a Usenet archive
>
> >>         One such searchable archive is
> >>         <URL:http://www.deja.com/home_ps.shtml>.
> >
> >How 'bout
> >
> >http://groups.google.com/groups?hl=en&lr=&safe=off&group=comp.lang.perl.misc
> >
> >instead?
>
> Let me take this opportunity to repeat what has become a bit of
> a mantra with me of late:
>
>   deja/google sucks!
>
> But I get your point. Yes, I'll need to do something about fixing the URL.
>
> The too-damn-long GETs at google may preclude doing more than just
> http://groups.google.com/ though.
>
> >>     Check Other Resources
> >>         You may want to check in books or on web sites to see if you can
> >>         find the answer to your question.
> >>
> >>         But you need to consider the source of such information, there are a
> >>         lot of very poor Perl books and web sites, and several good ones
> >>         too, of course.
> >
> >The logical question at this point is "like for instance?"
>
> The logical answer at this point (would be, after defining perldoc) is:
>
>    perldoc perlbook
>
>    perldoc -q book
>
> :-)
>

Yes, at the least you should make that reference. But once again, keep in mind that
you are talking to the clueless/lazy, so I believe that inserting a book list
(which maybe just a severely abridged version of perlbook) would increase the
effectiveness of this document.

>
> Examples of "bad" ones seems a waste of space.

I wonder. If you know about specific resources that give bad advice to beginners,
you can do them a big favor by warning them to stay away from those resources. But
I realize that this can be a very contentious issue -- potential courtroom
material, in fact. Also, this kind of blacklist is slightly off-topic for a
"Posting Guidelines" document.

>
>
> (though I would like to see the above perldoc entries become
> more complete.)

Me too.

>
>
> >> Posting to comp.lang.perl.misc
> >>     There can be 200 messages in clpmisc in a single day. Nobody is going to
> >>     read every article. They must decide somehow which articles they are
> >>     going to read, and which they will skip.
> >>
> >>     Your post is in competition with 199 other posts. You need to "win"
> >>     before a person who can help you will even read your question.
> >>
> >>     These sections describe how you can help keep your article from being
> >>     one of the "skipped" ones.
> >
> >Very, very good approach.
>
> The approach I took in developing the outline for the guidelines
> was to examine several scorefiles that I have accumulated, and
> noting what got scored down. Then adding a bullet point
> to help folks avoid hitting those score rules :-)
>
> >> AUTHOR
> >>     Tad McClellan <tadmc@augustmail.com>
> >
> >Good job, Tad!
>
> Err, you mean: "Good job, us!"   :-)
>

No, I mean, good job, Tad! But I have explained that further up.

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



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

Date: Sun, 13 May 2001 00:55:24 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3AFE13BB.7DD21598@mortgagestats.com>



tadmc@augustmail.com wrote:

[snip]

>     The comp.lang.perl.misc (clpmisc) Usenet newsgroup is for the discussion
>     of using the Perl programming language.

Tad,

Somewhere in these guidelines you should explicitly list a few topics that are
not appropriate for this group but people tend to bring up anyway. Two obvious
examples are non-perl-related CGI problems and job postings. You might also
mention topics that are not strictly about using the Perl programming language
but are tolerated anyway, such as conference and seminar announcements.



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

Date: Sun, 13 May 2001 07:04:33 +0200
From: Philip Newton <pne-news-20010513@newton.digitalspace.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <355sftgc6qdjtrih8kf1rcpj2vtmblsu31@4ax.com>

On 12 May 2001 18:18:38 -0500, logan@cs.utexas.edu (Logan Shaw) wrote:

> In article <3afdbd7f@news.microsoft.com>,
> Jürgen Exner <juex@my-deja.com> wrote:
> >E.g. "You may not walk on the lawn" is nothing but a friendly suggestion for
> >many non-native English speakers. You may do so or you may not do so. It's
> >up to you.
> 
> I think you are saying that native English speakers mean "you may
> choose not to walk on the lawn" when they say "you may not walk on the
> lawn".  This would be a way to say that, while one has the freedom to
> make either choice, a certain choice is suggested.
> 
> In reality, the meaning a native English speaker has in mind is closer
> to "it is not the case that you may walk on the lawn".  That is, the
> "not" applies to "may" not to "walk on the lawn".

Hm, looks like different preference rules. We should use parentheses to
disambiguate:

    You (may not) walk on the lawn

vs

   You may (not walk on the lawn)

:)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sun, 13 May 2001 07:06:45 +0200
From: Philip Newton <pne-news-20010513@newton.digitalspace.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <5f5sftcbdc3div3ukkaf7u7ifv0ek5hmqo@4ax.com>

On Sat, 12 May 2001 12:02:05 -0400, tadmc@augustmail.com (Tad McClellan) wrote:

[Perl documentation on Perl books]

> (though I would like to see the above perldoc entries become
> more complete.)

I believe they are slowly becoming more complete, at least in the latest
bleadperl versions. Unfortunately, newbies posting to the newsgroup tend not to
have those :(.

And if there are some books missing -- well, you know the saying: patches
welcome. Get yourself perl@10086.tbz (or whatever is current at the moment) and
patch against that.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sat, 12 May 2001 21:41:03 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: R: Price for work?
Message-Id: <slrn9frphf.6dk.tadmc@tadmc26.august.net>

BUCK NAKED1 <dennis100@webtv.net> wrote:

>I had someone ask me to do some HTML pages for them and told them $25/hr
>and never heard from them again... 


You have the potential to make more income if you can manage to
bid "by the job" instead of hourly. If what they are asking for
is well enough defined, I urge you to consider trying it.


>If I knew perl well, I think
>$50-$60/hr would a fair price. For an "expert" perler, maybe
>$75-$100/hr.


I like this place for looking over rates:

   http://www.realrates.com/


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


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

Date: Sat, 12 May 2001 20:27:08 -0700
From: Ben Hopkins <benhopkins@Mindspring.com>
Subject: Re: R: Price for work?
Message-Id: <3AFDFF0C.4EBE0177@Mindspring.com>

Misanthrope wrote:
> 
> I charge between $75 and $150 us per hour depending on the job.
> 
> "BUCK NAKED1" <dennis100@webtv.net> wrote in message
> news:28090-3AF84B11-10@storefull-243.iap.bryant.webtv.net...
> > I had someone ask me to do some HTML pages for them and told them $25/hr
> > and never heard from them again... though I think that $20-$25/hr is a
> > fair price for HTML. On the contrary, If I knew perl well, I think
> > $50-$60/hr would a fair price. For an "expert" perler, maybe
> > $75-$100/hr.

Since PERL is more fun than HTML, I'd charge more for 
HTML work.


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

Date: Sat, 12 May 2001 21:13:35 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: regex for html links
Message-Id: <3AFDDFBE.9602284@mortgagestats.com>



nobull@mail.com wrote:

> phocjop@hotmail.com (Moriarty) writes:
>
> > I'm trying to make a regex to find web links in a text file and ad <a href
> > stuff around it to link it up.
>
> You are not the first.  RE is not powerful enough to parse HTML
> reliably.  Give up. Use the standard modules.
>
> If you are determined to use an RE then please use a search engine
> on this newsgroup to find lots of imperfect solutions (this Q apears
> about every 2 weeks).

That probably would have been good advice, had the OP in fact wanted to parse
HTML. Alas, he wanted to go the other way. Good thing other posters actually
took the time to read and understand the OP's question and pointed out the
solution to his problem.



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

Date: Sat, 12 May 2001 19:14:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regex for html links
Message-Id: <3AFDEE14.95997205@stomp.stomp.tokyo>

Moriarty wrote:
 
> I'm trying to make a regex to find web links in a text file and ad <a href
> stuff around it to link it up.
 
> I tried: s/http:\/\/{.*?}{[\s|\n]}/<a href=http:\/\/$1>http:\/\/$1$2<\/a>/g
> but that didn't replace anything
 
> Any ideas?

A good idea is to provide clear and concise parameters.
However, few here care about parameters. Nonetheless,
I do care. Please provide parameters with your articles.
Another good idea is to write coherent articles which
are easy to read and understand. Good manners indicate
you should put out some effort when asking others to
put out effort for you, especially freebie effort.

**


You have provided zero parameters. This is most
inappropriate. Those who would respond have no
data sample with which to work and can only
surmise your parameters based on your code.

You code sample indicates your URL addresses
will always be followed by a space or by
a newline and, there is no indication of
spaces within your URL addresses along
with "http" being lowercase, always, 
with your lack of an i switch.

There are alternative methods to use of a
regex which may or may not be more efficient.
I use an index and substr method for this,
which will be very efficient, inherently.
Chances are, more efficient than a regex
but I would need to benchmark to be sure.

Although my code looks complex, written
in Plain English, it is easy to understand
and is quite logical in approach.

$string is simply some sample data input.


$string =~ s/\n/ \n/g;
$string = "$string ";

Those two lines above perform a function of
inserting a space before all newlines and,
tagging a space on the end of your data.
My code relies on indexing for a space
following an URL, unlike your regex which
looks for either a space or a newline.
If spaces are doubled up, this is not a
problem; they won't show in html. You
may use a regex to reduce multiple spaces
to a single space, as needed.


$start = index ($string, "http");

This line simply seeds the do / until
construct with an initial beginning
point, the first found http in $string.


Moving inside the do / until construct,


  $stop = index ($string, " ", $start);

$stop finds a space after an URL; an end point.


  $replace = substr ($string, $start, $stop - $start);
  $replace = "<a href=\"$replace\">$replace</a>";

$replace grabs an URL and, second line, formats
the URL per your code snippet parameters. This
second line is where you can insert whatever
html code you like, such as font tags, color,
linebreaks or even newlines for a neat crisp
appearing document source.


  substr ($string, $start, $stop - $start, $replace);

This performs the actual substitution of your
new format within your data.


  $jump = $start + length ($replace);

$jump is very critical for correct operation.
When your new format is inserted, you have
two instances of "http" where previously one
instance appeared. My code "jumps" over this
new format and continues to search for the
next url, following a previous new format.
The length of your new format is added to
$start to perform this jump over function.


  $start = index ($string, "http", $jump);

Last line in my do / until constuct. This
continues the search for the next URL in
your data. When it does not find anymore
URL addresses, it returns -1 killing the
do / until construct.

My print is actually three long lines.
I have split it up for easier reading
and to prevent browser word wrapping
from messing it up. You will see what
it looks like when you run this code.

Keep in mind, using this line,

  $replace = "<a href=\"$replace\">$replace</a>";

you can change this format to be anything you
want, including adding \n characters for your
plaintext prints to document source. I kept
this line separate specifically for this use.

I will remind you of your not providing any
parameters at all. I have extracted what I 
believe to be your parameters from your code
snippet, solely. If this test script does not
meet your parameters, don't bitch to me about
this. You provided no parameters, I won't listen!

Godzilla!
--


#!perl

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

$string = "IGNORE http://la.znet.com/~callgirl/androids.html
http://la.znet.com/~callgirl/cybe-idx.html IGNORE
http://la.znet.com/~callgirl/rockmusi.html";

$string =~ s/\n/ \n/g;
$string = "$string ";

$start = index ($string, "http");

do
 {
  $stop = index ($string, " ", $start);
  $replace = substr ($string, $start, $stop - $start);
  $replace = "<a href=\"$replace\">$replace</a>";
  substr ($string, $start, $stop - $start, $replace);
  $jump = $start + length ($replace);
  $start = index ($string, "http", $jump);
 }
until ($start == -1);

print $string;


exit;

PRINTED RESULTS (modified):
___________________________

IGNORE

<a href="http://la.znet.com/~callgirl/androids.html">
http://la.znet.com/~callgirl/androids.html
</a> 

<a href="http://la.znet.com/~callgirl/cybe-idx.html">
http://la.znet.com/~callgirl/cybe-idx.html
</a>

IGNORE 

<a href="http://la.znet.com/~callgirl/rockmusi.html">
http://la.znet.com/~callgirl/rockmusi.html
</a>


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

Date: Sun, 13 May 2001 05:21:48 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Removing blank lines at beginng/end of a file
Message-Id: <GD9DKC.5os@news.boeing.com>

In article <GD8wAD.M3C@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <m3d79ffl4h.fsf@mumonkan.sunstarsys.com>,
>Joe Schaefer  <joe+usenet@sunstarsys.com> wrote:
>>>...
>>
>>Anyway, here's what I came up with-
>>
>>  % perl -pi.bak -we 'for($_=<> until /\S/..0 or eof; !/\S/; $_.=<>) { 
>>                      if (eof) { $_=""; last } }' filename 
>>
>
>neat
>here's one inspired by above:
> 
>perl -ni.bak -we 'if(/\S/ or $s){$s .= $_;$l=length $s if //}; 
>                       print substr $s,0,$l if eof' filename 
>

I should mention that mine is hardly better than a slurp
though while the inspired one isn't.

--
Charles DeRykus


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

Date: Sat, 12 May 2001 20:51:59 -0600
From: phookie <phookie@xmission.com>
Subject: Taint
Message-Id: <3AFDF6CE.F6B1CFD@xmission.com>

anyone know where i can get any good information on untainting ENV
variables used in forms which capture info via cgi , web server
forms/cgi scripts...

Thanks...



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

Date: Sun, 13 May 2001 13:50:03 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Taint
Message-Id: <HhnL6.25377$482.121958@newsfeeds.bigpond.com>

"phookie" <phookie@xmission.com> wrote in message
news:3AFDF6CE.F6B1CFD@xmission.com...
> anyone know where i can get any good information on untainting ENV
> variables used in forms which capture info via cgi , web server
> forms/cgi scripts...
>
> Thanks...


http://www.perldoc.com/perl5.6/pod/perlsec.html has lots of information on
working with tainted data.

gtoomey




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

Date: Sun, 13 May 2001 07:15:14 +0200
From: Philip Newton <pne-news-20010513@newton.digitalspace.net>
Subject: Re: Unicode character (was: Re: If statement question)
Message-Id: <026sftg99nofu8qjtgofvuov7i9emi7las@4ax.com>

On Sat, 12 May 2001 14:01:28 +0200, eins@durchnull.de (Rudolf Polzer) wrote:

>                                                            I did not know
> Unicode emulates Wingdings.

This statement makes no sense to me. What is it supposed to mean?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 13 May 2001 02:03:57 GMT
From: falc2199@aol.comNOJUNK (Falc2199)
Subject: Wierd behavior from a Perl array in a function
Message-Id: <20010512220357.02933.00004056@ng-fv1.aol.com>

I have the following function which I use to print the contents of an array
(along with some JavaScript code)....

sub putDataInArr
{
  print $_[0];
  
   @temp = $_[1];
  
  foreach $question (@temp)
  {
    chomp ($question);
    
    print " $question,";
    
  }
  
  print $_[2];
  
}

and call it like this...

putDataInArr('threadQ = [', @Tarray, ']');

But this only prints the first 'threadQ = [' and then the first 2 elements of
the Perl array. It does not print any of the remiaining elements or the closing
']' ( the  last argument).

Can anyone tell me what is wrong?

Thanks in advance for any help,
Jehan


To e-mail, remove NOJUNK


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

Date: Sun, 13 May 2001 05:20:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Wierd behavior from a Perl array in a function
Message-Id: <3AFE19B0.CC04C6D4@acm.org>

Falc2199 wrote:
> 
> I have the following function which I use to print the contents of an array
> (along with some JavaScript code)....
> 
> sub putDataInArr
> {
>   print $_[0];
> 
>    @temp = $_[1];
> 
>   foreach $question (@temp)
>   {
>     chomp ($question);
> 
>     print " $question,";
> 
>   }
> 
>   print $_[2];
> 
> }
> 
> and call it like this...
> 
> putDataInArr('threadQ = [', @Tarray, ']');
> 
> But this only prints the first 'threadQ = [' and then the first 2 elements of
> the Perl array. It does not print any of the remiaining elements or the closing
> ']' ( the  last argument).
> 
> Can anyone tell me what is wrong?

You are only accessing the first three elements of the list passed to
your sub instead of all the elements.
Try this instead:

sub putDataInArr {
    my $start = shift;
    my $end   = pop;

    print "$start ", join( ', ', @_ ), " $end";
    }


John
-- 
use Perl;
program
fulfillment


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

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 886
**************************************


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