[19938] in Perl-Users-Digest
Perl-Users Digest, Issue: 2133 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 14 18:05:56 2001
Date: Wed, 14 Nov 2001 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005779113-v10-i2133@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 14 Nov 2001 Volume: 10 Number: 2133
Today's topics:
Re: Accessing NT Network Neighbourhood nobull@mail.com
Re: Accessing NT Network Neighbourhood <stuart@otenet.gr>
ANNOUNCE: Attribute::Handlers 0.76 (Damian Conway)
Re: backward compatible? nobull@mail.com
Bandwidth meter in cgi/perl? (bozko)
Call a CGI from another CGI script <th_gi@hotmail.com>
Can not create new HTML page with cgi.pm <pbennett@mills.edu>
Re: CGI links with a single argument <c_clarkson@hotmail.com>
Re: code phrases <c_clarkson@hotmail.com>
DBD for MS-SQL <rkapur@mpr.org>
Re: DBD for MS-SQL <bart.lateur@skynet.be>
Re: DBD for MS-SQL <Jon.Ericson@jpl.nasa.gov>
Declare Database Handle in Main or Module <caughran@chem.uga.edu>
Re: Declare Database Handle in Main or Module <rereidy@indra.com>
Re: distributing balanced elements across entities (RE <mbudash@sonic.net>
Re: distributing balanced elements across entities (RE <Laocoon@eudoramail.com>
Re: help with system calls (not a path problem) <godzilla@stomp.stomp.tokyo>
Re: Learning Perl Book Example problem <Tassilo.Parseval@post.rwth-aachen.de>
Re: Learning Perl Book Example problem <jessica.bull@broadwing.com>
Re: Match a pattern plus the next 3 lines... <godzilla@stomp.stomp.tokyo>
Re: Match a pattern plus the next 3 lines... <Laocoon@eudoramail.com>
Re: Parsing speed (John Kenyon)
Re: Parsing speed <wyzelli@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Nov 2001 19:22:26 +0000
From: nobull@mail.com
Subject: Re: Accessing NT Network Neighbourhood
Message-Id: <u91yj1kvil.fsf@wcl-l.bham.ac.uk>
"S Warhurst" <s.i.warhurst@rl.ac.uk> writes:
> "Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
> news:Pine.LNX.4.30.0111141349360.24772-
>
> > > That returns "Permission Denied" when you try to run it.
> >
> > So you don't have a Perl problem.
>
> How am I supposed to know that?
You just are. In the same way as you are supposed to intuatively know
that the route from Birmingham to London does not depend on if you are
driving a Volvo or a BMW (although it may be different if you are
driving an 18-wheeler rather than a car).
> It's all very well for people like you, who probably knows alot
> about Perl,
All you need to know about Perl is that it is a programming language.
Just like all you need to know about Volvo is that it is a manufacturer
in order to determine that the fact that your car is a Volvo is
unlikely to influence the best route.
> Yeah.. I wasn't intending on asking anymore about this matter on this
> newsgroup, and have posted to the CGI newsgroup.. at the end of the day,
> writing a file to a file server using CGI I would have thought to be a
> fairly common task, so anyone writing Perl may well have come across this
> issue before..
Yes of course they have. As have poeple writing programs that run in
background on NT servers (or indeed VMS and Unix) in other languages
and in contexts other than Web servers. However posting to a
newsgroup because the people who frequent it are likely know the
answer to a question that's not related to the subject of the
newsgroup is very poor form. There's a very high denisity of
Unix/NT/CGI/Apache/HTTP/HTML/SMTP gurus 'round here (beause these are
the sort of people who use Perl). You'll find that we do usually
answer such questions - but we generally make a point of saying that
you are in the wrong place.
The point is that in general programs that get called outside of your
current interactive login session (for any purpose, in any language,
on any OS) may run with different credentials from ones that run
inside your current interactive login session.
How to influence the these credentials will have a lot more to do with
the OS with and what's calling the program than it will to do with the
choice of programming language. To people who've been programming for
years (or even decades) (not necessarily in Perl) this seems as
blindingly obvious as my car manufacturer analogy above. It's very
hard for us to remember what it was like not to know these things
intuatively.
> not, it seems in here though..
I'm fairly sure I've answered this question in this newsgroup within
the last 5 weeks[1]. I have also answered it already in this thread.
> or perhaps no-one is taking me seriously, as you suggest.
Actually I do take you seriously. You'd definitely be scored-up in my
score file if I used one. If you carry on being defensive I may need
to revise my oppinion.
[1] <MrsKensingtonUK@yahoo.co.uk> "Checking Network Access"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 14 Nov 2001 20:59:21 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Accessing NT Network Neighbourhood
Message-Id: <9sukad$bim$2@usenet.otenet.gr>
> Thanks for having a look. I found various pages on permissions issues but
> none specific to what I want to do yet.. ie: mainly Unix & things like
> setting the permissions on the script itself with CHMOD. Also, some pages
> mentioned the user account the web server runs under and setting uid's..
> "nobody" came up often but I tihnk these terms were Unix again. IIS on NT
> runs on a special user account, but I can't find one for Apache in NT User
> Manager, so maybe it doesn't work in teh same way as IIS.
> Will keep looking anyway, as I really need to crack this one.
Apache is probably running "as a service"
Email me if you don't know how to get a service running on a user account.
--
--
Stuart Gall
------------------------------------------------
This message is not provable.
------------------------------
Date: 14 Nov 2001 19:35:19 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Attribute::Handlers 0.76
Message-Id: <9suh1n$rl5$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release
==============================================================================
Release of version 0.76 of Attribute::Handlers
==============================================================================
NAME
Attribute::Handlers - Simpler definition of attribute handlers
DESCRIPTION
This module, when inherited by a package, allows that package's class to
define attribute handler subroutines for specific attributes. Variables
and subroutines subsequently defined in that package, or in packages
derived from that package may be given attributes with the same names as
the attribute handler subroutines, which will then be called at the end
of the compilation phase (i.e. in a `CHECK' block).
EXAMPLE
package UNIVERSAL;
use Attribute::Handlers;
my %name;
sub name { return $name{$_[2]}||*{$_[1]}{NAME} }
sub Name :ATTR { $name{$_[2]} = $_[4] }
sub Purpose :ATTR { print STDERR "Purpose of ", &name, " is $_[4]\n" }
sub Unit :ATTR { print STDERR &name, " measured in $_[4]\n" }
package main;
my $capacity : Name(capacity)
: Purpose(to store max storage capacity for files)
: Unit(Gb);
package Other;
sub foo : Purpose(to foo all data before barring it) { }
AUTHOR
Damian Conway (damian@conway.org)
COPYRIGHT
Copyright (c) 2001, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
==============================================================================
CHANGES IN VERSION 0.76
- Fixed documentation nit (thanks Rick)
- Improving intuitiveness of autotie mechanism (thanks Marcel)
- Added $VERSION numbrs to demo modules (seems bizarre to me, but
they're core too now).
==============================================================================
AVAILABILITY
Attribute::Handlers has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Attribute-Handlers.tar.gz
==============================================================================
------------------------------
Date: 14 Nov 2001 19:40:50 +0000
From: nobull@mail.com
Subject: Re: backward compatible?
Message-Id: <u9wv0tjg3h.fsf@wcl-l.bham.ac.uk>
"Fringel" <robert@context.nl> writes:
> Is the new version of Perl 5.6 backward compatible with the script written
> for Perl 5.005.
>
> Or are there cases known for wich I have to edit my script in order to run
> them in v5.6.
In general no. Actually there were quite a few problem with 5.6.0 but
these were largely fixed by 5.6.1.
Eg. in 5.6.0 v65 is treated as 'A' even if it appears in a context
where words are usually implicitly quoted (such as the subscript of a
hash or the LHS of a fat comma). I recall this broke at least one of
my scripts.
Obviously any code written in 5.5 that only works because it exploits
bugs in 5.5 that were subequently fixed won't work in 5.6.x!
Another obvious[1] case is if you had any subroutines called CHECK.
[1] Obvious that is having just read 'perldoc perldelta'.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 14 Nov 2001 21:33:14 GMT
From: boz@jmtsystems.com (bozko)
Subject: Bandwidth meter in cgi/perl?
Message-Id: <3bf2df5f.167902110@news.elltel.net>
I need to implement a bandwidth meter using cgi/perl -- similar to
that which I found at http://www.dslreports.com. Apparently this
system (and many others like it) include the contents of a large file
(~500k worth of junk text) that gets sent to the user's browser. It
mustn't get cached either so that it can be run again by the same
user.
The time is checked before the 'junk' is sent, and then checked again
afterward. The time is then converted to kbps using the time and the
amount of bytes sent (typically 500). Example follows:
Eg.
:
:
<script>
<!--
time = new Date();
starttime = time.getTime();
// -->
</script>
<!--
U[72Fq*Я8msg
:
:
Dvb`"G+KUh=i~ hAZg226?
-->
<script>
<!--
time = new Date();
endtime = time.getTime();
:
<<calculate kbps>>
:
// -->
</script>
Has anyone seen this done in perl before? Can it be done? Are there
examples posted anywhere?
Thanks!
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Wed, 14 Nov 2001 23:36:34 +0100
From: "Th.G" <th_gi@hotmail.com>
Subject: Call a CGI from another CGI script
Message-Id: <3BF2F1F2.2040005@hotmail.com>
Hi
How can I call a CGI-script from another CGI, give any parameters to
that CGI and receive
any results from the other CGI.
Eg. 2 scripts 'main.cgi' and 'check.cgi'.
'main.cgi' calls 'check.cgi' and sends a parameter to check. 'check.cgi'
gives back any
result based on that parameter.
Can I use this:
in main.cgi:
.
.
allowance = check.cgi?param=<value>
if (allowance == ...) {
.
.
in check.cgi
.
if (param == ...)
{
return a; }
else
{
return b; }
how does this work?
Thank you
Tom Gossi
------------------------------
Date: Wed, 14 Nov 2001 14:40:57 -0800
From: Patrick Bennett <pbennett@mills.edu>
Subject: Can not create new HTML page with cgi.pm
Message-Id: <3BF2F2F9.760D644@mills.edu>
This is a multi-part message in MIME format.
--------------0C32157D06D3769C460D9369
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Created a simple enter information and then print results script using
cgi.pm.
The results page is appended to the bottom of the original enter your
information page.
This behavior causes the results page not to be shown without scrolling
down, if a
user is not aware of this behavior it seems as the page is doing
nothing. I have tried
many things... can not get the results page to reprint. New to cgi...
thanks in advance,
please reply to pbennett@mills.edu .
--------------0C32157D06D3769C460D9369
Content-Type: text/x-vcard; charset=us-ascii;
name="pbennett.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick Bennett
Content-Disposition: attachment;
filename="pbennett.vcf"
begin:vcard
n:Bennett;Patrick
tel;work:(510) 430 - 2265
x-mozilla-html:FALSE
org:Mills College;CSAC
adr:;;;;;;
version:2.1
email;internet:pbennett@mills.edu
title:System Administrator
fn:Patrick Bennett
end:vcard
--------------0C32157D06D3769C460D9369--
------------------------------
Date: Wed, 14 Nov 2001 10:00:40 -0000
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: CGI links with a single argument
Message-Id: <tv5n1akk270j4f@corp.supernews.com>
"Steven" <me@anywhere.com> wrote:
in message
news:20011113.142929.601385644.17659@anywhere.com...
: I was wondering if there is a way to use a link with a
single argument like
:
: <a
href="http://www.anywhere.com/cgi-bin/some.cgi?argument">xxx
</a>
:
: without using CGI.pm.
:
: I have got this working got this working using CGI.pm
using ('keywords') but
: I can't find a good way to build tables dynamically with
CGI.pm, which is
: what I need to do with my script. The single argument
would point to a file,
: my script would open that file and build a table out of
what it data it
: finds there.
:
You might look at Data::Table. Here's an excerpt:
use Data::Table;
# Read a csv file into a table object
$t = Data::Table::fromCSV("aaa.csv");
# Diplay a 'portrait' HTML TABLE on web.
print $t->html;
HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
Reality is that which, when you stop believing in it,
doesn't go away. - Philip K. Dick
------------------------------
Date: Wed, 14 Nov 2001 13:58:58 -0000
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: code phrases
Message-Id: <tv5n1bmlubvn50@corp.supernews.com>
"Houda Araj" <Houda.Araj@cogmedia.com> wrote:
in message
news:21916d9f.0111131426.5224b71@posting.google.com...
: Hello,
:
: I have a list of phrases in a file (phrase.txt). Is it
possible to
: write a perl script that takes this list (phrases.txt) and
highlight
: every words or phrases it finds in a text called
(source.txt)?
It is possible to find the occurances of a phrase in
source.txt. perl is great for that. The question is: How do
you
plan to display the text? (RTF, HTML, a word processor,
spreadsheet, etc.)
Steve's solution (news:w47wv0u8ezi.fsf@origo.ifa.au.dk)
will find phrases as long as they don't wrap lines. Your
solution may need to include more detail. Ultimately, your
solution will depend on the format you want to display
your text in.
This script, for instance, adapts Steve's script. It
assumes a bit about your text and returns a HTML
paragraph with bold highlighting.
#!/usr/bin/perl
use strict;
use diagnostics;
use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';
my $regex;
{
my $phrase_file = 'phrases.txt';
open my $fh, $phrase_file or die "$phrase_file: $!";
chomp( my @phrases = <$fh> );
$_ = "(?:$_)" foreach @phrases;
$regex = join '|', @phrases;
}
my $paragraph;
{
my $source_file = 'source.txt';
open my $fh, $source_file or die "$source_file: $!";
chomp( my @source = <$fh> );
$paragraph = join ' ', @source;
}
$paragraph =~ s/($regex)/b($1)/ige;
print p($paragraph);
__END__
HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
I submit that we are both atheist, I simply believe in one
fewer god than you.
When you can understand why you dismiss all other gods,
then you will understand why I dismiss yours.
- Stephen F. Frost
------------------------------
Date: Wed, 14 Nov 2001 22:00:40 GMT
From: "Rajesh Kapur" <rkapur@mpr.org>
Subject: DBD for MS-SQL
Message-Id: <cQBI7.180$Fm2.46236@news7.onvoy.net>
Gurus,
I have worked with Perl DBI and 'DBD for Informix' on Solaris. Now I am
being asked to work on MS Windows 2000, Perl and MS-SQL 7.0 database (I
have no experience on Windows). Where can I get the DBD for MS-SQL database?
It was not obvious which DBD to pick up for MS-SQL when I visited
www.cpan.org
(http://cpan.valueclick.com/modules/by-category/07_Database_Interfaces/DBD/)
. Can someone please enlighten me?
Also, is PERL on Windows any different from UNIX environment? What is the
best way to re-train myself on Windows?
Thanks.
- Rajesh
------------------------------
Date: Wed, 14 Nov 2001 22:45:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: DBD for MS-SQL
Message-Id: <70t5vt0b6310rovu73jupnrsv8td6sigbq@4ax.com>
Rajesh Kapur wrote:
> Now I am
>being asked to work on MS Windows 2000, Perl and MS-SQL 7.0 database (I
>have no experience on Windows). Where can I get the DBD for MS-SQL database?
Use DBD::ODBC.
--
Bart.
------------------------------
Date: 14 Nov 2001 14:25:33 +0000
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: DBD for MS-SQL
Message-Id: <86zo5p8m5e.fsf@jon_ericson.jpl.nasa.gov>
"Rajesh Kapur" <rkapur@mpr.org> writes:
> I have worked with Perl DBI and 'DBD for Informix' on Solaris. Now I
> am being asked to work on MS Windows 2000, Perl and MS-SQL 7.0
> database (I have no experience on Windows). Where can I get the DBD
> for MS-SQL database? It was not obvious which DBD to pick up for
> MS-SQL when I visited www.cpan.org
> (http://cpan.valueclick.com/modules/by-category/07_Database_Interfaces/DBD/)
> . Can someone please enlighten me?
I have never used that database, but DBD::ODBC is almost certainly
what you're looking for. (Is `MS-SQL' the same thing as Microsoft
SQL-Server mentioned in the DBI FAQ
(http://dbi.perl.org/doc/faq.html)?)
> Also, is PERL on Windows any different from UNIX environment? What
> is the best way to re-train myself on Windows?
There *are* differences, but in general the UNIX way of doing things
works within Perl on Windows. Look at perlport for more information.
Jon
--
"Consider carefully what you hear," he continued. "With the measure
you use, it will be measured to you--and even more. Whoever has
will be given more; whoever does not have, even what he has will be
taken from him." -- Mark 4:24-25 (NIV)
------------------------------
Date: Wed, 14 Nov 2001 16:10:08 -0500
From: Joel Caughran <caughran@chem.uga.edu>
Subject: Declare Database Handle in Main or Module
Message-Id: <3BF2DDB0.AA6A7307@chem.uga.edu>
I have been writing a few scripts that interact with a very simple
database. After some reading, I thought it would be a good idea to
create the database handle in a module and export it so that it would be
available to the scirpt. For example:
package myDB;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = wq( $dbh );
use DBI;
my $dbh = DBI->connect( "dbi:ODBC:Computer_Info" )
or die "Can't connect to 'Computer_Info':$DBI::errstr\n";
Then in the main script I would have:
#!perl
use strict;
use warnings;
use myDB;
$sth = $dbh->prepare( "SELECT * FROM table" )
or die "Can't retrieve records:$DBI::errstr\n";
The obvious advantage is that if I make some change to the database all
I really need to change is the myDB.pm. What are the disadvantages to
this plan?
Joel
--
Joel A Caughran caughran@chem.uga.edu
Chemistry Learning Center caughran@uga.edu
Department of Chemistry
University of Georgia (706) 542-1906 voice
Athens, Georgia 30602-2556 (706) 542-9454 fax
------------------------------
Date: Wed, 14 Nov 2001 14:39:56 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Declare Database Handle in Main or Module
Message-Id: <3BF2E4AC.631CA8D8@indra.com>
Joel Caughran wrote:
>
> I have been writing a few scripts that interact with a very simple
> database. After some reading, I thought it would be a good idea to
> create the database handle in a module and export it so that it would be
> available to the scirpt. For example:
>
> package myDB;
>
> require Exporter;
> @ISA = qw(Exporter);
>
> @EXPORT = wq( $dbh );
>
> use DBI;
>
> my $dbh = DBI->connect( "dbi:ODBC:Computer_Info" )
> or die "Can't connect to 'Computer_Info':$DBI::errstr\n";
>
> Then in the main script I would have:
>
> #!perl
>
> use strict;
> use warnings;
>
> use myDB;
>
> $sth = $dbh->prepare( "SELECT * FROM table" )
> or die "Can't retrieve records:$DBI::errstr\n";
>
> The obvious advantage is that if I make some change to the database all
> I really need to change is the myDB.pm. What are the disadvantages to
> this plan?
>
> Joel
> --
> Joel A Caughran caughran@chem.uga.edu
> Chemistry Learning Center caughran@uga.edu
> Department of Chemistry
> University of Georgia (706) 542-1906 voice
> Athens, Georgia 30602-2556 (706) 542-9454 fax
Well the disavantages are:
1. Namespace issues. Your main cannot see into the module's namespace.
2. Why use O-O techniques and then impose a requirement of changing
source code is your DB changes?
3. Error reporting and trapping is obfuscated.
4. Program complexity is increased.
Read Damien Conways Object Oriented Perl for guidance and insight on the
Perl O-O model and how to write good modules.
--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
------------------------------
Date: Wed, 14 Nov 2001 20:30:52 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: distributing balanced elements across entities (RE solution preferred)
Message-Id: <mbudash-7AFA07.12305514112001@news.sonic.net>
In article <187c116b.0111141009.24c93067@posting.google.com>,
showdog@my-deja.com (shwdg) wrote:
> here's my dilemma
>
> I have a string such as (linebreaks for clarity, actually all on one
> line):
>
> =c1 =it foo
> =c2 bar
> =c3 baz =ro
> =c4 yadda yadda
> =c5 =it still more text =ro
>
> where the =it and =ro are the opening and closing elements. What I
> need in the result is (again, linebreaks for clarity):
>
> =c1 =it foo =ro
> =c2 =it bar =ro
> =c3 =it baz =ro
> =c4 yadda yadda
> =c5 =it still more text =ro
>
> any suggestions? I have _no_ idea how to do this -- I've tried
> negative look ahead assertions and such but no joy!
>
> Thanks in advance
don't think you can do it with just a RE, but here's one way, assuming
the string is always "well-formed" (i.e., the =it's and the =ro's are
balanced):
#------------------------------------------------------------
$string = "=c1 =it foo =c2 bar =c3 baz =ro =c4 yadda yadda =c5 =it still
more text =ro";
print "$string\n";
$newstring = (join " ",
map {
$it = (/=it/) ? 1 : ((/=ro/) ? 0 : $it);
$_ = ((/=c\d/ && $it) ? "=ro $_ =it" : $_);
} split (/ /, $string)
);
print "$newstring\n";
#------------------------------------------------------------
yields:
=c1 =it foo =c2 bar =c3 baz =ro =c4 yadda yadda =c5 =it still more text
=ro
=c1 =it foo =ro =c2 =it bar =ro =c3 =it baz =ro =c4 yadda yadda =c5 =it
still more text =ro
does that help you?
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 14 Nov 2001 23:14:34 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: distributing balanced elements across entities (RE solution preferred)
Message-Id: <Xns9159EC7C33891Laocooneudoramailcom@62.153.159.134>
Here are three regex which will work on your sample data..I assumed the
second field is only one word and the fourth has multiple.. If that is so in
your data that fine..but if not then you have to check if it matched etc.. I
got no time to implent that now.. It 'might' be merged into a single regex..
not sure.. I actually split one regex into those three..
There are also some spacing matters which have to be fixed..can also be done
with a second regex i.e. 's/\s+/ /g' or something like that.. So what i mean
to say is : Test it and fix it :
s/(=c\d+)(?: =it)([^=]+)(?:=ro )?(?==c\d+)/$1 =it $2 =ro /g;
s/(=c\d+)(?: =it)?([^=]+)(?:=ro )(?==c\d+)/$1 =it $2 =ro /g;
s/(=c\d+) (\S+) (?==c\d+)/$1 =it $2 =ro /g;
Lao
------------------------------
Date: Wed, 14 Nov 2001 12:28:34 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: help with system calls (not a path problem)
Message-Id: <3BF2D3F2.95C652E6@stomp.stomp.tokyo>
J wrote:
> Godzilla! wrote:
( snipped - topic is little known bug in $ENV{PERL5SHELL} )
> Well, I've got it working now (see reply above) but
> I greatly appreciate the link. Thanks!
Upgrading is certainly a better choice than trying
to apply a patch to this problem.
Godzilla!
------------------------------
Date: Wed, 14 Nov 2001 20:01:58 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Learning Perl Book Example problem
Message-Id: <9suf35$6ln$01$1@news.t-online.com>
On Wed, 14 Nov 2001 13:43:59 -0500, Tom Atkins wrote:
> which perl shows /usr/bin/perl
> the first line of my script (created with pico total 2 lines) is
> #!/usr/bin/perl (I tried a space after ! also)
>
> enter test1 command not found
> enter . test1 bash errors
> enter perl test1 gets Hello World!
>
> all done in the directory where the file resides
In the directory where the file resides, you say? Unless '.' is part of
your path and you did not happen to create the file in one of the
path-directories, the bash just doesn't find the script since it does
not scan the current directory. Try ./test1 instead.
Tassilo
--
Lewis's Law of Travel:
The first piece of luggage out of the chute doesn't belong to anyone,
ever.
------------------------------
Date: Wed, 14 Nov 2001 21:25:41 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: Re: Learning Perl Book Example problem
Message-Id: <pjBI7.739345$Lw3.46262380@news2.aus1.giganews.com>
7.1 automatically defaults perl to /usr/bin/perl. To run it type: ./test1
"Tom Atkins" <tatkins@aug.com> wrote in message
news:1005759225.585101@savina...
> I am trying to run the examples in the O'Reilly book with Red Hat 7.1.
When
> I enter the problem as written, just the first Hello World example, set
the
> execute permission I get errors from bash. If I enter perl and then the
file
> name it runs OK with no errors. I thought all Linuxes recognized the #! as
> calling for the named processor but I get errors from bash not perl.
>
> Thanks for any help
>
>
>
------------------------------
Date: Wed, 14 Nov 2001 11:12:47 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Match a pattern plus the next 3 lines...
Message-Id: <3BF2C22F.B795E6D6@stomp.stomp.tokyo>
rab wrote:
> How can I make a script that will search a log file for a text
> pattern, say "ERROR" then upon finding the pattern also give me the
> next 3 lines in the file?
You have failed to provide clear and concise parameters.
There is no mention of nor example of your data structure.
Without decent parameters all answers, including my own,
are nothing more than wild guesses.
Do work on posting clear, concise and coherent articles.
It is rude to not provide information with which to work
and expect others to invest personal time, for free.
Here is a data structure which will create clear problems
based solely on what you have stated or, more appropriately,
what you have neglected to state. These are the data contained
within my test.txt for my example script.
line ERROR ONE
line 1
line 2
line 3
line ERROR TWO
line ERROR THREE
line 1
line 2
line 3
line ERROR FOUR
line 1
Should you be a relatively logical person, a relatively
clear thinking person, you can quickly surmise these
problems presented by both this data structure and your
failure to provide parameters.
Beneath my signature you will discover a test script with
which you may play and possibly attain your goal. This
script makes imaginative use of tell(), seek() and other
devices to cover for circumstances apparently you have
not considered. Perhaps you can successfully build upon
this test script of mine.
Godzilla!
--
#!perl
open (TEST, "test.txt");
while (<TEST>)
{
if (index ($_, "ERROR") > -1)
{
$position = tell(TEST);
$error_line = $_;
$line_1 = <TEST>;
$line_2 = <TEST>;
$line_3 = <TEST>;
print " $error_line $line_1 $line_2 $line_3\n\n";
if (!($line_1))
{ print " __End Of File__"; last; }
if (!($line_2))
{ print " __End Of File__"; last; }
if (!($line_3))
{ print " __End Of File__"; last; }
seek(TEST, $position, 0);
}
}
close (TEST);
exit;
PRINTED RESULTS:
________________
line ERROR ONE
line 1
line 2
line 3
line ERROR TWO
line ERROR THREE
line 1
line 2
line ERROR THREE
line 1
line 2
line 3
line ERROR FOUR
line 1
__End Of File__
------------------------------
Date: Wed, 14 Nov 2001 21:16:52 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Match a pattern plus the next 3 lines...
Message-Id: <Xns9159D88747EB0Laocooneudoramailcom@62.153.159.134>
"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> wrote in
news:9sude6$jba$02$1@news.t-online.com:
> On Wed, 14 Nov 2001 19:26:25 +0100, Laocoon wrote:
>> "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> wrote in
>
>>> while (<FILE>) {
>>> if (/PATTERN/) {
>>> push @three_lines, scalar <FILE> for 1 .. 3; } }
>>>
>>> I suppose someone will have a more elegant solution. I don't like this
>>> 'scalar <FILE>' thing very much.
>>
>> while (<INPUT>) {
>> next unless /ERROR/;
>> $error .= <INPUT> for 1..3 }
>
> Well, sure. But then you have to split to get an array. But who knows,
> it might serve the purpose of the original poster.
What do you want an array for ?? Anyway..add a [$i++] behind $error.
> Tassilo
------------------------------
Date: 14 Nov 2001 14:19:58 -0800
From: johnkenyon@usa.net (John Kenyon)
Subject: Re: Parsing speed
Message-Id: <5dd9e581.0111141419.3f44010b@posting.google.com>
"Wyzelli" <wyzelli@yahoo.com> wrote in message news:<B4qI7.1$7Q.43@vicpull1.telstra.net>...
> Here is a different approach...
>
> my $string = '"j","bob","tall","(","footy","rugby","golf","ski",")"';
> $string =~ s/.*\(",(.*),"\)/$1/;
> my @array = $string =~ m/"([^"]*)"/g;
> print "@array";
>
>
>
> Wyzelli
Hi, Thanks for the suggestion. I have modified it a bit to cope with "
in the sport strings (you never can trust end users :)
#!/usr/bin/perl
my $string = '"j","bob","tall","(","footy","rugby","golf","s"ki",")"';
$string =~ s/.*\(",(.*,)"\)/$1/;
my @array = $string =~ m/"([^,]*)"/g;
print "@array";
What do you think?
Cheers, John
------------------------------
Date: Thu, 15 Nov 2001 08:04:54 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Parsing speed
Message-Id: <njCI7.7$zV.140@vicpull1.telstra.net>
"John Kenyon" <johnkenyon@usa.net> wrote in message
news:5dd9e581.0111141419.3f44010b@posting.google.com...
> "Wyzelli" <wyzelli@yahoo.com> wrote in message
news:<B4qI7.1$7Q.43@vicpull1.telstra.net>...
> > Here is a different approach...
> >
> > my $string = '"j","bob","tall","(","footy","rugby","golf","ski",")"';
> > $string =~ s/.*\(",(.*),"\)/$1/;
> > my @array = $string =~ m/"([^"]*)"/g;
> > print "@array";
>
> Hi, Thanks for the suggestion. I have modified it a bit to cope with "
> in the sport strings (you never can trust end users :)
Very true
> #!/usr/bin/perl
> my $string = '"j","bob","tall","(","footy","rugby","golf","s"ki",")"';
> $string =~ s/.*\(",(.*,)"\)/$1/;
> my @array = $string =~ m/"([^,]*)"/g;
> print "@array";
>
> What do you think?
What if the user puts a , in the string?
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 2133
***************************************