[21741] in Perl-Users-Digest
Perl-Users Digest, Issue: 3945 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 10 09:10:41 2002
Date: Thu, 10 Oct 2002 06:05:12 -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 Thu, 10 Oct 2002 Volume: 10 Number: 3945
Today's topics:
Re: An RE to encode XML entities <flavell@mail.cern.ch>
Re: Can anyone tell me how to get GD (& GD::Graph) work <simon.andrews@bbsrc.ac.uk>
Re: cgi.pm code <flavell@mail.cern.ch>
Re: GMT Windows vs Linux news@roaima.freeserve.co.uk
Re: GMT Windows vs Linux <flavell@mail.cern.ch>
Re: ithreads, perl 5.8 and shared objects <nospam-abuse@ilyaz.org>
Newbie question regarding system command <test@yahoo.com>
Re: Newbie question regarding system command <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: newbie with datatype prob <simon.andrews@bbsrc.ac.uk>
Re: NEWBIE: Accessing FORM input with PERLSCRIPT <tennant2NOSPAM@theforge.demon.co.uk>
Re: parsing mount output. (Helgi Briem)
Problem with require() versus in-line code <jan@klaverstijn.nl>
Re: Problem with require() versus in-line code <dd@4pro.net>
Re: Problem with require() versus in-line code <dd@4pro.net>
Re: Problem with require() versus in-line code <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
regexp to match newlines <sjalloq@arm_removeMe_.com>
Re: regexp to match newlines <sjalloq@arm_removeMe_.com>
Re: regexp to match newlines (Tad McClellan)
regular expression to extract a string between 2 other (Red Ogden)
Re: regular expression to extract a string between 2 ot <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: regular expression to extract a string between 2 ot (Jay Tilton)
Re: Run perl script on web server from command line (Helgi Briem)
Re: tied hash consumes all memory (dan baker)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Oct 2002 10:39:55 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: An RE to encode XML entities
Message-Id: <Pine.LNX.4.40.0210101035390.11261-100000@lxplus075.cern.ch>
On Oct 10, cp inscribed on the eternal scroll:
> > &#number; references from MS where 'number' is in the range 128-159
> > decimal, you'll need a lookup table of unicode values, since XML rules
> > out 128-159 as illegal.
>
> Any idea where I can find a reference on those values?
The "reference" would be
http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
although that's tabulated in hexadecimal. You might find this more
usable: http://www.cs.tut.fi/~jkorpela/www/windows-chars.html
------------------------------
Date: Thu, 10 Oct 2002 11:21:41 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Can anyone tell me how to get GD (& GD::Graph) working on Win32!!
Message-Id: <3DA554B5.5112594@bbsrc.ac.uk>
Rubber Duck wrote:
>
> Can anyone tell me how to get GD (& GD::Graph) working on Win32!!
Use Active Perl (
ppm install GDGraph
http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/ for more
details.
Simon.
------------------------------
Date: Thu, 10 Oct 2002 13:34:59 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: cgi.pm code
Message-Id: <Pine.LNX.4.40.0210101331160.11261-100000@lxplus075.cern.ch>
On Oct 9, Joe Schaefer inscribed on the eternal scroll:
> > foreach $thingy(@display_items){
> > param('$thingy' => ~ s/\n/<BR>/g);
> > }
> >
>
> What sort of warning messages do you get when perl compiles
> this code? Are those warnings relevant to the problem you're
> having?
Good points. One might add, "what relationship does it have to the
topic stated in the Subject line?" (and one could have added that it's
CGI.pm - case sensitive).
all the best.
--
Gratuitous bigotry, pedantry and sophistry has no place on the Web.
That's what Usenet is for. - Andy Dingley
------------------------------
Date: Thu, 10 Oct 2002 09:27:08 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: GMT Windows vs Linux
Message-Id: <skd3oa.bom.ln@moldev.cmagroup.co.uk>
Darren Dunham <ddunham@redwood.taos.com> wrote:
> London is likely also in BST (British Summer Time) at the moment, so
> they are now one hour removed from UTC. (so you're 6 hours behind
> London, but not UTC).
Here in the UK we are indeed currently on summer time (the correct *IX
timezone is "GB" or "GB-Eire", *not* "GMT"):
$ date
Thu Oct 10 09:20:47 BST 2002
$ perl -e 'print scalar localtime, "\n"'
Thu Oct 10 09:20:47 2002
$ date -u
Thu Oct 10 08:20:48 UTC 2002
$ perl -e 'print scalar gmtime, "\n"'
Thu Oct 10 08:20:48 2002
and moreover,
$ perl -e '$ENV{TZ}="US/Central"; print scalar localtime, "\n"'
Thu Oct 10 08:20:50 2002
$ perl -e '$ENV{TZ}="CST6CDT"; print scalar localtime, "\n"'
Thu Oct 10 08:20:50 2002
I don't see the problem (or the relevance of the UK to this discussion -
the OP appeared to be discussing offsets from CDT to GMT/UTC, not from
CDT to UK time).
I'll happily take this offline with the OP if you would like to discuss
timezones and time offsets further. I've done a fair amount of work on
this in the past.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Thu, 10 Oct 2002 14:02:29 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: GMT Windows vs Linux
Message-Id: <Pine.LNX.4.40.0210101353010.11261-100000@lxplus075.cern.ch>
On Oct 10, news@roaima.freeserve.co.uk inscribed on the eternal scroll:
> Here in the UK we are indeed currently on summer time (the correct *IX
> timezone is "GB" or "GB-Eire", *not* "GMT"):
[...]
> I don't see the problem (or the relevance of the UK to this discussion -
> the OP appeared to be discussing offsets from CDT to GMT/UTC, not from
> CDT to UK time).
Quite,
This isn't a Perl issue as such, but one of the problems which one
needs to contend with on a dual-boot PC with Windoze and a unix-ish OS
(aka a "duel"-boot PC) is that Windoze insists on setting the hardware
clock to local time, and changing it (if given the chance) to
compensate for daylight saving time; whereas Unix has traditionally
expected hardware clocks to be set to UTC, and computing local time
based on that.
Linux (and presumably other PC-based unixes) have an option to make
them aware of the need to co-exist with Windows' habits on dual-boot
PCs. But when there has been a change to/from daylight saving, and
the system hasn't been rebooted in windows, there can be some
confusion. Or maybe it was just me that was confused, but I can
assure you there was confusion - which I assume could happen to other
folks too (I don't believe I have a monopoly on confusion ;-)
------------------------------
Date: Thu, 10 Oct 2002 07:49:19 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <ao3bdv$2875$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Benjamin Goldberg
<goldbb2@earthlink.net>], who wrote in article <3DA47FEC.CDEB13CC@earthlink.net>:
> > > > Now suppose two modules - which do not know about each other - try
> > > > to subclass select(). How would they do it?
> > >
> > > That's not how you would do it. Let's suppose you have written...
> >
> > I do not discuss applications. I discuss two *modules*. Both use
> > POE. Both substitute their own event loop.
>
> If they use POE, they should use POE's event loop.
> Stubstituting their own event loops is a *dumb* thing to do in general,
Maybe I use this "substitute" word incorrect? I see no way how a
serious project can work without replacing the select()-based loop by
something more capable.
> and should only be done if no other way will work.
I gave you examples (Tk and a wait()-based loop) where no other way will work.
> > You have a BourneShell module. This module is given a program (a
> > string) of a form
> >
> > (( a && ( b || c ) ) || (e && (f && h)) & (x || y) ; z ) | ( zz ||v zzz)
> >
> > and starts the applications *without any forking*. The event loop of
> > this module is based on wait().
>
> Why not wait for EOF from the STDOUT of the last process in the chain?
Hmm? The STDOUT of the last process is not redirected... *There is*
no last process in the chain. BourneShell runs several of the a..zzz
processes asyncroneously. When it sees that b ended unsuccessfully,
it starts c with necessary redirections.
> POE cannot use an externally supplied event loop except via a bridge
> class, such as the one which allows it to use Tk's event loop.
I read it as "POE can use an externally supplied event loop". Right?
> POE can only use one externally supplied event loop at a time.
This is exactly my point. POE does not scale to more than one
"extravagant" client. This makes it a toy only. 640K should be
enough for everything mentality.
The sad think is that I thought about this, and I saw no way to design
a framework a subclassable event loop - even with best support from
most advanced OSes... I saw several solutions which are pretty close
to be implementable, but I was pretty sure that on legacy systems they
will just testsuites for kernel bugs...
The problem: there is a dispatcher X which knows how to multiplex
events of types A,B,C; there is another dispatcher Y which knows how
to multiplex events of types A,D,E. Design the API which allows them
to cooperate with the dispatch kernel so that the kernel+X+Y can
multiplex A,B,C,D,E. X and Y know everything about the kernel; X and
Y do not know anything about each other; kernel know only the things
X and Y pass it via the API.
> Ok, so ShowMeTheTree has it's own bridge class to use POE (whereas
> BourneShell had a POE bridge class so POE can use *it*).
> > I think: now I can use these two modules and write a debugger for
> > bourne shell programs which is essentially a Perl one-liner. Can I?
> If POE is using BS's event loop, and SMTT is using the normal interface
> to POE's event loop (which gets routed through the bridge to BS), then
> it might indeed be possible.
BS handles wait() events only. It does not know that somebody may
need to examine the GUI event queue of Win32. Likewise SMTT does not
know that somebody may want to wait()...
Ilya
------------------------------
Date: Thu, 10 Oct 2002 22:17:16 +1300
From: "test" <test@yahoo.com>
Subject: Newbie question regarding system command
Message-Id: <ao3gkq$72j$1@lust.ihug.co.nz>
Hi,
Is it possible for me to write a perl script that will ping number a host
and based on the outcome certain parts of the script will be executed. For
eaxmple:
$t=system('ping 192.168.1.1');
If (system is alive or ping works)
{
than do something
}
else
{
print out host is not up
}
Can i do this in perl?
Thanks
------------------------------
Date: Thu, 10 Oct 2002 09:22:31 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Newbie question regarding system command
Message-Id: <slrnaqahjb.7rm.bernard.el-hagin@gdndev25.lido-tech>
In article <ao3gkq$72j$1@lust.ihug.co.nz>, test wrote:
> Hi,
> Is it possible for me to write a perl script that will ping number a host
> and based on the outcome certain parts of the script will be executed. For
> eaxmple:
> $t=system('ping 192.168.1.1');
> If (system is alive or ping works)
> {
> than do something
> }
> else
> {
> print out host is not up
> }
>
> Can i do this in perl?
Yes, you can.
perldoc -f system
perldoc Net::Ping
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 10 Oct 2002 10:51:10 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: newbie with datatype prob
Message-Id: <3DA54D8E.9A4E845F@bbsrc.ac.uk>
safari wrote:
> so can I just confirm that there's no problem for $CustomerID to
> contain eight digits, starting with a zero, and be tested against
> seven digit numbers. Perl's pretty smart, isn't it, in knowing they're
> both normal integers (not octo)?
perl -e 'print "Same" if ("07654321" == 7654321)'
Says they're the same on my system :-)
Perl is pretty good at doing the 'right' thing under these
circumstances. If you're treating a string like it should be a number,
then Perl will make it into a number.
> > Are you certain that you have a form parameter with that exact
> > name, and that it was given a value?
>
> yeah. There's some javascript on the form ensuring 8-digit CustomerID
> is entered.
Client side Javascript is fine as a quick check to save everyone time,
but it is NOT a replacement for checking the values in your server side
script. Javascript could be disabled on the client, or the data could
have come from somewhere other than the form you intended. You must
check all the data again when you process it.
if ($CustomerID and $CustomerID =~ /^(\d+)$/) {
$CustomerID = $1; # It exists and is an integer
}
else {
# Throw a friendly error message to stop internal server errors
}
Also it's worth reading perldoc perlsec to read about using Taint mode,
which is another good idea in CGI scripts.
Hope this helps
Simon.
------------------------------
Date: Thu, 10 Oct 2002 10:47:33 +0100
From: Tennant <tennant2NOSPAM@theforge.demon.co.uk>
To: comp.lang.perl.misc
Subject: Re: NEWBIE: Accessing FORM input with PERLSCRIPT
Message-Id: <qjiaqu0sc5ibotdhdm19ti21drsc61v8up@4ax.com>
On Wed, 9 Oct 2002 17:06:11 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:
>On Oct 9, Tennant inscribed on c.l.p.misc and other group(s?):
>
>Don't multipost. I've x-posted to the other group where I found this
>question had been posted separately, and set f'ups back to c.l.p.misc
>
Apologies, couldn't see from the archives which was the most suitable
of the two groups to post a query of this nature...as I stated in my
header, I'm new to Perl and hence also extremely new to these
newsgroups.
>Would this be running a Win32 OS? Since you don't seem to say, I'm
>assuming the answer is yes.[1]
>
Yes...as per your footnote ;-)
>With indigoperl you could install an Apache/Perl combo which would
>behave just like the familiar web technology, not needing any special
>expertise to cope with your unusual requirement. I would consider
>that to be a valuable bonus of leveraging a popular technology.
>http://www.indigostar.com/indigoperl.htm
>
But if the answer everytime there is a stumbling block in PerlScript
is to switch to an emulated server, what is the point of PerlScript
existing in the first place? If this newsgroup is not the right place
to be seeking PerlScript help, can you point me in the direction of
the correct one...I couldn't find any on our news server?
>
>Avoid posting masses of code or markup. If and when you reach the
>point where posting some code is appropriate, post just enough to
>demonstrate the substantive issue (preferably a complete but simple
>test case). This group's posting guidelines document _will_ help you
>to help yourself, honestly.
>
The code was heavily edited to highlight just the pertinent points, as
1) I wasn't sure I was explaining the problem very well and the code
would demonstrate what I was trying to achieve and 2) I may have made
a stupid error in my code which would be obvious to those with more
experience.
As it turned out, the latter was in fact the case. For others who may,
when searching the archives, what to know what the solution was; the
way to access the input was:
$name=$window->document->MyForm->name->{'value'}
However, my "stupid mistake" was to use a write() command to send a
progress update to the console...hence my current window no longer
contained the field I was trying to read. This may, of course, not be
the correct solution...but it works for me.
Tennant
------------------------------
Date: Thu, 10 Oct 2002 11:00:32 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: parsing mount output.
Message-Id: <3da55cac.114800955@news.cis.dfn.de>
On Wed, 9 Oct 2002 17:38:55 -0400, "dave"
<dmehler@siscom.net> wrote:
> I feel like i'm reinventing the wheel with this. I've got
> mount output that i need to parse.
What is "mount output"?
For parsing the output of external programs see
perldoc -q system and perldoc -f system
What have you tried? We are not going to write
a program for you from scratch, you know. What
does your input look like? What do you want your
output to look like?
>I'm looking for a specific pattern which i have found,
perldoc perlre
>then i need to get where the mount point is.
perldoc -f chdir
>If anyone has a script that comes close to doing this please
>could you send it my way?
Do you expect us to write the program for you
based on nothing? That's nice.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 10 Oct 2002 13:51:11 +0200
From: "Jan Klaverstijn" <jan@klaverstijn.nl>
Subject: Problem with require() versus in-line code
Message-Id: <3da569c9$0$11221$1b62eedf@news.euronet.nl>
Hi,
I run into a problem with "require()". In file file_a.pl I define a hash
with a list in it. In file file_b.pl I refer to this structure. Code
snippets are below.
Things works just fine when I physically combine a.pl and b.pl. But when I
use require "file_a.pl" to get code into file_b.pl I get
Global symbol "%fetchmailrc" requires explicit package name at file_b.pl
line ... (see offending line below)
I use strict and -w.
I did not expect to see any difference between "require()" and in-line code,
but their definitely is. I am sure I missed something very obvious, probably
about namespaces and scope.
Can someone enlighten me?
Thanks,
Jan Klaverstijn
These are my files:
file_a.pl:
======
use strict;
...
my %fetchmailrc = (
...
# List of server entries begins here
servers => [
{
...
} ]
)
file_b.pl
======
#!/usr/bin/perl -w
use strict;
require "file_a.pl";
for my $where ( @{ $fetchmailrc{servers} } ) { # <===== Offending line
...
}
}
------------------------------
Date: Thu, 10 Oct 2002 08:01:37 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: Problem with require() versus in-line code
Message-Id: <ao3q7s$j2bnc$1@ID-159100.news.dfncis.de>
You should use "our" declaration if your perl version implements it (I think
since 5.6), or "vars" pragma, or $::variablename.
file_a.pl:
======
use strict;
...
our %fetchmailrc = (
...
# List of server entries begins here
servers => [
{
...
} ]
)
or
file_a.pl:
======
use strict;
use vars qw (%fetchmailrc );
...
%fetchmailrc = (
...
# List of server entries begins here
servers => [
{
...
} ]
)
or
file_a.pl:
======
use strict;
...
%::fetchmailrc = (
...
# List of server entries begins here
servers => [
{
...
} ]
)
--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...
"Jan Klaverstijn" <jan@klaverstijn.nl> wrote in message
news:3da569c9$0$11221$1b62eedf@news.euronet.nl...
> Hi,
>
> I run into a problem with "require()". In file file_a.pl I define a hash
> with a list in it. In file file_b.pl I refer to this structure. Code
> snippets are below.
>
> Things works just fine when I physically combine a.pl and b.pl. But when I
> use require "file_a.pl" to get code into file_b.pl I get
> Global symbol "%fetchmailrc" requires explicit package name at file_b.pl
> line ... (see offending line below)
>
> I use strict and -w.
>
> I did not expect to see any difference between "require()" and in-line
code,
> but their definitely is. I am sure I missed something very obvious,
probably
> about namespaces and scope.
>
> Can someone enlighten me?
>
> Thanks,
> Jan Klaverstijn
>
> These are my files:
>
> file_a.pl:
> ======
> use strict;
> ...
> my %fetchmailrc = (
> ...
> # List of server entries begins here
> servers => [
> {
> ...
> } ]
> )
>
>
>
> file_b.pl
> ======
> #!/usr/bin/perl -w
> use strict;
> require "file_a.pl";
> for my $where ( @{ $fetchmailrc{servers} } ) { # <===== Offending line
> ...
> }
> }
>
>
------------------------------
Date: Thu, 10 Oct 2002 08:08:08 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: Problem with require() versus in-line code
Message-Id: <ao3qk2$j2uft$1@ID-159100.news.dfncis.de>
perldoc -f my
A "my" declares the listed variables to be local (lexically) to
the enclosing block, file, or "eval". ...
perldoc -f our
An "our" declares the listed variables to be valid globals
within the enclosing block, file, or "eval". ...
perldoc vars
... This will predeclare all the variables whose names are in the list,
allowing you to use them under "use strict", and disabling any typo
warnings. ...
perldoc -f package
... You can refer to variables and filehandles in other
packages by prefixing the identifier with the package name and a
double colon: "$Package::Variable". If the package name is null,
the "main" package as assumed. That is, "$::sail" is equivalent
to "$main::sail" (as well as to "$main'sail", still seen in
older code).
--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...
------------------------------
Date: Thu, 10 Oct 2002 14:35:21 +0200
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Problem with require() versus in-line code
Message-Id: <newscache$xymr3h$g0c$1@news.emea.compuware.com>
Jan Klaverstijn wrote (Thursday 10 October 2002 13:51):
> Hi,
>
> I run into a problem with "require()". In file file_a.pl I define a hash
> with a list in it. In file file_b.pl I refer to this structure. Code
> snippets are below.
>
> Things works just fine when I physically combine a.pl and b.pl. But when I
> use require "file_a.pl" to get code into file_b.pl
With the "require" you made the *source code* from A visible in B.
> I get
> Global symbol "%fetchmailrc" requires explicit package name at file_b.pl
> line ... (see offending line below)
Well you see, %fetchnailrc is invisible in A because it has been scoped to
its local block (you said "my"). That means it is only visible in that
block. Outside that block (in this case the file) it is not visible.
> I use strict and -w.
>
> I did not expect to see any difference between "require()" and in-line
> code, but their definitely is.
> I am sure I missed something very obvious,
> probably about namespaces and scope.
Indeed. It's the difference between typed source code and live data and
where they live.
If we leave the require in tact for now, a much cleaner approach would be to
define a function in A and call it from B:
a.pl:
sub fetchmail_configfile_parser {
my $hash_ref = shift;
... # do your stuff here and with $hash_ref as data container
return <whatever_there_is_to_return>;
}
b.pl:
require "a.pl";
# fill the hash %fetchmailrc
my $result = fetchmail_configfile_parser(\%fetchmailrc);
If you get that running, you can earn an additional 25 points by checking
the manpages on how to use modules. Read 'man perlmod' on how to "migrate"
from 'require' to 'use'.
Good luck!
--
KP
------------------------------
Date: Thu, 10 Oct 2002 11:04:26 +0100
From: Shareef Jalloq <sjalloq@arm_removeMe_.com>
Subject: regexp to match newlines
Message-Id: <3DA550AA.EFE39382@arm_removeMe_.com>
Hi,
I'm trying to find all the module instantiations in my verilog source
using the following regexp. It finds all instantiations of the type:
ModuleName uInstanceName (
but falls over when there is a newline between the module name and the
instance name:
ModuleName
uInstanceName (
Regexp:-
elsif ( m{
^\s* # Zero or more whitespace.
(\w+) # Store the ModuleName to $1.
\s+
(?:\#\s*\(.+\)\s+)* # Zero or more instance
parameters.
\w+ # Instance name. No leading
u.
\s* # Zero or more whitespace.
\(* # Opening parenthesis may be
on new line.
}x ) { # /xs modifiers.
push @MODULE, $1;
}
I'm not too bothered about what is captured into $1 as I have a
subroutine that tests the validity of the captured module name. The
only way I have been able to match all my instantiations is to use the
following regexp but it is going to match a hell of a lot more than it
needs to:
elsif ( m{
^\s* # Zero or more whitespace.
(\w+) # Store the ModuleName to $1.
.* # Match anything including
newlines.
}xs ) { # /xs modifiers.
I'm happy to use this last regexp but am just concerned about the amount
of resource it will take. Is there a cleaner way of doing it?
Many thanks, Shareef.
------------------------------
Date: Thu, 10 Oct 2002 11:33:36 +0100
From: Shareef Jalloq <sjalloq@arm_removeMe_.com>
Subject: Re: regexp to match newlines
Message-Id: <3DA55780.ED19B068@arm_removeMe_.com>
Forgot to say that I'm reading the file in a line at a time using the file
input operator. I've just been told that it may make it easier if I read
the whole file in at once. Any other suggestions welcome.
Cheers.
------------------------------
Date: Thu, 10 Oct 2002 07:10:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regexp to match newlines
Message-Id: <slrnaqarig.2ov.tadmc@magna.augustmail.com>
Shareef Jalloq <sjalloq@arm_removeMe_.com> wrote:
> using the following regexp. It finds all instantiations of the type:
> ModuleName uInstanceName (
>
> but falls over when there is a newline between the module name and the
> instance name:
> ModuleName
> uInstanceName (
Your code worked fine when I tried it with a newline in it.
I think this Question of yours is Asked Frequently too:
perldoc -q match
"I'm having trouble matching over more than one line.
What's wrong?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Oct 2002 01:43:01 -0700
From: redog6@hotmail.com (Red Ogden)
Subject: regular expression to extract a string between 2 other strings
Message-Id: <22768f84.0210100043.71a6dcf6@posting.google.com>
I am new to regular expressions and would really appreciate some
pointers in the right direction - I have searched google and can't get
the answer to the following problem
I want to extract a string from a file which is always surrounded by
the same text, eg.:
example.txt contains:
====================================================
lots of text
This is the identifier (STRING) lots of other text"
====================================================
I would like to extract STRING from example.txt. In all files like
example.txt STRING is always directly preceded by "This is the
identifier (" and directly followed by ")".
I would be grateful if someone could tell me the neatest way to
extract this.
TIA
Redge.
------------------------------
Date: Thu, 10 Oct 2002 08:53:23 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: regular expression to extract a string between 2 other strings
Message-Id: <slrnaqafsm.7rm.bernard.el-hagin@gdndev25.lido-tech>
In article <22768f84.0210100043.71a6dcf6@posting.google.com>, Red
Ogden wrote:
> I am new to regular expressions and would really appreciate some
> pointers in the right direction - I have searched google and can't get
> the answer to the following problem
>
> I want to extract a string from a file which is always surrounded by
> the same text, eg.:
> example.txt contains:
>====================================================
> lots of text
>
> This is the identifier (STRING) lots of other text"
>====================================================
>
> I would like to extract STRING from example.txt. In all files like
> example.txt STRING is always directly preceded by "This is the
> identifier (" and directly followed by ")".
>
> I would be grateful if someone could tell me the neatest way to
> extract this.
-------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
$_ = 'This is the identifier (STRING) lots of other text"';
print $1 if /This is the identifier \(([^)]+)\)/;
-------------------------------------
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 10 Oct 2002 09:12:56 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: regular expression to extract a string between 2 other strings
Message-Id: <3da5424d.209654540@news.erols.com>
redog6@hotmail.com (Red Ogden) wrote:
| I want to extract a string from a file which is always surrounded by
| the same text, eg.:
| example.txt contains:
| ====================================================
| lots of text
|
| This is the identifier (STRING) lots of other text"
| ====================================================
|
| I would like to extract STRING from example.txt. In all files like
| example.txt STRING is always directly preceded by "This is the
| identifier (" and directly followed by ")".
Use \Q...\E to escape whatever regex metachars are in the
leader/follower strings.
#!perl
use warnings;
use strict;
my $lead = 'This is the identifier (';
my $follow = ')';
my $rx = qr/\Q$lead\E(.+?)\Q$follow\E/;
my $string = 'This is the identifier (STRING) lots of other text';
print $1 if $string =~ /$rx/;
------------------------------
Date: Thu, 10 Oct 2002 10:50:58 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Run perl script on web server from command line
Message-Id: <3da55b37.114428219@news.cis.dfn.de>
>"Tad McClellan" <tadmc@augustmail.com> wrote in message
>news:slrnaq9a64.3ki.tadmc@magna.augustmail.com...
>> [snip upside-down quoted text. Please do not do that.]
On Wed, 9 Oct 2002 21:27:00 -0400, "Chuck"
<junk.kingsley@sympatico.ca> wrote:
>Thanks. The sample Perl script on that page did the trick.
Which part exactly of Tad's:
"snip upside-down quoted text. Please do not do that."
did you not understand, Chuck?
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: 10 Oct 2002 05:34:26 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: tied hash consumes all memory
Message-Id: <13685ef8.0210100434.62c48d0@posting.google.com>
stanton <stanton@lightlink.com> wrote in message news:<3DA4C73A.DA4429FC@lightlink.com>...
> I'm reading and parsing lines out of a file and populating
> a tied hash with key/value pairs, some values are references
> to anonymous arrays and anonymous hashes.
>
> I'm processing millions of lines and eventually the
> Perl program runs out of RAM and just hangs. I'm running
> Activestate Perl 5.6.1 build 633 on Win2k.
>
> If I had had to guess, I would have thought a hash tied
> to a disk file wouldn't consume all memory and then hang.
>
> -------------
oh bummer, I was just going to ask the group about memory usage with
tied hashes, but you have partly answered my concern. I need to
combine several lists of about 10k-50k items into one big list and
remove duplicates. I was considering creating a hash with the items as
keys and letting the hash handle the dupes rather than looping thru
the result file n times as I add entries looking for dupes .
my concern is that a regular hash would eat up all my RAM, so I was
going to try a tie()ed hash, but it sounds like this will eat up RAM
as well... I am wondering if a tie()ed hash uses less RAM for a given
number of entries, and whether there is a way I can estimate how much
memory would be used depending on the number o entries?
thanx,
D
------------------------------
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 3945
***************************************