[11226] in Perl-Users-Digest
Perl-Users Digest, Issue: 4826 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 4 15:07:25 1999
Date: Thu, 4 Feb 99 12:00:20 -0800
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, 4 Feb 1999 Volume: 8 Number: 4826
Today's topics:
A problem for all you perl guru's <jfish13@snip.net>
Re: A problem for all you perl guru's (Sean McAfee)
Re: any comments on the Ultimate Bulleting Board? <23_skidoo@geocities.com>
Re: Best string/hex/string conversion? (Greg Bacon)
Re: finding path to perl executable gulam.faruque@csfp.co.uk
Re: How to activate perl? (Greg Ward)
Re: libwww-perl and use strict (Greg Ward)
Re: libwww-perl and use strict (Marcus Tettmar)
Re: libwww-perl and use strict (Marcus Tettmar)
Re: Looking for subparseform.lib (Greg Ward)
Re: mkdir problems (Greg Ward)
Need help with search/replace chuck_mattern@my-dejanews.com
Re: Net::FTP (Robert Saunders)
Re: Newbie question on regular expressions <govier@michelob.wustl.edu>
Re: Numeric Value (Larry Rosler)
Perk/Tk Treeview gulam.faruque@csfp.co.uk
Question: Arrays of associative arrays <stevesc@synopsys.com>
Re: Read emails from a perl program (Greg Ward)
Re: Reference Question.... <dboorstein@ixl.com>
Re: Regex for e-mail addresses? (John Stanley)
Re: Regex for e-mail addresses? <revjack@radix.net>
Re: sending an attached file with Sendmail? (Greg Ward)
Re: Sorting with Matts simple search script? <uri@ibnets.com>
Re: UNIX 'tail' command in Perl?? <davem@nortak.com>
Re: Unix Perl Debugger Question (Greg Ward)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 Feb 1999 13:25:35 -0800
From: James Fisher <jfish13@snip.net>
Subject: A problem for all you perl guru's
Message-Id: <36BA104F.DF8F2D42@snip.net>
I am a perl newbie and would like to know if there is a perl solution
for my problem. I am working on a project and here is the current
process.
- 5 decent sized text files which hold customer data in fixed width
format. For ex. one file is 50,000 rows with 30 columns.
- We are importing them into staging tables in SQL Server 6.5 with BCP.
- Then we validate the data using a COM component (written in VB
utilizing ADO recordsets) which runs on the server.
- This validation goes row by row doing validation such as ....
checking for valid dates, deleting any duplicate primary keys.
- Then the data is inserted into our production tables.
- This process takes a good amount of time and COM components aren't
the most cooperative components sometimes.
I was wondering, since I have read and heard so many great things about
perl, if I could use a perl script to do the validation in the text
files before they are put into SQL Server 6.5. Any ideas for this
process.
JF
------------------------------
Date: Thu, 04 Feb 1999 18:58:57 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: A problem for all you perl guru's
Message-Id: <R5mu2.5613$Ge3.22969791@news.itd.umich.edu>
In article <36BA104F.DF8F2D42@snip.net>,
James Fisher <jfish13@snip.net> wrote:
>I am a perl newbie and would like to know if there is a perl solution
>for my problem. I am working on a project and here is the current
>process.
>- 5 decent sized text files which hold customer data in fixed width
>format. For ex. one file is 50,000 rows with 30 columns.
>- We are importing them into staging tables in SQL Server 6.5 with BCP.
>- Then we validate the data using a COM component (written in VB
>utilizing ADO recordsets) which runs on the server.
>- This validation goes row by row doing validation such as ....
>checking for valid dates, deleting any duplicate primary keys.
>- Then the data is inserted into our production tables.
>- This process takes a good amount of time and COM components aren't
>the most cooperative components sometimes.
>I was wondering, since I have read and heard so many great things about
>perl, if I could use a perl script to do the validation in the text
>files before they are put into SQL Server 6.5. Any ideas for this
>process.
It's fairly trivial:
use DBI;
use Date::Calc qw(check_date);
$/ = \30; # read in 30-character records
$dbh = DBI->connect("dbi:Oracle:", "username/password") or die;
$sth = prepare $dbh "insert into my_table values (?, ?, ?, ?)" or die;
# I'll assume for simplicity that the records consist only of a date and
# a primary key, where the first eight characters are the date in the
# format YYYYMMDD, and the rest is the key.
while (<>) { # for each record in each input file...
($year, $month, $day, $unique_key) = /(....)(..)(..)(.*)/;
next unless check_date($year, $month, $day); # validate date
next if $keycount{$unique_key}++; # eliminate duplicate keys
execute $sth $year, $month, $day, $unique_key; # insert into database
}
(I used Oracle here, since that's what I'm familiar with, but the code
would be essentially the same for any database, thanks to the DBI module.)
As an example of how this approach might be used, I've written a module for
a production environment in my workplace that encapsulates all of the
database-related operations that need to be performed. Then it's simple
to set up cron jobs that look like this:
0 0 * * * /usr/local/bin/perl -I/home/mcafee/perl -MWorkflow -e \
'call do_completion; call do_expiration; parse_new_exceptions; \
call process_exceptions'
Here, "call" is a function exported by my Workflow.pm module that invokes
an Oracle stored procedure, and "parse_new_exceptions" is another function
that parses new report files and inserts the data into the database.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Thu, 04 Feb 1999 18:23:13 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: Re: any comments on the Ultimate Bulleting Board?
Message-Id: <36B9E590.7E89@geocities.com>
Jonathan Feinberg wrote:
>
> 23_skidoo <23_skidoo@geocities.com> writes:
>
> > i'm looking into using the ultimate bulletin board instead as it
> > looks a tad more professionally done, has anyone else used this
> > script?
>
> This newsgroup is not really *for* the discussion of WWW middleware.
> It's for the discussion of the Perl language. Therefore, you're
> unlikely to get knowledgable responses about WWW middleware here!
>
> You might go to DejaNews and search for groups that deal with the web,
> CGI scripting, things like that. HTH.
well, i thought it was relevant since i was asking about any inherent
difficulties in modifying a perl script, i'm asking if it's well written
Perl or not *shrugs* everytime someone comes on this NG and says "i'm
having trouble with wwwboard" everyone says "uuurrgh, don't use it, it
sucks". this kind of information would have saved me a lot of time and
trouble about 6 months ago, just wondering if there are any opinions
about UBB in here.
------------------------------
Date: 4 Feb 1999 18:17:48 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Best string/hex/string conversion?
Message-Id: <79co8c$399$1@info.uah.edu>
In article <79cdtr$rsu$1@info.uah.edu>,
gbacon@itsc.uah.edu (Greg Bacon) writes:
: sub printable {
: my $bytes = shift;
:
: $bytes =~ s/([\000-\377])/sprintf "%X", ord $1/eg;
:
: '0x' . $bytes;
: }
...or maybe
sub printable {
my $bytes = shift;
my $string;
$string = '0x' . join '',
map sprintf("%X", $_),
unpack "C*", $bytes;
$string;
}
Greg
--
I guess I just prefer to see the dark side of things. The glass is always
half-empty. And cracked. And I just cut my lip on it. And chipped a tooth.
-- Janeane Garofalo
------------------------------
Date: Thu, 04 Feb 1999 18:06:23 GMT
From: gulam.faruque@csfp.co.uk
Subject: Re: finding path to perl executable
Message-Id: <79cnim$u9i$1@nnrp1.dejanews.com>
In article <797l10$m48$1@nnrp1.dejanews.com>,
mlevine@reshape.com wrote:
> Can anyone tell me how to find the path to the perl executable I am running?
>
> IE, from inside script foo, I'd like to be able to find out that it was run
> from /usr/local/bin/perl.
>
> Thanks!
>
> - Margie
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
try
print "$0\n";
You'll see.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 4 Feb 1999 18:07:40 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: How to activate perl?
Message-Id: <79cnlc$jls$2@news0-alterdial.uu.net>
Rob Kloots <rkloots@csf.nl> wrote:
> Here's the situation:
> The environment is Solaris 2.6 Sparc, KDE, ksh.
> Perl can't be found when trying to invoke in browser.
> Perl executes from terminal, but only when full path is given.
> Netscape's internal cgi/perl does work.
This is more of a Unix question than a Perl question. And it's a pretty
basic Unix question -- you should probably pick up an introductory book
on Unix.
The answer: check your PATH environment variable. Note that you have to
check it in two places: if you want to run Perl from an ordinary
command-line (trust me, you do: even if all you think you're doing is
writing CGI scripts, they're *much* easier to debug this way rather than
with several layers of browser, HTTP, and server getting in the way),
then check how it's defined for your ordinary user account (eg. in
~/.profile since you're using ksh).
And since you said "browser", I assume you are writing CGI scripts: thus
you'll need to figure out what user the CGI scripts are run as, and
where that user's PATH is set. And you'll need to fix it to include
Perl's location. (Alternately, you could hard-code Perl's path in the
!# line of your CGI scripts, but that's usually not a good idea. What
if it gets moved?)
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 4 Feb 1999 18:49:36 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: libwww-perl and use strict
Message-Id: <79cq40$jls$6@news0-alterdial.uu.net>
Marcus Tettmar <mtettmar@mjtnet.com> wrote:
> I'm new to perl. I have read the newsgroup faq. Quite ironic
> actually, because in the faq it says to make sure to use 'use
> strict;', but this is my problem :
Thank you for taking the time to help yourself before asking the
newsgroup for help. $you->{'karma'}++
> I'm trying to install libwww-perl. I have the correct one for my
> version of perl. When I do perl Makefile.PL I get the following
> errors :
>
> syntax error in file Makefile.PL at line 5, next 2 tokens "use strict"
> syntax error in file Makefile.PL at line 20, next 2 tokens "getopts("
Bzzzt! Perl 4 alert! Perl 4 alert! All hands to battle-stations!
You need to upgrade to Perl 5. Or pester your system administrators to
upgrade to Perl 5. Since you have read the FAQs, you are presumably
aware of the differences and do not need to be convinced that upgrading
from old, dead, unsupported Perl 4 is worth the trouble.
> I guessed that maybe I don't have strict installed.
A novel interpretation, and in fact true (in a narrow sense). But the
problem is your Perl, but your Perl library.
> Searched the newsgroups, read the FAQ, done everything the
> instructions say.
$you->{'karma'} += 5
> Perl works ok on my server as I have other scripts running.
Then you might want to be careful to preserve Perl 4 when you upgrade.
A small list of minor things broke in the jump to Perl 5; they're all
easy to fix on their own, but if you have many many scripts running it
could take several terious hours to fix them all. (Or, they might all
run flawlessly.) The bigger danger is that you'll start learning about
all the wonderful things Perl 5 offers, and want to fix all your old
scripts to use them... holy timesink, batman!
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Thu, 04 Feb 1999 19:08:22 GMT
From: mtettmar@mjtnet.com (Marcus Tettmar)
Subject: Re: libwww-perl and use strict
Message-Id: <36b9ef26.123448409@news.demon.co.uk>
>
>You need to upgrade to Perl 5. Or pester your system administrators to
>upgrade to Perl 5. Since you have read the FAQs, you are presumably
>aware of the differences and do not need to be convinced that upgrading
>from old, dead, unsupported Perl 4 is worth the trouble.
Hmmm. I have. I'm running Perl 5.
I installed it a while back.
All other perl scripts work, but I guess from the helpful responses
I've had here that some links must be screwy and when I run perl it's
actually running the old version.
At least I know where to look now.
>> I guessed that maybe I don't have strict installed.
>
>A novel interpretation, and in fact true (in a narrow sense). But the
>problem is your Perl, but your Perl library.
Novelly narrowly ... ta.
>> Searched the newsgroups, read the FAQ, done everything the
>> instructions say.
>
>$you->{'karma'} += 5
Uh - right. :-/
>> Perl works ok on my server as I have other scripts running.
>
>Then you might want to be careful to preserve Perl 4 when you upgrade.
>A small list of minor things broke in the jump to Perl 5; they're all
>easy to fix on their own, but if you have many many scripts running it
>could take several terious hours to fix them all. (Or, they might all
>run flawlessly.) The bigger danger is that you'll start learning about
>all the wonderful things Perl 5 offers, and want to fix all your old
>scripts to use them... holy timesink, batman!
>
Indeed.
Thanks for your help.
------------------------------
Date: Thu, 04 Feb 1999 19:09:40 GMT
From: mtettmar@mjtnet.com (Marcus Tettmar)
Subject: Re: libwww-perl and use strict
Message-Id: <36b9f02b.123708623@news.demon.co.uk>
On Thu, 4 Feb 1999 15:50:48 GMT, Eric Bohlman <ebohlman@netcom.com>
wrote:
>Marcus Tettmar <mtettmar@mjtnet.com> wrote:
>: I'm trying to install libwww-perl. I have the correct one for my
>: version of perl. When I do perl Makefile.PL I get the following
>: errors :
>
>: syntax error in file Makefile.PL at line 5, next 2 tokens "use strict"
>: syntax error in file Makefile.PL at line 20, next 2 tokens "getopts("
>
>Those sound like Perl 4 error messages (since "use" wasn't introduced
>until Perl 5). There's probably something screwy about your path that's
>causing an old version of perl to get invoked.
>
I installed Perl 5 a while back. I thought when I upgraded that it
had overwritten Perl4, but maybe not - must be still linking to Perl4
- thanks. That's very helpful. Thanks!!
------------------------------
Date: 4 Feb 1999 18:30:42 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Looking for subparseform.lib
Message-Id: <79cp0i$jls$4@news0-alterdial.uu.net>
Jim and Lois <kf4dmb@camcomp.com> wrote:
> Hello , I am new to perl. I am following a book and trying to write a
> script.
> But it requires subparseform.lib . Where is it ? I am using Linux redhat 5.1
> and apachee server
Ooh, sounds like you're following a book that will do you more harm than
good. By any chance is this book in the 1,000+ page category, with a
title like "Teach Yourself to Master Perl in 21 Days for Dummies"? If
so, I would dump it in the trash and go buy *Learning Perl* by Randal
Schwartz and Tom Christiansen (published by O'Reilly & Associates).
(The reason I draw this conclusion? Because nobody calls Perl libraries
or modules something.lib. And if the book was really clued in, it would
tell you all about CPAN, and all about the wonderful modules on CPAN.
And I strongly suspect that this "subparseform.lib" has something to do
with parsing web forms in a CGI script... which has already been done,
and done so exceedingly well that it's now included in the standard Perl
distribution. The module is called CGI. You can read about it with
"perldoc CGI", and there's even a book about it -- title is something
like "The Official Guide to Programming with CGI.pm", written by Lincoln
Stein -- the guy who wrote CGI.pm.)
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 4 Feb 1999 18:43:58 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: mkdir problems
Message-Id: <79cppe$jls$5@news0-alterdial.uu.net>
Einar Gudmundsson <einar.gudmundsson@realtime.co.uk> wrote:
> I'm having some problms using the perl built-in 'mkdir'
> function. The function works allright, but creates directories
> with very stange file permissions.
>
> Here's an example
>
> mkdir('test',0755) # Should cretae a test directory with drwxr-xr-x
>
> however when I do a 'ls -l test' I get this:
>
> d-wx--s--x 2 etg etg 1024 Feb 4 11:06 test
>
> What am I missing?
That's very odd. The most common error with mkdir is to specify the
mode in decimal, eg. "mkdir ('test', 755)". You're obviously not doing
that, though -- and the mode you're getting is not mode 01363 (which is
755 in octal).
umask shouldn't be responsible: how could it add that setgid bit? umask
only takes away bits.
The only thing that occurs to me is that you're running a very weird
Unix that interprets the permission bits differently from every other
Unix on the face of the planet. So, just what OS are you running? And
what filesystem?
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Thu, 04 Feb 1999 19:35:11 GMT
From: chuck_mattern@my-dejanews.com
Subject: Need help with search/replace
Message-Id: <79cspe$3bm$1@nnrp1.dejanews.com>
I have an application which I re-wrote (the original was to far afield to
save) which generates a list of files that is passed off to a command line
utility that then migrates said files to near-line storage. File names are
either determined as the result of a find or pulled from an ascii text file.
The file names are created by a third party application that uses what they
call base 41 notation, essentially files and directories can contain all
alpha's, numerics and all sorts of metacharacters (!@#$%&, et al) (and yes
these files live on and AIX machine <SIGH>... so the application has to take
these references and massage them into something palatable to the AIX command
line environment. I've got everything working EXCEPT a really strange
anomaly. In a recent test file I have the following lines:
USRB00001\###\###\##$\#$V\$$V38^M
\\cpaiss41\ANN_1\rb\#!!\###\##$\#$V\$$V38.!!$^M
USCD00019\###\###\##0\#-R\0-RM3^M
\\cpaiss41\ANN\fb\###\###\##-\#VB\-VBRO^M
\\cpaiss41\FB2\###\###\##-\#SW\-SW-5^M
\\cpaiss41\ANN\ps\#!!\###\##-\#VB\-VBRO.!!$^M
\\cpaiss41\PS2\#!!\###\##-\#SW\-SW-5.!!$^M
\\cpntss65\CA441DC\###\###\##1\#CV\1CV8D^M
\\cpntss65\CA441DC\###\###\##1\#CV\1CV8E^M
\\cpntss65\CA441DC\###\###\##1\#CV\1CV8F^M
\\cpntss65\CA441DC\###\###\##1\#CV\1CV8G^M
\\cpntss65\CA441DC\###\###\##1\#CV\1CV8H^M
\\cpntss65\CA441DC\###\###\##1\#CV\1CV8I^M
\\cpaiss41\CA\rpt\cld\pjr270m\###\###\##0\#B%\0B%HJ^M
\\cpaiss41\CA\rpt\cld\pjr270m\###\###\##0\#B%\0B%HJ^M
\\cpaiss41\CA\rpt\cld\pjr270m\###\###\##0\#B%\0B%HI^M
\\cpaiss41\CA\rpt\cld\pjr230m\###\###\##0\#7J\07J@P^M
Three of these lines end in the sequence .!!$ The first one is handled
correctly the second two are not so the file names output by this:
/run/ia/cache/us/lgl/img/rb/usrb0000.1/###/###/##\$/#\$v/\$\$v38
/run/ia/us/lgl/ann/rb/#!!/###/##\$/#\$v/\$\$v38.!!\$
/run/ia/cache/us/lgl/cld/cd/uscd0001.9/###/###/##0/#-r/0-rm3
/run/ia/us/bus/ann/fb/###/###/##-/#vb/-vbro
/run/ia/us/bus/img/fb2/###/###/##-/#sw/-sw-5
/run/ia/us/bus/ann/ps/#!!/###/###/#vb/vbro.!!$
/run/ia/us/bus/img/ps2/#!!/###/##-/#sw/sw-5.!!$
/run/ia/ca/rpt/cld/pjr270m/###/###/##0/#b%/0b%hj
/run/ia/ca/rpt/cld/pjr270m/###/###/##0/#b%/0b%hj
/run/ia/ca/rpt/cld/pjr270m/###/###/##0/#b%/0b%hi
/run/ia/ca/rpt/cld/pjr230m/###/###/##0/#7j/07j\@p
(some lines did not make it to the final output because they reside on a
different server and are consigned to the bit bucket) Not that the second
output file ends in .!!\$ (which AIX seems OK with) and that files 6 and 7
still end in .!!$ . All file names are processed one at a time the escaping
of the "$" character is done by this line:
$FILE=~s/\$/\\\$/g;
The only substantial difference I can see is that the two files that are not
parsed properly have embedded "-" characters, but I tried manually editing
the input file and replacing these with "#" characters (I cheated) and the
replacement still fails. I can post the entire code if needed figured 256
lines would be excessive for a post.
Any suggestions?
TIA,
Chuck
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 04 Feb 1999 18:14:34 GMT
From: robert@iminet.com (Robert Saunders)
Subject: Re: Net::FTP
Message-Id: <BC8C768C5900C928.EAB6BD23B46F5DE2.C70185D0EFA81D68@library-proxy.airnews.net>
On Thu, 04 Feb 1999 17:24:39 GMT, robert@iminet.com (Robert Saunders)
wrote:
>
>
>I have figured out almost everything I need to know about the Net::FTP
>that I found on Cpan. Going thru the docs that I found at
>http://www.connect.net/gbarr/pod/Net/FTP.html I can ftp a file to
>another machine now. I can remove files on the other machine..
>
>My question there is a command that I am very interested in
>
>ls ( [ DIR ] )
>Get a directory listing of DIR, or the current directory.
>In an array context, returns a list of lines returned from the server.
>In a scalar context, returns a reference to a list.
Before I get flamed to bad.. I did figure out what I was looking for..
and of course it was as simple as I thought it was going to be..
$files = $ftp->ls;
produced the results that I was looking for..
Robert Saunders
robert@iminet.com
------------------------------
Date: Sun, 31 Jan 1999 22:16:27 -0600
From: Fred Govier <govier@michelob.wustl.edu>
To: Ulrich Petri <UloPe@hotmail.com>
Subject: Re: Newbie question on regular expressions
Message-Id: <36B52A9A.5EED2E93@michelob.wustl.edu>
Ulrich Petri wrote:
> my code looks like:
>
> if ("hTtP://www.blah.com" =~ /http:/i)
> {
> <do something>
> }
>
> that works quite nice
> but actual i want to do the exact opposite
> like:
>
> if ("www.blah.com " !=~ /http:/i)
>
> and now this doesn'T work
Try
if ( ! ("www.blah.com " =~ /http:/i) )
{ <do something> }
-- Fred
------------------------------
Date: Thu, 4 Feb 1999 11:24:16 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Numeric Value
Message-Id: <MPG.112393b9bb0ff31989a04@nntp.hpl.hp.com>
[Posted and a courtesy copy sent to Ala Qumsieh.]
In article <MPG.112379cfa4568808989a03@nntp.hpl.hp.com> on Thu, 4 Feb
1999 09:33:45 -0800, Larry Rosler <lr@hpl.hp.com> says...
> In article <x3yognap2sa.fsf@tigre.matrox.com> on Thu, 4 Feb 1999
> 11:11:17 -0500 , Ala Qumsieh <aqumsieh@matrox.com> says...
> ...
> > print "Is numeric\n" if $string =~ /^[+-]?(?:\d+\.?\d*)|(?:\.\d+)$/;
>
> Still wrong -- fails '-.3' for example. The parentheses are wrong.
>
> > print "Is numeric\n" if $string =~ /^[+-]?(?:\d+\.?\d*|\.\d+)$/;
Ala points out in personal email (not clear that it is posted) that this
regex in fact succeeds for '-.3'. This is true, but it would also
succeed for 'x.3' and for '3x'. Let me spell it out more clearly:
The precedence of alternation '|' in a regex is the lowest possible. So
the first regex above parses as:
/ ^[+-]?(?:\d+\.?\d*) | (?:\.\d+)$ /x;
The first alternative has no end-of-string anchor; the second
alternative has no beginning-of-string anchor.
The second regex, which I posted above, is correct.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 04 Feb 1999 18:25:07 GMT
From: gulam.faruque@csfp.co.uk
Subject: Perk/Tk Treeview
Message-Id: <79coll$vba$1@nnrp1.dejanews.com>
Hi,
Has anyone found a way of displaying a treeview in Perl/Tk.
I've tried Tk-Tree by Chris Dean,
http://www.perl.com/CPAN-local/authors/id/CTDEAN
I keep getting Getimage error.
Im using Perl 5.004 on NT4.
Thanks in advance
GF
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 04 Feb 1999 14:23:07 -0500
From: Steve Chen <stevesc@synopsys.com>
Subject: Question: Arrays of associative arrays
Message-Id: <36B9F39A.F2365854@synopsys.com>
Hello,
Are "arrays of associative arrays" useful in Perl? I seem to be able to
construct it, but the problem
is, how do I access the values of the associative arrays? Let's say I
have an array:
@Array = (%comp1, %comp2, ..., %compn);
where
%compn = (keys, values)
To print all the values of the associative arrays, I tried
(loop over $i)
foreach $key (sort keys($Array[$i])) {
print ....
}
But this won't fly with the compiler. The function "keys" doesn't seem
to like things that begin
with a "$". Any ideas?
Thanks.
Steve
------------------------------
Date: 4 Feb 1999 18:19:35 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Read emails from a perl program
Message-Id: <79cobn$jls$3@news0-alterdial.uu.net>
dragnovich@my-dejanews.com <dragnovich@my-dejanews.com> wrote:
> I want to make a program that will be residing under my FreeBSD server. This
> program will do this simple task:
>
> Stay on the server crontab, if a NEW email comes to my account it detects it!
That depends on your MTA (mail transfer agent). If you're running
sendmail, you could create a .forward file that "forwards" mail to your
notification script before appending it to your inbox. Eg. if your
username is 'foo':
|notify_script
\foo
or something like that. Your 'notify_script' will then get the message
on its stdin, easy to parse.
But, this being Unix, There's More Than One Way To Do It. You might be
running a different MTA. You might be receiving email in an "on demand"
mode such as POP, in which case you could write a custom POP client --
or use an existing one such as fetchmail to do what you want.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Thu, 04 Feb 1999 12:56:41 -0500
From: Dan Boorstein <dboorstein@ixl.com>
Subject: Re: Reference Question....
Message-Id: <36B9DF59.57447D32@ixl.com>
hello,
how about an anonymous array reference wrapped around your function call:
$hash{foo} = [ $obj->function ];
chhers,
dan boorstein
Steve Wells wrote:
>
> I have an object that returns an array.
>
> If I use:
> my @array = $obj->function;
> $hash{foo} = \@array;
>
> It works. But I wanted to get rid of the array and
> just have it point to the data so I tried:
>
> $hash{foo} = \@{$obj->function};
>
> and it's not working as before... Any ideas?
>
> TIA,
> STEVE
> --
> -----------
> Stephen D. Wells
> http://www.iren.net/wellss/
------------------------------
Date: 4 Feb 1999 18:43:59 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Regex for e-mail addresses?
Message-Id: <79cppf$hr9$1@news.NERO.NET>
Keywords: Hexapodia as the key insight
In article <79an79$3js$1@news1.Radix.Net>,
Ed Hitler <revjack@radix.net> wrote:
>John Stanley explains it all:
>
>:Let's rephrase the question based on what you want to accomplish. You
>
>Well, what I really *really* wanted to accomplish was determining a
>regex that will pull an e-mail address from any arbitrary line of text.
Here's what you said you were doing:
](Note - I'm calculating newsgroup posting statistics, not authoring a
]spambot.)
Did you want to accomplish "posting statistics" or "pull an email
address from any arbitrary line of text"? The former does not imply the
latter.
>It would probably be amusing to observe attempts to compel this
>explanation.
If you don't want to explain what you are doing, by all means don't
bother wasting our time explaining what you are doing or what you want
to accomplish.
<plonk>
------------------------------
Date: 4 Feb 1999 18:51:49 GMT
From: Ed Hitler <revjack@radix.net>
Subject: Re: Regex for e-mail addresses?
Message-Id: <79cq85$h0$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
John Stanley explains it all:
:In article <79an79$3js$1@news1.Radix.Net>,
:Ed Hitler <revjack@radix.net> wrote:
:>John Stanley explains it all:
:>
:>:Let's rephrase the question based on what you want to accomplish. You
:>
:>Well, what I really *really* wanted to accomplish was determining a
:>regex that will pull an e-mail address from any arbitrary line of text.
:Here's what you said you were doing:
I lied.
--
/~\ Cretan they'll turban permeate acetic fear protrusion candidate
C oo ignominious cuisine hysterectomy Finnegan presentation temple m
_( ^) 1 , 0 0 0 , 0 0 0 m o n k e y s c a n ' t b e w r o n g
/___~\ http://3509641275/~revjack 02/04/99 13:51:38 revjack@radix.net
------------------------------
Date: 4 Feb 1999 18:52:47 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: sending an attached file with Sendmail?
Message-Id: <79cq9v$jls$7@news0-alterdial.uu.net>
Artoo <r2-d2@REMOVEbigfoot.com> wrote:
> How can you send an attached file (text file) with sendmail and Perl?
I've never used them, but there is a module distribution on CPAN called
MIME-tools. Betcha they contain something to build MIME messages (but I
don't promise anything!).
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 04 Feb 1999 14:05:16 -0500
From: Uri Guttman <uri@ibnets.com>
To: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Sorting with Matts simple search script?
Message-Id: <39emo6dm6r.fsf@ibnets.com>
>>>>> "JL" == James Ludlow <ludlow@us.ibm.com> writes:
JL> Uri Guttman wrote:
>>
>> >>>>> "epd" == el pollo diablo <bencas@bigfoot.com> writes:
>>
epd> Hi, I'm not much of a perl programmer but I'm trying to make
epd> matts simple search script (from www.worldwidemart.com) sort the
epd> outputted titles alphabetically.
>>
epd> foreach $key (keys %include) {
>> ^sort
JL> That will sort by key value. He wanted to sort by title. Only by
JL> coincidence would this work.
my bad. i didn't read the whole post carefully. i was just pissed
seeing matt's crap mentioned again.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 4 Feb 1999 14:36:12 -0500
From: "Dave McIntyre" <davem@nortak.com>
Subject: Re: UNIX 'tail' command in Perl??
Message-Id: <79csvs$pse$1@goblin.uunet.ca>
You could try:
open(FILE,"mybigfile");
@allrecords=<FILE>; #put all records in array
for ($i=0;$i<10;$i++)
{
$last=pop@allrecords; #get the last one
push (@last_ten, $last); # if you want to keep them for some reason
}
# @allrecords now has the last ten chopped off
This works, but there's probably an easier way.
Dave McIntyre
Peter Smith wrote in message <36B75FB3.9594626@mindspring.com>...
>I have a 650MB text file with 162,000 recortds that I need to do
>something with - I haven't yet been able to open with Access/Excel/etc.
>Soooooo, I thought I might be able to chop it up using the tail
>command. I don't have access to a UNIX box, however.
>
>So I need an efficient tail command so I can chop off the last x
>thousand records. How do I use Perl to get the last 10 records?
>
>open(FILE,"<mybigfile");
>seek(eof); //??
>read backwards??
>
>Thanks for any hints!
------------------------------
Date: 4 Feb 1999 18:55:13 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Unix Perl Debugger Question
Message-Id: <79cqeh$jls$8@news0-alterdial.uu.net>
Ban Spam Now <no_spam@no_spam.com> wrote:
> Hi, using debugger for the first time and have set a conditional breakpoint.
>
> How do I tell it to continue execution until it reaches my breakpoint?
perldoc perldebug
See particularly the 'c' (continue) command.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4826
**************************************