[7262] in Perl-Users-Digest
Perl-Users Digest, Issue: 887 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 18 19:09:13 1997
Date: Mon, 18 Aug 97 16:00:23 -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 Mon, 18 Aug 1997 Volume: 8 Number: 887
Today's topics:
a regexp for compiler syntax :) (Terry Michael Fletcher - PCD ~)
Re: BeagleSQL now as a Perl API (Mike Stok)
Re: emacs? No thank you (Ronald L. Parker)
Re: fly, gd.pm help? (Matthew Burnham)
Re: hel[p <petri.backstrom@icl.fi>
Re: How do I find the system date/time? <flavell@mail.cern.ch>
Re: how to use format to build strings (Matthew Burnham)
HTML-TEXT (<b>Michael (Sandman) Sandler</b>)
Re: HTML-TEXT <zenin@best.com>
IPC Open2 question (Teebu Philip)
Re: JAPH (was: function pointer dereferencing) (Terry Michael Fletcher - PCD ~)
Looking for efficient suggestions for searching a file randy.paries@avex.com
Re: Looking for efficient suggestions for searching a f (Mike Stok)
Need some explanation about unpack. (dave)
oracle->perl frontend <kluff@enterprise.net>
Re: Overriding Functions in Modules, i.e. File::Find ls (Stuart Poulin)
Re: Pattern repacement with variables question <mark@pbi.net>
Re: Q: assoc. arrays as subroutine argument <petri.backstrom@icl.fi>
reading and writting to the same file <dev@sgi.net>
Re: reading remote files (Matthew Cravit)
regex opinions wanted <dturley@rocketmail.com>
ShowTable <jdlong00@pop.uky.edu>
Re: The user and his hotline... (was: Date::Manip Error (Thomas L. Bodine)
What is the most effiecent way to search a file randy.paries@avex.com
Re: Win32 Perl & UNC names - Problem? ("John Dallman")
Re: XS (converting perl array to char**..) <buzz@bear.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Aug 1997 22:15:08 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: a regexp for compiler syntax :)
Message-Id: <5tahhc$7qo$1@news.fm.intel.com>
here's a regexp problem that maybe some of you (if you're like me) regexp
lovers can mull over.
i have a two-pass compiler that translates into Perl on the first pass,
then executes it on the second. there is a small set of 3-letter commands
(really Perl subroutines) for this language, the names of which arent
important. what is important is that i allow for the following syntaxes
(that have already been decided):
cmd "<arguments with or w/out embedded double quotes>";
cmd <arguments with or w/out embedded double quotes, but not trailing>;
cmd (<arguments with or w/out embedded double quotes>);
cmd ();
cmd;
# the angle brackets arent really there, by the way
the arguments are actually a list, but the items in the list *may contain
double quote chars* as part of their string, and also may be Perl
variables (whew!), like this:
cmd (blah,$yippee,stuff=x"junk",hmmm=x"hey");
what i do is take that argument list, and convert it into one interpolated
string, and the subroutine knows how to handle it, like this:
cmd (qq|blah,$yippee,stuff=x"junk",hmmm=x"hey"|);
here are my (uncommented, because they kept changing) regexp's and
substitutions:
if (/(cmd)[^\;]+\;/) {
$cmd = $1;
(m/(cmd)\s*(\(\))?\s*\;/ ||
s/(cmd\s+)[\("]?\s*(\w[^\;]+[^"\)]{1})(?:(")"\s*\;|(")\)\s*\;|"\s*\;|\)\s*\;|\s*\;)\s*/$1\(qq|$2$3$4|\)\;\n/)
|| warn "Warning: possible misuse of the command \"$cmd\" at $file line $..\n";
}
this is disgustingly ugly, and appears incredibly cryptic to the regexp
impaired, even with the /x and inserted comments. if anyone finds this
kind of stuff fun and can offer suggestions on simplifying, i'll gladly
take them!
--
"Give me ambiguity or give me something else."
______ ______ _ _
(_) | (_) | | | | |
| _ ,_ ,_ _|_ | | _ _|_ __ | | _ ,_
_ ||/ / | / | | | / | ||/ |/ | / |/ \ |/ / |
(_/ |__/ |_/ |_/ \_/|/ (_/ |__/|__/|_/\___/| |_/|__/ |_/
*+*+*+*+*+*+*+*+*+*+*+* /| *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
\| tfletche@pcocd2.intel.com
*+*+*+*+*+ Views expressed...not INTeL's...yadda yadda yadda.... *+*+*+*+*+*
------------------------------
Date: 18 Aug 1997 20:31:43 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: BeagleSQL now as a Perl API
Message-Id: <5tabff$og5@news-central.tiac.net>
In article <Pine.SGI.3.95q.970813173116.11548A-100000@triton.towson.edu>,
Robert Klein <rklein@triton.towson.edu> wrote:
>
>A Perl API has been added for all you Perl guys.
>You can learn more about Beagle at http://www.beaglesql.org
Looks interesting, are you aware of the DBI/DBD mechanism which is used
by Perl 5 to allow a common database interface to different drivers? You
might want to look at http://www.hermetica.com and follow the DBI link to
see what's going on. This is in no way a sleight on the work you have
done (which I'll have to grab later...)
Regards,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 18 Aug 1997 22:02:58 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: emacs? No thank you
Message-Id: <33f8c648.3961248@207.126.101.82>
On Fri, 15 Aug 1997 08:12:48 -0500, pudge@pobox.com (Chris Nandor)
wrote:
> Very functional, not very good UI.
>A Microsoft employee must have written it.
No, then it would have a flashy UI with lots of bells and whistles
that only work "most of the time."
------------------------------
Date: Mon, 18 Aug 1997 21:41:47 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: fly, gd.pm help?
Message-Id: <3403b928.28186565@news.enterprise.net>
Matthew Knight <matt@geenite.demon.co.uk> wrote:
>can anyone who is familiar with gd.pm or fly give me a run down on how
>to install it on a unix machine. i'm a mac user, and although i have
>macperl running fine, there aren't ports to the mac for these - and i
>need to work out how to use either module.
The easiest way is to get a fly port that's already compiled for your
machine (sorry I don't have a URL, but it wasn't that hard to find on a
search engine).
Remember that you might need to open "./fly" not just "fly" as the
current dir isn't always searched.
--
Matthew Burnham | danew@enterprise.net
Manager, MindWeb | http://www.mindweb.co.uk/
Page me: http://
Web design and hosting | UKP24/Mb/Year for DIY space
WWW, FTP, CGI scripting, mailing lists, autoresponders and more!
------------------------------
Date: Mon, 18 Aug 1997 12:06:40 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: hel[p
Message-Id: <33F810A0.3468@icl.fi>
Brian P. Moffatt wrote:
>
> How can I test perl scripts on my win95 machine.
By installing the Perl interpreter on your Windows 95
machine.
And in case you need to test CGI scripts written in
Perl, then you should also install a web server, or
use the CGI.pm module from the command line.
Start with
http://www.perl.com/perl/
http://www.perl.com/FAQ/
http:///www.perl.com/CPAN/
Remember to read the "Perl for Win32 Frequently
Asked Questions" list.
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Mon, 18 Aug 1997 21:35:42 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do I find the system date/time?
Message-Id: <Pine.A41.3.95a.970818232518.139018A-100000@sp055>
On Mon, 18 Aug 1997, Marcantonio Fabra wrote:
> print "Today's date is: <B>$months[$mon] $mday, 19$year</B><BR>\n";
Y2K, here we come.
Better make that 1900+$year , methinks.
--
[One of the first pieces of OS code I ever saw, back in the 1960's, had
a big warning comment along the lines of "THIS CODE WILL NOT WORK IN
2100". In fact, that code only worked in 2000 because that year is an
exception to an exception. I mean, it _would_ have worked, if the
machine that executed that machine-code still existed!]
------------------------------
Date: Mon, 18 Aug 1997 21:41:40 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: how to use format to build strings
Message-Id: <3402b894.28037885@news.enterprise.net>
emv@umich.edu (Ed Vielmetti) wrote:
>: In Perl5, how can one use format statements to construct a string? I
>: know write() uses a filehandle, but are there any tricks to write to a
>: buffer using formats? I know there is sprintf, but that doesn't provide
>: the same formatting capabilities.
>The Camel book has the answer (p 127) which yields a subroutine
>called "swrite", which exposes the secret that write() just uses
>an internal routine called formline() to do its dirty work.
This is also in perlform
--
Matthew Burnham | danew@enterprise.net
Manager, MindWeb | http://www.mindweb.co.uk/
Page me: http://
Web design and hosting | UKP24/Mb/Year for DIY space
WWW, FTP, CGI scripting, mailing lists, autoresponders and more!
------------------------------
Date: 18 Aug 1997 19:51:59 GMT
From: sandler@ren.eecis.udel.edu (<b>Michael (Sandman) Sandler</b>)
Subject: HTML-TEXT
Message-Id: <5ta94v$440$1@dewey.udel.edu>
Before I re-invent the wheel:
Does anyone have a utility to strip the HTML stuff out of
text (I want to use to read E-Mail that comes from stupid
people). I can write one but will not if I someone else has.
Mike Sandler
sandler@eecis.udel.edu
PS: I can read it through the HTML but...save time/effort
--
-------------
Michael Sandler <sandler@eecis.udel.edu>
If you "C:>Win" you lose.
------------------------------
Date: 18 Aug 1997 20:30:40 GMT
From: Zenin <zenin@best.com>
Subject: Re: HTML-TEXT
Message-Id: <5tabdg$c15$2@nntp2.ba.best.com>
<b>Michael (Sandman) Sandler</b> <sandler@ren.eecis.udel.edu> wrote:
> Before I re-invent the wheel:
> Does anyone have a utility to strip the HTML stuff out of
> text (I want to use to read E-Mail that comes from stupid
> people). I can write one but will not if I someone else has.
lynx -dump foobar.html
--
-Zenin
zenin@best.com
------------------------------
Date: 18 Aug 1997 20:02:59 GMT
From: tphilip@bnr.ca (Teebu Philip)
Subject: IPC Open2 question
Message-Id: <5ta9pj$krq@brtph500.bnr.ca>
I have the following code frag(taken from camel p.456)
#!/usr/bin/perl
use IPC::Open2;
use Symbol;
$WTR = gensym();
$RDR = gensym();
$pid = open2($RDR, $WTR, 'bubba');
while (<STDIN>)
{
print $WTR $_;
$readline = <$RDR>;
print "$readline";
}
exit 0;
--------
i have created a simple executable called bubba from the following code:
#include <stdio.h>
main()
{
int x;
scanf("%d", &x);
while (x > 0)
{
printf("hi teebu\n");
scanf("%d", &x);
}
}
-------------
i am trying to get this piece of code to work like the example listed in
the book. they are using bc instead of my simple bubba program. bubba like
bc takes exactly 1 line of input then outputs of 1 line ... like bc.
i can't get this perl code fragment to work with bubba, but i do get it to
work with bc ... i am at wits end ... any suggestions/hints would be greatly
appreciated. thanks.
--
Teebu Philip EMAIL: tphilip@nortel.ca
NORTEL (RTP Lab) XPM Diagnostic Development, Dept. 3X41
35 Davis Dr. Voice: (919) 991-2602 ESN: 294-2602
RTP, NC 27709 FAX: (919) 991-4126 ESN: 294-4126
------------------------------
Date: 18 Aug 1997 21:05:39 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: JAPH (was: function pointer dereferencing)
Message-Id: <5tadf3$5pc$1@news.fm.intel.com>
M.J.T. Guy (mjtg@cus.cam.ac.uk) so eloquently and verbosely pontificated:
> Tom Grydeland <tom@mitra.phys.uit.no> wrote:
> >
> >The funny thing is, since I happened upon one of the previous
> >incarnations of the above JAPH, I've tried numerous other ways to
> >define a subroutine named q( ) or q(,). All in vain. Any takers?
>
> What's the problem? Why not just do it:
>
> sub q { print "q here\n" };
> &{'q'};
>
> prints as expected.
this was interpreted many ways when first posted a few weeks ago. the
original poster was just wanting to literally call a subroutine "SPACE
CHARACTER" or "COMMA CHARACTER" if you know what a mean. when he said
q( ) and q(,), he actually mean the character inside those parans, as if
he were single quoting them. get it? it caused a flood of simple
solutions, similar to yours, but Randal was the only one that truly
understood what he meant, and said something like:
*{" "} = sub {some code};
*{","} = sub {some code};
as ways to do it.
so the question was just a hard one to interpret :)
although a good question, nonetheless.
--
"Give me ambiguity or give me something else."
______ ______ _ _
(_) | (_) | | | | |
| _ ,_ ,_ _|_ | | _ _|_ __ | | _ ,_
_ ||/ / | / | | | / | ||/ |/ | / |/ \ |/ / |
(_/ |__/ |_/ |_/ \_/|/ (_/ |__/|__/|_/\___/| |_/|__/ |_/
*+*+*+*+*+*+*+*+*+*+*+* /| *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
\| tfletche@pcocd2.intel.com
*+*+*+*+*+ Views expressed...not INTeL's...yadda yadda yadda.... *+*+*+*+*+*
------------------------------
Date: Mon, 18 Aug 1997 15:01:40 -0600
From: randy.paries@avex.com
Subject: Looking for efficient suggestions for searching a file in perl
Message-Id: <871934208.7408@dejanews.com>
Hello,
I have a file (a kinda of password file)
that is made up of : delimited lines(each line is a user)
I have to pull out the of the file groups of people..
Currently I am opening a file, then spliting the line and checking a
particular field area. If it is the one I want I push it on an array.
so kinda like::
while (<filehandle>){
@tmp = split/:/;
if ( @tmp[5] == 4 ){
push @LoL, [ @tmp ];
}
}
is there a more efficient way of doing this??? this file will be up to
6000 lines. Could I use grep or something...
Looking for suggestions/examples
Thanks for any help/input.
Randy P......
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 18 Aug 1997 20:21:20 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Looking for efficient suggestions for searching a file in perl
Message-Id: <5taas0$nlp@news-central.tiac.net>
In article <871934208.7408@dejanews.com>, <paries@advicom.net> wrote:
>so kinda like::
>
>while (<filehandle>){
> @tmp = split/:/;
> if ( @tmp[5] == 4 ){
> push @LoL, [ @tmp ];
> }
>}
>
>is there a more efficient way of doing this??? this file will be up to
>6000 lines. Could I use grep or something...
Looks reasonable, as you probably only want a line at a time in memory,
but your check might be better written as
if ($tmp[5] == 4) {
...
}
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 18 Aug 1997 20:43:14 GMT
From: over@the.net (dave)
Subject: Need some explanation about unpack.
Message-Id: <33f8b392.1466332@news.one.net>
Hi,
I'm unpacking messages I receive from a C program.
For the structure, struct { char val[256]; },
$val = unpack "A256", $message;
works OK.
But for a structure containing two strings,
struct { char val1[64], val2[256]; },
( $val1, $val2 ) = ( unpack "A64 A256", $message );
does not work OK.
If I use struct { int v1len,v2len; char vals[320]; },
then the following seems to work:
( $v1len, $v2len, $vals ) = unpack "LL A320", $message;
($val1, $val2 ) = unpack "A$v1len A$v2len", $vals;
Could someone please explain why cases 1 and 3 work, but case 2 does
not?
Thanks,
Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: Mon, 18 Aug 1997 21:36:00 +0100
From: Kevin Luff <kluff@enterprise.net>
Subject: oracle->perl frontend
Message-Id: <33F8B22F.7F49BC73@enterprise.net>
Hi all,
before I go and reinvent the wheel........
has anybody got scripts that enable you (in a format easy for users to
understand) to select an oracle table from a selection of those
available, then select fields required, with optional condition
statements and display|print|save the results.
Pref http based....
all the relevant dbi/dbd stuff is installed
cheers
Kevin
ps Making the tea and coffee would be handy as well ;-)
------------------------------
Date: Mon, 18 Aug 1997 19:28:50 GMT
From: stuart@cdac.com (Stuart Poulin)
Subject: Re: Overriding Functions in Modules, i.e. File::Find lstat
Message-Id: <1997Aug18.192850.24846@ole.cdac.com>
In article <Pine.GSO.3.96.970814185511.18525F-100000@julie.teleport.com> Tom Phoenix <rootbeer@teleport.com> writes:
>On Thu, 14 Aug 1997, Stuart Poulin wrote:
>
>> How do I go about overriding a function in a module?
>> For example: I want File::Find to use 'stat' instead of 'lstat'
>
>I'm not sure why you want it, but assuming that it's a Good Thing :-)
>here's a pretty good way to make it happen: Make your own copy of
>File::Find, and add an option in the form of a global package variable
>called (say) $File::Find::use_stat. Fix the code to notice whether that
>variable is set, and to use stat instead of lstat when it is. Then, when
>you have it all debugged and documented, if you think anyone else might
>also find that feature useful, send a patch to the Perl developers and ask
>what they think. It might become a part of a future release of Perl. Have
>fun with it!
>
>--
>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/
>
Thanks Tom.
I wanted to override File::Find::lstat to see if File::Find could be
coerced into following symbolic links. Looks like it can if you set up
things in the following order. And set $File::Find::dont_use_nlink=1;
#!/usr/local/bin/perl
#
package File::Find;
use subs qw(lstat);
sub File::Find::lstat {
stat(@_);
}
package main;
use File::Find;
$File::Find::dont_use_nlink=1;
find(\&wanted, '.');
sub wanted {
print "$File::Find::name\n";
}
__END__
In general, I was looking for methods to override functions and
subs in non-OO modules.
--
-------------------
Stuart Poulin
stuart@cdac.com
------------------------------
Date: Mon, 18 Aug 1997 14:07:38 -0700
From: Mark Tripod <mark@pbi.net>
Subject: Re: Pattern repacement with variables question
Message-Id: <33F8B99A.1202@pbi.net>
Vince Busam wrote:
>
> I want to perform pattern replacement based on variables which contain
> backreferences. Similar to :
> $test = "one two";
> $match = '^([^ ]+) +([^ ]+)';
> $replace = '$2 $1';
change $replace = '$2 $1';
to $replace = "$2 $1";
single quotes prevent the variable substitution that you are looking
for.
> $test =~ s/$match/$replace/;
> print "$test\n";
>
> The output is:
> $2 $1
>
> instead I'd like to see:
> two one
>
> Any suggestions?
>
> Vincent Busam
> vincent.busam@ngc.com
Mark Tripod
------------------------------
Date: Mon, 18 Aug 1997 22:18:41 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Q: assoc. arrays as subroutine argument
Message-Id: <33F8A011.3F26@icl.fi>
Sascha Kerschhofer wrote:
>
> i'm a litte confused.
> how can i handle an assoc. array as argument for a subroutine.
> eg: all of my cgi values are stored in the assoc. array "%data". i nedd a
> subroutine, which replaces all the non HTML conform charqacter (like "&,
> <, >") in their html equivalents:
>
> sub ascii2html {
> foreach $wert (keys @_[0]) {
> $_{$wert} =~ s/&/&/g; # i'm sure this is wrong!
> $_{$wert} =~ s/</</g;
> $_{$wert} =~ s/>/>/g; }
> }
>
> the routine is invoked by "ascii2html(%data)"
>
> but this doesn't work. what am i doing wrong?
> any help is appreciated. thank you!
>
> Sascha Kerschhofer, Vienna
You need to pass a reference( "ascii2html(\%data)" ) and
then dereference it in the sub. For example:
use strict;
mysubtoprintahash( \%ENV );
sub mysubtoprintahash( \% ) {
my $hashref = shift;
if ( ref( $hashref ) eq 'HASH' ) {
foreach ( keys %$hashref ) {
print "Key: $_, Value: $$hashref{$_}\n";
}
}
}
See the Perl documentation (the perlref part) for more
information.
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Mon, 18 Aug 1997 16:56:22 -0400
From: Devin Anderson <dev@sgi.net>
Subject: reading and writting to the same file
Message-Id: <33F8B6F6.22CB@sgi.net>
I'm trying to read and write to the same file. Now my perl book says
this is possible by opening the file with a "+>" mode. However, it just
destroys the file when I do this. Here is my code.
I just need to scan through the file, make any replacements, and close.
Because this routine could get called multiple times, writing to a
second file then copying would be a waste of io, (at least the way I
see, please disagree with me if you think otherwise). Any ideas?
open(DB,"+>ipdatabase");
while(<DB>){
s/$for:::.*/$for:::$replace/ig;
print DB $_;
}
close(DB);
Please cc responce to dev@sgi.net also.
Thanks!!
---
Devin P. Anderson
Webmaster, Systems Administrator
Stargate Industries, Inc.
http://www.sgi.net/
Phone: 412.930.STAR (7827) ext. 241
F a x: 412.930.7110
kernel, n.:
A part of an operating system that preserves the medieval
traditions of sorcery and black art.
-----PGP PUBLIC KEY AVAILABLE-----
------------------------------
Date: 18 Aug 1997 13:57:04 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: reading remote files
Message-Id: <5tacv0$5j1$1@shell3.ba.best.com>
In article <33F898BB.B04AA5D5@instinet.com>,
David Mossakowski <dmoss@instinet.com> wrote:
>I'm trying to read a file from a remote web server.
>
>Such as : http://internalserver/doc.txt
Sure, if you have the LWP:: modules, which are available from your local
CPAN mirror. Then, you can just do something like:
use LWP::Simple;
$content = get("http://internalserver/doc.txt");
You can find a list of CPAN mirrors at (I think)
http://www.perl.com/perl/CPAN/
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: Mon, 18 Aug 1997 15:02:09 -0600
From: David Turley <dturley@rocketmail.com>
Subject: regex opinions wanted
Message-Id: <871934320.7637@dejanews.com>
This has probably been covered to death, but those who wish to reply will
have their opinions gratefully accepted.
After looking thru the various perl animal books, and ora's regex book, I
believe I have come up with a regex to match a US$ amount, and am lloking
for feedback.
The latest incarnation is;
/^\d+(\.\d\d)?$|^\.\d\d$|^\d+\.$/
(dollar sign is stripped off before processing)
I believe this match a number without a decimal point, a number with a
decimal followed by 2 digits, but not a lone decimal point or an empty
string. I also allowed for a decimal point not followed by any digits, as
this seems to come up occassionally.
I look forward to seeing what the regex experts make of this.
Cheers,
david
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 18 Aug 1997 15:52:23 -0600
From: James Long <jdlong00@pop.uky.edu>
Subject: ShowTable
Message-Id: <871937142.11604@dejanews.com>
I am just getting into Perl programming and have a hang-up using Mr.
Stebbens Data::Showtable module. I have the module installed and it seems
to work fine for the examples, and I have read the Man pages 20 or so
times. Only I cannot figure out some of the basics.
Here is a description of my problem:
I want to use data in a text file, tab delimited, like the one following:
(first row is headers)
State County Year Crop Data
KY Fayette 1995 Corn 400
KY Fayette 1995 Beans 100
KY Fayette 1996 Beans 10
TN Obion 1996 Corn 30
TN Obion 1995 Beans 50
TN Obion 1996 Beans 400
I want the user to enter the variables $state and $county and the software
to return a table with headers "Crop", "Year", and "Data" filled in with
the appropriate data.
My problems:
I can't figure out how to get the program to look to the datafile, set it
as a hash, and then to run a query. After that, how would I format
results?
I have poured over the docs, and I am sure my answers are right in front
of my face, but I can't seem to get going well. If someone could give me
an example, or some coding helps, it would be greatly appreciated.
James Long
University of Kentucky
Department of Agricultural Economics
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 18 Aug 1997 20:18:23 GMT
From: tbodine@amd.com (Thomas L. Bodine)
Subject: Re: The user and his hotline... (was: Date::Manip Error)
Message-Id: <5taamf$h6p$1@amdint2.amd.com>
In the cited articles the authors talk about uninformed or dumb users.
This sounds like the old Bastard Operator from Hell stories.
Maybe there is already a thread for Dumbest Users from Hell or DUH for short.
--
# Dancing to the music life has given me.
# Thomas L. Bodine
# Technical System Administrator, Advanced Micro Devices, Austin
------------------------------
Date: Mon, 18 Aug 1997 15:11:27 -0600
From: randy.paries@avex.com
Subject: What is the most effiecent way to search a file
Message-Id: <871934475.7824@dejanews.com>
Hello,
I have a file (a kinda of password file)
that is made up of : delimited lines(each line is a user)
I have to pull out the of the file groups of people..
Currently I am opening a file, then spliting the line and checking a
particular field area. If it is the one I want I push it on an array.
so kinda like::
while (){
@tmp = split/:/;
if ( @tmp[5] == 4 ){
push @LoL, [ @tmp ];
}
}
Is there a more efficient way of doing this??? this file will be up to
6000 lines. Could I use grep or something...
Looking for suggestions/examples
Thanks for any help/input.
Randy P......
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 18 Aug 1997 20:52:11 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: Win32 Perl & UNC names - Problem?
Message-Id: <EF4nAz.4r@cix.compulink.co.uk>
In article <1.5.4.32.19970818201247.002fc030@popmail.dircon.co.uk>,
clem@bastet.dircon.co.uk (Clem Dye) wrote:
> However, if I execute the script in the format PERL script.pl
> \\<servername>\<sharename>, the test for directory
> existence in step (2) fails. (A straight DIR \\<servername>\<sharename>
> works fine.)
Weird. I have a production system that does thousands of those every night
with no observable problems. But I don't pass my UNCs in on the command
line. Try:
PERL script.pl \\\\<servername>\\<sharename>
---
John Dallman jgd@cix.co.uk
------------------------------
Date: Mon, 18 Aug 1997 17:07:26 -0400
From: Buzz Moschetti <buzz@bear.com>
To: John Tucker <jatucker@austin.dsccc.com>
Subject: Re: XS (converting perl array to char**..)
Message-Id: <33F8B98E.7935@bear.com>
John Tucker wrote:
>
> Hello,
>
> I'm using perlxs to create a perl extension package for a set C
> functions
> and most of thes functions expect a "char**" member which represents an
> array of file pathnames.
> [...]
> int
> func(files, branch="", comment=".")
> char **files;
> char *comment;
The out-of-the-box typemap of char** is
char** p_arr = XS_unpack_charPtrPt(ST(0))
XS_unpack_charPtrPtr is not defined anywhere and even if it was,
there's a small matter of the memory allocated for p_arr.
I recommend passing either a va list or an AV*, mallocing the
char** yourself, and iterating over the collection, calling
SvPV(ST(n), na) to populate the elements of the array.
------------------------------
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 887
*************************************