[16727] in Perl-Users-Digest
Perl-Users Digest, Issue: 4139 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 26 14:05:28 2000
Date: Sat, 26 Aug 2000 11: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: <967313109-v9-i4139@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 26 Aug 2000 Volume: 9 Number: 4139
Today's topics:
Formatting text (CGI) <bretttdonovan@netscapeonline.co.uk>
Re: Formatting text (CGI) <jhelman@wsb.com>
Re: Help Calling Functions (Greg Bacon)
Re: How to hide running perl window in Activeperl? roh_youngjin@hotmail.com
How to sort with split values? <bfb@att.net>
Re: How to sort with split values? nobull@mail.com
Installation of perl 5.6 on Solaris 2.5.1 <jmwjr@bellsouh.net>
Internet Protocol was(Re: stupid question probably) <timewarp@shentel.net>
Re: Internet Protocol was(Re: stupid question probably) (Andrew Johnson)
Re: Internet Protocol was(Re: stupid question probably) (Marcel Grunauer)
Kill Me! <timewarp@shentel.net>
Re: Kill Me! <jeff@vpservices.com>
Re: Kill Me! <timewarp@shentel.net>
my($a)=shift or warn; <Hans@kolej.mff.cuni.cz>
Re: newbie question about "uninitialized variables" <iltzu@sci.invalid>
Perl error: glob failed (child exited with status 126) migres@my-deja.com
Re: RegEx problem (Keith Calvert Ivey)
Re: RegEx problem <jhelman@wsb.com>
regular expressions and urls. johnvert@my-deja.com
Re: regular expressions and urls. <jhelman@wsb.com>
Re: regular expressions and urls. johnvert@my-deja.com
Re: Replace "XYZ" but not "ABCXYZ"??? - HELP!! (Keith Calvert Ivey)
Re: stupid question probably (BUCK NAKED1)
Re: stupid question probably (Keith Calvert Ivey)
Re: stupid question probably <flavell@mail.cern.ch>
Re: TextAreas and Security (Keith Calvert Ivey)
Re: URLs ending in / <iltzu@sci.invalid>
What is a Linux file type of 'application/x-cgi' ? gevens@my-deja.com
Re: Writing FAQs via PERL <ozette@imaginative-creations.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 26 Aug 2000 15:08:32 +0100
From: "bretttdonovan" <bretttdonovan@netscapeonline.co.uk>
Subject: Formatting text (CGI)
Message-Id: <39a7c383_3@einstien.netscapeonline.co.uk>
Does anyone know how to format text strings so that I can for example have
scripts kicking out arial font instead of default?
Thanks
Brett
------------------------------
Date: Sat, 26 Aug 2000 15:33:16 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Formatting text (CGI)
Message-Id: <39A7E3B2.B1C0DFA8@wsb.com>
bretttdonovan wrote:
>
> Does anyone know how to format text strings so that I can for example have
> scripts kicking out arial font instead of default?
>
> Thanks
>
> Brett
Yes. First, investigate an HTML book to learn about the <FONT> tag.
Then incorporate that into your perl output.
JH
------------------------------
Date: Sat, 26 Aug 2000 17:57:26 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Help Calling Functions
Message-Id: <sqg1863dt9160@corp.supernews.com>
In article <8o6p51$lea$1@nnrp1.deja.com>,
<houseofpain@my-deja.com> wrote:
: I don't think that exactly works because i wan't perl to work its way
: up the inheritence tree looking for the function. I think that trys
: the parent right away. Is that correct?
I'm confused. In your first post, you wrote
> I know you can say &{function} to call that function but how do I
> call a function in a parent class unsing the $this-> pointer.
Are you asking how to set up inheritance? The perlobj manpage gives
the details on that.
If you want to call a method whose name is in $meth, do this
$obj->$meth();
For this particular form, you have to use a scalar (as opposed to an
expression yielding a scalar), and the parentheses are mandatory.
Greg
--
Procrastination is the art of keeping up with yesterday.
-- George Carlin
------------------------------
Date: Sat, 26 Aug 2000 16:13:33 GMT
From: roh_youngjin@hotmail.com
Subject: Re: How to hide running perl window in Activeperl?
Message-Id: <8o8qb1$qcf$1@nnrp1.deja.com>
In article <8nudjq$u2v$1@nnrp1.deja.com>,
frederic_grondin@my-deja.com wrote:
> In article <8nu7v3$mp8$1@nnrp1.deja.com>,
> roh_youngjin@hotmail.com wrote:
> > Hello experts!
> >
> > I am using Activeperl 616.
> > When I launch my perl program from explorer, normally a window pops
> > up. I can minimize the window. But how can I hide the windows?
> > Hiding the window and putting it as Task-icon would be the best
> > solution.
> >
> > Thanks in advance!
> >
>
> Hi,
> Isn't there a wperl binary in your distribution ?
> If so, it's a windowless perl.
>
> If not, other solutions are given in :
> http://jenda.mccann.cz/perl/GUIscripts.html
>
> Regrads, F.Grondin.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Thank you very much for your help.
It is very helpful and I solved the problem almost all.
Is there any easy way to put the perl program in to Task Icon?
Sincerely, Youngjin Roh
roh_youngjin@hotmail.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 26 Aug 2000 15:01:48 GMT
From: Bernie <bfb@att.net>
Subject: How to sort with split values?
Message-Id: <39A7DBCC.76245C35@att.net>
How would I sort each record in a tab delimited file based on one
one of the fields, in this case $col8 in the fragment below? The $col8
field is actually a time value in the format hh:mm:ss, and I need to
display the records sorted by time in decending order, using the write
function.
-Thanks
open(HFILE, $ARGV[0]) || die "Can't open $$ARGV[0]: $!\n";
while (<HFILE>) {
($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8, $col9, $col10) =
split(/\t/, $_);
write;
}
close(HFILE);
format TOP =
.
format RECORD =
@<<<<<<< @<<<<<< @<<<<<<@<<<<<<@<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<
$col4, $col5, $col6, $col7, $col8, $col10
.
------------------------------
Date: 26 Aug 2000 16:40:58 +0100
From: nobull@mail.com
Subject: Re: How to sort with split values?
Message-Id: <u9itsoyqr9.fsf@wcl-l.bham.ac.uk>
Bernie <bfb@att.net> writes:
> How would I sort
The sort function.
> each record in a tab delimited
split /\t/
> file
The "diamond" operator aka readline().
> based on one one of the fields
A subscript.
> in this case $col8 in the fragment below?
You probably should not use several scalar variables called foo1 foo2
foo3 and so on, use an array. Thix is not just Perl advice it's
generic programming advice.
> The $col8 field is actually a time value in the format hh:mm:ss,
> and I need to display the records sorted by time
Is that hh zero-padded? If so then you can simply sort on it as a string.
> in decending order
reverse() the output of the sort or reverse the condition as per the
documentation on the sort() function.
> using the write function.
In that case use the write function.
> while (<HFILE>) {
> ($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8, $col9, $col10) =
> split(/\t/, $_);
> write;
> }
for (sort { $b->[7] cmp $a->[7] } map { [ split /\t/ ] } <HFILE>) {
($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8, $col9,
$col10) = @$_;
write;
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 26 Aug 2000 11:55:31 -0400
From: "Mike Wilson" <jmwjr@bellsouh.net>
Subject: Installation of perl 5.6 on Solaris 2.5.1
Message-Id: <KTRp5.8499$OE4.84353@news1.atl>
I recently installed perl 5.6 using pkgadd on a solaris box. Everything
seemed to go ok, but when i tried
perl I got a message saying cannot find libgdbm.o.2. After some searching I
found a file in perl
called libGDBM.o. I copied it to /usr/lib, renaming it to libgdbm, and perl
now works. I am not to
familar with installing programs on Solaris. Any help in understanding what
was going on would be great.
Thanks, Mike
------------------------------
Date: Sat, 26 Aug 2000 11:35:56 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Internet Protocol was(Re: stupid question probably)
Message-Id: <39A7E3DC.2D793AAB@shentel.net>
WTF???
Who wrote the book on newsgroup posting ethics that demanded that the reply be
posted after the quoted text? My view is if the reply is a single block of text
and refers to the original post as a whole, I see no problem with posting it
before the quoted text. This way it is easier for others to get to the part that
they are interested in reading w/o having to scroll, scroll, scroll down to
where the reply lives if you were to place it after the quoted text as you
people are suggesting we all should do. Besides, if you are following that
particular thread anyway, you already know what the quoted text says, so why the
hell do you people want to have to scroll past it just to get to the reply? Now
the case is different if one is posting multiple small responses that are in
answer to the various parts of the quoted text, then sure, the reply text should
appear after the relevant passage(s) of quoted text. No problem here. What
annoys me, (call me crazy and non conformist) is when a thread gets so long in
terms of quoted text within qouted text within quoted text and the replier is
too lazy to <snip> the quoted text and then posts his reply after that huge long
string of quoted text making me scroll way down to the bottom just to see what
the hell he had to say. I am sorry, but that, my friends is a pain. I do not
enjoy having to scroll past a bunch of garbage like that just to read that some
idiot posted 'LOL' or some equally stupid comment.
Go ahead and flame me. Ignore me. Add me to your kill list. I will continue as I
have done for the past 7 years since I first started reading newsgroups. Until
the Gods of the internet write the ten commandments of internet protocol, I will
remain steadfast.
Albert Dewey
jason wrote:
> Abigail <abigail@foad.org> wrote ..
> >Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDLII September
> >MCMXCIII in <URL:news:slrn8qe4id.5ap.mgjv@martien.heliotrope.home>:
> >-:
> >-: One noticeable thing in this thread: All the posts that are discussing
> >-: the problem are posted in jeopardy style. All the posts that point out
> >-: correctly that this has nothign to do with Perl, and should therefore be
> >-: discussed somewhere else, are formatted correctly, i.e. response after
> >-: quoted text.
> >
------------------------------
Date: Sat, 26 Aug 2000 16:08:25 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Internet Protocol was(Re: stupid question probably)
Message-Id: <ZXRp5.5882$a5.60844@news1.rdc1.mb.home.com>
In article <39A7E3DC.2D793AAB@shentel.net>,
Albert Dewey <timewarp@shentel.net> wrote:
> Who wrote the book on newsgroup posting ethics that demanded that
> the reply be posted after the quoted text? My view is if the
> reply is a single block of text and refers to the original post
> as a whole, I see no problem with posting it before the quoted
> text.
[snip: why he likes jeopardy posts]]
> What annoys me,
[snip ... complaints about other post formats]
> Go ahead and flame me. Ignore me. Add me to your kill list. I
> will continue as I have done for the past 7 years since I first
translation:
I do not care what the majority of this community seems to
prefer, I will barge in and format my posts however I want.
Ok, *plonk*
andrew
--
Andrew L. Johnson http://members.home.net/perl-epwp/
Doing linear scans over an associative array is like
trying to club someone to death with a loaded Uzi.
-- Larry Wall
------------------------------
Date: Sat, 26 Aug 2000 17:20:00 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Internet Protocol was(Re: stupid question probably)
Message-Id: <slrn8qfv0p.i2c.marcel@gandalf.local>
On Sat, 26 Aug 2000 11:35:56 -0400, Albert Dewey <timewarp@shentel.net> wrote:
> Go ahead and flame me. Ignore me. Add me to your kill list.
Thanks, applied.
(I always wanted to write that... :-)
> I will continue as I have done for the past 7 years since I first
> started reading newsgroups. Until the Gods of the internet write the
> ten commandments of internet protocol, I will emain steadfast.
--
Marcel Gr\"unauer - Codewerk plc . . . . . . . . . . . <http://www.codewerk.com>
Perl Consulting, Programming, Training, Code review . . . <marcel@codewerk.com>
mod_perl, XML solutions - email for consultancy availability
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Sat, 26 Aug 2000 13:39:34 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Kill Me!
Message-Id: <39A800D6.83CEA245@shentel.net>
To all the self proclaimed 'News Group Gods' out there -
You are hereby instructed to add me to your 'Kill List' as an annoying
poster for the following reasons :
# I will continue to answer other's posts 'Jeopardy Style'.
# I will answer off topic questions if I really believe that I can help
that person with an answer that is Perl related or even combining Perl
with other solutions.
# I will not flame other people with worthless masturbatory replies.
# I won't criticize people for posting Newbie Questions other than
suggest that they get a good book on Perl to help them in their quest to
learn Perl.
# I won't answer people's questions with snippets of a solution that are
clearly over the poster's head in an effort to razzle dazzle that person
with my sheer brilliance.
# I won't even criticize people such as yourselves when you post after
the quoted content.
At least I made an effort in my prior post regarding the Jeopardy issue
as to why I do this and supported it with logic. Every post I have read
criticizing the jeopardy poster has had no rhyme or reason other than
some really weak argument referring to the 'natural flow of time'. Keep
in mind that the 'natural flow of time' also dictates that lemmings will
run off of cliffs on a regular basis.
----- <insert flaming reply here> -----
Just my 2¢ worth.
Albert Dewey
------------------------------
Date: Sat, 26 Aug 2000 10:45:21 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Kill Me!
Message-Id: <39A80231.9C37F14C@vpservices.com>
Albert Dewey wrote:
>
> # I will not flame other people with worthless masturbatory replies.
What do you call your past six posts?
*plonk*
--
Jeff
------------------------------
Date: Sat, 26 Aug 2000 13:50:52 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Kill Me!
Message-Id: <39A8037C.1565A7DD@shentel.net>
Jeff -
6 Posts? Sorry bub. No such animal.
Albert Dewey
Jeff Zucker wrote:
> Albert Dewey wrote:
> >
> > # I will not flame other people with worthless masturbatory replies.
>
> What do you call your past six posts?
>
> *plonk*
>
> --
> Jeff
------------------------------
Date: Sat, 26 Aug 2000 19:18:29 +0200
From: Hans Ginzel <Hans@kolej.mff.cuni.cz>
Subject: my($a)=shift or warn;
Message-Id: <Pine.OSF.4.10.10008261910090.3848-100000@albert.karlin.mff.cuni.cz>
Hello.
What does the assignmen my($a)=shift return?
Try this:
sub test {
print @_, "\n";
(my($a)=shift) or print "A\n";
(my($b)=shift) and print "B\n";
}
test;
test "X";
test "X", "Y";
The output is:
B
X
B
XY
B
Hans Ginzel
------------------------------
Date: 26 Aug 2000 13:54:53 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <967296869.1314@itz.pp.sci.fi>
In article <39a67fab.3334402@news.earthlink.net>, Jon S. wrote:
>On 23 Aug 2000 21:46:17 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
[snip]
>
>But, to use it, I'd just need to place Carp.pm in my cgi-bin, and call
>it via a...
>use Carp qw(fatalsToBrowser);
>
>Rather than the...
>> use lib '/home/username/perlmod';
>> use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
>...you listed at the end of the message, which applies only if I can
>actually install the entire module locally.
The issue is that the module contains a package named CGI::Carp, so
that's what you should call it in the "use" statement to make the
import mechanism work as intended. And if you write "use CGI::Carp",
it looks for a file named "Carp.pm" in a directory named "CGI".
So what you can do is either:
a) Get your sysadmin to install it somewhere along the default @INC
path list, for example as /usr/lib/perl5/5.005/CGI/Carp.pm
b) Put it in a subdirectory of the current directory of your script,
i.e. ./CGI/Carp.pm, and make sure what you think is the current
really _is_ the current directory when the script is run by the
webserver.
c) Put it anywhere, as long as the path ends in "/CGI/Carp.pm", and
put the beginning of that path in a "use lib" statement.
The order of preference is generally a > c > b.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Sat, 26 Aug 2000 17:16:52 GMT
From: migres@my-deja.com
Subject: Perl error: glob failed (child exited with status 126)
Message-Id: <8o8u1l$uhv$1@nnrp1.deja.com>
Hi Slackware Experts,
I have a problem that I cannot figure out. I purchased not long ago a
Pentium III computer with an 8 GB ATA/66 hard disk. I installed the
ZipSlack distribution which I had in another computer before (a Pentium
II). I tried to run some Perl programs I had written and used many times
in the previous machine and they don't work. They bail out and say: glob
failed (child exited with status 126). The line in question says this:
for $file (<*.f>) {
`cat $file`
}
This works fine in Perl on DOS and it used to work with the other
computer and zipslack. What's going on? the kernel it uses is 2.0.37,
and of course it uses the UMSDOS file system. I am using an "old" kernel
because of the known issues of UMSDOS on the 2.2.x series of kernels.
What's going on? any help will be appreciated.
Regards,
Miguel Restrepo
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 26 Aug 2000 16:10:17 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: RegEx problem
Message-Id: <39b0ea66.51440751@news.newsguy.com>
Jeff Helman <jhelman@wsb.com> wrote:
>Derek Lavine wrote:
>> $text =~ s/$_/$fieldData[$i]/ge;
>>
>> The problem is, that $_ is not getting evaluated so the patern match is
>> being performed against $_ literally rather than what $_ contains. I need
>> to know how to get it to match against the content of $_
[snip]
>$Var = "foobar";
>$_ = foo;
>$Val[1] = "bar";
>$Var =~ s/$_/$Val[1]/ge;
>print "$Var\n";
>
>Prints: "barbar" and a newline under 5.6.0
I suspect that the original poster misunderstands the /e
modifier, which causes the replacement (last) part of the
substitution to be evaluated. It has no effect on the regex
(first) part of the substitution.
And your snippet works the same without it. The /e modifier is
useless (unless doubled) when the replacement expression is a
single scalar variable.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sat, 26 Aug 2000 17:29:19 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: RegEx problem
Message-Id: <39A7FEE5.A78C7FC9@wsb.com>
Keith Calvert Ivey wrote:
>
> Jeff Helman <jhelman@wsb.com> wrote:
> >Derek Lavine wrote:
>
> >> $text =~ s/$_/$fieldData[$i]/ge;
> >>
> >> The problem is, that $_ is not getting evaluated so the patern match is
> >> being performed against $_ literally rather than what $_ contains. I need
> >> to know how to get it to match against the content of $_
>
> [snip]
> >$Var = "foobar";
> >$_ = foo;
> >$Val[1] = "bar";
> >$Var =~ s/$_/$Val[1]/ge;
> >print "$Var\n";
> >
> >Prints: "barbar" and a newline under 5.6.0
>
> I suspect that the original poster misunderstands the /e
> modifier, which causes the replacement (last) part of the
> substitution to be evaluated. It has no effect on the regex
> (first) part of the substitution.
>
> And your snippet works the same without it. The /e modifier is
> useless (unless doubled) when the replacement expression is a
> single scalar variable.
>
> --
> Keith C. Ivey <kcivey@cpcug.org>
> Washington, DC
I realized that the /e was superfluous, but I wanted an indentical regex
to show that the problem wasn't in his snippet. And looking at my code,
I'm rather chagrined that I so obviously avioded "use strict".
JH
------------------------------
Date: Sat, 26 Aug 2000 14:20:48 GMT
From: johnvert@my-deja.com
Subject: regular expressions and urls.
Message-Id: <8o8jnl$jg0$1@nnrp1.deja.com>
Hi, I'm building a simple regexp that could identify URLs. So far all I
could come up with is: m!^http://(.+?)[com net org gov mil]! which is
crappy because it depends on the amount of . url extensions I know of
(i.e. com, org, net), which is constantly changing. Is there a better
way?
Also, I have a question about the (.+?) part. I once asked how to match
the stuff between the " " of <a href="link">, and I was told to replace:
\<a href=\".*\"\>
with:
\<a href=\"(.+?)\">
But I can't figure out why. + matches one character followed by any
number of the following character afterwards, and ? means one or more of
the previous string. So ab+ matches a followed by any number of b
characters, and ab? matches one or more `ab'. The dot obviously means
any character -- I still don't see how that would do the trick and .*
doesn't. I was hoping someone could explain it.
Thanks a lot,
-- john
perl -we '$s="mewbie%oerl%znother%iust";for(reverse
split(/%/,$s)){$s=(++substr($_,0,1)).substr($_,1)."
";$s=~s/aa/a/;print$s}'
==
Suggestions on the above lame attempt are welcomed.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 26 Aug 2000 15:27:52 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: regular expressions and urls.
Message-Id: <39A7E26D.56991B06@wsb.com>
johnvert@my-deja.com wrote:
>
> Hi, I'm building a simple regexp that could identify URLs. So far all I
> could come up with is: m!^http://(.+?)[com net org gov mil]! which is
> crappy because it depends on the amount of . url extensions I know of
> (i.e. com, org, net), which is constantly changing. Is there a better
> way?
Depending on formatting considerations, this should work. Since URLs
aren't supposed to contain whitespace (assuming that the formatting of a
given page didn't break a long one), then this should work (assumes your
entire file is in $FileText):
while ($FileText =~ m!(https?://\S+)!ig) {
push (@URLS, $1);
}
Now all of the URLs are contained as the elements of @URLS. Note the
added s? to match URLs that require SSL. If you want to exclude those,
take it out.
One caveat I can think of (and I'm sure there are others) is that if you
are extracting from paragraphs of normal information and the url is
followed by a period indicating the end of a sentence, the above regex
will match that.
> Also, I have a question about the (.+?) part. I once asked how to match
> the stuff between the " " of <a href="link">, and I was told to replace:
>
> \<a href=\".*\"\>
>
> with:
>
> \<a href=\"(.+?)\">
>
> But I can't figure out why. + matches one character followed by any
> number of the following character afterwards, and ? means one or more of
> the previous string. So ab+ matches a followed by any number of b
> characters, and ab? matches one or more `ab'. The dot obviously means
> any character -- I still don't see how that would do the trick and .*
> doesn't. I was hoping someone could explain it.
You are correct in that by themselves, + matches as many characters as
possible (maximal match) and ? matches zero or one occurance (again
maximal). But the constructs *? +? and ?? are different. These are
minimal matches (i.e., match as few characters as possbile). They still
mean what you think (*? = match zero or more, +? = match one or more, ??
= match zero or one), but instead of matching as many characters as
possible, they match as few as possible.
Thus, your /<a href="(.+?)">/ regex is telling it that following the
opening double-quote, match as few characters as possible before another
double quote is found that is followed by a closing bracket.
> Thanks a lot,
> -- john
> perl -we '$s="mewbie%oerl%znother%iust";for(reverse
> split(/%/,$s)){$s=(++substr($_,0,1)).substr($_,1)."
> ";$s=~s/aa/a/;print$s}'
>
Clever :)
JH
------------------------------
Date: Sat, 26 Aug 2000 16:23:48 GMT
From: johnvert@my-deja.com
Subject: Re: regular expressions and urls.
Message-Id: <8o8qu4$r0k$1@nnrp1.deja.com>
In article <39A7E26D.56991B06@wsb.com>,
Jeff Helman <jhelman@wsb.com> wrote:
> johnvert@my-deja.com wrote:
> >
> > Hi, I'm building a simple regexp that could identify URLs. So far
all I
> > could come up with is: m!^http://(.+?)[com net org gov mil]! which
is
> > crappy because it depends on the amount of . url extensions I know
of
> > (i.e. com, org, net), which is constantly changing. Is there a
better
> > way?
>
> Depending on formatting considerations, this should work. Since URLs
> aren't supposed to contain whitespace (assuming that the formatting of
a
> given page didn't break a long one), then this should work (assumes
your
> entire file is in $FileText):
>
> while ($FileText =~ m!(https?://\S+)!ig) {
> push (@URLS, $1);
> }
>
> Now all of the URLs are contained as the elements of @URLS. Note the
> added s? to match URLs that require SSL. If you want to exclude
those,
> take it out.
>
> One caveat I can think of (and I'm sure there are others) is that if
you
> are extracting from paragraphs of normal information and the url is
> followed by a period indicating the end of a sentence, the above regex
> will match that.
>
> > Also, I have a question about the (.+?) part. I once asked how to
match
> > the stuff between the " " of <a href="link">, and I was told to
replace:
> >
> > \<a href=\".*\"\>
> >
> > with:
> >
> > \<a href=\"(.+?)\">
> >
> > But I can't figure out why. + matches one character followed by any
> > number of the following character afterwards, and ? means one or
more of
> > the previous string. So ab+ matches a followed by any number of b
> > characters, and ab? matches one or more `ab'. The dot obviously
means
> > any character -- I still don't see how that would do the trick and
.*
> > doesn't. I was hoping someone could explain it.
>
> You are correct in that by themselves, + matches as many characters as
> possible (maximal match) and ? matches zero or one occurance (again
> maximal). But the constructs *? +? and ?? are different. These are
> minimal matches (i.e., match as few characters as possbile). They
still
> mean what you think (*? = match zero or more, +? = match one or more,
??
> = match zero or one), but instead of matching as many characters as
> possible, they match as few as possible.
>
> Thus, your /<a href="(.+?)">/ regex is telling it that following the
> opening double-quote, match as few characters as possible before
another
> double quote is found that is followed by a closing bracket.
>
> > Thanks a lot,
> > -- john
> > perl -we '$s="mewbie%oerl%znother%iust";for(reverse
> > split(/%/,$s)){$s=(++substr($_,0,1)).substr($_,1)."
> > ";$s=~s/aa/a/;print$s}'
> >
> Clever :)
> JH
Thank you very much for your extremely helpful response!
-- john
sorry, I can't come up with another one of those JAPNs.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 26 Aug 2000 15:58:10 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Replace "XYZ" but not "ABCXYZ"??? - HELP!!
Message-Id: <39ace0d9.48995525@news.newsguy.com>
jason <elephant@squirrelgroup.com> wrote:
>Keith Calvert Ivey <kcivey@cpcug.org> wrote ..
>>One possibility is
>>
>> s{(\w+@\w+\.\S+)}
>> { substr($1, 0, 3) eq 'XYZ' ?
>> $1 :
>> 'WHATEVERTEXT' }e;
>
>eww .. that's a smelly WTDI .. even if you're trying to conform to some
>sort of "everything must be done within a s///" then you've already got
>everything in the regex in $_ (or something else assuming the =~
>operator somewhere) so why capture it to test it ?
>
>I don't know why everyone would try to cram everything into the regex
>when Perl maps so perfectly onto the pseudo-code of
>
> make the substitution unless it begins with 'XYZ'
>
>with
>
> s/\w+@\w+\.\S+/WHATEVERTEXT/ unless substr( $_, 0, 3) eq 'XYZ';
Sorry to offend you. No doubt Abigail would have done it more
elegantly.
But we're solving different problems. I was assuming that the
original poster was operating on a long string of text, and the
e-mail address was just *part* of $_ -- in fact, I intended to
add a /g modifier. You're assuming that $_ *is* the (possible)
e-mail address, in which case I think you should anchor your
regex at the start. With your assumption, I'd probably have
done this:
s/^(?!XYZ)\w+@\w+\.\S+\z/WHATEVERTEXT/;
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sat, 26 Aug 2000 10:56:28 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: stupid question probably
Message-Id: <12065-39A7E8AC-23@storefull-244.iap.bryant.webtv.net>
Sometimes instead of using server-side includes or .shtml, you can
insert a perl script just by using the HTML embed tag, such as: <embed
src="myscript.pl". (Note: make sure your bgcolor on the webpage matches
the bgcolor on your script page).
However, the method of calling out the webpage from within the perl
script(as suggested in another post) is probably better.
I hope this helps you.
Kindest Regards,
Dennis
------------------------------
Date: Sat, 26 Aug 2000 15:58:14 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: stupid question probably
Message-Id: <39ade3ca.49747894@news.newsguy.com>
Albert Dewey <timewarp@shentel.net> wrote:
> $Time = scalar localtime(time);
And if you don't enjoy typing for typing's sake, you can express
that as
$Time = localtime;
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sat, 26 Aug 2000 19:34:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: stupid question probably
Message-Id: <Pine.GHP.4.21.0008261921480.11020-100000@hpplus03.cern.ch>
On Sat, 26 Aug 2000, BUCK NAKED1 wrote:
> Sometimes instead of using server-side includes or .shtml, you can
> insert a perl script just by using the HTML embed tag,
Standard HTML has no such tag, and this has nothing to do with Perl.
Another good reason for people to distrust off-topic advice.
If you genuinely believe you have a good answer to the off-topic
question, you should at least have the self-confidence to cross-post
your answer to the appropriate group, so that it can be reviewed by
that group's regulars (and set followups to that group, of course).
[However, any reasonable usenaut who has been watching the current
lynch-party in progress on c.i.w.a.h will presumably understand my
reluctance to get involved in anything over there just now.]
f'ups set.
--
A patent application requires an implementation,
which is impossible due to the lack of sufficently
dense material to make one that would work.
- Glenn Randers-Pehrson discussing specification for a clue-stick
------------------------------
Date: Sat, 26 Aug 2000 15:16:10 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: TextAreas and Security
Message-Id: <39abddc5.48206559@news.newsguy.com>
"Chris Stith" <mischief@motion.thispartfake.net> wrote:
>Or, if you want something procedural that checks the
>size of an individual textarea for when (if) you do a small
>script not worth the overhead of a module, you could try this:
>
>if( len( $FORM{datafromtextarea} ) > $size_limit ) {
> print_error_message_page();
>}
This doesn't really help. By the time you've gotten the data
into %FORM, the denial-of-service attack the original poster was
worried about has already occurred. Your disk space filled up
during the data-parsing step, before you ever got to this point
in the program. You have to check while you're getting the form
data in the first place, as CGI.pm does.
>assuming, of course, that the variables are proper for your
>particular implementation.
>
>I'm aware this probably isn't what the OP particularly
>needed at the moment, since he already thanked the
>previous poster. It does give an option for those who do
>'dirty little tools'.
Dirty little tools can get you into trouble, because you
overlook important things. That's why people recommend using
established tools that have been extensively tested and
reviewed.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 26 Aug 2000 14:25:01 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: URLs ending in /
Message-Id: <967299632.9340@itz.pp.sci.fi>
In article <8o5bsc$vca$1@nnrp1.deja.com>, cbdeja@my-deja.com wrote:
>The only difference I could guess at is that the first could concievably
>be referencing a file, whereas the second implies that it MUST be a
>directory.
Your guess, unfortunately, is wrong:
http://www.sci.fi/~iltzu/cgi-bin/fnord/foo
http://www.sci.fi/~iltzu/cgi-bin/fnord/foo/
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Sat, 26 Aug 2000 14:03:09 GMT
From: gevens@my-deja.com
Subject: What is a Linux file type of 'application/x-cgi' ?
Message-Id: <8o8imm$i9t$1@nnrp1.deja.com>
Hi all,
I have been given a Linux server with a web site to pick through.
The home/website/cgi directory contains what I hoped to be cgi scripts
in a plain text format, but instead contains cgi scripts in a format
that almost look like they have been compiled in some way.
1) Is it possible to compile a perl script ?
2) If so does this mean you don't need the perl interpreter on the
server ie. usr/bin/perl ?
3) Is there a way I can revert them to plain text ?
Forgive me please if I have somehow missed the point of something
somewhere !
Any help is most appreciated.
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 26 Aug 2000 11:30:04 -0400
From: "Mr. Ozette Brown" <ozette@imaginative-creations.com>
To: Roger Daniel Pease <rpease@mets.micro.ti.com>
Subject: Re: Writing FAQs via PERL
Message-Id: <39A7E27C.F884C988@imaginative-creations.com>
Roger,
Check out something called the "FAQ-O-Matic". You should be able to find it at CPAN.
Cheers,
Ozette
Roger Daniel Pease wrote:
> I think I once heard that there was a module or methodology for writing FAQ's in PERL.
> The idea was that you enter the question and answer (for some topic often
> completely unrelated to PERL) only once and the results would be printable in text,
> HTML, or whatever other format you choose to output. Unfortunately every time I look
> for 'PERL FAQ' in search engines/etc I get information about the PERL faq's.
>
> I guess it'd be as simple as a list or assoc. array, but wondered if there was
> some 'cooked' methodology so I wouldn't end up just doing it over again.
>
> Any pointers are appreciated.
>
> Thanks,
>
> Roger
> --
--
Mr. Ozette J. Brown <President>
Imaginative Creations <webmaster@imaginative-creations.com>
A Website Development and Consulting Company.
http://www.imaginative-creations.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 4139
**************************************