[15537] in Perl-Users-Digest
Perl-Users Digest, Issue: 2947 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 4 11:06:18 2000
Date: Thu, 4 May 2000 08:05:13 -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: <957452712-v9-i2947@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 4 May 2000 Volume: 9 Number: 2947
Today's topics:
Re: BUG? Get comand line parameter with ActiveState Per <enders@mail.sub.uni-goettingen.de>
Calling `J' (Iverson's J, _not_ Java) from perl <DNess@Home.Com>
Re: CGI and Radio buttons <lr@hpl.hp.com>
Re: CGI and Radio buttons <bmb@ginger.libs.uga.edu>
Re: Clarify A Code Snippet (Tad McClellan)
Re: Clarify A Code Snippet <sariq@texas.net>
COPY <herbert_wolf@eunet.at>
Re: COPY <billy@arnis-bsl.com>
Dialing a Modem with Perl markhunnibell@my-deja.com
Re: finding and replacing a string (Steve)
Re: finding and replacing a string (Tad McClellan)
Re: finding and replacing a string <tony_curtis32@yahoo.com>
Function to filter HTML? <c.treczoks@ndh.net>
Re: Function to filter HTML? <snowphoton@mindspring.com>
Re: get the mails from the inbox in unix (Villy Kruse)
Re: Guess what? the largest online book store Amazon.co (Steve)
Re: Guess what? the largest online book store Amazon.co <toma@fluence.com>
help about NDBM_File and tie <fabascal@gredos.cnb.uam.es>
Hierscript in perl <bpolarsk@yahoo.com>
How can I declare variables in the command line at Dos <saddek@arch.chalmers.se>
Re: How can I install perl modules under Windows ? <jeff@vpservices.com>
Re: How can I install perl modules under Windows ? (Steve)
Re: How single-line switch (/s) works in regexps? (Steve)
Re: How single-line switch (/s) works in regexps? <mjcarman@home.com>
Re: How to find a matching ")"? (Steve)
Re: How to find a matching ")"? (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 May 2000 16:29:40 +0100
From: Markus Enders <enders@mail.sub.uni-goettingen.de>
Subject: Re: BUG? Get comand line parameter with ActiveState Perl
Message-Id: <39119764.C14B9975@mail.sub.uni-goettingen.de>
Hi Clinton,
"Clinton A. Pierce" wrote:
> Post code please.
There is really no need to post code. @ARGV has no centents, though it
should have one.
But if you want, I just wrote a small script, to check it:
#!/usr/bin/perl
print "Get command line parameters....\n";
print "Anzahl:".$#ARGV."\n";
print "Parameter:\n";
foreach $parameter (@ARGV) {
print $parameter."\n";
}
> If you claim to have a bug, show us.
The problem is, I do not know, why this error occured. It occured
suddenly, as I described in my posting.
After I deinstalled the whole PERL and installed it again, it worked. I
just wonder, without doing anything on the machine: why did the error
occur.
Under Windows NT there is a message in the "Ereignismonitor"
(eventmonitor). It's about the same time, when this error occured:
event-id 5000 and event-id 5001:
perlSE.dll detached by process ID 228
Both events occured in the same second.
I'd really know, what happened. It is quite important to us, that the
scripts are running (they are doing some batch processing).
Ciao
Markus
------------------------------
Date: Thu, 04 May 2000 14:22:23 GMT
From: David Ness <DNess@Home.Com>
Subject: Calling `J' (Iverson's J, _not_ Java) from perl
Message-Id: <391187A6.AC62FCEE@Home.Com>
ISI's `J' programming language (broadly speaking Iverson's follow-on to APL)
provides a .DLL `server' that can be called to run J code and to very
effectively handle array computations. Are there any perl functions available
for calling a `J' server?
------------------------------
Date: Thu, 4 May 2000 07:10:38 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: CGI and Radio buttons
Message-Id: <MPG.137b24b03f322c8c98a9f4@nntp.hpl.hp.com>
In article <brian-0405000245440001@187.new-york-63-64rs.ny.dial-
access.att.net> on Thu, 04 May 2000 02:45:44 -0400, brian d foy
<brian@smithrenaud.com> says...
> In article <3910FC92.1D9A37@stomp.stomp.tokyo>, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>
> >sub Akostininchi_Ithana
> > {
> > local (*in) = @_ if @_;
> > local ($i, $key, $value);
> > read (STDIN,$in,$ENV{'CONTENT_LENGTH'});
> > @in = split (/&/,$in);
> > foreach $i (0 .. $#in)
> > {
> > $in[$i] =~ s/\+/ /g;
> > ($key, $value) = split (/=/,$in[$i],2);
> > ($value eq "") && next;
> > $key =~ s/%(..)/pack ("c",hex($1))/ge;
> > $value =~ s/%(..)/pack ("c",hex($1))/ge;
> > $in{$key} .= $value;
>
> there's a bug i haven't seen in the other bad CGI parsers.
> just concatenate all of the values so you can't tell what
> the original values are.
...
> the reason that one is motivated to use CGI.pm is to avoid
> these sorts of silly bugs, and, rather than waste a lot of
> time reinventing square wheels, getting on with the meat of
> the script.
>
> so much for your claim that your scripts work.
The bug would bite only if two or more parameters had the same name.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 4 May 2000 10:36:40 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: CGI and Radio buttons
Message-Id: <Pine.A41.4.10.10005041032340.21122-100000@ginger.libs.uga.edu>
On Thu, 4 May 2000, Larry Rosler wrote:
> In article <brian-0405000245440001@187.new-york-63-64rs.ny.dial-
> access.att.net> on Thu, 04 May 2000 02:45:44 -0400, brian d foy
> <brian@smithrenaud.com> says...
> > In article <3910FC92.1D9A37@stomp.stomp.tokyo>, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> >
> > >sub Akostininchi_Ithana
...
> > > $in{$key} .= $value;
> >
> > there's a bug i haven't seen in the other bad CGI parsers.
> > just concatenate all of the values so you can't tell what
> > the original values are.
...
>
> The bug would bite only if two or more parameters had the same name.
As is common with checkboxes.
--
Brad
------------------------------
Date: Thu, 4 May 2000 09:33:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Clarify A Code Snippet
Message-Id: <slrn8h2v1e.2am.tadmc@magna.metronet.com>
On Thu, 4 May 2000 08:03:37 -0500, spurcell <skpurcell@hotmail.com> wrote:
>for ($fish, $lion) {
> s/^\s+//; s/\s+$//;
>}
>
>Which looked cool, but got me thinking.
^^^^^^^^
It should have got you _reading_ too. Then you wouldn't have
to do so much thinking, you would _know_ :-)
>How does this actually work.
Pretty much like the manual says it works, I would guess.
Have you read the "Foreach Loops" section in perlsyn.pod ?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 04 May 2000 09:56:47 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Clarify A Code Snippet
Message-Id: <39118FAF.FFA90040@texas.net>
spurcell wrote:
>
> Hello,
> I posted a question the other day about stripping out some white space on a
> few different variables:
> eg.
> for ($fish) {
> s/^\s+//; s/\s+$//;
> }
>
> Then I asked if I had two variables that needed cleaning, then how does this
> work, and someone shot me back a line
> for ($fish, $lion) {
> s/^\s+//; s/\s+$//;
> }
>
> Which looked cool, but got me thinking. How does this actually work. I
> believe that it sees $fish and $lion as basically a list, and so therefore
> each variable ($fish and $lion) gets set to the default variable, and get
> cleaned, and replaced?
Rather than relying on instinct, RTFM.
I know that at least one response told you to read perlsyn, because it
was mine. Your question is answered in the *first sentence* of the
section discussing foreach loops.
- Tom
------------------------------
Date: Thu, 4 May 2000 15:05:21 +0200
From: "Herbert Wolf" <herbert_wolf@eunet.at>
Subject: COPY
Message-Id: <3BeQ4.42$nR1.1668@nreader2.kpnqwest.net>
Hello!
Can anybody tell me how to copy a file with Perl?
Thanks!
herbert.wolf@siemens.at
------------------------------
Date: Thu, 04 May 2000 13:40:33 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: COPY
Message-Id: <8eruke$sj4$1@nnrp1.deja.com>
In article <3BeQ4.42$nR1.1668@nreader2.kpnqwest.net>,
"Herbert Wolf" <herbert_wolf@eunet.at> wrote:
> Hello!
>
> Can anybody tell me how to copy a file with Perl?
>
use File::Copy;
See File::Copy pod documentation for details.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 04 May 2000 14:49:11 GMT
From: markhunnibell@my-deja.com
Subject: Dialing a Modem with Perl
Message-Id: <8es2l0$1cg$1@nnrp1.deja.com>
Hello:
I am trying to find a perl module or a program snipit that will allow
me to have a script dial a modem connected to one of our serial ports.
Right now, we have "cu" to dial the modem and I suppose I can make some
kind of pipe script, but I was hoping for an "all-perl" solution. This
is probably a stupid question because I don't know as much as I might
about I/O and even perl, but I just don't seem to understand how to
make perl directly access and dial the modem. Do you know of any
scripts or modules specifically designed for this? I searched CPAN and
came up essentially empty, which surprised me, so I just have to
believe I am missing something very basic about how to do this.
Thanks for any insight or reference anyone might provide.
Mark Hunnibell
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 4 May 2000 15:06:31 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: finding and replacing a string
Message-Id: <slrn8h2vl7.vi1.sjlen@zero-pps.localdomain>
On Thu, 4 May 2000 09:41:56 +0100, Richard Quick wrote:
>Hi,
>We have been given permission to harvest content off a horoscope site, but
>we need to change some of the imagery.
>I have the following Perl script , which harvests the content from the site.
>All the pictures are referenced absolutely
>(http://www.awebsite.com/neo/images/pic.gif), and so I want to be find all
>the instances of
>awebsite.com/neo/images/
>and replace them with
>ourwebsite.com/images/
You don't need a script to do this, you could do it quicker in vi.
vi the_perl_script.file
then when open
:%s/oldweb\/site/new\/website/g
then save it with w and quit with I think it's q .
I havn't test this, it's from memory from long ago, so make a copy of your
original file before you do anything else.
--
Cheers
Steve email mailto:sjlen@ndirect.co.uk
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.ndirect.co.uk/~sjlen/
or http://start.at/zero-pps
1:09pm up 7 days, 15:10, 3 users, load average: 1.68, 1.52, 1.28
------------------------------
Date: Thu, 4 May 2000 09:02:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: finding and replacing a string
Message-Id: <slrn8h2t6b.23o.tadmc@magna.metronet.com>
On Thu, 4 May 2000 09:41:56 +0100, Richard Quick <richard_quick@quick2001.freeserve.co.uk> wrote:
>All the pictures are referenced absolutely
>(http://www.awebsite.com/neo/images/pic.gif), and so I want to be find all
>the instances of
>awebsite.com/neo/images/
>and replace them with
>ourwebsite.com/images/
s#awebsite\.com/neo/images/#ourwebsite.com/images/#g;
>#!/usr/bin/perl -w
use strict;
>print "$content";
print $content;
># this part will get the amount of bytes of the url :
># my $bytes;
># $bytes = lenght $content;
^^
$bytes = length $content;
>sub get_form {
You should use a standard module to decode URLs.
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
So you do not need to support GET requests then?
> if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
if ($INPUT{$name}) { $INPUT{$name} .= ",$value" }
> else { $INPUT{$name} = $value; }
So if $INPUT{$name} = '0', you want to discard the zero?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 04 May 2000 09:21:26 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: finding and replacing a string
Message-Id: <87bt2ms8ex.fsf@shleppie.uh.edu>
>> On 4 May 2000 15:06:31 GMT,
>> sjlen@ndirect.co.uk (Steve) said:
> On Thu, 4 May 2000 09:41:56 +0100, Richard Quick wrote:
>> Hi, We have been given permission to harvest content
>> off a horoscope site, but we need to change some of the
>> imagery. I have the following Perl script , which
>> harvests the content from the site. All the pictures
>> are referenced absolutely
>> (http://www.awebsite.com/neo/images/pic.gif), and so I
>> want to be find all the instances of
>> awebsite.com/neo/images/ and replace them with
>> ourwebsite.com/images/
> You don't need a script to do this, you could do it
> quicker in vi.
> vi the_perl_script.file then when open
> :%s/oldweb\/site/new\/website/g
Ewww! You can use other characters as the separator in
regexps, not just '/'. Saves backslashing '/' in the
content.
> then save it with w and quit with I think it's q .
> I havn't test this, it's from memory from long ago, so
> make a copy of your original file before you do anything
> else.
And you're going to volunteer to go in overnight and do
this for them? I suspect they're going to end up with a
large tree of files (although they don't say so). This
user-at-a-terminal approach simply doesn't scale.
A perl program iterating over the files with s/// should
do the trick (assuming it is really "all the instances"
that should be substituted regardless of context).
OTOH a shell script using sed might be just as easy.
hth
t
------------------------------
Date: Thu, 04 May 2000 15:23:12 +0200
From: Christian Treczoks <c.treczoks@ndh.net>
Subject: Function to filter HTML?
Message-Id: <391179C0.AFE59B6B@ndh.net>
Dear Netizens, Perl-Wizards, and Co-Apprentices,
I can't believe that there is no function or module for this task:
What I have: A tainted string (returned from an HTML form).
What I want: The string cleaned of any "harmful" HTML formatting.
No "harmful" HTML is defined by a limitation to certain tags
(e.g. <I>, </I>, <B>, </B>, <BR>), checking the matching of opening
and closing tags, and the correctness of special character encodings
("ü" etc.).
There are numerous examples of "how to kill all HTML from a string",
but this is not my intention. I thought about replacing all
<VALID TAG> by {VALID TAG} and then eradicate the rest, and replace
back, but there must be nicer ways (IMHO).
Yours, advTHANKSance, Christian Treczoks, Perl Apprentice.
------------------------------
Date: Thu, 04 May 2000 07:16:06 -0700
From: james archer <snowphoton@mindspring.com>
Subject: Re: Function to filter HTML?
Message-Id: <39118626.8E379E2A@mindspring.com>
Use s///
Problem solved.
James
ICQ: 49636524
snowphoton@mindspring.com
http://www.mindspring.com/~snowphoton/
------------------------------
Date: 4 May 2000 14:50:33 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: get the mails from the inbox in unix
Message-Id: <slrn8h33hp.tte.vek@pharmnl.ohout.pharmapartners.nl>
On Thu, 04 May 2000 07:22:19 GMT, k_ahg@my-deja.com <k_ahg@my-deja.com> wrote:
>hi,
>
> I'm actually trying to write a perl program to grep certain mails in
>my inbox in unix to do some processing.Is it possible to do that can
>anybody help me.
>
I would suggest to get a POP3 client and access the mailbox through the
POP3 server. Otherwise you might forget about the .lock file, file
permissions, and other nasty pitfals when accessing the mailbox directly.
Look in the CPAN archives for POP3 clients, and also for mbox access
routines, if you don't want to go the POP3 way.
Villy
------------------------------
Date: 4 May 2000 15:06:28 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: Guess what? the largest online book store Amazon.com
Message-Id: <slrn8h2uqf.vi1.sjlen@zero-pps.localdomain>
On Thu, 04 May 2000 07:06:00 -0400, Freelancer wrote:
>I told our secretary order two O'Reilly books Java Enterprise in a
>Nutshell and
>Programming the Perl DBI for me. She ordered from Amazon.com instead
>O'Reilly.
>Guess what? She got replied said Amazon only has 1 book each on their
>stock,
>so they could not sell those two books to us any more. (^0^)
>
>BTW, Amazon.com is the largest online book store in the world.
>
Get off your fat arse and walk to a real book shop, it's a much
better experience than ordering on line and it supports your local
community.
--
Cheers
Steve email mailto:sjlen@ndirect.co.uk
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.ndirect.co.uk/~sjlen/
or http://start.at/zero-pps
1:09pm up 7 days, 15:10, 3 users, load average: 1.68, 1.52, 1.28
------------------------------
Date: Thu, 04 May 2000 07:16:12 -0700
From: Tom Almy <toma@fluence.com>
Subject: Re: Guess what? the largest online book store Amazon.com
Message-Id: <3911862C.C3B9A3C1@fluence.com>
I always buy through bookpool.com when I can, finding their prices (both
for
books and shipping) far lower than, for instance, amazon.com. However
there
are two downsides:
1. The don't carry as many publishers. Some titles I've needed they
don't have.
2. You can't be in a hurry. They claim they get the lowest price at the
expense
of speed.
If (1) or (2) are problem, I buy locally (the famous Powells is here
with a superb
selection but no discounts on new books)or from Amazon.
"Paul R. Andersen" wrote:
>
> I don't want to sound like an advertisement cause I have no interest in
> this place but we have found generally better prices and availability on
> technical books through bookpool.com, YMMV.
------------------------------
Date: Thu, 04 May 2000 16:04:28 +0200
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: help about NDBM_File and tie
Message-Id: <3911836B.261AF829@gredos.cnb.uam.es>
Hello,
I don't find documentation about perl's NDBM_File module.
I only find examples like this:
tie(%hash, 'NDBM_File', './nueva.dbx', O_RDWR|O_CREAT, 0640);
but I would like to know what do the parameters mean, what can I do with
them. (I want to store hashes at files)
Another question I have is why there are so many *DBM* modules, is some
of them better to store hashes at files?
Thanks in advance,
Federico
------------------------------
Date: Thu, 04 May 2000 13:07:17 GMT
From: Bernard Polarski <bpolarsk@yahoo.com>
Subject: Hierscript in perl
Message-Id: <8erslq$qej$1@nnrp1.deja.com>
Hello,
I am trying to port Shell script from Ksh Unix onto perl. The following
procedure work perfectly uder difital Unix :
$a=`sqlplus <<EOF bpa/bpa\@NOSIQA
set feed off head off
select sysdate from dual ;
exit
EOF`;
printf "a=$a";
output is :
<cut>
a=
SQL*Plus: Release 3.3.4.0.0 - Production on Thu May 4 15:02:27 2000
Copyright (c) Oracle Corporation 1979, 1996. All rights reserved.
Connected to:
Oracle7 Server Release 7.3.4.1.0 with the 64-bit option - Production
With the distributed and Parallel Server options
PL/SQL Release 2.3.4.1.0 - Production
SQL> SQL>
04-MAY-00
SQL> Disconnected from Oracle7 Server Release 7.3.4.1.0 with the 64-bit
option - Production
With the distributed and Parallel Server options
PL/SQL Release 2.3.4.1.0 - Production
</cut>
But the code does not work under Perl NT :
<cut>
<< was unexpected at this tile
</cut>
Does anybody know how to run hierscripts under Perl for NT ?
--
B.Polarski
http://www.geocities.com/bpolarsk
Email : bpolarsk@yahoo.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 04 May 2000 16:54:37 +0200
From: Saddek Rehal <saddek@arch.chalmers.se>
Subject: How can I declare variables in the command line at Dos prompt?
Message-Id: <39118F2D.E2F58FB9@arch.chalmers.se>
This is a multi-part message in MIME format.
--------------00025A83CDEB31E152E526DD
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Hi!
Let say that I have the following script called: test.pl
#!\apache\Perl\bin\perl.exe
print "$city";
How do I assign a value to $city in the command line when I start the
script. I tried: c:\apache\perl\bin> perl test.pl $city=Paris but
without success.
Thank you if you want to help me.
--
Saddek Rehal
Chalmers tekniska högskola,
Arkitektur, Byggnadskonst
412 96 Göteborg
Tel: 031-772 24 75
--------------00025A83CDEB31E152E526DD
Content-Type: text/x-vcard; charset=us-ascii;
name="saddek.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Saddek Rehal
Content-Disposition: attachment;
filename="saddek.vcf"
begin:vcard
n:Rehal;Saddek
tel;cell:0703088885
tel;home:031-144120
tel;work:031 7722475
x-mozilla-html:FALSE
url:pc15.arch.chalmers.se/saddek.html
org:Chalmers tekniska högskola;Arkitektur/Innovativ Design
version:2.1
email;internet:saddek@arch.chalmers.se
adr;quoted-printable:;;Sven Hult=E9nsgatan=0D=0A412 96;Göteborg;;;
x-mozilla-cpt:129.16.160.85;-1
end:vcard
--------------00025A83CDEB31E152E526DD--
------------------------------
Date: Thu, 04 May 2000 06:30:46 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How can I install perl modules under Windows ?
Message-Id: <39117B86.A5B10372@vpservices.com>
Francois Dupradeau wrote:
>
> Hello !
>
> I made a perl script under Linux and now I'd like to run it under
> Windows NT. The problem is I must install some modules (HotKey.pm and
> ANSIColor.pm). I can't install these modules because I can't do a make
> and make install.
> Can I can install these modules ?
Yes.
> How ?
With activestate's PPM (perl package manager)
> Can you give me an URL where I can download executables modules under
> Windows ?
Just type "ppm install ModuleName" at a DOS prompt.
See your online documentation
(start-menu/programs/activPerl/online-documentation) or
www.activestate.com for details especially if you are behind a firewall.
--
Jeff
------------------------------
Date: 4 May 2000 15:06:26 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: How can I install perl modules under Windows ?
Message-Id: <slrn8h2u9u.vi1.sjlen@zero-pps.localdomain>
On Thu, 04 May 2000 12:02:20 +0200, Francois Dupradeau wrote:
>Hello !
>
>I made a perl script under Linux and now I'd like to run it under
>Windows NT. The problem is I must install some modules (HotKey.pm and
>ANSIColor.pm). I can't install these modules because I can't do a make
>and make install.
>Can I can install these modules ? How ?
>Can you give me an URL where I can download executables modules under
>Windows ?
You havn't looked very far, on the CPAN front page (I think it's the
first link), there's a link to a page called something like how to
install a module. That page gives details specific to each platform
and is easy to follow.
http://www.perl.com/CPAN/
--
Cheers
Steve email mailto:sjlen@ndirect.co.uk
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.ndirect.co.uk/~sjlen/
or http://start.at/zero-pps
1:09pm up 7 days, 15:10, 3 users, load average: 1.68, 1.52, 1.28
------------------------------
Date: 4 May 2000 15:06:29 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: How single-line switch (/s) works in regexps?
Message-Id: <slrn8h2v8j.vi1.sjlen@zero-pps.localdomain>
On Thu, 04 May 2000 12:42:01 +0200, Zoltan Gyenes wrote:
>In s/// command I can use the /s switch the matching to treat the
>input lines as a (long) single line. I have to use that feature on big
>(>70MB) postscript files to scan for a string that (in certain cases)
>can be wrapped into 2 lines. Because of that sizes I'm curious about
>the way that switch works, does it treat the whole file as a single
>line or maybe (I hope) it only joins lines in case of a possible
>match?
The lines may look like two lines in a text viewer, but if you
open the file without having lines wrap you'll probably see
that they are only one line but very long ones.
Read the docs on finding strings in files, perldoc perlre is
probably a good place to start. There are some real good
books out there aswell.
--
Cheers
Steve email mailto:sjlen@ndirect.co.uk
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.ndirect.co.uk/~sjlen/
or http://start.at/zero-pps
1:09pm up 7 days, 15:10, 3 users, load average: 1.68, 1.52, 1.28
------------------------------
Date: Thu, 04 May 2000 08:45:57 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: How single-line switch (/s) works in regexps?
Message-Id: <39117F15.FA2CE995@home.com>
Zoltan Gyenes wrote:
>
> In s/// command I can use the /s switch the matching to treat the
> input lines as a (long) single line. I have to use that feature on big
> (>70MB) postscript files to scan for a string that (in certain cases)
> can be wrapped into 2 lines. Because of that sizes I'm curious about
> the way that switch works, does it treat the whole file as a single
> line or maybe (I hope) it only joins lines in case of a possible
> match?
You want to look at 'perldoc perlre' which contains a description of all
the modifiers. Basically, all /s does is change '.' so that it matches
any character including newlines, instead of any character except
newlines.
-mjc
------------------------------
Date: 4 May 2000 15:06:07 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: How to find a matching ")"?
Message-Id: <slrn8h2u01.vi1.sjlen@zero-pps.localdomain>
On Thu, 04 May 2000 17:02:23 +0800, Dayang Lily wrote:
>Hi,
>
>I have a script that reads a file, finds some matching words in that
>file and put the entire line that contains the matched word into an
>variable. For example :
>my_file :
>(value name linda mary)
>(value class A B C)
>(value title "Note").
>
>My script works something like this:
>while(<my_file>) {
> if(/value name/)
> { $thename = $_}
> if(/value title)
> { $thetitle = $_
> &dosomething($thename,$thetitle)}
>}
>
>The problem occurs when I have more than one line in the list, eg
>(value name linda mary
>jane peter
>joan ross
>)
>How do I read this entire list into my variable? How do I find a
>matching ")"?
push (@the_names, $_);
This will put the names into an array. Then print them out:
while (<@the_names>)
{
print "$_ \n";
}
For the matching pairs thing I've seen a function mentioned somewhere
but can't remember, I'd suggest you start at perldoc perlre there's
lots of good stuff in there and well worth a read.
--
Cheers
Steve email mailto:sjlen@ndirect.co.uk
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.ndirect.co.uk/~sjlen/
or http://start.at/zero-pps
1:09pm up 7 days, 15:10, 3 users, load average: 1.68, 1.52, 1.28
------------------------------
Date: Thu, 4 May 2000 08:14:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to find a matching ")"?
Message-Id: <slrn8h2qca.23o.tadmc@magna.metronet.com>
On Thu, 04 May 2000 17:02:23 +0800, Dayang Lily <r19610@email.sps.mot.com> wrote:
>I have a script that reads a file, finds some matching words in that
>file and put the entire line that contains the matched word into an
>variable. For example :
>my_file :
>(value name linda mary)
>(value class A B C)
>(value title "Note").
>
>My script works something like this:
^^^^^^^^^^^^^^
>while(<my_file>) {
^^^^^^^
Except you use MY_FILE in your real code, right?
> if(/value name/)
> { $thename = $_}
> if(/value title)
^^
Except you terminate that search pattern in your real code, right?
> { $thetitle = $_
^^^
Except you terminate that statement with a semicolon, right?
> &dosomething($thename,$thetitle)}
>}
If you post pseudo code, you can expect only pseudo answers.
Please take the time to post real Perl code.
>The problem occurs when I have more than one line in the list, eg
>(value name linda mary
>jane peter
>joan ross
>)
>How do I read this entire list into my variable? How do I find a
>matching ")"?
$/ = ")\n";
See the description of that special variable in perlvar.pod.
See also
perldoc -f local
(ignore that "use my() instead" part, that does not apply
to built-in variables, for those you must use local())
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 2947
**************************************