[7438] in Perl-Users-Digest
Perl-Users Digest, Issue: 1063 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 23 11:17:13 1997
Date: Tue, 23 Sep 97 08:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 23 Sep 1997 Volume: 8 Number: 1063
Today's topics:
Re: "here document" method of print erroring <rootbeer@teleport.com>
abs() function (Helen Shen)
Re: bitwise xor of strings <jim.michael@gecm.com>
comp.lang.perl doesn't exist (was: Re: Memory leak?) <rootbeer@teleport.com>
Re: Converting encoded strings (Mike Stok)
Re: Deleting Files <merlyn@stonehenge.com>
Re: Deleting Files <aaron@soltec.net>
Re: Exponential Calculation Problems <rootbeer@teleport.com>
Re: file flush (I R A Aggie)
Re: file flush (Jeremy D. Zawodny)
Re: help for new man (Jeremy D. Zawodny)
Re: How to set variables from another file (Mike Stok)
Re: How to set variables from another file <rootbeer@teleport.com>
Re: long versus short filenames in win32 (Jeremy D. Zawodny)
Re: Need bulk Unix <-> PC file conversion <aaron@soltec.net>
Re: Need help with pesky warning... (Tad McClellan)
Perl & Locale on NT <pinne@pegit.se>
Re: Perl <=> C Server <seay@absyss.fr>
Printing lines that remain after a search result <bobm@tiac.net>
Re: Printing perl - Win'95 (Scott McMahan)
regex matching HTML comments (Tom Grydeland)
Regular Expressions: Negating bracketed strings <jde@tomedii.demon.co.uk>
Re: Regular Expressions: Negating bracketed strings (Tom Grydeland)
UserName Info <ratzan@us.ibm.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Sep 1997 07:48:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: "here document" method of print erroring
Message-Id: <Pine.GSO.3.96.970923074752.1200G-100000@usertest.teleport.com>
On Mon, 22 Sep 1997, Brandon S. Allbery KF8NH; to reply, change void to kf8nh wrote:
> Is he using Perl 4, by any chance? Neither Perl3 nor Perl4 worked right
> when combining print() and here documents (no output); in Perl 5 it
> works.
In what way do you mean that Perl4 didn't work right? I have an old copy
of Perl4, and it's able to print here documents without problem.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 23 Sep 1997 10:46:48 -0400
From: helen@panix.com (Helen Shen)
Subject: abs() function
Message-Id: <608koo$d35@panix3.panix.com>
Keywords: int, perl
Here is my code
$sNetExcep = ($NetLimit - abs($entityNet)) > 0 ? 0 : ($NetLimit - abs($entityNet));
it's suppose to return a non-zero value if $entityNet is a larger number than $NetLimit, but it doesn't.
am I using abs() incorrectly?
------------------------------
Date: Tue, 23 Sep 1997 08:20:36 -0400
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: bitwise xor of strings
Message-Id: <3427B414.6BAF@gecm.com>
Tom Phoenix wrote:
> On Mon, 22 Sep 1997, Jim Michael wrote:
> > Tom Phoenix wrote:
> > > sub dumphex {
> > > print join(" ", map unpack("H*", $_), @_), "\n";
> > > }
> > > $b = "0101";
> > > $c = "0011";
> > > dumphex $b ^ $c;
> > From which I get the interesting result:
> > 00010100
> Surprised? You wouldn't be if you'd read the rest of my message, in which
> I said "Perl is xoring the hex values 30313031 and 30303131 to get the hex
> value 00010100, a four byte string". Hope this helps!
Yes, I missed that part and it took me a while to figure out what was
going on there. I tried some other unpack arguments in your function in
order to try to get an output which looks like the input (i.e. same
width). My results were:
unpack arg ^ result & result
========================================================================================================
b* 00000000100000001000000000000000 00001100000011000000110010001100
bbbb 0110 0001
b4 0000 0000
According to my Perl docs:
"Each letter may optionally be followed by a number which gives a repeat
count. With all types except ``a'', ``A'', ``b'', ``B'', ``h'' and
``H'', and ``P'' the pack function will gobble up that many values from
the LIST. A * for the repeat count means to use however many items are
left. "
OK, so b4 is undefined, but does the third sentence also not apply to b?
I have been using a hash for storing hex values and their bit string
equivalents and then looking up the hex value of the bit string for
performing the bitwise op. Which method should be more efficient?
Cheers,
Jim
------------------------------
Date: Tue, 23 Sep 1997 07:41:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: comp.lang.perl doesn't exist (was: Re: Memory leak?)
Message-Id: <Pine.GSO.3.96.970923072340.1200E-100000@usertest.teleport.com>
On Mon, 22 Sep 1997, Steve Wolfe wrote:
> > Also to the original poster there is no such group as comp.lang.perl
> > anymore.
>
> I just read 13 messages in it today - your news feed must not carry
> it. Talk to your admin, and they can probably add it for you, if the
> feed that they get carries it.
They shouldn't. It's defunct. It's an ex-newsgroup. It's deceased.
comp.lang.perl has joined the spool celestial. It's gone to meet its
rmgroup-er. It's been zeroed, and there's no backup. Kibo doesn't read it
anymore. It's been left uncapped and the fizz is all gone. comp.lang.perl
has been erased from the global history file. It's sleeping with the
fishes. It's been paved over, lines have been painted, and eighty-eight
cars are parked on it today. It's a stiff, and the autopsy reported foul
play. The buzzer has sounded and the fans have gone home. The staff of Zot
has spoken. comp.lang.perl is floating belly-up. The core has been dumped,
Captain, and it exploded two kilometers off the starboard hull. I found it
in the back of the fridge and threw it out two weeks ago. A comet
crashlanded 65 million years ago and wiped out comp.lang.perl. The
manufacturer has recalled it. With one last bright flash, the filament
snapped and the bulb went out. Elvis has left the building.
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 23 Sep 1997 13:37:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Converting encoded strings
Message-Id: <608gn3$4sj@news-central.tiac.net>
In article <874989447.14509@dejanews.com>, <barman@cs.unc.edu> wrote:
>I have a similar question to the one posted below. How
>do I remove the hex representation of special characters?
>I have a string,
>$_ = "Here%27s An Example"
>and want it to be simply
>"Here's An Example".
>What hex or ord operators do I need to use to substitute? Thanks!
One way to do it is
s/%([0-9A-F]{2})/chr hex $1/gie;
if you're doing WWW work you may be better served by something like
uri_unescape in the URI::Escape module e.g.
use URI::Escape;
print uri_unescape "Here%27s An Example";
prints Here's An Example
URI::Escape comes as part of the libwww-perl module distribution which can
be found on the comprehensive perl archive network (CPAN, if you have a
web browser then http://www.perl.com/CPAN is a place to start...)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 23 Sep 1997 05:49:31 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: capulet16@hotmail.com
Subject: Re: Deleting Files
Message-Id: <8c90woi49w.fsf@gadget.cscaper.com>
>>>>> "Melinda" == Melinda <capulet16@hotmail.com> writes:
Melinda> Can anyone tell me how to delete a file ?
[...]
Melinda> I know it must be a simple solution but as yet the answer to doing it
Melinda> has eluded me.
Let's see... a quick quick quick scan of "man perlfunc" shows:
the delete function (nope... for hashes)
rmdir (nope... for directories)
something weird in the tie for hashes
and BING! the unlink function (deletes files!)
Now wouldn't this have been faster than waiting for answers from all
over the world?
Please people. You have manpages. Use them *first*. (And yes, every
legitimate distribution of Perl includes the manpages. Really.)
Grrr. Sorry... I'm starting to sound like everyone else. I'm really
trying not to be... but this question was WAAAAAY too simple to be
wasting our time here.
I can see it when the specific word you are looking for does *not*
occur in the manpage. comp.lang.perl.misc can be your online
thesaurus then. :-) But when it's findable with a SIMPLE STRING SEARCH
of the MANPAGE (not even the FAQ :-), let's try to do a *little*
homework *first* please???
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 343 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 23 Sep 1997 13:50:01 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Re: Deleting Files
Message-Id: <01bcc827$976fd660$b5910a9f@aurora.cna.com>
Try looking at the unlink("filename") command in the llama book.
or I could just say
unlink("filename") and there you would have it
or maybe
unlink("filename") || print "cannot unlink filename";
Melinda <capulet16@hotmail.com> wrote in article
<342776C9.3D10@hotmail.com>...
> Can anyone tell me how to delete a file ?
> I am writing a homepage designer and have created a temp file while the
> page is being designed. My present solution is to make the file size
> equal to 0 bytes but it's an untidy way of doing things. Also if anyone
> uploads new picture files I want to delete others of their choice as I
> have set limits on total space for the image directory.
> I know it must be a simple solution but as yet the answer to doing it
> has eluded me.
> Hope to hear from someone out there,
> Warren
>
------------------------------
Date: Tue, 23 Sep 1997 07:52:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rod Moore <rodm@studiopointe.com>
Subject: Re: Exponential Calculation Problems
Message-Id: <Pine.GSO.3.96.970923075128.1200I-100000@usertest.teleport.com>
On Mon, 22 Sep 1997, Rod Moore wrote:
> I am trying to figure out how to calculate a number with an exponent.
I believe you want the ** operator, documented in the perlop(1) manpage.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Tue, 23 Sep 1997 09:45:31 -0400
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: file flush
Message-Id: <-2309970945310001@aggie.coaps.fsu.edu>
In article <342b142a.1030737291@woody.wcnet.org>, jzawodn@wcnet.org
(Jeremy D. Zawodny) wrote:
+ By default Perl is buffering output to the file. Setting $| will turn
+ that behavior off:
In a word: NO.
Consulting the Blue Camel, pg 130, under $| we see a parenthetical
comment:
This is called "command buffering". Contrary to popular belief, setting
this variable does not turn off buffering.
James
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Tue, 23 Sep 1997 14:00:45 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: file flush
Message-Id: <3428caab.79823349@igate.hst.moc.com>
[cc'd automagically to original author]
On Tue, 23 Sep 1997 09:45:31 -0400, fl_aggie@thepentagon.com (I R A
Aggie) wrote:
>In article <342b142a.1030737291@woody.wcnet.org>, jzawodn@wcnet.org
>(Jeremy D. Zawodny) wrote:
>
>+ By default Perl is buffering output to the file. Setting $| will turn
>+ that behavior off:
>
>In a word: NO.
>
>Consulting the Blue Camel, pg 130, under $| we see a parenthetical
>comment:
>
> This is called "command buffering". Contrary to popular belief, setting
> this variable does not turn off buffering.
If I may quote the perlvar manpage:
---snip---
$|
If set to nonzero, forces a flush after every write or print on
the currently selected output channel. Default is 0. Note that STDOUT
will typically be line buffered if output is to the terminal and block
buffered otherwise. Setting this variable is useful primarily when you
are outputting to a pipe, such as when you are running a Perl script
under rsh and want to see the output as it's happening. (Mnemonic:
when you want your pipes to be piping hot.)
---snip---
As you can see, it's a shorter version of what's in the new Camel.
Does that not address what the original poster needed?
It does what he needed--flush the buffer. I mis-spoke in the post
you've quoted, but the solution, IMHO is nonetheless correct.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Tue, 23 Sep 1997 10:55:09 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: help for new man
Message-Id: <34279fda.1066497422@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On 23 Sep 1997 08:09:35 GMT, "David" <mysun@mbox2.singnet.com.sg>
wrote:
>Hi, all there,
>
>I am a new man in perl programming, I have a simple problem as follows:
>
>(ScriptFileName.pl)
>
>print <<"END_1";
>Content-type: text/html
>
><HTML>
> <HEAD>
> <TITLE>Hello World</TITLE>
> </HEAD>
> <BODY>
> H1>Greetings,World!<H1>
> </BODY>
></HTML>
>END_1
>
>When I execute this perl script (at dos command prompt, execute perl
>ScriptFileName,pl) a error message appears:
>
>Can't find string terminator "END_1" anywhere befor EOF as
>ScriptFileName,pl line 1.
[This is rapidly becoming a FAQ...]
The most common cause of this problem is that you've got some
"invisible" text at the end of "END_1". That's typically caused
by creating the script on a one computer (using editors which place
control characters at the end of lines) and transferring them in
BINARY mode via FTP to the machine on which you're running Perl.
The solution to that problem is to be sure and transfer in ASCII mode.
On the other hand, if that's not what's happening, I'd suggest making
sure there aren't any extra spaces at the end of "END_1". Some
editors make such spaces less visible than others.
Good Luck,
Jeremy
--
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: 23 Sep 1997 13:21:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How to set variables from another file
Message-Id: <608fp4$42m@news-central.tiac.net>
In article <34270daf.4000587@news.stlnet.com>,
T. Wheeler <twheeler@m-net.arbornet.org> wrote:
>I can't seem to find this in a book, nor have I been able to figure it
>out (yet).
>
>I want to create a script that will basically do a find and replace
>across a directory, replacing certain keywords with the value of a
>scalar variable set in a master file. It will be used to allow
>non-technical people create html pages through templates.
>Any ideas? Or maybe you could tell me an even better way of doing
>this. I do see the problem of tags like <P> and the like being a pain
>to include, but I want to be able to retain control over the overall
>look of the site without resorting to something like FrontPage.
If you're using a recent perl then the Text:;Template module might be one
way of doing it. The README is at
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/Mark-Jason_Dominus/Text-Template-0.1b.readme
You can browse the CPAN (comprehensive perl archive network) using a web
browser starting at http://www.perl.com/CPAN
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Tue, 23 Sep 1997 07:46:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "T. Wheeler" <twheeler@m-net.arbornet.org>
Subject: Re: How to set variables from another file
Message-Id: <Pine.GSO.3.96.970923074445.1200F-100000@usertest.teleport.com>
On Tue, 23 Sep 1997, T. Wheeler wrote:
> I want to create a script that will basically do a find and replace
> across a directory, replacing certain keywords with the value of a
> scalar variable set in a master file.
> Any ideas?
It shouldn't be hard to write this in Perl. If you get stuck partway and
you can't find what you need in the docs and FAQs, please ask here. Good
luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Tue, 23 Sep 1997 12:17:09 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: long versus short filenames in win32
Message-Id: <3428b2c8.73708066@igate.hst.moc.com>
[cc'd automagically to original author]
On 23 Sep 1997 01:15:35 GMT, "David Ransier"
<david_ransier@intercept.com> wrote:
>Is there a Win32 module function call, or some other Perl (Win API) call I
>can use to get long versus short pathnames.
The following recently appeared on the Perl-Win32-Users mailing list:
---snip---
The Win32 API function you want is GetShortPathName (converts a long
name to a short name). To go from short filename to long use the
FindFirstFile function.
I haven't tried using it myself, but you should be able to call these
functions via the Win32::API module.
Hope this helps,
Joe
********************************************************
* Joe Schmetzer *
* e-mail: jschmetz@ozemail.com.au *
* *
* Don't worry if you're a kleptomaniac, you can always *
* take something for it. *
********************************************************
---snip---
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: 23 Sep 1997 13:57:37 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <01bcc828$a6ded640$b5910a9f@aurora.cna.com>
See what happens when I respond too quickly (I actually never make that
mistake in real life)
I usually type perl -pi.bak -e 's/\r//g' *.htm*
Thanks
Greg Zevin <greg@turing.une.edu.au> wrote in article
<5vq58l$kk@turing.une.edu.au>...
> "Aaron" <aaron@soltec.net> writes:
>
>
> >Hmmmmmmmm
> >> I need to convert the PC style (CR LF) files to unix style (LF) files.
> >> The text editor I use can do this (UltraEdit32) but it is kinda
tedious.
> >>
>
> >Let's see
>
> >If I were going to do this (and I have wrestled with the problem in the
> >past)
>
> >I would write a perl script that did something like
>
> >s/\r/\n/g *.htm
>
> >I know you can do it from the command line (UNIX) like this
>
> >perl -pi.bak -e 's/\r/\n/g' *.htm
>
> Aaron, do you understand that the result of your commaned would be double
> "\n" in the end of each line?
>
>
> Greg Zevin
>
------------------------------
Date: Tue, 23 Sep 1997 06:22:22 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Need help with pesky warning...
Message-Id: <ep8806.ci.ln@localhost>
Dave Schenet (shodan@shodan.erols.com) wrote:
: David S. Patterson (david.s.patterson@boeing.com) wrote:
: : I am trying to figure out how to avoid getting run-time
: : warnings when executing the following program:
: : #!/usr/local/bin/perl_5.003 -w
: : open (FP1, "mydata.txt");
: : while (<FP1>)
: : {
: : chop;
: : m/^(\w+ +\w+) +(\w{10})(\w{10})?(\w{10})?/;
: : print "[$1] [$2] [$3] [$4]\n";
: : }
: [snip]
: You could try putting your match in an if statement. i.e.
Which will still print the warnings since the parts corresponding to
$3 and $4 are optional...
: if (m/<your regex>/) { print "[$1] [$2] [$3] [$4]\n"; }
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Sep 1997 12:57:06 +0200
From: Pinne <pinne@pegit.se>
Subject: Perl & Locale on NT
Message-Id: <3427A082.4247@pegit.se>
Hi,
I'm using Acivewares port of Perl 5.003 on NT S 4.0.
I have problems getting Perl to be nice to our beloved
swedish national characters.
(I can write swedish characters to a file, view it in notepad,
but when i read it back again the show up as though i
had used another character set).
I've scanned the docs as much as possible and came to the
conclusion that the localization support is limited on Perl
< 5.004, which is not yet available on NT.
For instance there's not locale-module supplied w 5.003.
The mentioned however that one could use the LC_LOCALE
and similar other variables. But I couldn't find any
docs on how to use them.
Please help and reply by email if possible.
/regards
------------------------------
Date: Tue, 23 Sep 1997 10:10:03 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Perl <=> C Server
Message-Id: <3427795B.828B1EF@absyss.fr>
Andrew M. Langmead wrote:
>
> gmui@jpmorgan.com (Gary Mui) writes:
>
> >Is it possible to have a perl program talk to a server written
> >in C that reads and writes normal C structures (as opposed
> >to parseable text)?
>
> Otherwise take a look at the "pack" and "unpack" functions. Something
> like this:
>
> struct foo {
> char name[32];
> int id;
> };
>
> could be converted like this:
>
> ($name, $id) = unpack 'A32I', $data;
True in this case, but what about
struct bar
{
char one;
int two;
};
This will be a bit harder to pack because of alignment questions. The
obvious unpacking pattern "CI" won't work with the C compiler of most 32
bit unix systems, you would need "CxxxI" to keep bar.two on a 32 bit
boundry. Of course, this can be very compiler dependant, so you'll need
to play around a bit to make sure things line up. If you don't
understand what is going on with this,
try testing
sizeof(bar) > sizeof(bar.one) + sizeof(bar.two)
If this is TRUE, your C compiler inserted unused bytes to keep fields
well aligned and you will need to find out how your compiler places
fields in a struct.
- doug
------------------------------
Date: Tue, 23 Sep 1997 09:35:18 -0400
From: Bob Maillet <bobm@tiac.net>
Subject: Printing lines that remain after a search result
Message-Id: <3427C595.AEC9946D@tiac.net>
I am trying to get the remaining lines of a file to print after a search
has been created..I have been able to create the search and find to
print the string using :
foreach $line (@file)
{
$_ = $line;
if (/$rif/){
@ok = split(/ /, $line);
print "$ok[0] $ok[1] $ok[2]\n";
}
}
but am stumped on the rest..I was using the print to test this, but
would actually like to print all the lines that remain in the file after
the search request is completed. Any suggestions or assistance would be
appreciated.
Bob
------------------------------
Date: 23 Sep 1997 12:09:51 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Printing perl - Win'95
Message-Id: <608bif$qid$1@mainsrv.main.nc.us>
Lynn. Rickards (lynnr@lynn.softnet.co.uk) wrote:
: How do you achieve this under Win95? Printer selection would be nice,
: too - the default printer on my own '95 machine is an A1 plotter,
: so I'd like to be able to choose a more sensible alternative....
There's a generation gap between the line-oriented world of UNIX and
the bitmap world of Windows. Just dumping text to a printer under
Windows is generally not what you want, because it looks UGLY and you
have no way to format it.
You have several options, which I'll list vaugely in order of best
output:
1. Use OLE Automation to control a program like Word. Import
the text file, format it nicely in a fixed width font and a
decent point size, and use Word's built in printing to print
the file. This gives you the best of all worlds: it's
noninteractive, and the output looks nice.
2. Just create a text file and have users print it out however
they want to. That's totally under their control, and they can
make it look as good or ugly as they like.
3. Save the text to a file and use the trusty old "PRINT"
command to dump it to a file.
In 1 or 2, you could use RTF or HTML to make the output look nicer. I
almost always add an HTML option to my scripts, that will at least
print out an HTML header and <pre> tags.
Scott
------------------------------
Date: 23 Sep 1997 14:22:12 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: regex matching HTML comments
Message-Id: <slrn62fk4k.sm0.Tom.Grydeland@mitra.phys.uit.no>
Yes, I'm perfectly aware that to do this in the general case, you'll
need a proper HTML::Parser, but for simple cases when there are no
+<!--;s in strings or other tags anywhere, this substitution should
strip all legal comments from a scalar containing an entire HTML
document:
$html =~ s {
<! # Start of SGML entity
(?: # begin a new group (no whitespace before first comment)
-- # begin comment
.*? # comment text (as little as possible)
-- # end of comment
\s*? # whitespace (as little as possible)
)+ # as many comments as possible, at least one
> # end of SGML entity
}{}gsx; # Delete it all
(It passes Randal's browserkiller test)
Comments from the SGML wizards out there?
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Tue, 23 Sep 1997 11:58:54 +0100
From: John Edwards <jde@tomedii.demon.co.uk>
Subject: Regular Expressions: Negating bracketed strings
Message-Id: <3427A0EE.C34@tomedii.demon.co.uk>
I've had a good look round the FAQs, but I can't work this one out.
I want to find every occurrence of ABC _not_ followed by XX\d+ (e.g.
ABCXX123 is fine, ABCXY123 is not). I tried using this:
/ABC[^(XX\d+)]/
which doesn't work - I guess everything within [] is just being treated
as a character class, so the parentheses and + lose their meta-ness.
I can see how to solve this programmaticlly (i.e. search for ABC, then
check XX\d+ for each one found), but this would mean I'd be looping in
Perl for every _valid_ use of ABC, whereas I only want to process
"errors".
Does anyone know how to do it in a single expression?
Thanks,
John Edwards
john.edwards@bbc.co.uk
------------------------------
Date: 23 Sep 1997 11:43:56 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Regular Expressions: Negating bracketed strings
Message-Id: <slrn62fars.sm0.Tom.Grydeland@mitra.phys.uit.no>
On Tue, 23 Sep 1997 11:58:54 +0100,
John Edwards <jde@tomedii.demon.co.uk> wrote:
> I've had a good look round the FAQs, but I can't work this one out.
>
> I want to find every occurrence of ABC _not_ followed by XX\d+ (e.g.
> ABCXX123 is fine, ABCXY123 is not). I tried using this:
Look for "lookahead" in the perlre (regular expressions) manpage
> john.edwards@bbc.co.uk
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Tue, 23 Sep 1997 06:46:06 -0700
From: John Ratzan <ratzan@us.ibm.com>
Subject: UserName Info
Message-Id: <3427C81C.48B3@us.ibm.com>
Hello,
I am trying to access $ENV{'REMOTE_USER'}.
I am showing a blank variable.
I am using <FORM METHOD=post ACTION=someperl>
I am calling <SNIP> require ("cgi-lib.pl"); </snip>
I am using a Notes/Domino server.
How would I get the UserName information
--
Thanks in advance
John Ratzan
mailto:ratzan@us.ibm.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1063
**************************************