[12636] in Perl-Users-Digest
Perl-Users Digest, Issue: 45 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 06:48:43 1999
Date: Wed, 7 Jul 1999 03:37:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Jul 1999 Volume: 9 Number: 45
Today's topics:
Q: Get free disk space? (muvol)
Re: Q: Get free disk space? (Andrew Allen)
Re: Q: Get free disk space? (Alan Barclay)
Re: Q: Get free disk space? <swiftkid@bigfoot.com>
Question for regex gurus. <JFedor@datacom-css.com>
Re: Question for regex gurus. (elephant)
Re: Question for regex gurus. <JFedor@datacom-css.com>
Re: Question for regex gurus. <JFedor@datacom-css.com>
Re: Question for regex gurus. (Abigail)
Re: Question for regex gurus. (I.J. Garlick)
Reading a flat file backwards billy_collins@my-deja.com
Re: Reading a flat file backwards (Abigail)
Re: Reading a flat file backwards <uri@sysarch.com>
Re: reading log files (Abigail)
Receiving binaries <breville@mpce.mq.edu.au>
Re: Receiving binaries <swiftkid@bigfoot.com>
Re: regex to match nested paranthesis (Damian Conway)
Re: regexp riddle <mike@crusaders.no>
Re: regexp riddle (Bart Lateur)
Re: regexp riddle (Ronald J Kimball)
Re: regexp riddle (Sean McAfee)
Re: Regexpr tool? <monty@primenet.com>
Re: Regexpr tool? <mike@crusaders.no>
Re: Regexpr tool? (Ilya Zakharevich)
regexprs question <mark.stellaard@knoware.nl>
Re: regexprs question <swiftkid@bigfoot.com>
Re: regexprs question (Marcel Grunauer)
Re: Reorder bytes within 90-byte records in a file with <ejohnso9@earthlink.net>
repeating variables of the same name?? <bobby@alpstreet.net>
Retrieving NT Services <gio98dr@yahoo.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 03 Jul 1999 13:59:45 -0600
From: muvol.remove-this@aol.dot.com (muvol)
Subject: Q: Get free disk space?
Message-Id: <muvol.remove-this-0307991359450001@98caebb5.ipt.aol.com>
Hi,
I would like to find out how much free disk space is available on a
certain drive before beginning a large, critical set of file transfers.
I'm working in ActivePerl on WinNT 4, but I would prefer to kepp my code
cross-platform compatable. This seems like a simple question, but I
cannot find the answer anywhere. (And, yes, I have searched "Programming
Perl", the Perl docs, and at Deja.)
If no one has a better answer, I'll just parse the results of system("DIR")
Thanks,
Mike
---
------------------------------
Date: 3 Jul 1999 19:34:46 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Q: Get free disk space?
Message-Id: <7llokm$a41$7@fcnews.fc.hp.com>
muvol (muvol.remove-this@aol.dot.com) wrote:
: Hi,
: I would like to find out how much free disk space is available on a
: certain drive before beginning a large, critical set of file transfers.
: I'm working in ActivePerl on WinNT 4, but I would prefer to kepp my code
: cross-platform compatable. This seems like a simple question, but I
: cannot find the answer anywhere. (And, yes, I have searched "Programming
: Perl", the Perl docs, and at Deja.)
: If no one has a better answer, I'll just parse the results of system("DIR")
Perhaps when you get it working, you could add it to the CPAN module
Filesys::DiskSpace
(which appears to be unix-centric) so that others can use it. Perhaps
a Mac-specific version could also be written.
Andrew
------------------------------
Date: 4 Jul 1999 02:45:30 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Q: Get free disk space?
Message-Id: <931056316.352833@elaine.drink.com>
In article <7llokm$a41$7@fcnews.fc.hp.com>, Andrew Allen <ada@fc.hp.com> wrote:
>Perhaps when you get it working, you could add it to the CPAN module
>
> Filesys::DiskSpace
>
>(which appears to be unix-centric) so that others can use it. Perhaps
It's Unix centric mainly cause that's what I use, and have received
details on. If anyone has Mac or other OS information, I'll gladly
add it to the module.
------------------------------
Date: Sun, 4 Jul 1999 11:12:59 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Q: Get free disk space?
Message-Id: <7lo1an$asd2@news.cyber.net.pk>
> > Filesys::DiskSpace
> >
> >(which appears to be unix-centric) so that others can use it. Perhaps
>
> It's Unix centric mainly cause that's what I use, and have received
> details on. If anyone has Mac or other OS information, I'll gladly
> add it to the module.
How about this short little funny proggy:
print &FreeSpaceDos ( "c:" );
sub FreeSpaceDos
{
return if $^O ne 'MSWin32';
my $path = shift;
`dir /w $path` =~ /([\d,]+?) bytes free$/;
my $space = $1;
$space =~ tr/,//d;
$space;
}
------------------------------
Date: Mon, 5 Jul 1999 18:45:02 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Question for regex gurus.
Message-Id: <7lralu$h3$1@plonk.apk.net>
As a million other people, I'm parsing html. Everything is in $html.
I can easily eliminate all tags using:
$html =~ s/<[^>]+>//g;
works great... but.. before I do this, I also want to extract all ALT tags
also.
My dilema:
using :
$html =~ s/<IMG.+(ALT='|ALT=")//ig;
I eliminated the <IMG SRC="/gif/test.gif" ALT=" from <IMG
SRC="/gif/test.gif" ALT="Test Gif"> but am left with: Test Gif">
I then use:
$html =~ s/("|').?>/ /g;
This eliminates all of the "> or '> in the file. Problem, say there is a
tag that says :
<TR ALIGN="TOP">
Some crazy text here
<TD ALIGN="LEFT" WIDTH=75%>
the last regex will make it
<TR ALIGN="TOP
Some crazy text here
<TD ALIGN="LEFT" WIDTH=75%>
and the last regex: $html =~ s/<[^>]+>//g;
it will eliminate "Some crazy text here" also.
I've tried to clean up the mess created by ( $html =~ s/("|').?>/ /g; ) by
trying to focus it on "> or '> only if there isn't a < before it but this is
where I come up short. Any ideas?
$html =~ s/>[^<]("|').?>//g; Does not work.
I'm trying to replace any "?> or '?> where it is after a > without a < in
front of it.
Jody
------------------------------
Date: Tue, 6 Jul 1999 09:29:31 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Question for regex gurus.
Message-Id: <MPG.11ebeaea9a78fd5989afe@news-server>
Jody Fedor writes ..
>$html =~ s/<IMG.+(ALT='|ALT=")//ig;
>
>I eliminated the <IMG SRC="/gif/test.gif" ALT=" from <IMG
>SRC="/gif/test.gif" ALT="Test Gif"> but am left with: Test Gif">
ignoring the dangers in stripping HTML this way .. here's the regex
you're looking for
#--begin
$html =~ s/<img.+alt=['"](.+?)['"]>/\1/ig;
#--end
NB: this makes a heap of assumptions .. but no more than you're already
making
and just quietly .. you should learn about how enclosing things in
parentheses in a search populates variables that you can use both within
the substitution and afterwards as \1 and $1 respectively - covered in
perlop (and every beginners book on perl) .. it's one of perl's pearls
--
jason - remove all hyphens for email reply -
------------------------------
Date: Mon, 5 Jul 1999 20:08:58 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Question for regex gurus.
Message-Id: <7lrfj8$49j$1@plonk.apk.net>
What's in $html:
<TD BGCOLOR=#FFFFFF ROWSPAN=1 VALIGN=TOP>
<IMG SRC='/gif/100_Texas Instruments.gif' WIDTH=100 HEIGHT=15 BORDER=0
ALT='Geniuine Texas Instruments from DATACOM'></TD>
after $html =~ s/<IMG.+(ALT='|ALT=")//ig;
<TD BGCOLOR=#FFFFFF ROWSPAN=1 VALIGN=TOP>
Texas Instruments from DATACOM'></TD>
with $html =~ s/>[^<]+>/>/;
my match is: >Texas Instruments from DATACOM'>
$html is:
<TD BGCOLOR=#FFFFFF ROWSPAN=1 VALIGN=TOP></TD>
of course what I want is:
<TD BGCOLOR=#FFFFFF ROWSPAN=1 VALIGN=TOP>
Texas Instruments from DATACOM</TD>
I can get a match but need to leave what is matched rather than destroy it!
LOL.
Jody
------------------------------
Date: Mon, 5 Jul 1999 20:15:08 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Question for regex gurus.
Message-Id: <7lrfup$4ef$1@plonk.apk.net>
elephant wrote in message ...
>and just quietly .. you should learn about how enclosing things in
>parentheses in a search populates variables that you can use both within
>the substitution and afterwards as \1 and $1 respectively - covered in
>perlop (and every beginners book on perl) .. it's one of perl's pearls
>
>--
> jason - remove all hyphens for email reply -
Thanks for the pointer Jason, that is what I was looking for, the ().
Believe me, I've got and read them all, The Camel, the Ram, the Panther, the
Owls. I guess it is just knowing what I'm looking for and having someone
rubbing your nose in it. Thanks and I'll study more in this area.
Jody
PS - I was just reading about these today \1 \2 \3 etc. but didn't know how
to apply that knowledge, You've shown me the light... a thousand blessings
on you. :-)
------------------------------
Date: 5 Jul 1999 19:08:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Question for regex gurus.
Message-Id: <slrn7o2i70.h6v.abigail@alexandra.delanet.com>
Jody Fedor (JFedor@datacom-css.com) wrote on MMCXXXIV September MCMXCIII
in <URL:news:7lralu$h3$1@plonk.apk.net>:
`` As a million other people, I'm parsing html. Everything is in $html.
`` I can easily eliminate all tags using:
``
`` $html =~ s/<[^>]+>//g;
No you can't. And 999.999 of the 1.000.000 people can tell you why.
Because *they* have read the FAQ.
`` works great... but.. before I do this, I also want to extract all ALT tags
`` also.
There is no such thing as an ALT tag. However, let's us for a moment assume
there is such a thing as an ALT tag. A few lines above, you claimed to have
a regex that finds all tags. Why wouldn't it find an ALT tag?
`` My dilema:
``
`` using :
``
`` $html =~ s/<IMG.+(ALT='|ALT=")//ig;
Oh. You mean an ALT *attribute*!
`` I eliminated the <IMG SRC="/gif/test.gif" ALT=" from <IMG
`` SRC="/gif/test.gif" ALT="Test Gif"> but am left with: Test Gif">
``
`` [ A see of problems deleted ]
``
`` I've tried to clean up the mess created by ( $html =~ s/("|').?>/ /g; ) by
`` trying to focus it on "> or '> only if there isn't a < before it but this is
`` where I come up short. Any ideas?
I can give hundreds of examples where your utterly simplistic approach will
fail. But I have a suggestion for you. It's called reading. Try reading the
FAQ. Slowly. It will bring enlightment.
`` $html =~ s/>[^<]("|').?>//g; Does not work.
Nope. It doesn't. I've yet to see any single regex on clp.misc that parses
HTML correctly. And I've read this group from the beginning. Give reading
the FAQ a try. It might actually work!
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 6 Jul 1999 07:53:55 GMT
From: ijg@connect.org.uk (I.J. Garlick)
Subject: Re: Question for regex gurus.
Message-Id: <FEFv9v.It4@csc.liv.ac.uk>
In article <7lrfup$4ef$1@plonk.apk.net>,
"Jody Fedor" <JFedor@datacom-css.com> writes:
>
> elephant wrote in message ...
>>and just quietly .. you should learn about how enclosing things in
>>parentheses in a search populates variables that you can use both within
>>the substitution and afterwards as \1 and $1 respectively - covered in
>>perlop (and every beginners book on perl) .. it's one of perl's pearls
You still haven't read the docs have you? Trust me Abigail is extremely
enlightened if somewhat machiavalin with advice.
You don't want to use a regex. Do your self a favour and check out
HTML::Parser and HTML::TokeParser. Then see what the docs have to say on
the issue. In next to no time you will have simple, robust HTML ALT
attribute finder and stripper that will work every time.
I know. I have been there and got the T-Shirt.
--
Ian J. Garlick
ijg@csc.liv.ac.uk
As long as the answer is right, who cares if the question is wrong?
------------------------------
Date: Sat, 03 Jul 1999 18:52:06 GMT
From: billy_collins@my-deja.com
Subject: Reading a flat file backwards
Message-Id: <7llm4k$bka$1@nnrp1.deja.com>
Hi,
I am wondering if there is a way I can open a file handle in such a way
that the last line in a text file gets read first (LIFO). I don't want
to store the whole text file into an array and the read the array
backwards.
Thanks,
B
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 3 Jul 1999 16:53:26 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Reading a flat file backwards
Message-Id: <slrn7nt1i4.31h.abigail@alexandra.delanet.com>
billy_collins@my-deja.com (billy_collins@my-deja.com) wrote on MMCXXXII
September MCMXCIII in <URL:news:7llm4k$bka$1@nnrp1.deja.com>:
$$ Hi,
$$
$$ I am wondering if there is a way I can open a file handle in such a way
$$ that the last line in a text file gets read first (LIFO). I don't want
$$ to store the whole text file into an array and the read the array
$$ backwards.
Open the file, seek to the end, seek back a little, use sysread to read
the part you seeked back over. If it contains a newline, you now know
the part you can read, else you seek back a bit more, rinse and repeat.
I think Dominus has a module for that.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 03 Jul 1999 21:38:41 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Reading a flat file backwards
Message-Id: <x7g135yz19.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@delanet.com> writes:
[cc to original poster]
A> billy_collins@my-deja.com (billy_collins@my-deja.com) wrote on MMCXXXII
A> September MCMXCIII in <URL:news:7llm4k$bka$1@nnrp1.deja.com>:
A> $$ Hi,
A> $$
A> $$ I am wondering if there is a way I can open a file handle in such a way
A> $$ that the last line in a text file gets read first (LIFO). I don't want
A> $$ to store the whole text file into an array and the read the array
A> $$ backwards.
A> Open the file, seek to the end, seek back a little, use sysread to read
A> the part you seeked back over. If it contains a newline, you now know
A> the part you can read, else you seek back a bit more, rinse and repeat.
A> I think Dominus has a module for that.
no, i do. i have to cpan it but it works fine.
you can get it at http://www.sysarch.com/perl/Backwards.pm
it will be called File::ReadBackwards.pm when it is released. so don't
get used to the package name Backwards.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 2 Jul 1999 20:09:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: reading log files
Message-Id: <slrn7nqolq.31h.abigail@alexandra.delanet.com>
Jaime D. Perez (jaimedp@pacbell.net) wrote on MMCXXXI September MCMXCIII
in <URL:news:377C1916.A8848F78@pacbell.net>:
$$ Has anybody created a program to read the log files?
$$
$$ I need to read my log files to find out who and how many people have
$$ downloaded files
$$ from one of my Internet file servers.
Read the file line by line, and each time you see a line that indicates
someone downloaded a file, increment your counter by one.
Then, at the end, after you close the file, you *PRINT* the counter!
(That's a real 133+ h4x0R trick).
Abigail
--
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
for (??;(??)x??;??)
{??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 6 Jul 1999 23:58:52 +1000
From: "Brendan Reville" <breville@mpce.mq.edu.au>
Subject: Receiving binaries
Message-Id: <7lt254$11i$1@sunb.ocs.mq.edu.au>
hi all,
this is a little CGI-related but their moderated newsgroup has carked it..
so hopefully it's still relevant here:
Can I post a reasonable amount of binary data (say a several kilobyte
graphical image) through a form via CGI to a Perl script? Or is this too
much data?
thanks
------------------------------
Date: Tue, 6 Jul 1999 19:24:33 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Receiving binaries
Message-Id: <7lu6t7$dfl6@news.cyber.net.pk>
> Can I post a reasonable amount of binary data (say a several kilobyte
> graphical image) through a form via CGI to a Perl script? Or is this too
> much data?
I don't know the limit, but I have posted about 4mb of data which works
fine.
------------------------------
Date: 3 Jul 1999 03:16:07 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: regex to match nested paranthesis
Message-Id: <7ljv9n$h7i$1@towncrier.cc.monash.edu.au>
mjd@op.net (Mark-Jason Dominus) writes:
>Better strategies:
>1. use: @parens = $string =~ /[()]/g;
>2. See http://www.plover.com/~mjd/perl/LOD/#1
>3. Write a real parser and do the parenthesis checking as part of the parser.
4. Use the Text::Balanced module (on the CPAN):
use Text::Balanced qw( extract_balanced );
my ($parenthesized) = extract_balanced($string, "()");
or, if you want to actually remove the parenthesized bit from $string:
my $parenthesized = extract_balanced($string, "()");
Damian
------------------------------
Date: Sat, 3 Jul 1999 02:54:17 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: regexp riddle
Message-Id: <dcdf3.633$cR6.5778@news1.online.no>
Trond Michelsen <mike@crusaders.no> wrote in message
news:cMbe3.664$U%.5209@news1.online.no...
> Jordan Hiller <hiller@email.com> wrote in message
> news:377935BC.D1FE1515@email.com...
> > > [dxbe]{1,4}
> > > Simple. However, I need to add one more condition. The
> > > characters are not permitted to repeat.
> wouldn't /([dxbe])\1{0,3}/ do the trick?
*blush*
> > > characters are **not** permitted to repeat.
for (1..1000) {
print "I shall always read and understand a posting before I reply to it\n";
}
--
Trond Michelsen
------------------------------
Date: Sat, 03 Jul 1999 11:05:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regexp riddle
Message-Id: <377ee9c4.6282486@news.skynet.be>
Soulier, Michael [SKY:1Z22:EXCH] wrote:
>For the gurus here, this is probably simple, but I have a regexp question.
>I need to match a string consisting of the characters d, x, b and e,
>in any order, and any length from 1 to 4 characters long. The regexp for
>my specifications so far is
>
> [dxbe]{1,4}
>
> Simple. However, I need to add one more condition. The
>characters are
>not permitted to repeat.
I'd try negative lookaheads.
/([dxbe])(?!\1)([dxbe])(?!\1|\2)([dxbe])(?!\1|\2|\3)([dxbe])/
That would only accepts 4 character length strings, but I think it'll
work:
foreach (qw(dd dx xd xx)) {
if(/([dx])(?!\1)([dx])/) {
print "Match for $_: ($1)($2)\n";
} else {
print "No match for $_\n";
}
}
-->
No match for dd
Match for dx: (d)(x)
Match for xd: (x)(d)
No match for xx
Bart.
------------------------------
Date: Sat, 3 Jul 1999 12:31:02 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: regexp riddle
Message-Id: <1dud8g0.r2tkh081w01pN@p86.tc1.metro.ma.tiac.com>
Soulier, Michael [SKY:1Z22:EXCH] <msoulier@americasm01.nt.com> wrote:
> > ([dxbe])([dxbe^\1])([dxbe^\1\2])([dxbe^\1\2\3])
>
> Now, someone mentioned that the ^ negation in regexps is only supposed
> to work if it's the first character in the pattern. The above regexp
> doesn't quite do the trick because it assumes 4 characters, but it
> almost works. Is it true that it's not supposed to work? Would the fact
> that the ^'s cause negation when they're not the first character after
> the [ be a bug?
Yes, if that is what they did. Since they don't, there's no bug in
Perl.
[dxbe^\1]
matches any character which is 'd', 'x', 'b', 'e', '^', or "\1". Inside
a character class, \1 is an character specification in octal.
I'm not sure what you mean when you say this regexp 'almost' works,
since it really doesn't come close to doing what was asked.
DB<1> x 'dxbe' =~ /([dxbe])([dxbe^\1])([dxbe^\1\2])([dxbe^\1\2\3])/
0 'd'
1 'x'
2 'b'
3 'e'
DB<2> x 'dddd' =~ /([dxbe])([dxbe^\1])([dxbe^\1\2])([dxbe^\1\2\3])/
0 'd'
1 'd'
2 'd'
3 'd'
DB<3> x 'b^^^' =~ /([dxbe])([dxbe^\1])([dxbe^\1\2])([dxbe^\1\2\3])/
0 'b'
1 '^'
2 '^'
3 '^'
DB<4>
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 05 Jul 1999 06:21:17 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: regexp riddle
Message-Id: <x9Yf3.160$uf.2356@news2.itd.umich.edu>
In article <930846582.24525@www2.remarq.com>,
Ashish Kadakia <anonymous@web.remarq.com> wrote:
>Actaully this is a smart solution..
>He forgot to mention what should appear there though..
>The look ahead are zero width, so it doesn't contain
>anything in $&
That wasn't given as a requirement.
>also it will match "de b" (note the space)
>since it satisfies both the conditions..
No, it won't. Did you try it?
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: 3 Jul 1999 01:19:40 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Regexpr tool?
Message-Id: <7ljofc$ivv$2@nnrp03.primenet.com>
David Pautler <pautler@hawaii.edu> wrote:
> One feature that I think would be quite difficult to implement, but also
> very useful, is a GUI that could be given a regexpr and a source string,
> and it would highlight in red the section of the regexpr that led to the
> most successful PARTIAL match, assuming there was no perfect match. The
> matched part of the source string would also be highlighted.
Better yet, how about a graphical application to illustrate the
whole internal operation of Perl's regular expression engine as it
applies any user-specified regular expression pattern to any
user-specified string?
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Sat, 3 Jul 1999 03:39:47 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Regexpr tool?
Message-Id: <YSdf3.649$cR6.5767@news1.online.no>
David Pautler <pautler@hawaii.edu> wrote in message
news:377D4D12.E7F2DB14@hawaii.edu...
> One feature that I think would be quite difficult to implement, but also
> very useful, is a GUI that could be given a regexpr and a source string,
> and it would highlight in red the section of the regexpr that led to the
> most successful PARTIAL match, assuming there was no perfect match. The
> matched part of the source string would also be highlighted.
Well, wouldn't it be a lot easier to just enter 5 - 10 strings and let a
program create the optimal regexp that will match all cases?
(no - I don't know of a program like this either)
--
Trond Michelsen
------------------------------
Date: 4 Jul 1999 00:57:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regexpr tool?
Message-Id: <7lmbi3$l23$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jim Monty
<monty@primenet.com>],
who wrote in article <7ljofc$ivv$2@nnrp03.primenet.com>:
> David Pautler <pautler@hawaii.edu> wrote:
> > One feature that I think would be quite difficult to implement, but also
> > very useful, is a GUI that could be given a regexpr and a source string,
> > and it would highlight in red the section of the regexpr that led to the
> > most successful PARTIAL match, assuming there was no perfect match. The
> > matched part of the source string would also be highlighted.
>
> Better yet, how about a graphical application to illustrate the
> whole internal operation of Perl's regular expression engine as it
> applies any user-specified regular expression pattern to any
> user-specified string?
-Mre=debugcolor
Ilya
------------------------------
Date: Mon, 5 Jul 1999 10:40:17 +0200
From: "Mark Stellaard" <mark.stellaard@knoware.nl>
Subject: regexprs question
Message-Id: <7lpnjm$tte$1@tasmania.dev.ict.nl>
Hello everybody,
I want to place a text line (string), inside a textfile.
But i want to place this text line on a certain place.
e.g.
<BR>
\n
\n <-- place text line here !!
\n
\n
</BODY>
I need to place the textline between <BR> and </BODY> but there are one or
more \n btween them, how can i place the text I want between the two HTML
tag's, when there are one or more \n between them ??
Greets Mark
------------------------------
Date: Mon, 5 Jul 1999 14:21:21 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: regexprs question
Message-Id: <7lr0np$coh2@news.cyber.net.pk>
> I want to place a text line (string), inside a textfile.
> But i want to place this text line on a certain place.
> e.g.
>
> <BR>
> \n
> \n <-- place text line here !!
> \n
> \n
> </BODY>
>
> I need to place the textline between <BR> and </BODY> but there are one or
> more \n btween them, how can i place the text I want between the two HTML
> tag's, when there are one or more \n between them ??
you mean:
$str = <<EOT;
<BR>
</BODY>
EOT
$str =~ s#(<br>)\s+(</body>)#$1REPLACED TEXT$2#is;
print $str;
------------------------------
Date: Mon, 05 Jul 1999 09:29:48 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: regexprs question
Message-Id: <37817ab5.2137583@enews.newsguy.com>
On Mon, 5 Jul 1999 10:40:17 +0200, "Mark Stellaard"
<mark.stellaard@knoware.nl> wrote:
><BR>
> \n
>\n <-- place text line here !!
>\n
>\n
></BODY>
>
>I need to place the textline between <BR> and </BODY> but there are one or
>more \n btween them, how can i place the text I want between the two HTML
>tag's, when there are one or more \n between them ??
Use the /s switch to match on multiple lines.
$html =~ s!<BR>\s*</BODY>!<BR>the text line</BODY>!gs;
Marcel
--
perl -e 'print unpack(q$u$,q$82G5S="!!;F]T:&5R(%!E<FP@2&%C:V5R$)'
------------------------------
Date: Tue, 06 Jul 1999 10:42:14 -0700
From: Erik Johnson <ejohnso9@earthlink.net>
Subject: Re: Reorder bytes within 90-byte records in a file with 1,000,000 records?
Message-Id: <37823FF6.8E7B7113@earthlink.net>
Greg Teets wrote:
> I have a big file with over 1,000,000 90-byte records. I would like
> to move the bytes around within each record. For instance, bytes
> 11-15 might be reordered as 15 14 13 12 11.
>
> I've seen pack and unpack suggested but I need some example code for
> my example above.
>
> I'd appreciate any help with the most efficient way to do this.
>
> Thanks in advance.
>
> Greg Teets
> Cincinnati OH
You can use pack() and unpack() to manipulate the string of bytes in
your record,
use seek() to position yourself in the file at the appropriate place.
See "The Camel Book"
entry in chapter 3 for seek() or perldoc perlfunc. If efficiency is a
big concern,
it may be faster to read the entire file into memory (or as much as your
machine can handle) and
modify an array of records, then write back out to file. You'll have to
benchmark it to know for
sure.
Hope that helps.
-ej
------------------------------
Date: Tue, 06 Jul 1999 12:30:54 +0100
From: bobby <bobby@alpstreet.net>
Subject: repeating variables of the same name??
Message-Id: <3781E8EE.F7D33B8A@alpstreet.net>
Can anyone help me with repeating variables
I'm using a script to suck data out of a pipe delimited .dat file and
format a html page... to produce something like this:
<input type=checkbox name=person value=$field[1]><B>$field[1]</B><P>
$field[2]<p>
<BR><U>Nationality</U>: $field[8]
<BR><U>Size</U>: $field[3]
<BR><U>Weight</U>: $field[4]
<BR><U>Other</U>: $field[7]
this gets repeated for any matched queries.
I want to let people check more than one checkbox (name=person
value=$field[1]) - click submit to go to another screen that has all the
people they selected .... the problem is i'm only getting the first
checkbox they click, none of the other selections come through..
Would be very grateful for any light shed.
bobby.
------------------------------
Date: Tue, 06 Jul 1999 18:59:25 GMT
From: "Giovanni Davila" <gio98dr@yahoo.com>
Subject: Retrieving NT Services
Message-Id: <hmsg3.4976$w4.68410@news1.frmt1.sfba.home.com>
I've used Win32::Service::GetServices and no luck!
I'm looking for a way to retrieve all NT services from a machine. I'm
currently using "sclist" from the NT resource kit and then putting the data
into a file that I read with Perl and finally get it the way I want.
I want to be able to skip the use of sclist if possible.
Thank you!
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 45
************************************