[16308] in Perl-Users-Digest
Perl-Users Digest, Issue: 3720 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 10:23:02 2000
Date: Tue, 18 Jul 2000 07:22:52 -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: <963930172-v9-i3720@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3720
Today's topics:
New posters to comp.lang.perl.misc (Greg Bacon)
Re: New to perl, need help (M.J.T. Guy)
NEW: AI::NeuralNetwork - idea, comments (Josiah Bryan)
Re: NEW: AI::NeuralNetwork - idea, comments (Mark Wright)
Newbie - "open for read" w/ perl function (not shell) ()
Re: Newbie - "open for read" w/ perl function (not shel (jason)
Re: Newbie - How can I set up a secure directory that i (David Efflandt)
Newbie - How can I set up a secure directory that is on (Liam)
newbie - like it so far - (Art Heyman)
Re: newbie - like it so far - (David Ness)
Re: newbie - like it so far - (Bart Lateur)
Re: Newbie Globbing Question (Kiel Stirling)
Newbie needs help! (Eric Selin)
Re: Newbie needs help! (Spike)
Re: Newbie needs help! (Jim Mauldin)
Re: Newbie needs help! (Jim Mauldin)
Re: Newbie needs help! (Keith Calvert Ivey)
Re: Newbie needs help! (Jim Mauldin)
Re: Newbie needs help! (Bart Lateur)
Re: Newbie needs help! (jason)
NEWBIE QUESTION !!!!! (Félix Gourdeau)
Re: NEWBIE QUESTION !!!!! (Pavel Hlavnicka)
Re: NEWBIE QUESTION !!!!! (Thoren Johne)
Re: NEWBIE QUESTION !!!!! (multiplexor)
Newbie Question (Allanon69)
newbie: incrementing the value of a byte (Revd. Kermit)
Re: newbie: incrementing the value of a byte (Eric Bohlman)
Re: newbie: incrementing the value of a byte (Makarand Kulkarni)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Jul 2000 14:10:01 GMT
From: gbacon@cs.uah.edu.bbs@openbazaar.net (Greg Bacon)
Subject: New posters to comp.lang.perl.misc
Message-Id: <3bREUP$W8K@openbazaar.net>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 10 Jul 2000 15:14:17 GMT and ending at
17 Jul 2000 23:34:01 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2000 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 275 (46.4% of all posters)
Articles: 561 (27.4% of all articles)
Volume generated: 959.2 kb (27.3% of total volume)
- headers: 453.5 kb (8,829 lines)
- bodies: 494.2 kb (17,598 lines)
- original: 358.0 kb (13,355 lines)
- signatures: 10.9 kb (224 lines)
Original Content Rating: 0.724
Averages
========
Posts per poster: 2.0
median: 1 post
mode: 1 post - 176 posters
s: 3.1 posts
Message size: 1750.8 bytes
- header: 827.7 bytes (15.7 lines)
- body: 902.2 bytes (31.4 lines)
- original: 653.5 bytes (23.8 lines)
- signature: 19.9 bytes (0.4 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
44 70.1 ( 40.5/ 29.6/ 20.1) p3rlc0dr@my-deja.com
14 20.1 ( 12.4/ 7.6/ 3.9) "Ecco" <ecco64@chello.nl>
10 18.3 ( 9.1/ 9.2/ 6.2) "Alex T." <samara_biz@hotmail.com>
9 12.9 ( 8.4/ 4.5/ 3.1) James Mauldin <mauldin@netstorm.net>
9 15.4 ( 8.4/ 6.9/ 3.7) "Cal Henderson" <cal@iamcal.com>
9 18.2 ( 7.5/ 10.6/ 6.1) dejajason@my-deja.com
8 13.3 ( 7.3/ 4.8/ 2.4) Ilmari Karonen <usenet11149@itz.pp.sci.fi>
8 11.9 ( 7.3/ 4.6/ 3.6) Marc Schaefer <marc.schaefer@warwick.ac.uk>
8 10.3 ( 4.2/ 6.1/ 4.7) Alan Page <alandpage@aol.comnospam>
8 16.9 ( 8.0/ 9.0/ 3.8) "Alejandro Kurczyn" <akurczyn@usa.net>
These posters accounted for 6.2% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
70.1 ( 40.5/ 29.6/ 20.1) 44 p3rlc0dr@my-deja.com
24.7 ( 0.7/ 24.0/ 22.4) 1 Michelle Dawkins <surinder@my-deja.com>
20.1 ( 12.4/ 7.6/ 3.9) 14 "Ecco" <ecco64@chello.nl>
18.3 ( 9.1/ 9.2/ 6.2) 10 "Alex T." <samara_biz@hotmail.com>
18.2 ( 7.5/ 10.6/ 6.1) 9 dejajason@my-deja.com
16.9 ( 8.0/ 9.0/ 3.8) 8 "Alejandro Kurczyn" <akurczyn@usa.net>
15.4 ( 8.4/ 6.9/ 3.7) 9 "Cal Henderson" <cal@iamcal.com>
14.0 ( 4.5/ 9.5/ 8.8) 6 joerg@sql.de
13.3 ( 7.3/ 4.8/ 2.4) 8 Ilmari Karonen <usenet11149@itz.pp.sci.fi>
13.2 ( 4.9/ 8.3/ 2.6) 5 Bill Webster <billw@dal.asp.ti.com>
These posters accounted for 6.4% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 2.5 / 2.5) 3 Sean Lavelle <slavelle@concentus-tech.com>
0.984 ( 1.0 / 1.0) 3 Tom <chaptera@hotmail.com>
0.979 ( 2.1 / 2.1) 3 The WebDragon <nospam@nospam.com.invalid>
0.962 ( 2.0 / 2.1) 3 "Simon Armstrong" <Simon.Armstrong@nojunkmail.uk.origin-it.com>
0.923 ( 8.8 / 9.5) 6 joerg@sql.de
0.912 ( 3.7 / 4.1) 3 Haazi2 <haazi2@aol.com>
0.860 ( 1.2 / 1.4) 3 Antony <mcnultya@nortelnetworks.com>
0.848 ( 1.8 / 2.1) 4 tbalazs-this-must-go@netcomuk.co.uk
0.826 ( 2.1 / 2.6) 3 rhys <rhys.tucker@dtn.ntl.com>
0.823 ( 5.3 / 6.5) 6 jason iversen <jasoniversen@my-deja.com>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.486 ( 0.5 / 1.1) 3 Cameron Kennedy <kenned57@pilot.msu.edu>
0.452 ( 1.5 / 3.2) 4 Nobody <nobody@contract.Sun.COM>
0.435 ( 2.7 / 6.2) 5 Russell Smallwood <rsmallwood@mindspring.com>
0.434 ( 3.2 / 7.4) 5 kmhanser@my-deja.com
0.425 ( 3.8 / 9.0) 8 "Alejandro Kurczyn" <akurczyn@usa.net>
0.403 ( 2.2 / 5.4) 4 Pasquale <pdmos23@geocities.com>
0.365 ( 0.7 / 2.0) 3 "Konstantin Stupnik" <skv@iis.nsk.su>
0.340 ( 0.8 / 2.3) 4 John <john99@NOSPAMcanada.com>
0.316 ( 2.6 / 8.3) 5 Bill Webster <billw@dal.asp.ti.com>
0.260 ( 0.9 / 3.6) 3 "John" <john@nomailplease>
54 posters (19%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
52 alt.perl
36 comp.lang.perl
29 comp.lang.perl.modules
10 comp.lang.javascript
8 alt.html
7 alt.perl.sockets
6 alt.html.editors.toppage
5 comp.programming
5 comp.os.linux.misc
5 comp.sys.sun.apps
Top 10 Crossposters
===================
Articles Address
-------- -------
12 Greg Treece <gtreece@vhbtech.com>
8 kmhanser@my-deja.com
6 Tom <chaptera@hotmail.com>
4 Steffen Beyer <sb@muccpu1.muc.sdm.de>
3 NO_SPAM
3 "Jamie" <jamcquay@BOOM.hotmail.com>
3 spike1@freenet.co.uk
3 Alan Coopersmith <alanc@alum.calberkeley.org>
3 "Alex T." <samara_biz@hotmail.com>
3 "Konstantin Stupnik" <skv@iis.nsk.su>
------------------------------
Date: 18 Jul 2000 12:40:05 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: New to perl, need help
Message-Id: <8l1j75$mlg$1@pegasus.csx.cam.ac.uk>
Greg Snow <snow@statsci.com> wrote:
>
>If your going for speed, then the following probably deserves
>consideration:
>
>#!/usr/bin/perl -w
>
>use strict;
>
>use constant PHI => (1+sqrt(5))/2;
>use constant PHIH => 1-(PHI);
>use constant MULT => 1/sqrt(5);
>
>sub fib {
>
> sprintf "%.0f", MULT * ( PHI**$_[0] - PHIH**$_[0]);
>
>}
>
>
>for my $i (0..100) {
>
> print fib($i),"\n";
>
>}
Or if you're really going for speed, note that the second term is
(to within sign) the reciprocal of the first, so you don't need to
calculate the exponential twice.
Or, since it is less than 1/2 (at least for non-negative n), and since
sprintf rounds, you can drop it entirely:
sub fib { sprintf "%.0f", MULT * PHI**$_[0] }
Mike Guy
------------------------------
Date: 18 Jul 2000 05:10:03 GMT
From: jdb@wcoil.com.bbs@openbazaar.net (Josiah Bryan)
Subject: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <3bRc3R$Wbx@openbazaar.net>
Greetings perlfolk,
I have finished a new module designed to simulate simple neural
networks completly with Perl. I am writing to .modules mainly to
see if anyone has any objections to the namespace, or suggestions
for a better namespace.
Synopsis:
use AI;
my $net = new AI::NeuralNetwork($number_of_layers,$neurons_per_layer);
$net->learn(\@input_pattern_to_learn,\@desired_output_pattern);
my $output_array_ref = $net->run(\@new_pattern_to_test_network_with);
Description:
AI::NeuralNetwork allows creation of simple neural networks using only
perl.
You can teach it to associate patterns together, and then present it with a
completly
new pattern and it will attempt to match it with the best possible result
from the
stored patterns in the network.
The network learns via a generlalzation of the Delta rule combined with
a
makeover of Hobbs rule. It uses back-prop. for error-correction, and neurons
assume a single threshold value of 1 or 0.
I am putting the final touches on this version of the network code to get it
ready
for upload to CPAN under cpan author id JBRYAN. Any comments or criticims
about this module from the posting are welcome! :-) I will try to remember
to announce in CPLA when I upload the first public release of this module.
Cheers!
~ josiah
--
--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."
vp@tdcj.com
http://www.josiah.countystart.com/
Tel: 937.316.6256
------------------------------
Date: Tue, 18 Jul 2000 10:52:57 GMT
From: mark@giallo.demon.nul (Mark Wright)
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <39743651.215836@194.159.73.10>
One joyful day (Tue, 18 Jul 2000 01:50:16 -0700 to be precise),
Kiralynne Schilitubi <callgirl@la.znet.com> decided that the Usenet
community would benefit from this remarkable comment:
>(snipped)
<snipped again>
What's the matter, pharmacy out of Prozac?
Give the guy a break, at least he's trying to do something useful,
possibly pushing the limits of Perl.
If you must retort at least do it with some dignity, don't ponce about
like a peacock.
Embarrassed? You bloody well should be.
Mark Wright
- mark@giallo.demon.nl
--
perl -e "print join' '=>map{$_ if s/(\w*)(.)ay/\U$2\E$1/}grep/^\w/=>reverse qw+ackerhay :o( erlpay :o| notheraay :o\ ustjay :o)+"
------------------------------
Date: 18 Jul 2000 03:50:02 GMT
From: santi_fisher@my-deja.com.bbs@openbazaar.net ()
Subject: Newbie - "open for read" w/ perl function (not shell)
Message-Id: <3bRZlQ$Wrv@openbazaar.net>
Hi,
I have a newbie question, and since I didn't find a "perl-newbie"
newsgroup I'm posting it here... sorry if it's way too basic.
I want to fetch a remote web page and extract certain information from
it to send in an email. I plan to use LWP::Simple's "getprint" function
to get the html code.
I thought the most elegant way to pipe getprint's STDOUT in order to
process it would be something like:
open (HTML, "getprint 'http://webserver.com/specific.page.html' |");
but I'm realizing that this kind of "open for reading" only applies to
shell processes and not to perl functions like getprint (am I right
here?).
What would be the best workaround for this ? I want to avoid writing
html code to a local file and then working on it. Should I read html
into an array ? Or is there a way to work directly with an "open for
reading" filehandle like I mentioned ?
TIA for your help. Regards,
Santiago
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 04:20:04 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Newbie - "open for read" w/ perl function (not shell)
Message-Id: <3bRab4$X5j@openbazaar.net>
santi_fisher@my-deja.com wrote ..
>I want to fetch a remote web page and extract certain information from
>it to send in an email. I plan to use LWP::Simple's "getprint" function
>to get the html code.
>
>I thought the most elegant way to pipe getprint's STDOUT in order to
>process it would be something like:
>
>open (HTML, "getprint 'http://webserver.com/specific.page.html' |");
>
>but I'm realizing that this kind of "open for reading" only applies to
>shell processes and not to perl functions like getprint (am I right
>here?).
yes .. you're right there .. of course you could always open the Perl
shell process
open HTML, q[perl -MLWP::Simple -e"getprint q[<URL>]" |] or die $!;
it's a bit messy though - see below
>What would be the best workaround for this ? I want to avoid writing
>html code to a local file and then working on it. Should I read html
>into an array ? Or is there a way to work directly with an "open for
>reading" filehandle like I mentioned ?
while LWP::Simple is very nice .. for something like this you may want
to bypass the simple methods and use LWP::UserAgent directly .. see the
lwpcook documentation
perldoc lwpcook
read the LARGE DOCUMENTS section .. this shows how to handle large
documents by providing a code reference to the Request method on an
LWP::UserAgent object (which is all that getprint does anyway)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 18 Jul 2000 01:40:02 GMT
From: efflandt@xnet.com.bbs@openbazaar.net (David Efflandt)
Subject: Re: Newbie - How can I set up a secure directory that is only accessi
Message-Id: <3bRWT2$Vfg@openbazaar.net>
On Mon, 17 Jul 2000 16:05:55 GMT, Liam <lkenny@fisheries.org> wrote:
>I am tryoing to set up a password protected 'Members Only' section.
>I have written the script and gotten that together. But I am
>uncertain on how to make a directory only accessible through the
>perl-cgi script.
>
>This may not be a definite perl question, it may be an html issue on
>the directory side. I'm not sure. If it isn't, I would appreciate
>any helpful direction you can point me in to resolve this issue.
Usually it is best to use server authentication which is fairly easy to do
with apache, http://www.apache.org/docs/mod/core.html#require
That way it would protect all html and other files in a dir or
subdirectories. For questions see comp.infosystems.www.servers.unix
You might want to grab crypt.txt (crypt.cgi source) from
http://cgi-help.virtualave.net/pub/ or
http://hammer.prohosting.com/~cgi-wiz/pub/
for an example of how to crypt passwords if you don't have shell access.
For IIS4 I found something on http://www.15seconds.com/ like "Authenticate
using ASP without NT" that explains how to use .asp with an included
script instead of .html to auth web pages. But I wouldn't know how to
protect other filetypes there except by serving them up by a protected
script.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: 17 Jul 2000 16:00:02 GMT
From: lkenny@fisheries.org.bbs@openbazaar.net (Liam)
Subject: Newbie - How can I set up a secure directory that is only accessib;le
Message-Id: <3bRHO6$UKJ@openbazaar.net>
I am tryoing to set up a password protected 'Members Only' section.
I have written the script and gotten that together. But I am
uncertain on how to make a directory only accessible through the
perl-cgi script.
This may not be a definite perl question, it may be an html issue on
the directory side. I'm not sure. If it isn't, I would appreciate
any helpful direction you can point me in to resolve this issue.
Thank you in advance for any help you can offer,
Liam
------------------------------
Date: 16 Jul 2000 16:50:01 GMT
From: us004258@mindspring.com.bbs@openbazaar.net (Art Heyman)
Subject: newbie - like it so far -
Message-Id: <3bQTEP$Xjr@openbazaar.net>
2 simple questions -
How do I get a sub string ? I want to grab all text between two known
characters -
And - where do I find the socket add on for network calls ? I've
found a fine site for a lesson on how to do , but no pointer to the add
in code -
It's a wonderful language - CGI/text database programming was a
pleasure - but the substring idea is daunting - Many thanks -
------------------------------
Date: 16 Jul 2000 18:10:06 GMT
From: DNess@Home.Com.bbs@openbazaar.net (David Ness)
Subject: Re: newbie - like it so far -
Message-Id: <3bQVIW$VSF@openbazaar.net>
Art Heyman wrote:
>
> 2 simple questions -
> How do I get a sub string ? I want to grab all text between two known
> characters -
> And - where do I find the socket add on for network calls ? I've
> found a fine site for a lesson on how to do , but no pointer to the add
> in code -
>
> It's a wonderful language - CGI/text database programming was a
> pleasure - but the substring idea is daunting - Many thanks -
Try
perldoc -f substr
------------------------------
Date: 16 Jul 2000 21:20:08 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: newbie - like it so far -
Message-Id: <3bQaG7$UTd@openbazaar.net>
Art Heyman wrote:
> How do I get a sub string ? I want to grab all text between two known
>characters
People usually uses regexes for that. For example, if that character is
a quote, this will work:
$string = 'He said: "Hello, how are you?"';
($quote) = $string =~ /"(.*?)"/;
print $quote;
The question mark makes the regex non-greedy, so the search stops at the
second quote found -- not at the last, which is what you'd get without
it.
--
Bart.
------------------------------
Date: 14 Jul 2000 13:30:03 GMT
From: taboo@doofa.net.bbs@openbazaar.net (Kiel Stirling)
Subject: Re: Newbie Globbing Question
Message-Id: <3bOj4R$XHc@openbazaar.net>
"Mark Fletcher" <MarkOn******@ukgateway.net> wrote:
>Hi,
>
>Please find enclosed a script that I wrote that attempts to use globbing.
>Unfortunately I am having problems with it. The purpose of the script is to
>copy logfiles to a certain location and then cat logfiles of a similar type
>
>The files have a naming format like:
>
>log.processname.0714.05
>
>Where 0714 is the date in mm/dd 05 is the hour that the log is created.
>
>I have two issues with my script.
>
>1) Id like to copy logs ending in .01 to .23, while the glob statement I
>have works, is there any way of simplifying it?
>2) Id like to cat logs of a the same process into one big file. The cat
>statement I have doesnt produce the desired effects. How do I fix it?
>
>Ive consulted the usual sources (Learning Perl, Perl Cookbook, Programming
>Perl) but to no avail ;-(
>
>Any help would be greatly appreciated!
>
>Thanks,
>
>Mark
>
>#!/usr/bin/perl -w
>
>$yest = 712;
>$today = 713;
>$yestlog = '$_$yest';
>$todylog = '$_$today';
>
>@logs = qw(log.lotinq.0);
> # log.pfc.u.0 );
>
>while ( defined ( $filename = glob( "/home/mark/testglob/*" ) ) ) {
> $filename =~ s#.*/##;
> print "I found the file $filename \n";
>}
>print "$yest $today \n";
>
>foreach $_ (@logs) {
> while ( defined ( $filename =
> ### Can this glob statement be tidied up?
> <./$_$yest.0[1-9]* ./$_$yest.1[2-8]* ./$_$yest.2[0-3]* ./$_$today.00>
> ) ) {
> system("cp $filename \/home\/mark");
> ### How do I get the cat statement to work properly?
> system("cat $filename > log");
> $filename =~ s#.*/##;
> print "I found the file $filename \n";
> }
>}
>
Well I think your cat statement maybe needs a >
try system "cat $filename >>log";
#!/usr/bin/perl
opendir DIRHANDLE, "/var/log/";
@files=readdir DIRHANDLE;
foreach $filename (@files)
{
$filename =~ /\./;
system "cat $filename >>log" if $' <= 24;
}
Hope this helps :)
Kiel Stirling
------------------------------
Date: 17 Jul 2000 10:30:02 GMT
From: eric.selin@pp.inet.fi.bbs@openbazaar.net (Eric Selin)
Subject: Newbie needs help!
Message-Id: <3bR8hQ$UeO@openbazaar.net>
I am having trouble with regexps on several lines. My program should grep
info from a textfile like this:
Textfile:
[link to a site] [explanation]
[link to a site] [explanation]
[link to a site] [explanation]
e.g.
www.perl.com A perl site
The program should make a link with the text before the tab.
The idea is that the program greps all lines including e.g. "perl".
Don't ask but I have to do it this way.
I hope you get the idea....
Thanks, Eric Selin
------------------------------
Date: 17 Jul 2000 11:10:02 GMT
From: sp@spike.co.za.bbs@openbazaar.net (Spike)
Subject: Re: Newbie needs help!
Message-Id: <3bR9jS$W1s@openbazaar.net>
Try this:
while(<TEXTFILEHANDLE>) {
if (/^(.+)\t(.+)$/) {
$link = $1 ;
$descr = $2 ;
# now you can do what you like with $link and $descr ...
}
}
Hope this is what you are looking for !
Spike
www.spike.co.za
On Mon, 17 Jul 2000 10:38:06 GMT, "Eric Selin" <eric.selin@pp.inet.fi>
wrote:
>I am having trouble with regexps on several lines. My program should grep
>info from a textfile like this:
>Textfile:
>[link to a site] [explanation]
>[link to a site] [explanation]
>[link to a site] [explanation]
>e.g.
>www.perl.com A perl site
>The program should make a link with the text before the tab.
>The idea is that the program greps all lines including e.g. "perl".
>Don't ask but I have to do it this way.
>
>I hope you get the idea....
>
>Thanks, Eric Selin
>
>
------------------------------
Date: 17 Jul 2000 12:30:03 GMT
From: mauldin@netstorm.net.bbs@openbazaar.net (Jim Mauldin)
Subject: Re: Newbie needs help!
Message-Id: <3bRC1R$VC1@openbazaar.net>
Spike wrote:
> if (/^(.+)\t(.+)$/) {
> $link = $1 ;
> $descr = $2 ;
> }
($link, $descr) = (/\[(.*?)]/g);
will get the contents within the brackets.
-- Jim
------------------------------
Date: 17 Jul 2000 12:40:02 GMT
From: mauldin@netstorm.net.bbs@openbazaar.net (Jim Mauldin)
Subject: Re: Newbie needs help!
Message-Id: <3bRCE2$VqF@openbazaar.net>
Jim Mauldin wrote:
> ($link, $descr) = (/\[(.*?)]/g);
($link, $descr) = /\[(.*?)]/g;
Correction: parens not needed in /\[(.*?)]/g. ($link, $descr) supplies
the list context. (For my own edification, really).
-- Jim
------------------------------
Date: 17 Jul 2000 13:50:02 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: Newbie needs help!
Message-Id: <3bRE5Q$UqP@openbazaar.net>
Jim Mauldin <mauldin@netstorm.net> wrote:
>Jim Mauldin wrote:
>
>> ($link, $descr) = (/\[(.*?)]/g);
>
>($link, $descr) = /\[(.*?)]/g;
>
>Correction: parens not needed in /\[(.*?)]/g. ($link, $descr) supplies
>the list context. (For my own edification, really).
Yes, but then you'll get the brackets included in $link and
$descr.
It's impossible to tell, but my interpretation is that the
brackets in the original post weren't intended as literals.
I think what's needed is just
my($link, $descr) = split /\t/;
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: 17 Jul 2000 14:30:01 GMT
From: mauldin@netstorm.net.bbs@openbazaar.net (Jim Mauldin)
Subject: Re: Newbie needs help!
Message-Id: <3bRF7Q$THW@openbazaar.net>
Keith Calvert Ivey wrote:
> Jim Mauldin <mauldin@netstorm.net> wrote:
>
> >($link, $descr) = /\[(.*?)]/g;
> >
> Yes, but then you'll get the brackets included in $link and
> $descr.
>
Not so. perldoc perlop, and try it on $_ = "[www.perl.org]\t[A Perl site]";
It only returns what's inside the ( ) after matching the whole expression.
> It's impossible to tell, but my interpretation is that the
> brackets in the original post weren't intended as literals.
> I think what's needed is just
>
> my($link, $descr) = split /\t/;
>
This is probably what he meant.
-- Jim
------------------------------
Date: 17 Jul 2000 16:10:02 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: Newbie needs help!
Message-Id: <3bRHaS$XHW@openbazaar.net>
Jim Mauldin wrote:
>> >($link, $descr) = /\[(.*?)]/g;
>> >
>> Yes, but then you'll get the brackets included in $link and
>> $descr.
>>
>
>Not so. perldoc perlop, and try it on $_ = "[www.perl.org]\t[A Perl site]";
>It only returns what's inside the ( ) after matching the whole expression.
Aren't people paying attention, or what?!?!
Keith simple pointed out that if you drop the parents in the above,
($link, $descr) = /\[.*]/g;
*then* the square brackets will be included in the results, just as with
($link, $descr) = /(\[.*])/g;
--
Bart.
------------------------------
Date: 17 Jul 2000 22:00:02 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Newbie needs help!
Message-Id: <3bRQg2$TDX@openbazaar.net>
Bart Lateur wrote ..
>Jim Mauldin wrote:
>
>>> >($link, $descr) = /\[(.*?)]/g;
>>> >
>>> Yes, but then you'll get the brackets included in $link and
>>> $descr.
>>>
>>
>>Not so. perldoc perlop, and try it on $_ = "[www.perl.org]\t[A Perl site]";
>>It only returns what's inside the ( ) after matching the whole expression.
>
>Aren't people paying attention, or what?!?!
>
>Keith simple pointed out that if you drop the parents in the above,
>
> ($link, $descr) = /\[.*]/g;
>
>*then* the square brackets will be included in the results, just as with
>
> ($link, $descr) = /(\[.*])/g;
it is you Bart who's not paying attention .. Jim originally had
($link, $descr) = (/\[(.*?)]/g);
^ ^...these parens were dropped
and he dropped the surrounding parens with the comment that the LHS
provides the list context .. then Keith misunderstood thinking that he
was intending on dropping the capturing parens inside the regex .. which
he never was
sheesh ;)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 16 Jul 2000 14:20:02 GMT
From: felix.gourdeau@videotron.ca.bbs@openbazaar.net (Félix Gourdeau)
Subject: NEWBIE QUESTION !!!!!
Message-Id: <3bQPJ4$UuM@openbazaar.net>
Hello everybody,
i have a little question in perl :
i have this string :
$sun =3D <<'FF';
aaaaa [
bbbbbb
bbb
]
aaaaaa
[
bbbbbbbb
bbb
]
FF
and i want to delete all newline \n characters inside all brackets
[...]. Can someone help me ???
I know there is an easy solution but i tried everything and didn't found
anything.
Thanx
F=E9lix Gourdeau
felix.gourdeau@videotron.ca
------------------------------
Date: 16 Jul 2000 16:30:03 GMT
From: pavel@gingerall.cz.bbs@openbazaar.net (Pavel Hlavnicka)
Subject: Re: NEWBIE QUESTION !!!!!
Message-Id: <3bQSbR$WTZ@openbazaar.net>
Hi,
I don't like this my solution, but is works:
sub replnl {
$a =3D shift;
$a =3D~ s/\n//sg;
$a;
}
$sun =3D~ s/(\[.*?])/ replnl($1) /esg;
Pavel
> Hello everybody,
> =
> i have a little question in perl :
> =
> i have this string :
> =
> $sun =3D <<'FF';
> =
> aaaaa [
> bbbbbb
> bbb
> ]
> aaaaaa
> [
> bbbbbbbb
> bbb
> ]
> =
> FF
> =
> and i want to delete all newline \n characters inside all brackets
> [...]. Can someone help me ???
> I know there is an easy solution but i tried everything and didn't foun=
d
> anything.
> =
> Thanx
> =
> F=E9lix Gourdeau
> felix.gourdeau@videotron.ca
------------------------------
Date: 16 Jul 2000 16:40:01 GMT
From: thoren@southern-division.com.bbs@openbazaar.net (Thoren Johne)
Subject: Re: NEWBIE QUESTION !!!!!
Message-Id: <3bQT21$Ue2@openbazaar.net>
Félix Gourdeau <felix.gourdeau@videotron.ca> wrote in message
news:3971C773.8408B5E4@videotron.ca...
> i have this string :
>
> $sun = <<'FF';
>
> aaaaa [
> bbbbbb
> bbb
> ]
> aaaaaa
> [
> bbbbbbbb
> bbb
> ]
>
> FF
>
> and i want to delete all newline \n characters inside all brackets
> [...]. Can someone help me ???
> I know there is an easy solution but i tried everything and didn't
> found anything.
please use a better (and not all Caps) subject next time - more people might
help you then.
perhaps there is an easier solution, but what i found does what it should.
brackets must come in pairs, nested brackets are not supported:
################################
#!/usr/local/bin/perl -w
use strict;
sub swap {
my $list = shift;
$list =~ s/\n//g;
return '[' . $list . ']';
}
my $sun = <<'FF';
aaaaa [
bbbbbb
bbb
]
aaaaaa
[
bbbbbbbb
bbb
]
FF
$sun =~ s/\[(.+?)\]/swap($1)/esg;
print $sun;
################################
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: 16 Jul 2000 17:00:03 GMT
From: abuse@localhost.bbs@openbazaar.net (multiplexor)
Subject: Re: NEWBIE QUESTION !!!!!
Message-Id: <3bQTR3$Wbz@openbazaar.net>
###
$sun =~ s!
(\[.*?])
!
my $temp = $1; # Including square bracket
$temp =~ s/\n//g; # Remove new line
$temp; # Return it
!esgx; # Needs x modifier
###
Or in more compact form:
###
$sun =~ s!(\[.*?])! my $temp = $1; $temp =~ s/\n//g; $temp; !esg;
###
"Félix Gourdeau" <felix.gourdeau@videotron.ca>wrote
Hello everybody,
i have a little question in perl :
i have this string :
$sun = <<'FF';
aaaaa [
bbbbbb
bbb
]
aaaaaa
[
bbbbbbbb
bbb
]
FF
and i want to delete all newline \n characters inside all brackets
[...]. Can someone help me ???
I know there is an easy solution but i tried everything and didn't found
anything.
Thanx
------------------------------
Date: 18 Jul 2000 02:10:02 GMT
From: allanon.69@no.spam.bigpond.com.bbs@openbazaar.net (Allanon69)
Subject: Newbie Question
Message-Id: <3bRXIR$VO2@openbazaar.net>
Hi,
It's been years since I've done any real coding and now with my new job I've
got to learn Perl. At this point I'm translating a HTML file to ASCII, yeah
I know I could use the HTML parser :) , at this stage this is more to teach
myself how things fit together than to do anything really useful. This is
the first thing I've written in Perl as well.
Anyway the problem is that I'm reading in a file, getting the title and
later searching for the title so I can replace it with some other text. The
line below works fine if the text is one word, eg "FRED". However if it
includes several words with spaces it doesn't match, eg. "FRED AND BARNEY".
I can't seem to find anything to give me a hint as to what to do here...
should I be quoting the $search with qw?
($first_pass = $_) =~
s{(</)(a|h[1..6])((\s.*?)?>)$search.*?(</)(a|h[1..6])(>)}{}isx;
Thanks in advance
--
Danny
------------------------------
Date: 17 Jul 2000 20:00:10 GMT
From: kermit23@raegunne.com.bbs@openbazaar.net (Revd. Kermit)
Subject: newbie: incrementing the value of a byte
Message-Id: <3bRNaE$WHq@openbazaar.net>
I am using read to read in a byte from a file, but if I can't work out how
to increment the value of the byte rather than the ascii representation of
it.
thanks to anyone that responds.
Ian Barber
------------------------------
Date: 17 Jul 2000 21:10:02 GMT
From: ebohlman@netcom.com.bbs@openbazaar.net (Eric Bohlman)
Subject: Re: newbie: incrementing the value of a byte
Message-Id: <3bRPRP$Vy1@openbazaar.net>
Revd. Kermit (kermit23@raegunne.com) wrote:
: I am using read to read in a byte from a file, but if I can't work out how
: to increment the value of the byte rather than the ascii representation of
: it.
The ord() and chr() functions are what you need; read about them in perlfunc.
------------------------------
Date: 17 Jul 2000 21:20:02 GMT
From: makarand_kulkarni@my-deja.com.bbs@openbazaar.net (Makarand Kulkarni)
Subject: Re: newbie: incrementing the value of a byte
Message-Id: <3bRPe3$UPs@openbazaar.net>
> I am using read to read in a byte from a file, but if I can't work out how
> to increment the value of the byte rather than the ascii representation of
> it.
use the "use bytes" pragma if you are using perl 5.6
------------------------------
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 3720
**************************************