[18042] in Perl-Users-Digest
Perl-Users Digest, Issue: 202 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 2 18:06:16 2001
Date: Fri, 2 Feb 2001 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981155115-v10-i202@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 2 Feb 2001 Volume: 10 Number: 202
Today's topics:
Re: 'print' problem-again! <b0l4549@cs.tamu.edu>
Re: ActiveState Perl Threads <kevin.murphy@jhuapl.edu>
Apologies to Joyce Kilmer, a hack for your enjoyment (Clinton A. Pierce)
Re: Calling all DB_File Gurus. <bart.lateur@skynet.be>
Re: Calling all DB_File Gurus. (Garry Williams)
Re: dealing with the gaps (Ange)
Executing CGI from PerlScript shakazulu_69@yahoo.com
Re: FAQ 3.0: What is perl.com? Perl Mongers? pm.org? (David H. Adler)
File download with hidden URL (BobBerry)
Re: File download with hidden URL <amonotod@netscape.net>
File time difference <ashley@pcraft.com>
Re: File time difference (John Joseph Trammell)
Re: first real PERL script . . . <bart.lateur@skynet.be>
Re: flexible scripts <rbfitzpa@my-deja.com>
Re: flexible scripts <motiNOvus@hotSPAMmail.com>
Re: flexible scripts tigra@sky.deep.ru
Getting comma separated number from comma separated fil time4tea@my-deja.com
Re: Getting comma separated number from comma separated (Craig Berry)
Re: Getting comma separated number from comma separated <godzilla@stomp.stomp.tokyo>
having problems w/ $( $) ...or... :( with $( chains@yahoo.com
Help about perl -e '`ping server`' (Ken Laird)
Re: Help about perl -e '`ping server`' <ajborla@bigpond.com>
Re: Help Reg expr to handle variables safely? perlop co chuckk@monmouth.com
Re: Help: Script only runs if ' -w' is on line 1 <ren.maddox@tivoli.com>
implace substitution <bcaligari@my-deja.com>
Re: implace substitution (Eric Bohlman)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 2 Feb 2001 14:27:26 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
Subject: Re: 'print' problem-again!
Message-Id: <Pine.SOL.4.10.10102021426330.16431-100000@robert>
But I can't use if-else since I need to run them both. Any clue again???
On Thu, 1 Feb 2001, it was written:
> if() {
> # redirect
> } else {
> # don't redirect
> }
>
> j.
>
> "Bin - Lu" <b0l4549@cs.tamu.edu> wrote in message
> news:Pine.SOL.4.10.10102010006070.3492-100000@robert...
> >
> > I have such a problem:
> >
> > At the beginning of my code I have to use
> > print "content-type: text/html\n\n";
> >
> > But then I want to use:
> > print "Location: $link\n\n";
> > exit;
> >
> > which achieves redirection and requires not to use the first 'print' line.
> > How can I 'deactivate' the first 'print' line or change the print content
> > type?
> >
>
>
>
>
------------------------------
Date: Fri, 2 Feb 2001 14:57:31 -0500
From: "Kevin Murphy" <kevin.murphy@jhuapl.edu>
Subject: Re: ActiveState Perl Threads
Message-Id: <95f3fo$rs8$1@houston.jhuapl.edu>
"Daniel Berger" <djberg96@my-deja.com> wrote in message
news:95en1j$5g7$1@nnrp1.deja.com...
> With a non-activestate install of perl, you would be asked if you want
> your distro to include perl threads during installation. The
> ActiveState distro never asks that AFAIK, so you won't be able to
> use threads.
>
> You're right, though, their "title" suggests that threading is
> automatically enabled. I've already sent them one email about this
> but got no response.
Oh well. I had been rather surprised to see such an "experimental"
feature included in their standard distribution. Guess it doesn't surprise
me all that much to find it boils down to misleading file names.
Thanks,
Kevin Murphy
------------------------------
Date: Fri, 02 Feb 2001 22:40:11 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Apologies to Joyce Kilmer, a hack for your enjoyment
Message-Id: <fHGe6.273433$hD4.66305660@news1.rdc1.mi.home.com>
#!/usr/bin/perl -w
'% * % % * % %<>
* % ~ * % % * % * * % * *
* % % * * % * % *<> * % ~ % % % * %
* * * % * % % % % * % % % % % % * % % * %
% * % % ^ * % % % % *[] % % * * % * * % % %
% * % % % % % % * * % * * @ * @ % * % %
% ^ % * % * % * * % % * % <> % % % % * % %() %
% % * * * % % * % % * * % * * * * % * * % % * * *
% * * * % % * % % *[]<> % % % % * % * * * % % *<>
% * * % % % * * % * * * \ * %\ * * * %/ \ # % * *
% % % *\ * /\ * *// % %\ <>\ // % %/ % \// % * %
* * *\ \|| \ \/ / % %// \ \ *\ /<> %// %// % %<>
* % * %\ \ | | ||// % || // \// % // * * * %
%{} % * ----\ \ | / %||// / ---/ / * % % *
% * *\ ____\ \| | / / / /----/ * %
\ ----\ | / // /
\ \ / /'
=~m/(.*)/s;$_=$1;
s![-\\|_/\s]!!g
;%e=('%',0,
'^',132918,
'~'=>18054,
'@'=>19630,
'*' =>0b01,
'#'=>13099,
'[]'=>4278,
'<>'=>2307,
'{}'=>9814,
'()',2076);
for $a(keys
%e){$e{$a}=
sprintf"%b"
, $e{$a};}
$y= qq{(}.join(
'|',map "\Q$_\E"
,keys %e).qq{)};s/$y
/$e{$1}/gex;print pack"B*",$_;
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Fri, 02 Feb 2001 20:55:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Calling all DB_File Gurus.
Message-Id: <cn7m7t0s1040rn5bc118i9d5emmli2ed4n@4ax.com>
Jody Fedor wrote:
>My humble apology to the creator of such awesome, extensive and
>glorious documentation. I lacked the understanding to perceive the
>words I perused.
Now, go and repeat at least one thousand times: "I am not worthy..."
Gee, is this groveling in the dust really necessary? The Perl docs *are*
pretty thick for newcomers. I remember having needed at least one hour
to get through just one printed page of perlsyn. That doesn't mean
they're bad.
--
Bart.
------------------------------
Date: Fri, 02 Feb 2001 21:36:17 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Calling all DB_File Gurus.
Message-Id: <lLFe6.538$Sn3.20643@eagle.america.net>
On Fri, 2 Feb 2001 11:59:50 -0500, Jody Fedor <Jodyman@usa.net> wrote:
>Garry Williams wrote in message ...
>>Or why construct a new instance of the type/openinfo data structure at
>>all? Just do as the manual says: assign to the one that already
>>exists before calling tie:
>>
>> $DB_RECNO->{reclen} = 512;
>>
>>This is well-documented in the DB_File manual page. See the "Opening
>>a Berkeley DB Database File" section in the manual.
>
> Is this DB_File manual available on-line? I only had the DB_File
>documentation from www.perl.com which was 25 pages long. These
>weren't so clear to me. Are there more extensive documentation online?
>If so, where might they be found.
*All* the documentation for Perl is on *your* computer. You access
the manual pages with the man and/or perldoc command. On Windows
machines, the manual pages have been installed as HTML documents, if
you are using the ActiveState distribution. (You will find them
somewhere in the Start menu.)
>PS - Or is there a good book? Programming the Perl DBI from O'Reilly
>didn't have the information I was looking for either.
Can't recommend one; don't know. Use the manual.
>PSS - Am I also understanding the documentation that I have correctly that
>DB_File actually reads the entire DB into memory, manipulates it there and
>then restores it to the drive?
I know that this is *not* the way that the DB_HASH and DB_BTREE file
types behave. I doubt that RECNO does, but I have not researched it.
It may also depend on the release of Berkeley DB that is underneath
DB_File. There is no mention of this behavior in my version of
DB_File:
$ perl -MDB_File -wle 'print DB_File->VERSION'
1.73
$
I don't see a reason that this would have to be the underlying
implementation. But I didn't have to implement it. :-)
[snip]
--
Garry Williams
------------------------------
Date: Fri, 2 Feb 2001 21:25:52 +0000
From: ange@cybernospampage.co.uk (Ange)
Subject: Re: dealing with the gaps
Message-Id: <1eo80je.5w371g1ekqoykN%ange@cybernospampage.co.uk>
<nobull@mail.com> wrote:
> ange@cybernospampage.co.uk (Ange) writes:
>
> > The product names contain gaps ie R679:Adraplan Model 769, but
> > unfortunately the perl script only produces R679:Adraplan.
> >
> > It works if I change the product name to R679:Adraplan-Model-769.
> >
> > Can anyone sugggest a reason for this happening,
>
> Probably splitting input file on whitespace when you probably want to
> be splitting on some delimiter. Quite possibily on comma when it does
> not appear inside quotes (see FAQ).
>
> > or location for a script which can do the job?
>
> Planet Earth. I realise that's not a terribly precise location but
> it's about as precise as the specification you've given of "the job".
Ta very much for the response. I've managed to suss it now - and
embarrassingly enough I hadn't put quotes around the name of the hidden
form field.
ange
------------------------------
Date: Fri, 02 Feb 2001 19:45:35 GMT
From: shakazulu_69@yahoo.com
Subject: Executing CGI from PerlScript
Message-Id: <95f2os$h8o$1@nnrp1.deja.com>
I'm trying to open a CGI script from a PerlScript page so that I
can "wrap" the CGI and use PerlScript features such as retrieving
cookies, etc. However, when I try to run the CGI (a *.exe) from within
my PerlScript, I get a 502 CGI error. It works if the script is *.pl.
Any ideas on whether this is even possible? Any help would be
appreciated.
The Perlscript file has the following:
<%
######
#
# the cgi called
#
######
my $CGI_CMD="\\inetpub\\scripts\\CGI_SCRIPT.EXE |";
######
#
# call the cgi, set all descriptors to binary mode
#
######
open(CGI_IN, $CGI_CMD) || failure ("Could not open $CGI_CMD");
binmode (CGI_IN);
binmode (STDOUT);
my $haveHTML = 0;
HEADERLINE: while (<CGI_IN>)
{
$Response->write( $_ );
last HEADERLINE if /^$/; # the header terminating blank line
last HEADERLINE if /^\r$/; # (which may contain a CR)
$haveHTML = 1 if m!text/html!;# check for mime type "text/html"
}
######
#
# read HTML data line-wise
#
######
if ($haveHTML)
{
while (<CGI_IN>)
{
$Response->write( $_ );
}
}
######
#
# all other, non-HTML data, stream unchanged
#
######
else
{
while ( $cb = read(CGI_IN, $data, 1024) )
{
$Response->write( $data );
}
}
######
#
# close the cgi
#
######
close CGI_IN;
%>
Thanks,
Shamir
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 2 Feb 2001 22:02:40 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: FAQ 3.0: What is perl.com? Perl Mongers? pm.org? perl.org?
Message-Id: <slrn97mbk0.coi.dha@panix2.panix.com>
On Fri, 02 Feb 2001 03:45:25 GMT, Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>in article slrn97j9cn.d5s.dha@panix2.panix.com, David H. Adler at
>dha@panix2.panix.com quoth:
>> On Thu, 01 Feb 2001 02:57:34 -0500, brian d foy <comdog@panix.com> wrote:
>>>> Perl Mongers is an advocacy organization for the Perl language. For
>>>> details, see the Perl Mongers web site at http://www.perlmongers.org/.
>>>
>>> that should be www.perl.org.
>>>
>>> [dha - what's up with that ;) ]
>>
>> I forget when this was last patched. Also, there has been some
>> indication lately that the FAQ autoposter may not be posting the most
>> up to date entries... I'll have to take a look.
>
>This has been changed/corrected in the 5.6.1 faq. :)
But, from what I can see, not in a moderately recent bleedperl... odd.
*shrug*
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I drink to my coming cirrhosis... - Charles Aznavour
------------------------------
Date: 02 Feb 2001 19:06:16 GMT
From: bobberry@aol.com (BobBerry)
Subject: File download with hidden URL
Message-Id: <20010202140616.19839.00000434@ng-cd1.aol.com>
I have a perl script that validates a user and then sends him a file by
printing a "Location: (url)" to stdout. I now see that Netscape's "Smart
Download" (or whatever it's called) displays the full URL, which I do not want
the user to be aware of.
Is there some other way to send the user a file WITHOUT using the true URL?
Perhaps some kind of http header and then writing the binary file data?
------------------------------
Date: Fri, 02 Feb 2001 22:46:41 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: File download with hidden URL
Message-Id: <95fdce$re1$1@nnrp1.deja.com>
In article <20010202140616.19839.00000434@ng-cd1.aol.com>,
bobberry@aol.com (BobBerry) wrote:
> I have a perl script that validates a user and then sends him a file
> by printing a "Location: (url)" to stdout. I now see that Netscape's
> "Smart Download" (or whatever it's called) displays the full URL,
> which I do not want the user to be aware of.
>
> Is there some other way to send the user a file WITHOUT using the true
> URL? Perhaps some kind of http header and then writing the binary file
> data?
You should search the archives at www.deja.com. You'll see that I asked
this same question some time ago. While I didn't get a concrete "this
is how you do it" answer, I did get the task completed. You can find my
work here:
http://www.geocities.com/amonotod/download_pl.html
You should be able to use it in a <body onload=""> statement at the top
of some kind of 'thank you' page.
hth,
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 14:57:05 -0700
From: "Ashley M. Kirchner" <ashley@pcraft.com>
Subject: File time difference
Message-Id: <3A7B2D31.4DE8A284@pcraft.com>
I have a program that creates lock files whenever it's run, however
sometimes these locks become stale. I'd like to write a script that
will scan that particular directory and determines if a lock file is
older than a preset time, before deleting it. Considering there may be
more than one single lock file, it needs to check each file, and if
they're, say over 60 minutes old, it can go ahead and delete the file.
Any suggestions/pointers?
--
W |
| I haven't lost my mind; it's backed up on tape somewhere.
|____________________________________________________________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130
SysAdmin / Websmith . 800.441.3873 x130
Photo Craft Laboratories, Inc. . eFax 248.671.0909
http://www.pcraft.com . 3550 Arapahoe Ave #6
.................. . . . . Boulder, CO 80303, USA
------------------------------
Date: Fri, 02 Feb 2001 22:26:50 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: File time difference
Message-Id: <slrn97mb1n.5ug.trammell@bayazid.hypersloth.net>
On Fri, 02 Feb 2001 14:57:05 -0700, Ashley M. Kirchner <ashley@pcraft.com>
wrote:
>
> I have a program that creates lock files whenever it's run, however
> sometimes these locks become stale. I'd like to write a script that
> will scan that particular directory and determines if a lock file is
> older than a preset time, before deleting it. Considering there may be
> more than one single lock file, it needs to check each file, and if
> they're, say over 60 minutes old, it can go ahead and delete the file.
>
> Any suggestions/pointers?
man find
------------------------------
Date: Fri, 02 Feb 2001 20:56:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: first real PERL script . . .
Message-Id: <po7m7tsja7376qojl5lcodidd0oavkefel@4ax.com>
Uri Guttman wrote:
> JWK> my $EOR = 0x0D;
>
>better make that "\x0D" as they are meant to be bytes and not
>integers. same thing for EOF
> JWK> print FILE $EOR;
>
>that would print 4 bytes (assuming a 32 bit perl) instead of the 1 byte
>the OP wanted.
No. Just two: a "1" and a "3".
--
Bart.
------------------------------
Date: Fri, 02 Feb 2001 19:25:39 GMT
From: igotlooks.com <rbfitzpa@my-deja.com>
Subject: Re: flexible scripts
Message-Id: <95f1j5$g4t$1@nnrp1.deja.com>
I'm not so sure that I know the answer or exactly what your looking for
but it seems to me that you should work with Global Variables which are
set up front according to the O/S your working on.
I've seen many scripts ready to work on several platforms without
modifications and they weren't much more than a bunch of 'if/then' or
'case' statements. This can be simplified with Global Variables as
follows:
--Initialization Process--
if ($OS = "Sun")
then
{
$contents_of_dir="/usr/local/bin";
}
elsif ($OS = "Win")
then
{
$contents_of_dir="dir"
}
NOTE:
This code DOES NOT work but the idea should suffice for your purpose. If
you write your script(s) with a Global Function 'contents_of_dir' the
initialization stage should enable it to run on any platform. Hope this
helps. This same idea can be used to make your scripts flexible based on
content type.
In article <NJCe6.30$gp6.24527@news.pacbell.net>,
"B McDonald" <motiNOvus@hotSPAMmail.com> wrote:
>
> Although this question is probably fundamental to all that we do in
perl, I
> think that the question is probably off-topic. Still I don't know
where to
> get an answer. So, at the very least, I hope that someone can direct
me to
> the proper group or resource that will answer my question.
>
> Basically, I've created one perl script that serves to parse a CSV
file into
> a specific XML format, and another that takes the XML and injects the
data
> into SQL 7.
>
> The issue is how to make these tools flexible in their invokation and
in the
> generation of their output, be it XML files or statistical reports. In
other
> words, I would like the intended users of the scripts to be able to
invoke
> them in whatever directory they may be working, on load files
whereever they
> may be located, and the output placed in directories wherever the user
> decides to create them.
>
> I'm not exactly certain how to frame the question, or what this is
called --
> but I figure there are perl experts and novices out there who have
mastered
> making their tools flexible within the OS environment. I am on a Win
NT
> machine.
>
> Thanks,
>
> Brian
>
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 2 Feb 2001 12:31:45 -0800
From: "B McDonald" <motiNOvus@hotSPAMmail.com>
Subject: Re: flexible scripts
Message-Id: <%PEe6.41$gp6.54854@news.pacbell.net>
"igotlooks.com" <rbfitzpa@my-deja.com> wrote in message
news:95f1j5$g4t$1@nnrp1.deja.com...
> I'm not so sure that I know the answer or exactly what your looking for
> but it seems to me that you should work with Global Variables which are
> set up front according to the O/S your working on.
>
> I've seen many scripts ready to work on several platforms without
> modifications and they weren't much more than a bunch of 'if/then' or
> 'case' statements. This can be simplified with Global Variables as
> follows:
>
> --Initialization Process--
> if ($OS = "Sun")
> then
> {
> $contents_of_dir="/usr/local/bin";
> }
> elsif ($OS = "Win")
> then
> {
> $contents_of_dir="dir"
> }
>
> NOTE:
> This code DOES NOT work but the idea should suffice for your purpose. If
> you write your script(s) with a Global Function 'contents_of_dir' the
> initialization stage should enable it to run on any platform. Hope this
> helps. This same idea can be used to make your scripts flexible based on
> content type.
>
No, that's not exactly what I had in mind. Right now I'm not even concerning
myself with cross-platform issues.
I guess what I am asking is what perl programmers normally do with the tools
they write. Is there a convention for the name of the directory they store
them in? Is it /bin? Or is bin strictly for binary executable files? (I feel
that is probably a stupid question.) And then, I would like to make those
perl scripts (the first is txt2xml.pl and the second is xml2sql.pl) callable
from any directory on a Win NT/2000 network. I'm not very familiar with
getting these things to run over a network...
Brian
------------------------------
Date: Fri, 02 Feb 2001 21:57:46 GMT
From: tigra@sky.deep.ru
Subject: Re: flexible scripts
Message-Id: <95fagi$olu$1@nnrp1.deja.com>
In article <%PEe6.41$gp6.54854@news.pacbell.net>,
"B McDonald" <motiNOvus@hotSPAMmail.com> wrote:
> I guess what I am asking is what perl programmers normally do with the
tools
> they write. Is there a convention for the name of the directory they
store
> them in? Is it /bin? Or is bin strictly for binary executable files?
(I feel
> that is probably a stupid question.) And then, I would like to make
those
> perl scripts (the first is txt2xml.pl and the second is xml2sql.pl)
callable
> from any directory on a Win NT/2000 network. I'm not very familiar
with
> getting these things to run over a network...
I'll try outline some key features of a flexible script and a method to
create one.
First try to standardize the location of your modules (if you use some
of your own). The second is usage of globals (or create a standalone
module with them to encapsulate all the stuff at one place). After all,
if you call some programs outside your script make sure that they are
standard or provide the end user with a bundle of these tools.
Once you decided that your script is rather distributable just try to
install it on another machine and see the result. That's it.
Sergey
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 20:50:19 GMT
From: time4tea@my-deja.com
Subject: Getting comma separated number from comma separated file
Message-Id: <95f6i7$kpi$1@nnrp1.deja.com>
Hi,
Apologies if this is a FAQ, but I couldn't find the information
anywhere....
I have a csv, that looks like this
a,b,c,d,e,f,$1,234,567.00,other,stuff
How can I extract the fields out correctly? A simple split won't work,
and I had real trouble thinking up a regex that will remove the ','(s)
in the number.
The number will always start with '$' and end with '.00', but may vary
between $0.00 and some large number.
If this is not in the FAQ, then i vote it gets added!
Any help much appreciated.
Thanks!
James
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 22:03:16 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Getting comma separated number from comma separated file
Message-Id: <t7mbl4i9v1n7e8@corp.supernews.com>
time4tea@my-deja.com wrote:
: I have a csv, that looks like this
:
: a,b,c,d,e,f,$1,234,567.00,other,stuff
A "proper" CSV will have quotes around fields containing commas.
: How can I extract the fields out correctly? A simple split won't work,
: and I had real trouble thinking up a regex that will remove the ','(s)
: in the number.
For arbitrary values in the other fields, there's no way to do it. If the
only place where a comma will be followed by three digits is inside a
currency field, then this will work:
$str = 'a,b,c,d,e,f,$1,234,567.00,other,stuff';
@fields = split /,(?!\d{3})/, $str;
print join(':', @fields), "\n";
Output: a:b:c:d:e:f:$1,234,567.00:other:stuff
The split pattern uses negative lookahead to ignore commas which are
followed by three digits.
Do note again that your real problem here is improper CSV format, though.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: Fri, 02 Feb 2001 14:35:34 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Getting comma separated number from comma separated file
Message-Id: <3A7B3636.60D78DD6@stomp.stomp.tokyo>
time4tea@my-deja.com wrote:
(various snippage)
> I have a csv, that looks like this
"...looks like this"
Posting a database sample which is not a factual
representation of a database in use, is rather
a poor choice when asking for help. Does your
example precisely represent a database sample
or have you simply posted something unrelated?
> a,b,c,d,e,f,$1,234,567.00,other,stuff
> How can I extract the fields out correctly?
This is not a question of how to extract data
correctly. This is a question of why you did
not correctly format your database. A database
should not contain meta-characters and, a comma
delimited database should not contain monetary
values delimited with commas.
This displayed database sample, which is quite
dubious not being a true sample, indicates you
have made poor choices in database management
and are not qualified to write Perl scripts
which manage a database. An inability to
create a correct database is a reflection of
an inability to write correct Perl code.
Edit your database to remove meta-characters,
such as a dollar sign, edit your database to
delimit monetary values with a character other
than a comma. This would be an intelligent
and most logical solution for these problems
you, yourself, created.
Godzilla!
--
This test script shows a method. However, it
will fail if you have a single digit data entry,
followed by another single digit data entry,
both delimited by a comma.
Learn how to establish a correct and effective
database, then learn how to write Perl code.
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
$string = 'a,b,c,$1,234,567.00,d,e,f';
$string =~ tr/$/¢/;
$string =~ s/(\d),(\d)/$1¿$2/g;
@Array = split (/,/, $string);
foreach $element (@Array)
{
$element =~ tr/¢¿/$,/;
print "$element ";
}
exit;
PRINTED RESULTS:
________________
a b c $1,234,567.00 d e f
------------------------------
Date: Fri, 02 Feb 2001 21:25:13 GMT
From: chains@yahoo.com
Subject: having problems w/ $( $) ...or... :( with $(
Message-Id: <95f8je$mqo$1@nnrp1.deja.com>
Hello,
I'm having some problems setting $( and $) w/ Perl 5.6 on Linux 2.2.16
could someone please show me what I'm doing wrong. I really need to run
it this way w/out suid/sgid bit set.
Recompliled Perl and verified that setregid() was found and definded.
---8<---8<---
#!/usr/bin/perl
print "EUID was $>\n";
$> = 529;
print "EUID now $>\n\n";
print "RUID was $<\n";
$< = 529;
print "RUID now $<\n\n";
print "EGID was $)\n";
$) = 100;
print "EGID now $)\n\n";
print "RGID was $(\n";
$( = 100;
print "RGID now $(\n\n";
exec "/usr/bin/id";
---8<---8<---
Output is...
[root@franklin chains]# ./testpl.pl
EUID was 0
EUID now 529
RUID was 0
RUID now 529
EGID was 0 10 6 4 3 2 1 0
EGID now 0 10 6 4 3 2 1 0
RGID was 0 10 6 4 3 2 1 0
RGID now 0 10 6 4 3 2 1 0
uid=529(chains) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@franklin chains]#
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 21:16:59 GMT
From: kenlaird@yahoo.com (Ken Laird)
Subject: Help about perl -e '`ping server`'
Message-Id: <ftFe6.5752$335.28575@amsnews03.chello.com>
I'd like to see the result of this command :
perl -e '`ping server`'
it works , but is it possible to see the output on the screen ?
Moreover , why
perl -e 'system ping server'
is not working at all?
Ken Laird
kenlaird@yahoo.com
------------------------------
Date: Sat, 3 Feb 2001 08:41:02 +1100
From: "Anthony Borla" <ajborla@bigpond.com>
Subject: Re: Help about perl -e '`ping server`'
Message-Id: <8FFe6.15338$65.82265@newsfeeds.bigpond.com>
"Ken Laird" <kenlaird@yahoo.com> wrote in message
news:ftFe6.5752$335.28575@amsnews03.chello.com...
> I'd like to see the result of this command :
>
> perl -e '`ping server`'
>
> it works , but is it possible to see the output on the screen ?
>
Try redirecting output to a specific device:
(UNIX) perl -e '`ping server > /dev/tty`'
You may obtain your current console via the shell command:
myConsole=`tty`;
So that you can change the above to:
perl -e "`ping server > $myConsole`"
The Win32 version is:
perl -e "`ping server > con`"
with 'con' being the console device.
> Moreover , why
>
> perl -e 'system ping server'
> is not working at all?
>
It should be:
(UNIX) perl -e 'system "ping server" '
(Win32) perl -e "system \"ping server\" "
or try:
(UNIX) perl -e 'system("ping server");'
(Win32) perl -e "system(\"ping server\");"
Do you see why *your* example was not working ?
I hope this helps.
------------------------------
Date: Fri, 02 Feb 2001 21:14:39 GMT
From: chuckk@monmouth.com
Subject: Re: Help Reg expr to handle variables safely? perlop confusing.
Message-Id: <95f7vl$m7i$1@nnrp1.deja.com>
Your absolutly right. Not needed on the replacement side.
(I guess it makes sense if I had stopped to think about it.
Chuck
In article <95bqst$lmd$1@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> <nobull@mail.com> wrote in comp.lang.perl.misc:
> >chuckk@monmouth.com writes:
> >
> >> I've just read the perlop section of the faq on quoting.
> >> But I'm still confused about special charaters in the string like
> >
> >
> >> Say I have a variable that contains the following:
> >> $a='mydir/myfile$_&?.txt';
> >> $b='$_&?';
> >> $c='^&*"';
> >>
> >> $d= $a;
> >> $d =~ s,\Q$b\E,\Q$c\E,g;
> >>
> >> IS THIS THE SAFEST SIMPLEST WAY - OR WHAT OTHER WAYS COULD I DO
THIS?
> >
> >Yes, but IHMO it looks untidy.
> >
> >Well IMHO comma is a poor choice of delimiter for s///g - especially
> >if there's no reason not to use the forward slash. Oh, and the \E
are
> >redundant.
> >
> > $d =~ s/\Q$b/\Q$c/g;
> >
> >This is semantically exaclty the same as your solution.
>
> I'd question the use of \Q on the replacement side. There is normally
> no need to do that, and the effect is to insert not the literal con-
> tents of $c but its quotemeta()d equivalent.
>
> Anno
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 02 Feb 2001 13:13:15 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <m3y9vo525w.fsf@dhcp11-177.support.tivoli.com>
vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse) writes:
> Didn't think perl was so picky about CRs as some other unix programs are.
Perl isn't, but the kernel is. If the first line is:
#!/usr/bin/perl\n
Then the kernel will try to pass the script to the program called
"perl\n" in /usr/bin. In fact, if you just link the real perl
executable to that name, the problem will go away. If you find
yourself having to remove newlines in this situation often, adding the
extra link to "perl\n" is a convenient work-around.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 02 Feb 2001 18:59:29 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: implace substitution
Message-Id: <95f02a$eh0$1@nnrp1.deja.com>
Following works under linux build
perl -pi -e 's/foo/bar/g' test
But not under win32
In both cases I am using ActivePerl build 623
Any idea?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 2 Feb 2001 23:04:08 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: implace substitution
Message-Id: <95fed8$3g1$1@bob.news.rcn.net>
Brendon Caligari <bcaligari@my-deja.com> wrote:
> Following works under linux build
> perl -pi -e 's/foo/bar/g' test
> But not under win32
On Win32 the command-line quote character is " rather than '.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 202
**************************************