[7051] in Perl-Users-Digest
Perl-Users Digest, Issue: 676 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 28 00:07:10 1997
Date: Fri, 27 Jun 97 21:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 27 Jun 1997 Volume: 8 Number: 676
Today's topics:
Re: 64-bit compilation of Perl (David B.Anderson)
Re: 64-bit compilation of Perl (Lamont Alan Lucas)
<Writers Seeking Publication> Litagent345@aol.com
Re: ?: How to copy a file? ( Tina Marie Holmboe )
Re: Changing environmental variables <keys@babylon5fan.corn>
Commented Complex Regexes? <cbevis@nsinet.corn>
Re: Compiling with wrapsuid <rootbeer@teleport.com>
Databases (Sam Scruggs)
Re: Detecting dead client sockets <g-fast@ux9.cso.uiuc.edu>
Re: editing inputed strings in Perl script (brian d foy)
Re: Eval'ing arrays <rootbeer@teleport.com>
Re: Event Log Reporting - Doesn't Work <dave@turfpit.demon.co.uk>
File Flush <oliver@inetu.net>
Re: Fun with ".cgi contained no blank line separating h (M. muPe)
Re: Help with getting file contents <sfairey@adc.metrica.co.uk>
Re: Help with getting file contents (Craig Berry)
Re: how compute variable names from other variables in <rootbeer@teleport.com>
How do I decipher Time format? <ashfield.matthew@miti.nb.ca>
Re: How to get browser window size? <bryan@eai.com>
Re: Inconsistent crossplatform Pack!? (John W. Komp)
Newbee Perl Question.. Perl5 and NT? <Brian_Gruttadauria@dg.com>
Re: Newbee Perl Question.. Perl5 and NT? <rootbeer@teleport.com>
no. of days between two dates ? (*/chebs)
Re: Novell's ActiveX controls w/NT Perl 5 -doh! (Gurusamy Sarathy)
Re: passing sort subroutines? <rueger@io.com>
Re: Perl Extensions -- how to write, etc... <rootbeer@teleport.com>
Re: Regexp with exclusion <ajohnson@gpu.srv.ualberta.ca>
Re: Regexps on streams (Andrew Pimlott)
simple open statement gives me error <ss51@columbia.edu>
strings (Tri Tram)
Re: Stumped .... (Bob Wilkinson)
tchrist's insulting email <usenet-tag@qz.little-neck.ny.us>
Re: Trapping the output of the System command into a va (Tim Gim Yee)
Re: Trickey Regex... need thoughts (A. Deckers)
Re: Trickey Regex... need thoughts <sfairey@adc.metrica.co.uk>
Re: Trickey Regex... need thoughts (John C. Randolph)
Re: Very Basic Perl Question on Array (Jeff Stampes)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Jun 1997 22:36:24 GMT
From: davea@quasar.mti.sgi.com (David B.Anderson)
Subject: Re: 64-bit compilation of Perl
Message-Id: <5p1f98$35d@fido.asd.sgi.com>
In article <uqfn2oc9ji0.fsf@drmail.dr.lucent.com>,
Larry Mulcahy. See Signature For Real Email Address <postmaster@cyberpromo.com> wrote:
>"James J. Heck" <jheck@merck.com> writes:
>
>> I am trying to compile Perl in 64-bit mode on a SGI running IRIX 6.2
>> Has anyone run into problems compiling Perl in 64-bit? Also if you have
>> an comments or suggestions on common mistakes for building it in 64-bit
>> please let me know.
>> I get a ton of "warning" messages but it finally comes to a halt with
>> these last few lines of output:
>
>I don't really understand the LD_LIBRARY64_PATH and LD_LIBRARYN32_PATH
>business. I am setting them to what rld claims to be the defaults. If
>I don't, rld spews warnings throughout, though it doesn't seem to effect
>the outcome.
Right: setting them avoids some warnings but does not affect the outcome.
>From the IRIX rld(1) man page:
For n32 or 64-bit programs, if LD_LIBRARYN32_PATH or LD_LIBRARY64_PATH is
not specified, then rld will honor LD_LIBRARY_PATH if specified.
If you set LD_LIBRARY_PATH but not LD_LIBRARYN32_PATH
rld attempts to use the LD_LIBRARY_PATH path
DSOs in n32 programs and that generates messages.
Messages you cannot even redirect with
normal shell redirects (since rld writes to /dev/tty
if it can (unless rld logging is redirected with -log <filename> in
_RLD_ARGS)). (Similar wording applies to LD_LIBRARY64_PATH).
Example of an annoying rld message:
25150:./a.out: rld: Warning: elfmap: running new 32-bit executable
but finding old 32-bit shared objects with matching DSO
name in the search path. You may not have set the environment
variables correctly, please set LD_LIBRARY_PATH for old 32-bit
objects, LD_LIBRARYN32_PATH for new 32-bit objects and
LD_LIBRARY64_PATH for 64-bit objects -- continue searching ...
Ugly message.
If we simply make these (normally useless) messages about the
DSOs-that-are-the-wrong-ABI be suppressed when the messages are
truly useless then the problem will go away. I have filed a note in
our bug system as a reminder to fix this in rld in some future release.
[ David B. Anderson (415)933-4263 davea@sgi.com ]
------------------------------
Date: 27 Jun 1997 13:01:21 -0500
From: lamont@thrakkorzog.ece.utexas.edu (Lamont Alan Lucas)
Subject: Re: 64-bit compilation of Perl
Message-Id: <5p0v5h$861@thrakkorzog.ece.utexas.edu>
In article <33B3C10E.446B@merck.com>, James J. Heck <jheck@acm.org> wrote:
> sh mv-if-diff tmp lib/Config.pm
>UX:mv: ERROR: tmp - No such file or directory
You remember that warning at the begining of Configure, about some
broken ksh implementations? Well, running irix, that applies to you
buddy. Be sure to use bash ./Configure, just to make sure that
everything works.
As for a 64 bit perl, I've compiled a 32 bit perl on an Origin 200,
which is a 64 bit machine. I assume that's not what you were intrested
in though.
Still, try using a shell other than ksh, and you'll probably get better
results.
------------------------------
Date: Fri, 27 Jun 1997 22:24:35
From: Litagent345@aol.com
Subject: <Writers Seeking Publication>
Message-Id: <33b475c6.0@news1.ibm.net>
We are accepting new and previously published writers for publication. We are a NEW
YORK based international literary agency with three offices: 2 in NEW YORK and
one in FLORIDA. Please follow guidelines for submission:
For all fiction, including screenplays for TV & Movies: Send us a brief synopsis, the
first chapter, and include a self-addressed, stamped envelope=S.A.S.E.
Short Stories: Send brief synopsis, 3 pages, S.A.S.E.
Poetry: Send 3 poems, S.A.S.E.
For all nonfiction: Send us a brief synopsis, the first chapter, and include a S.A.S.E.
Do not send complete manuscript unless invited.
WOODSIDE INTERNATIONAL LITERARY AGENCY>>>
33-29 58 Street>>>
Woodside, New York>>>>
zip: 11377>>>
Tel: 718-651-8145>>>>>
------------------------------
Date: 27 Jun 1997 16:45:25 GMT
From: tina@elfi.adbkons.se ( Tina Marie Holmboe )
Subject: Re: ?: How to copy a file?
Message-Id: <5p0qn5$mnm$1@uabs64.uab.ericsson.se>
[Fri, 27 Jun 1997 12:06:39] [Jay Flaherty]
> M. Mustun (mustun@active.ch) wrote:
>: Hello
>:
>: how can I copy a file in perl?
>:
>
> use File::Copy;
>
> copy("src-file", "dst-file");
And if the original poster still wants to know HOW to copy a file,
and not how to call on libraries, here is a suggestion:
# Open, or die...
open(IN, "<$SourceFile") || die("Unable to open $SourceFile, $!\n" ) ;
open(OUT, ">$TargetFile") || die("Unable to open $TargetFile, $!\n" ) ;
# Sysread in, and syswrite out.
while( sysread(IN, $tmp, 250000) ) {
syswrite(OUT, $tmp, 250000) ;
}
# Close files.
close(OUT) ;
close(IN) ;
There are probably better and more efficient methods out there; not to
mention quite a few almost-one-liner'ers. This, methinks, works quite
nicely though.
--
Tina Marie Holmboe
[ tina@htmlhelp.com ] WDG [ http://www.htmlhelp.com/%7Etina/ ]
[ tina@ifi.uio.no ] University [ http://www.ifi.uio.no/%7Etina/ ]
[ tina@elfi.adbkons.se ] Private [ http://www.elfi.adbkons.se/%7Etina/ ]
------------------------------
Date: Thu, 26 Jun 1997 22:21:00 -0600
From: Keys <keys@babylon5fan.corn>
Subject: Re: Changing environmental variables
Message-Id: <33B33FAC.47D5CB91@babylon5fan.corn>
Ray Mitchell wrote:
>
> Hi all,
> I'm using perl 5 under Windows NT 4.0. Is it possible to change the
> environmental variables from inside a perl script. I've tried adding
> new key/value pairs to the %ENV hash as well as executing `set
> VAR=VALUE` and system "set VAR=VALUE". None of these ideas work. All
> other system commands work fine when executed with backtics or system.
Try setenv instead of set...
--
Keys
Spam sucks. To reply, please change "corn" to "com" in my return
address...
------------------------------
Date: Fri, 27 Jun 1997 21:36:49 -0500
From: Cam Bevis <cbevis@nsinet.corn>
Subject: Commented Complex Regexes?
Message-Id: <33B478C1.303ACA0A@nsinet.corn>
Hello All,
I have found some nice code that doesn't do exactly what I want, and
I would like to modify it. Problem is, it has some REALLY HAIRY regex
patterns in it (you know the ones 80 characters long that look like your
cat danced on the keyboard). I've read and re-read both the perlre man
page and 2.4 of Camel, and can't seem to work through them. I know it
sounds silly, but does anyone know of a site with some fairly complex
patterns that are nicely commented out, step-by-step for an oaf like me?
My next step is to go out and buy Freidel's(sic) text on regexes (I
know, I should already have it), any other suggestions?
--
Cam Bevis
President
NetCom Systems, Inc.
cbevis@nsinet.corn
This message has an anti-spam mechanism-change ".corn" to com to reply
------------------------------
Date: Fri, 27 Jun 1997 11:02:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: David Cross <davidc@wrs.com>
Subject: Re: Compiling with wrapsuid
Message-Id: <Pine.GSO.3.96.970627110131.17693Q-100000@kelly.teleport.com>
On Thu, 26 Jun 1997, David Cross wrote:
> Does wrapsuid need to compile its wrapper scripts in the same directory
> - or at least under the same OS - as the one where they need to be run?
> The machine where things _need_ to work is Solaris
Doesn't Solaris support setuid scripts directly? You shouldn't need
wrapsuid if that's the case. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 27 Jun 1997 15:06:37 -0400
From: sscruggs@widomaker.com (Sam Scruggs)
Subject: Databases
Message-Id: <5p12vt$h9v@wilma.widomaker.com>
I have been programming perl for several months now, and part of what I have
been doing is with simple databases, with entries looking like:
fn:ln:email
Sam:Scruggs:sscruggs@cucinc.com
and then using the split command. My next project requires something slightly
more complex than this. I need the ability to store multiple lines of
info, with carriage returns and other characters.
Perl's documentation does not delve too deeply into it's built-in
commands, and I was hoping someone out there has some resources I could
draw off of.
Thanks,
Sam
(sscruggs@cucinc.com)
------------------------------
Date: 27 Jun 1997 22:15:30 -0500
From: gregory douglas fast <g-fast@ux9.cso.uiuc.edu>
Subject: Re: Detecting dead client sockets
Message-Id: <m7gwwnfs9il.fsf@ux9.cso.uiuc.edu>
Well, I figured out what I was doing wrong, so I'll answer myself.
Trying to read is indeed the Right Way, but the client sockets must be
made non-blocking also...
#--- accept and make non-blocking
$paddr = accept($clients[$n],$server);
fcntl($clients[$n], F_SETFL, O_NONBLOCK);
...
#--- send message to clients ---
for($i=0;$i<@clients;$i++) {
$err = sysread($clients[$i], $x,1);
(close $clients[$i], undef($clients[$i])) if defined($err);
}
#--- remove dead bodies ---
[as below...]
Much nicer.
> smallish) number of clients. It keeps track of the connected clients
> with a list of IO::Handles. In order to do this, I've set the socket
> the server sits on to non-blocking so that I can just try to accept()
> every couple of seconds instead of waiting indefinitely for connections.
>
> I'm trying to come up with a good way of testing whether or not a
> client is still there. The second form of select() doesn't seem to
> return anything useful, and read() and sysread() both seem to block
> until they have something to read regardless of whether or not the
> socket and clients are set to non-blocking.
>
> This is the method I'm currently using to detect dead clients:
>
> #--- send message to clients ---
> $SIG{PIPE} = sub { $pipefail = 1 };
> for($i=0;$i<@clients;$i++) {
> $pipefail = 0;
> print {$clients[$i]} "PROST!\n";
> undef($clients[$i]) if $pipefail;
> }
> $SIG{PIPE} = 'DEFAULT';
> #--- remove dead bodies ---
> $i = scalar(@clients);
> while($i--) {
> $x = shift(@clients);
> push(@clients, $x) if defined($x);
> }
>
> This doesn't seem like the most efficient way to do this... Does
> anyone have any suggestions? I'm more familiar with doing this kind
> of thing in perl than in c, so I may be missing the obvious and
> canonical way of Doing Things.
--
-- Greg Fast --- g-fast@uiuc.edu -------------------------------------------
"Go ask Joven for a little schoolboy, you fecal freak." -- calvin
------------------------------------------------------------------------------
------------------------------
Date: Fri, 27 Jun 1997 23:09:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: editing inputed strings in Perl script
Message-Id: <comdog-ya02408000R2706972309290001@nntp.netcruiser>
In article <33B45597.5242@upnaway.com>, maelstrom@deathsdoor.com wrote:
[redirected to comp.lang.perl.misc]
> Hi, I'm trying to add an exclamation mark to the end of a test string
> that
> a user has sent in from a field. So that if they enter "bob" I get
> "bob!" At the moment the field is held in the array value
> $CONFIG{'word')
> I've tried
>
> @CONFIG(word) = $CONFIG{'word'} + '!';
the concatenation operator is '.', so you would want to do something like
$CONFIG('word') = $CONFIG{'word'} . '!';
you can get more information about Perl's operators in the man pages
or in the Blue Camel [1]
[1]
Programming Perl, Larry Wall, Tom Christensen, & Randal L. Schwartz
ISBN 1-56592-149-6.
<URL:http://www.ora.com>
--
brian d foy <URL:http://computerdog.com>
------------------------------
Date: Fri, 27 Jun 1997 11:30:07 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Adam Tokish <utokiac@lexis-nexis.com>
Subject: Re: Eval'ing arrays
Message-Id: <Pine.GSO.3.96.970627112310.17693Z-100000@kelly.teleport.com>
On Fri, 27 Jun 1997, Adam Tokish wrote:
> sub a_routine
> {
> print "@AN_ARRAY\n";
> }
>
> when I try to bring this guy online using either an eval
> or a require I get an error:
>
> Literal @DESIG now requires backslash at ga.cfg line 48, within string
Yes; Perl won't let you interpolate an array like that if it hasn't seen
you use the array already (when it gets there at compile time).
You can get the same result without the error by using this code.
sub a_routine {
print join($", @AN_ARRAY), "\n";
}
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 27 Jun 1997 19:30:31 GMT
From: "David Richards" <dave@turfpit.demon.co.uk>
Subject: Re: Event Log Reporting - Doesn't Work
Message-Id: <01bc8330$a74dbd90$0101010a@turfpit>
Frank Huddleston <Frank.Huddleston@guardian.brooks.af.mil> wrote in article
<01bc8272$15f631b0$70058c8c@oepc05112>...
>
> Greetings,
>
> I've been trying to run a script which prints events from a
> system's event logs. I copied this script from somewhere, I think a Byte
> Magazine article, and I think I ran it successfully with an earlier
version
> of perl - which one I don't remember. I did have problems trying to
select
> a certain kind of event, so that I could print out only errors, but at
> least the script would print the last n event entries. Now I revisit it
> after a while, and I've tried builds 302, 304, and 306. All produce the
Frank
Try this - straight from the docs for Win32 Perl build 306. Works for me
on NT4 SP3 with build 306.
use Win32::Eventlog;
sub TEST1
{
my $number, $EventLog;
Win32::EventLog::Open($EventLog , "System", '') || die $!;
$EventLog->GetNumber($number) || die $!;
print "There are $number records in the System Event Log\n";
}
TEST1;
Note the order of Open parameters is 'eventlog' then 'server'. The 3rd
parameter is null for default server. The docs now match the code !
David
------------------------------
Date: Sat, 28 Jun 1997 02:20:28 -0400
From: Oliver Giller <oliver@inetu.net>
Subject: File Flush
Message-Id: <33B4AD2C.1B77DAD1@inetu.net>
I have looked through both Cammel books and can't find it.
How do I fflush a file, like in C?
Thanks
Oliver
--
-------------------------------------------------------
Oliver Giller mailto:oliver@inetu.net
Pagemaster http://www.inetu.net/
-------------------------------------------------------
------------------------------
Date: Fri, 27 Jun 1997 17:02:37 GMT
From: mupe@desk.nl (M. muPe)
Subject: Re: Fun with ".cgi contained no blank line separating header and data"
Message-Id: <5p0od6$g4h$1@news2.xs4all.nl>
In article <5p0ca4$2c8_002@interaccess.interaccess.com>, shelle@interaccess.com (Shelle) wrote:
>OK, we're dealing with a Win95 (rev. b) system, running WebSite 1.1e, and Perl
> for Win32 5.003_07:
>
>This Server Error 500 message has plagued me for weeks with various scripts
>Although I'm feeling somewhat vindicated in that I can see the content-type
>info followed by 2 spaces print from the DOS command line, it really doesn't
>help too much to kill the problem.
>
Folowed by two spaces?? It must be 2 new lines "\n\n"
Hope your problem was as simple as that.
Mathilde muPe
------------------------------
Date: Fri, 27 Jun 1997 17:03:41 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: perrella andrew c <perrella@ehsn6.cen.uiuc.edu>
Subject: Re: Help with getting file contents
Message-Id: <33B3E45D.31DF@adc.metrica.co.uk>
perrella andrew c wrote:
>
> How do you get read the contents of a file into a scalar variable?
>
> This has me stumped. I'd like to take a file in the same directory as my
> script and end up with a scalar, for example $file_contents, that contains
> the contents of the file I want.
>
> any ideas?
>
> thanks,
>
> Andrew Perrella
> perrella@uiuc.edu
You do this by undefining the input record seperator and slurping the
whole file into your variable.
undef $/;
$file_contents = <FILE>;
$/ = '\n';
Take care if you are going to do any pattern matching or substitution on
this scalar. You will want to look at the /m operator.
Simon
------------------------------
Date: 27 Jun 1997 17:16:44 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help with getting file contents
Message-Id: <5p0shs$flu$1@marina.cinenet.net>
perrella andrew c (perrella@ehsn6.cen.uiuc.edu) wrote:
: How do you get read the contents of a file into a scalar variable?
:
: This has me stumped. I'd like to take a file in the same directory as my
: script and end up with a scalar, for example $file_contents, that contains
: the contents of the file I want.
The easiest way is:
undef $/; # Input record separator turned off.
open(DATA, "<myfile.dat") or die "Can't open data file: $!\n";
$file_contents = <DATA>;
close(DATA);
Turning off the input record separator causes the entire file to be read
in as one long string, with newlines intact.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 27 Jun 1997 11:20:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Sascha Ottolski <sascha@ella.ww.tu-berlin.de>
Subject: Re: how compute variable names from other variables in a loop ?
Message-Id: <Pine.GSO.3.96.970627111745.17693X-100000@kelly.teleport.com>
On 27 Jun 1997, Sascha Ottolski wrote:
> Since I need to stat several files in several scripts I want to do this
> in a loop to avoid typing lots of stuff again and again, and to use many
> variables to make it easily reusable;
Yes; you're doing this with soft links, which are potentially scary.
> I'm wondering if there is a more elegant way to do this, maybe with
> hash-lists or more arrays or whatever...
Yes, there is. Make a hash whose keys are the filenames (or whatever other
data you wish, as a string). You'll probably want to use references, so
see perlref(1), perllol(1), and perldsc(1). Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 27 Jun 1997 18:56:27 GMT
From: "mashfiel" <ashfield.matthew@miti.nb.ca>
Subject: How do I decipher Time format?
Message-Id: <01bc8262$293e83e0$3e080a0a@mashfiel.miti.nb.ca>
sorry if this was double posted
Hi,
I have what I think to be a rather difficult question. I have a log of
occurences of things, the log being updated every 5 minutes for 24 hours.
Each entry in the log has a time entry given in the time() format ( ie.
866575492, which would translate somewhow into Tue Jun 17 16:24:42 97). My
question is how does Perl do this translation. I used the localtime()
function to do it for me, but I think I need to know how it did this. This
is because as mentioned before, my log polls every 5 minutes. However if I
only want to extract the entries from say 8:30 am to 4:30 pm, I must have
to figure out how the localtime() function deciphers hours, minutes and
seconds. My program has to work for different days, so my extract has to be
able to only extract based on hours minutes and seconds, not days or years.
Any help/advice would be greatly appreciated. Note: I looked in the man
page and it said that the time() function got broken down into:
"9-element array" set up as
"$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst"
but how does 866575492 get broken into these 9 elements. Going by this,
then $sec couldn't be bigger than 9 could it?
Anyway this is probably all very confusing, but any help/advice would be
greatly appreciated, preferably via email.
Thanks for your time,
Matt
ashfield.matthew@miti.nb.ca
------------------------------
Date: Fri, 27 Jun 1997 10:25:45 -0500
From: Bryan Hart <bryan@eai.com>
Subject: Re: How to get browser window size?
Message-Id: <33B3DB79.41C6@eai.com>
Tina Marie Holmboe wrote:
>
> [Wed, 18 Jun 1997 06:12:09] [Zonycat]
>
> > I am trying to get the size of my browser window or anybody's browser
> > window that displays my WEB page. Is there an environmental variable or
> > cookie I could look at to see the window size?
> > I am trying to dynamically resize my images I display depending on the
> > window size. Basically different people have different screen sizes.
>
> In short: it isn't possible. Some browsers *may* send such information, but
> it is as far from a standard as it is possible to come.
It is possible, but it requires javascript calling java methods. Check
out comp.lang.javascript - I posted an answer to this a few days ago.
>
> The question is also *abit* off-topic for comp.lang.perl.misc; followups
> set accordingly.
Agreed!
Bryan
--
-------------------------------
| Bryan Hart
| Network Products Engineer
| Engineering Animation Inc.
| Phone: (515) 296-5979
| Fax: (515) 296-7025
| Email: bryan@eai.com
| Web: http://www.eai.com/
-------------------------------
"A conclusion is simply the place where you got tired of thinking"
------------------------------
Date: 27 Jun 1997 20:34:00 GMT
From: jk0101@medtronic.com (John W. Komp)
Subject: Re: Inconsistent crossplatform Pack!?
Message-Id: <5p183o$h6c$1@gazette.corp.medtronic.com>
John W. Komp (jk0101@medtronic.com) wrote:
[problem with pack varying between Unix and DOS deleted]
Problem solved! Declaring the file with binmod took care of the
funnies on the DOS side of things.
Thanks for all the help from everyone that e-mailed me. The solution
worked like a champ.
-John
--
****************************************************
This morning I shot six holes in my freezer
I think I've got cabin fever
Somebody sound the alarm
- J. Buffett
****************************************************
------------------------------
Date: 27 Jun 1997 13:45:40 GMT
From: "Brian Gruttadauria" <Brian_Gruttadauria@dg.com>
Subject: Newbee Perl Question.. Perl5 and NT?
Message-Id: <01bc8300$07a56610$45efdd80@slick>
I am trying to perform a simple sed string replace
using Perl5 on NT.
perl.exe -pi.bak -e 's/foo/bar/g' filename.ini
filename.ini contains:
foo test
foo
test test
It does nothing to the file???
Is the string replace feature supported on perl5 for NT
or is there something I am missing?
------------------------------
Date: Fri, 27 Jun 1997 11:16:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Gruttadauria <Brian_Gruttadauria@dg.com>
Subject: Re: Newbee Perl Question.. Perl5 and NT?
Message-Id: <Pine.GSO.3.96.970627111528.17693W-100000@kelly.teleport.com>
On 27 Jun 1997, Brian Gruttadauria wrote:
> I am trying to perform a simple sed string replace
> using Perl5 on NT.
>
> perl.exe -pi.bak -e 's/foo/bar/g' filename.ini
I think that on NT you have to use double quotes in command lines where a
Unix user would use single quotes. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 27 Jun 1997 19:22:45 GMT
From: martin@chebs.demon.co.uk (*/chebs)
Subject: no. of days between two dates ?
Message-Id: <33b612e1.11233294@news.demon.co.uk>
Hi
can anyone help me with this one I have been trying to
calculate the difference in days between two dates in a form
with out much success.
all my attempts are way to complicated and I can't work out how to adjust
for the different no. of days in the months and leap years.
Any help towards my understanding of this or example code would be great
thanks
martin
@chebs.demon.co.uk
------------------------------
Date: 27 Jun 1997 16:50:28 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: Novell's ActiveX controls w/NT Perl 5 -doh!
Message-Id: <5p0r0k$n9p@srvr1.engin.umich.edu>
[ mailed and posted ]
In article <33B26D00.A7170B05@gre.ac.uk>,
Robert Rainthorpe <R.J.Rainthorpe@gre.ac.uk> wrote:
>
>Incidentally, is anyone using the Perl 5.004 for NT that has been ported
>by Gurusamy Sarathy <gsar@umich.edu>?
Just to make it clear, the win32 support in the official 5.004 distribution
and later was developed by many people that hang out on the perl5-porters
list. It is by no means a solo effort.
- Sarathy.
gsar@umich.edu
------------------------------
Date: 28 Jun 1997 01:04:19 GMT
From: Tim Rueger <rueger@io.com>
Subject: Re: passing sort subroutines?
Message-Id: <5p1nuj$d8a$1@nntp-2.io.com>
In article <ECC30v.H22@world.std.com> Andrew M. Langmead, aml@world.std.com writes:
> Tim Rueger <rueger@io.com> writes:
> >But (well, I wouldn't be posting if it worked), it doesn't work. What's
> >the right way to think about implementing this? If I need to use
> >anonymous subs, how do I dereference them? Thanks...
>
> It works for me. I just tested it. Ran it through the debugger. It
> uses the feature shown in the perlfunc man page of giving sort a
> scalar that contains the name of a subroutine.
>
> What problems were you having with it?
It turns out things were working just fine. I was using the -w flag (I
hadn't used it much before), so I was getting messages along the lines
of:
Use of uninitialized value at ./sort_all line 76, <> chunk 4370.
occasionally when the sort routines were invoked. The snippet I posted
was the simplest way of expressing what I was trying to do; the actual
code was bigger and hairier, and the input data was less well-behaved
than the code implied.
I presumed this message was indicating some fatal error. I neglected to
check that the actual output was, in fact, correct. (augh...)
Thanks for all the replies - some of you posted or emailed deeply
magical code that will take some effort to grok...
-Tim
--
Tim and/or Shelley Rueger - rueger "at" io.com
WWW page: http://www.io.com/~rueger/
------------------------------
Date: Fri, 27 Jun 1997 12:11:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bonita Dattner-Garza <drajg@conetic.com>
Subject: Re: Perl Extensions -- how to write, etc...
Message-Id: <Pine.GSO.3.96.970627121004.17693d-100000@kelly.teleport.com>
On Fri, 27 Jun 1997, Bonita Dattner-Garza wrote:
> I am looking for information of how to write PERL Extensions
Is there something which the manpages don't tell you? Start with perlmod
and perlxs and see where those take you. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 26 Jun 1997 12:04:18 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Regexp with exclusion
Message-Id: <33B2A112.1B92C3FF@gpu.srv.ualberta.ca>
Simon Fairey wrote:
!
! Per Olesen wrote:
! >
! > Hello
! >
! > I need a way to substituate multi whitespace with
! > single whitespace globally in a string. BUT. Everything
! > in the string, which is enclosed within " must NOT
! > participate in the substitution.
! >
! > example:
! >
! > $line = 'hello world "dab dab dab" more';
!
! Not sure how easy this would be to do with a regexp, I suspect it
! might not be possible ( waiting for a real regexp wiz to prove me
well, I'm certainly not a 'real regexp whiz', not even an
artificial one :-)
but a simple version of a regex solution (with caveats) is
given below...
! wrong ) but I will be interested to see what people come up with.
! My quick attempt would be as follow:
!
! #!/bin/perl
!
! $string = 'hello world "dab dab dab" more hello world "dab
! dab dab" more';
!
! @temp=split(/"/,$string);
! for($i=0;$i<=$#temp;$i++){$i%2 or $temp[$i] =~ s/\s+/ /g}
! $string = join("\"",@temp);
!
! print "\n$string";
!
! Here it is only going to remove spaces from every even field thus
! hopefully avoiding those in double quotes. You will need to add a
! check though to see if the string starts with " if it does then
! you want to process every odd field. Additionally you might also
! want to check that there is an even number of " in the string in
! the first place otherwise you may run into problems with things
! like 'foo bar " um what now'.
Well, if in fact you might have strings with embedded newlines,
you might not want to replace \s+ with a space, because if there
is a space and a newline, this will replace it with just a space
and mess up your linebreaks.
The following matches either: 1) a double quoted sub-string, and
replaces it with itself; or 2) multiple spaces and replaces with
just a space --- in the $_ string below, the third logical line
ends with 3 spaces and a newline...the spaces will be compressed
but the newline will remain (if you want to compress newlines when
combined with one or spaces, change the second alternative
from ' +' to '\s+'):
$_ = '"" blah blah "x x x"blah" x x" blah
blah blah "x
x x x" blah
blah blah';
s/(\"[^"]*\")| +/$1?$1:" "/ge;
print;
note: this one does not allow for escaped quotes--- and
it is entirely possible that I've not taken some other obvious
or not-so-obvious possibility into account...:-)
regards
andrew
------------------------------
Date: 27 Jun 1997 15:42:55 GMT
From: andrew@pimlott.student.harvard.edu (Andrew Pimlott)
Subject: Re: Regexps on streams
Message-Id: <slrn5r7ntu.6dj.andrew@pimlott.student.harvard.edu>
On 26 Jun 1997 22:21:26 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>In article <Pine.GSO.3.96.970626070536.9758H-100000@kelly.teleport.com>,
>Tom Phoenix <rootbeer@teleport.com> wrote:
I'm very happy to hear you are putting this feature into the RE code. I've
been thinking about it some more, and have a few comments.
>> Agreed! :-) If using a RE on a stream does get into the core, it would
>> really help if there were some way for Perl to be able to warn or abort
>> when a regular expression is thrashing, since it will be an easy feature
>> to misunderstand and misuse.
>
>What does it mean "thrashing" in this context? Anything specific can
>be implemented, but you need to know first what to implement.
thrashing == swapping. Tom's suggesting some way to bail out before the
entire (possibly huge) stream is read into memory. I agree that this is
very useful. One handy form of this would be to pass a maximum number of
lines (or calls to the refill function) over which the RE may spread.
>> > The only reason it is not in the jumbo patch is that before your post
>> > I could not squeeze an extra argument (refilling function and data)
>> > into the RE engine API. Your post somehow triggered an idea how to do
>> > it... ;-)
>>
>> Oh, no. :-) Well, if a user-function is going to re-supply the stream
>> data upon request, will there be some way for it to report failure? The
>> reason I ask is because I'm thinking of what will happen if you abort a
>> match halfway through. Where does control continue? Or is that event like
>> a die() which could be trapped within eval{}?
>
>RE code is safe wrt die()ing inside. And the function can reply that
>in added 0 bytes to the string, which clearly indicates a failure.
This refill function is a regular perl function, right? Will it get called
every time we get to the end of the string, or only when we have a potential
match going (or will both be possible!)? I would like the second to be
supported, since it's usually more convenient to consider the data line by
line (despite the fact that my original question was on streams). For
example, suppose I want to make two replacements (both possibly across
multiple lines, of course)--then I want to read in one line at a time any
only get more if it looks like the next line(s) could complete a match. So
my code might look something like this:
$refill_function = sub { scalar <> };
while (<>) {
# somehow associate $refill_function with the following two
# substitutions
s/Camelus(\s+)bactrianus/Camelus${1}dromedarius/;
s/Tom(\s+)Phoenix/Ilya${1}Zakharevich/; # er, no significance to this
print;
}
$_ might be "grown" due to refills by either substitution. This does bring
up some annoying questions, however, like what happents if the second s///
calls the refill function once to get a match, and that second line would
have been matched by the first s///? Ideally, there might be another
function to "put back" lines grabbed for refills after the substitution has
been made, or at least a way to figure out how many times the refill was
called on a particular match... Anyway, this may be more complicated than
what you want to build into the engine, but it would be cool. Any thoughts
on how it could be done?
>> Also, if you've got a user function which can source the stream, it's only
>> a small leap to having another user function to be a sink, thereby
>> enabling s/// to work directly upon (yow) entire files of unlimited size.
>
>Yes, this is a part of specification. ;-)
Neat! If it is (or becomes) available anywhere, I'd love to see exactly
what you have in mind.
Andrew
------------------------------
Date: Fri, 27 Jun 1997 12:32:08 -0400
From: SS <ss51@columbia.edu>
Subject: simple open statement gives me error
Message-Id: <33B3EB08.41C6@columbia.edu>
what is wrong with
open(MOL1, "$ARGV[0]") || die "$ARGV[0] doesn't exist\n";
it gives me the warning (when run with -w flag)
Possible typo: "MOL1" at int_area line 3
SS
------------------------------
Date: Fri, 27 Jun 1997 18:26:35 GMT
From: tram@olympic.seas.ucla.edu (Tri Tram)
Subject: strings
Message-Id: <ECG5wC.J92@seas.ucla.edu>
I am wondering, is there a string to integer conversion under perl?
If I have a string:
$string="44";
if ($string > 10)
{
print "$string is greater than 10";
}
Thanks.
-----------------------------------------------------------------
Tri Tram, Computer Science and Engineering at UCLA
http://www.seas.ucla.edu/~tram
------------------------------
Date: Thu, 26 Jun 1997 14:52:07 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: Stumped ....
Message-Id: <b.wilkinson-2606971452070001@ip57-york.pindar.co.uk>
In article <33B1BC00.7C1F@jpmorgan.com>, Arun Saxena
<saxena_arun@jpmorgan.com> wrote:
> Folks,
>
> This is what I am trying to do ..... Replace the following
> text
>
> kkkk d;ckdk ;dkckd kkk k kd
> ddk dkd dkkdk dkkd
> kkdk kddd kkk d kkk
>
> with
>
> kkkk\5 d:ckdk ;dkckd kkk\7 k\8 kd
> ...
>
> ( Basicall replace 4 or more spaces w "\<cnt # of spaces> "
> I am having one hell of a time with this. I would think the
> following would work, but it does not
>
> s/(\s{4,})/join (\s, \ length$1)/eg
>
> Please also email me any suggestions...
>
>
> Arun
>
> saxena_arun@jpmorgan.com
Hello,
Your substitution expression is almost correct. This works for me.
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
s/( {4,})/"\\" . length($1) . " "/eg;
print;
}
__END__
kkkk d;ckdk ;dkckd kkk k kd
ddk dkd dkkdk dkkd
kkdk kddd kkk d kkk
----------------------------
Output is
kkkk\5 d;ckdk ;dkckd kkk k\4 kd
ddk\6 dkd dkkdk\5 dkkd
kkdk kddd kkk d\6 kkk
--
Do what thou wilt shall be the whole of the law.
------------------------------
Date: 28 Jun 1997 03:10:46 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: tchrist's insulting email
Message-Id: <eli$9706272309@qz.little-neck.ny.us>
Netusa.net is *NOT* a "spam-hosting site". I generally killfile
people who send me these things. IT IS VERY INSULTING TO BE
BOUNCED BECAUSE OF A SUPERFICIAL SIMILARITY IN DOMAIN NAME THAT
COULD BE NOTICED BY CHECKING WORD BOUNDRIES.
Elijah
------
From MAILER-DAEMON Fri Jun 27 22:53:13 1997
Return-Path: <MAILER-DAEMON>
Received: from jhereg.perl.com (199.45.129.30) by NetUSA.Net with smtp
(Linux Smail3.1.28.1 #1) id m0whncT-001vx1C; Fri, 27 Jun 97 22:52 EDT
Received: from localhost (localhost) by jhereg.perl.com (8.7.4/8.7.3) with internal id UAA30657; Fri, 27 Jun 1997 20:50:40 -0600
Date: Fri, 27 Jun 1997 20:50:40 -0600
From: Mail Delivery Subsystem <MAILER-DAEMON@jhereg.perl.com>
Subject: Returned mail: Service unavailable
Message-Id: <199706280250.UAA30657@jhereg.perl.com>
To: <eli@NetUSA.Net>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="UAA30657.867466240/jhereg.perl.com"
Auto-Submitted: auto-generated (failure)
JMDigest-Score: good 0
This is a MIME-encapsulated message
--UAA30657.867466240/jhereg.perl.com
The original message was received at Fri, 27 Jun 1997 20:46:40 -0600
from Mail.NetUSA.Net [204.141.0.25]
----- The following addresses have delivery notifications -----
"|/home/tchrist/.audit_mail tchrist" (unrecoverable error)
(expanded from: tchrist)
----- Transcript of session follows -----
Mail from known spam-hosting site rejected
554 "|/home/tchrist/.audit_mail tchrist"... Service unavailable
--UAA30657.867466240/jhereg.perl.com
Content-Type: message/delivery-status
Reporting-MTA: dns; jhereg.perl.com
Received-From-MTA: DNS; Mail.NetUSA.Net
Arrival-Date: Fri, 27 Jun 1997 20:46:40 -0600
Final-Recipient: RFC822; perlbug@jhereg.perl.com
Action: expanded (to multi-recipient alias)
Status: 2.0.0
Last-Attempt-Date: Fri, 27 Jun 1997 20:50:40 -0600
Final-Recipient: RFC822; perlbug@jhereg.perl.com
X-Actual-Recipient: RFC822; |/home/tchrist/.audit_mail tchrist@jhereg.perl.com
Action: failed
Status: 5.5.0
Last-Attempt-Date: Fri, 27 Jun 1997 20:47:40 -0600
--UAA30657.867466240/jhereg.perl.com
Content-Type: message/rfc822
Return-Path: eli@NetUSA.Net
Received: from NetUSA.Net (Mail.NetUSA.Net [204.141.0.25]) by jhereg.perl.com (8.7.4/8.7.3) with SMTP id UAA30646 for <perlbug@perl.com>; Fri, 27 Jun 1997 20:46:40 -0600
Received: from Alpha.NetUSA.Net (204.141.0.10) by NetUSA.Net with smtp
(Linux Smail3.1.28.1 #1) id m0whnWs-001vx1C; Fri, 27 Jun 97 22:46 EDT
Received: by Alpha.NetUSA.Net (Linux Smail3.1.28.1 #1)
id m0whnWq-001yXmC; Fri, 27 Jun 97 22:46 EDT
Message-Id: <m0whnWq-001yXmC@Alpha.NetUSA.Net>
Date: Fri, 27 Jun 97 22:46 EDT
From: eli@NetUSA.Net (Eli The Bearded)
To: perlbug@perl.com
Subject: perlembed sample code bug
Reply-To: eli@alpha.netusa.net
This is a bug report for perl from eli@alpha.netusa.net,
generated with the help of perlbug 1.17 running under perl 5.004.
-----------------------------------------------------------------
[Please enter your report here]
The perlembed documentation includes some sample code which has
some long strings in it. The code mallocs space for these strings
using hardcoded constants. These constants should include some
slack. Code cut and pasted from formatted versions of the
documentation are likely to have different embedded whitespace,
particularly on folded lines. Malloc'ing more space than needed,
such as double the string length, would provide some more slack
in these cases. Even better might be some sort of string
concatenation, eg 'sprintf(text,"This" "Is" "One" "Long" "String");'.
It would probably be good for perlembed to stress more the usefulness
of reading perlguts as well:
myStr=perl_get_sv("main:str",TRUE);
...
sv_setpv(myStr,foo);
is a lot handier than
sprint(text,"$str='%s';",foo);
...
perl_eval_pv(text,TRUE);
if only because you don't have to worry about q:': in foo...
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Site configuration information for perl 5.004:
Configured by eli at Tue May 27 12:39:42 EDT 1997.
Summary of my perl5 (5.0 patchlevel 4 subversion 0) configuration:
Platform:
osname=linux, osvers=2.0.30, archname=i586-linux
uname='linux alpha 2.0.30 #1 tue apr 22 23:51:59 edt 1997 i586 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=n useperlio= d_sfio=
Compiler:
cc='cc', optimize='-O2', gccversion=2.6.3
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
stdchar='char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=4, usemymalloc=n, randbits=31
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -ldld -lm -lc
libc=/lib/libc.so, so=so
useshrplib=true, libperl=libperl.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags='-rdynamic -Wl,-rpath,/u1/home/eli/lib/perl5/5.004/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
---
@INC for perl 5.004:
/u1/home/eli/lib/perl5/5.004
/u1/home/eli/usr/lib/perl5
/u1/home/eli/lib/perl5/site_perl/i586-linux
/u1/home/eli/lib/perl5/site_perl
.
---
Environment for perl 5.004:
PATH=/home/eli/bin:/usr/X11R6.1/bin:/bin:/usr/bin:/usr/local/bin:/usr/X386/bin:/usr/TeX/bin:/usr/bin/X11:/usr/TeX/bin:/usr/openwin/bin:/usr/games:/home/eli/usr/bin
LD_LIBRARY_PATH (unset)
PERL_BADLANG (unset)
--UAA30657.867466240/jhereg.perl.com--
------------------------------
Date: Sat, 28 Jun 1997 03:02:35 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: Trapping the output of the System command into a variable
Message-Id: <33b47d07.2064698@news.oz.net>
On Fri, 27 Jun 1997 15:17:31 -0700, venugopal koppala
<kvenug@hotmail.com> wrote:
>Hi,
>
>I am in the process of converting Unix shell scripts into Perl.
>
>Any body can suggest me how to Trap the output from system command into
>a variable.
Nope. But you can try using backticks or an open with a pipe:
$stuff = `command`;
open PIPE "command |";
-- Tim Gim Yee tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"
------------------------------
Date: 27 Jun 1997 16:09:30 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: Trickey Regex... need thoughts
Message-Id: <slrn5r7pdp.65r.deckers@news.rediris.es>
In <spectranECFyK8.DBn@netcom.com>,
Tracy Bednar <spectran@netcom.com> wrote:
>I am trying to parse some db text files. They look like this:
>
>clientname character(60,1) Not Null
>action_item text(80,80,80,1) Not Null
>date date(3) Not Null
>
>The "Not Null" is optional. I am trying to grab the numbers between
>(..) especially the first number.
(Untested, but looks fairly straightforward.)
while (<>) {
m/\(([\d,]+)\)/;
@nums = split /,/, $1;
# ...
}
HTH,
Alain
--
Perl information: <URL:http://www.perl.com/perl/>
Perl archive: <URL:http://www.perl.com/CPAN/>
Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: Fri, 27 Jun 1997 17:36:10 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Tracy Bednar <spectran@netcom.com>
Subject: Re: Trickey Regex... need thoughts
Message-Id: <33B3EBFA.237C@adc.metrica.co.uk>
Tracy Bednar wrote:
>
> I am trying to parse some db text files. They look like this:
>
> clientname character(60,1) Not Null
> action_item text(80,80,80,1) Not Null
> date date(3) Not Null
>
> The "Not Null" is optional. I am trying to grab the numbers between
> (..) especially the first number.
>
> I've come up with
> $line =~ m/(.*\()(.*\,)(.*\))(.*)/;
> and
> $line =~ m/(.*\()(.*,)+(.*)/
>
> where $line = one of the above lines. Niether regex works
> correctly. It grabs up to the first "(" ok, but then the problems
> occur.
>
> I thought it would be something like, grab .* to each comma,
> continue this until you reach ")", which would end the (..).
> Each of these grabs goes into $2, $3, $4, etc. Then I can strip the
> trailing character off.
>
> Thnx,
>
> - T
Try this
#!/bin/perl
open(DB_FILE, 'db_filename') or die "Unable to open file: $!.";
while(<DB_FILE>){
# Extract the bit inside the parentheses.
/^[^(]*\(([^)]*)/;
# Split the result on ',' and generate an array of the numbers.
@nums = split( /,/, $1 );
# Now do whatever you wish with the numbers in @nums
print "\nNumbers from line are ", join( " ", @nums );
}
close DB_FILE;
If you get stuck trying to understand the regexp ( or why yours failed )
then shout. I tend to find decipher what a working regexp is actually
doing can be quite enlightening :)
Simon
------------------------------
Date: 27 Jun 1997 19:14:52 -0700
From: jcr@idiom.com (John C. Randolph)
Subject: Re: Trickey Regex... need thoughts
Message-Id: <5p1s2s$fs1@idiom.com>
This is a job for tr///!
using tr/// should be about as fast as the regex in this situation,
and it's a whole lot simpler. The line:
tr/0-9\,//cd;
will throw out any characters in $_ that aren't digits or commas, and
that leaves you with a simple split() call to extract the values.
-jcr
spectran@netcom.com (Tracy Bednar) writes:
>I am trying to parse some db text files. They look like this:
>clientname character(60,1) Not Null
>action_item text(80,80,80,1) Not Null
>date date(3) Not Null
>The "Not Null" is optional. I am trying to grab the numbers between
>(..) especially the first number.
>I've come up with
>$line =~ m/(.*\()(.*\,)(.*\))(.*)/;
>and
>$line =~ m/(.*\()(.*,)+(.*)/
>where $line = one of the above lines. Niether regex works
>correctly. It grabs up to the first "(" ok, but then the problems
>occur.
>I thought it would be something like, grab .* to each comma,
>continue this until you reach ")", which would end the (..).
>Each of these grabs goes into $2, $3, $4, etc. Then I can strip the
>trailing character off.
>Thnx,
>- T
------------------------------
Date: 28 Jun 1997 01:24:31 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Very Basic Perl Question on Array
Message-Id: <5p1p4f$9tm$1@neocad.com>
hcchan@wellsfargo.com wrote:
: I am new to Perl and have a very basic question.
Then you should go to www.perl.com and find the link to the
FAQ. This will save all of us much heartburn.
: How do I write up a perl program which will create an array.
: I have a file which contains the name of tablespaces in Oracle and
: will be insert into the array.
: The size of tablespace grows/shrink dynamcially, so it
: may be different each day. And I don't know how big
: an array I should set aside.
You don't need to know in perl. For example, if we're talking
flat text file, one entry per line:
open FILE, $file_name;
@entries = <FILE>;
close FILE;
HTH
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 676
*************************************