[13757] in Perl-Users-Digest
Perl-Users Digest, Issue: 1167 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 24 15:06:21 1999
Date: Sun, 24 Oct 1999 12:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940791908-v9-i1167@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 24 Oct 1999 Volume: 9 Number: 1167
Today's topics:
Re: Associative Array <schapel@cs.uiowa.edu>
Re: calling a dll from perl <matthias.schwarze@wiesbaden.netsurf.de>
Re: CGI[perl] output picture <@mdo.net>
Re: create hash for db index?? (Abigail)
Re: hashes of hashes to/from DBM files... <seetherNOseSPAM@bellsouth.net.invalid>
Re: How to send & recv via UDP ... with IO:: ?? (Abigail)
HOWTO convert year/week date 1999/43 to 24.10.1999??? <thomas.frei@erp-solutions.de>
invalid transmission? <smt@bpsinet.com>
Re: invalid transmission? <marcel.grunauer@lovely.net>
Need help With Date and Time Stamps on a File <Ghassemlou@home.com>
Re: Need help With Date and Time Stamps on a File (Michael Budash)
Re: Need Help With Perl and PGP and CGI (Pete Holsberg)
Re: New short cut assignment operators? (Craig Berry)
not enough swap space <ysofer@md2.huji.ac.il>
perl browser cnsxxx09@my-deja.com
Perl Message Board problem <ebow2000NOebSPAM@aol.com.invalid>
Re: Perl vs. REBOL <bz9t@yahoo.com>
Re: Perl vs. REBOL <jtsai@virginia.edu>
Re: Perl vs. REBOL <bz9t@yahoo.com>
Re: Perl vs. REBOL <flavell@mail.cern.ch>
Re: Regular Expression...to remove last Field!!!! <schapel@cs.uiowa.edu>
Re: Regular Expression...to remove last Field!!!! (Michael Budash)
removing newlines from a string. <tom@no-spam.tnunn.demon.co.uk>
Re: removing newlines from a string. (Gordon Clemmons)
Re: removing newlines from a string. <ltl@rgsun40.viasystems.com>
Re: removing newlines from a string. (Michael Budash)
Re: removing newlines from a string. <tom@no-spam.tnunn.demon.co.uk>
Re: removing newlines from a string. <tom@tnunn.demon.co.uk>
Text::Template and -T <warnock@home.com>
Re: uninitialized value on ftp subroutine <dutch@mindspring.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 24 Oct 1999 12:18:27 -0500
From: Steve Chapel <schapel@cs.uiowa.edu>
Subject: Re: Associative Array
Message-Id: <38133F63.35195B27@cs.uiowa.edu>
Abigail wrote:
>
> Govindaraj (umungo01@shafika.vetri.com) wrote on MMCCXLII September
> MCMXCIII in <URL:news:s0tdjgatr0132@corp.supernews.com>:
> ::
> :: I just like to know this...!!! Sorry, I am not able to find this in any
> :: perl references.....!!!
>
> Then look harder. It's there.
They're now called hashes.
------------------------------
Date: Fri, 22 Oct 1999 21:35:50 +0200
From: Matthias Schwarze <matthias.schwarze@wiesbaden.netsurf.de>
Subject: Re: calling a dll from perl
Message-Id: <3810BC96.9FE2312B@wiesbaden.netsurf.de>
Hi!
> Does anyone know if it's possible to call a dll in the Win32 version of
> perl?
Yes, you can. Have a look at Win32::API!
Matthias
------------------------------
Date: Sun, 24 Oct 1999 14:39:09 -0400
From: "CS" <@mdo.net>
Subject: Re: CGI[perl] output picture
Message-Id: <ukIQ3.34434$E_1.1935252@typ11.nn.bcandid.com>
>1) Go to CPAN, and look up GD.
Good tip. Thanks. Its now installed.
p.s. (Your post did not go in vain.)
------------------------------
Date: 24 Oct 1999 11:12:25 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: create hash for db index??
Message-Id: <slrn816buh.fji.abigail@alexandra.delanet.com>
Shmooth (shmooth@yahoo.com) wrote on MMCCXLI September MCMXCIII in
<URL:news:380E142E.ED3462F5@yahoo.com>:
() I'm using Oracle 8i and I need to create a unique key for these long
() records I have. I know nothing of Oracle, so I thought maybe I could
() create a hash of the concatentation of several fields to obtain a unique
() value?
Perhaps if you need to do something with Oracle, you would have to
make yourself familiar with it?
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 24 Oct 1999 10:36:28 -0700
From: seether <seetherNOseSPAM@bellsouth.net.invalid>
Subject: Re: hashes of hashes to/from DBM files...
Message-Id: <000b8d9b.10822a3c@usw-ex0101-006.remarq.com>
Thanks. After seeing the output I thought that might be the issue.
I'll check that book out.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 24 Oct 1999 12:35:48 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to send & recv via UDP ... with IO:: ??
Message-Id: <slrn816gqs.fji.abigail@alexandra.delanet.com>
Mark Bakker (ceesbakk@casema.nl) wrote on MMCCXLII September MCMXCIII in
<URL:news:380eed53$0$4065@reader1.casema.net>:
## One little questing why do you want to use the UDP protocol if you can use
## TCP?
## I think TCP is a much better way (error correction ect.).
##
## John Stumbles <visstmbl@reading.ac.uk> schreef in berichtnieuws
## Pine.WNT.4.10.9910201813130.195-100000@supc16.rdg.ac.uk...
[ Snip 127 lines ]
Please don't post Jeopardy style, and don't quote 127 lines to add 2
lines that are hardly relevant to your reply.
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 24 Oct 1999 19:16:31 +0200
From: Thomas Frei <thomas.frei@erp-solutions.de>
Subject: HOWTO convert year/week date 1999/43 to 24.10.1999???
Message-Id: <38133EEF.7CDF6D87@erp-solutions.de>
I`ve got strings holding "1999/43" or "1999/44".
Does anybody now how I can convert that string to the date of the first
monday of that week?
Thanks
Thomas
visit me at: http://www.erp-solutions.de
------------------------------
Date: Sun, 24 Oct 1999 13:04:35 -0500
From: "Steve" <smt@bpsinet.com>
Subject: invalid transmission?
Message-Id: <ASHQ3.1907$SU1.175103@news1.primary.net>
Have set up a web page with a shop online section ...worked fine did not
change a thing now I get an error "invalid transmission #3 received from:
(ip address) if your connection is interupted enter the shop from the
beginning" Any ideas why this would happen? could the server have changed
something? and if they did what did they change?......this is a paying
customer's website and need to get it running soon! Thanks in advance!
------------------------------
Date: Sun, 24 Oct 1999 18:07:32 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: invalid transmission?
Message-Id: <WVgTOE6flISR+i1HSDcbkspmAQnR@4ax.com>
On Sun, 24 Oct 1999 13:04:35 -0500, "Steve" <smt@bpsinet.com> wrote:
> Have set up a web page with a shop online section ...worked fine did not
> change a thing now I get an error "invalid transmission #3 received from:
> (ip address) if your connection is interupted enter the shop from the
> beginning"
Doesn't sound like a Perl error message.
> Any ideas why this would happen? could the server have changed
> something? and if they did what did they change?......this is a paying
> customer's website and need to get it running soon! Thanks in advance!
If you're in a hurry, hire a programmer. Usenet is not an
instant-response technology, nor do I feel compelled to drop
everything just because you say it's urgent.
Now, do you have a specific Perl question?
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: Sun, 24 Oct 1999 18:00:39 GMT
From: "B.J.G." <Ghassemlou@home.com>
Subject: Need help With Date and Time Stamps on a File
Message-Id: <bPHQ3.11700$Ua7.317278@news2.rdc1.on.home.com>
I am trying to get the time/date of last update on certain files on the
server
is there any perl command that supports that
Thanks
bGhassemlou@yahoo.com
------------------------------
Date: Sun, 24 Oct 1999 11:09:36 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Need help With Date and Time Stamps on a File
Message-Id: <mbudash-2410991109360001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <bPHQ3.11700$Ua7.317278@news2.rdc1.on.home.com>, "B.J.G."
<Ghassemlou@home.com> wrote:
>I am trying to get the time/date of last update on certain files on the
>server
>is there any perl command that supports that
>Thanks
>bGhassemlou@yahoo.com
see perl's stat function
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 24 Oct 1999 17:46:52 GMT
From: pjh@mccc.edu (Pete Holsberg)
Subject: Re: Need Help With Perl and PGP and CGI
Message-Id: <7uvgmc$qd2$3@lawrenceville.mccc.edu>
The following script works from the command line when
executed by "nobody", the owner of httpd. When executed
from the cgi-bin directory via Netscape, it does the "pgp
-kv" but it won't encrypt the file.
????
#!/usr/bin/perl
$pgpprog = "/usr/bin/pgp";
$pgptempdir = "/.pgp/temp";
$tempfile = "test.txt";
$kvfile = "KV";
$pgpuserid = "getlik";
$pgp_version = "0";
#$ENV{'PGPPATH'} = '/home/.pgp';
print "Content-Type: text/html\n\n test<BR>";
if ($pgp_version eq "5.0")
{
system("$pgpprog -r $pgpuserid $pgptempdir/$tempfile");
}
else
{
# system("$pgpprog +batchmode -eat $pgptempdir/$tempfile $pgpuserid");
system("$pgpprog -kv $pgpuserid /usr/local/lib/pgp/pubring.pgp > $pgptempdir/$kvfile");
system("$pgpprog -e $pgptempdir/$tempfile $pgpuserid" > /dev/null);
}
#@list = system("$pgpprog pgpk -1 $pgpuserid");
#foreach (@list) { print "$_<BR>"; }
The web server error log has this:
We need to generate 192 random bits. This is done by measuring the
time intervals between your keystrokes. Please enter some random text
on your keyboard until you hear the beep:
cannot open tty, using stdin
Unable to get terminal characteristics: ioctl: Invalid argument
I'm really stumped.
Thanks for the help.
Pete Holsberg
--
Pete Holsberg
MCCC
Trenton, NJ
------------------------------
Date: Sun, 24 Oct 1999 17:08:26 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: New short cut assignment operators?
Message-Id: <s16f8aal8599@corp.supernews.com>
Abigail (abigail@delanet.com) wrote:
: Craig Berry (cberry@cinenet.net) wrote on MMCCXLIII September MCMXCIII in
: <URL:news:s11dkh435n676@corp.supernews.com>:
: --
: -- Benchmark: timing 500000 iterations of a += b, a = a + b...
: -- a += b: 10 secs ( 5.71 usr 0.01 sys = 5.72 cpu)
: -- a = a + b: 16 secs (10.74 usr 0.00 sys = 10.74 cpu)
: --
: -- Oops, guess Perl's expression optimizer isn't as good as most modern C
: -- compilers'.
:
: Maybe, maybe not. Since the arguments are strings, and not coderefs,
: you are measuring here the *compile time* and the execution time.
: Perhaps the extra 5 secs were spend in the compiler....
Okay, Perl gurus, can someone please give me the skinny on Benchmark? I
used to use coderefs, until Ilya dressed me down for it, saying coderefs
would never give good results. Now Abigail is telling me that string
evals are bad. What's up with this? Which is The True Way of Benchmark
(tm)?
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Sun, 24 Oct 1999 17:47:18 +0200
From: Yael Sofer <ysofer@md2.huji.ac.il>
Subject: not enough swap space
Message-Id: <38132A06.3BD4CC1F@md2.huji.ac.il>
When running a script I've written which is supposed to run apps I get
the message "unable to obtain requested swap space". The script runs
on, obtaining unwanted results. Is there a way to get more swap space
or to divide the swap space somehow (I don't have SU privileges in the
specific computer).
thank you,
Yael.
------------------------------
Date: Sun, 24 Oct 1999 18:13:00 GMT
From: cnsxxx09@my-deja.com
Subject: perl browser
Message-Id: <7uvi7c$ld7$1@nnrp1.deja.com>
Hi,
If have used the code in the Perl Cookbook to write a simple Perl
text browser...and most of the time it works quite well...whether static
or cgi generated pages.
Instead of firing up a browser (especially at work....:-)....), I can
customise the script to get the info I want.
But on one site it fails:
http://uk.finance.yahoo.com/q?m=l&s=ibm&d=v1
Somehow, unless the site is viewed with a browser, it returns a standard
server error message that the URL '/q' cannot be found.
Somehow the server must distinguish between a browser and a non-browser?
Is there any way of supplying more information and getting what I want?
TIA
C.
--
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 24 Oct 1999 11:31:52 -0700
From: Iain <ebow2000NOebSPAM@aol.com.invalid>
Subject: Perl Message Board problem
Message-Id: <0a0133f8.39bd6ef9@usw-ex0102-014.remarq.com>
Hello,
I'm looking to password protect an area of a site that contains a
message board. The password protection system I've created works just
fine, but I'm at a loss as to how to take the user details and set them
up as the default in the message board, which was going to be the
WWWBoard by Matt Wright.
Does anyone have any ideas how I can solve this problem, or know of any
.cgi message boards that would help?
Thanks in advance.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Sun, 24 Oct 1999 13:23:12 -0400
From: Billy Zhao <bz9t@yahoo.com>
To: mgjv@comdyn.com.au
Subject: Re: Perl vs. REBOL
Message-Id: <38134080.E69DB7E5@yahoo.com>
Martien,
Again, if you actually read what I said, I did not ask for "you" to do my work
for me. I'm merely asking if anyone who has worked with Perl has had any
experience with REBOL. Carl Sassenrath touts all the benefits of REBOL over
Perl. I didn't want to evaluate a language based on the words of the author.
So, I went looking for a contrasting view. None of this would count as "doing my
work for me."
I don't see your point about how comparing two languages are evil. Case in
point, take C++ and Java. C++ allows pointers and pointer arithmetic. Java
doesn't. Obviously Java has a tighter type system and errors are less likely
than with a language that lets programmers access arbitrary parts of memory. On
the other hand, C++ gains more flexibility than Java. Everything above can be
inferred from merely looking at the specs of the language. BUT, what I'm asking
is "in practice, is this the case." Well, I know the answer to the C++ and Java
question. I don't know some of the answers to the Perl and REBOL questions.
That's all I'm asking, if you have any experience with both languages, email me.
If not, don't. Now, I don't know about you Martien, but if you need psychiatric
counselling to get past a thread in a newsgroup, you have much more seriously
issues than "comparing two languages."
You haven't even said whether you've used/know REBOL. So, do you?
No, I'm guessing not. Yet you have the time to meddle in business that doesn't
concern you. Please, get a life and don't bother me. I'm waiting for somebody
helpful.
Billy Zhao
Martien Verbruggen wrote:
> [Your newsreader seems to have a chronology problem. Your reply to my
> post come before the quoted text. Please reverse the clock on your
> machine]
>
> [fixed format]
>
> On Sat, 23 Oct 1999 23:49:27 -0400,
> Billy Zhao <bz9t@yahoo.com> wrote:
> > Martien Verbruggen <mgjv@wobbie.heliotrope.home> wrote in message
> > news:slrn813cue.dii.mgjv@wobbie.heliotrope.home...
> > > On Fri, 22 Oct 1999 23:05:48 -0400, Billy Zhao <bz9t@yahoo.com> wrote:
> > > > Hi,
> > > >
> > > > I'm working on a project for my programming languages class. Given as
> > > > how REBOL is still relatively new and there're not too many
>
> [snip of rest of post, quoted in entirity, including signature]
>
> > Martien,
> >
> > "Keep in mind that it is intended to help inform newcomers." That's in the
> > email from Nathan Torkington.
>
> Yes? I read that. And?
>
> > I count myself as a newcomer. If you feel
>
> So do I.
>
> > If you feel
> > like patronizing me, email the reponse to me, there's no need to post
> > sarcastic comments to the group. If you don't feel like helping, don't.
>
> I don't at all feel like patronising you. Not at all. I've got better
> things to do. I was just pointing out to you that posts about language
> comparisons are considered evil, and that posts asking newsgroups to do
> _your_ work are considered lazy. Yours falls in both categories.
>
> If that isn't helping to prevent you making the same mistake when you
> need to know the respective strengths of Basic vs. C or Pythin s. tcl,
> then I don't know any more.
>
> Besides that, I wasn't using sarcasm. Just information.
>
> > But please keep your mean spirited arrogance to yourself.
>
> `mean' implies intent.
> `spirit' implies the belief in something ethereal.
> `arrogance' implies more than two syllables.
>
> I feel thoroughly rebuked. Thank you.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | Never hire a poor lawyer. Never buy
> Commercial Dynamics Pty. Ltd. | from a rich salesperson.
> NSW, Australia |
------------------------------
Date: Sun, 24 Oct 1999 13:37:18 -0400
From: James Tsai <jtsai@virginia.edu>
Subject: Re: Perl vs. REBOL
Message-Id: <381343CE.6C10AA7A@virginia.edu>
Hello CLPMers,
I'm James Tsai and I'm in Billy's group for the project htat we're working on.
I'm a little bit concerned about the negativity I'm reading in the threads on
his question.
We decided as a group that it was a good idea for a post to what we figured was
an open forum of ideas of topics related to Perl language topics.
No, we are not asking for anyone to write our project for us. Any good research
project requires research and we figured, what better than asking the veteran
Perl community about Perl in comparison to what seems like a budding language?
We are simple college students that like you at one point needed to learn things
from someone. We can't all learn everything on our own through books and just
"trying things" on our own -- this is where the sense of community that
programmers need to develop, and reading what Larry Wall has written, I would
think that there would be some community and pride in their language.
But at the same time, the extreme of this may be a bad idea. Could it be, it
seems from reading the threads, that people are so attached to their language
that they refuse to even consider looking at anything new? Look at Fortran.
Still the fastest language, it is still snubbed at by the newer programming
class as "outdated," "antique," and certainly something "old fossils" only would
program in. No. It's really a great language and all and has great advantages.
But sometimes it is necessary to recognize that there are other languages that
are better made for certain projects.
And that is what we are trying to figure out with this project. Could Rebol wipe
out Perl in the future? If it's psychologically distressful for you, then maybe
it's time to move along and get another job -- computer programmers HAVE to
understand that languages die and continue to grow and be born or else they
really are toast. I worked in a research lab last summer, and that was the talk.
Cobol, fortran, basic, pascal...
Thank you for you time and consideration of this matter. I invite any comments
you may have.
-- James Tsai
CS III, University of Virginia.
jtsai@virginia.edu
Billy Zhao wrote:
> Hi,
>
> I'm working on a project for my programming languages class. Given as how
> REBOL is still relatively new and there're not too many testimonials out
> there, I was just wondering if someone who has used REBOL and/or Perl can
> run down a list of specs I have and tell me which language has the advantage
> over the other?
>
> The project is to evaluate the suitability of Perl and REBOL for use in
> "constructin an infrastructure for sharing information among a set of
> company databases." This infrastructure should communicate with the
> databases though their APIs. Although, I imagine that the fact that it is
> to be used in a database is pretty much irrevelant, we're just trying to
> contrast the two languages.
>
> The following is a list of specifications my group came up with:
>
> 1. external interface (how well can the end-user utilize the program, how
> clean and intuitive is the compiler interface)
>
> 2. portability (Perl and REBOL both support system independent code, and
> REBOL doesn't support system dependent code. But to what degree does Perl
> support the latter?)
>
> 3. supporting datatypes (do the languages provide data types that allow for
> programming the associated database programs)
>
> 4. speed (how fast are corresponding processes performed? Larry Wall says
> that REBOL runs about 10 times slower than Perl, but has REBOL made any
> improvements since?)
>
> 5. extensibility (how easy is it to extend the database program beyond the
> stage it is at today, does each language provide libraries?)
>
> 6. security (how safe is the lanugage in terms of doing things over an open
> network? file security?)
>
> 7. readability (REBOL was made to be written and read easily, but does it
> work in practice?)
>
> 8. fault tolerance (how is the built in error catching and exception
> handling mechanisms?)
>
> 9. flexibility (how easy is it to do really different things with the
> language (i.e. be suitable for a database AND a game))
>
> Thanks in advance for any help!
>
> Billy Zhao
------------------------------
Date: Sun, 24 Oct 1999 13:51:22 -0400
From: Billy Zhao <bz9t@yahoo.com>
Subject: Re: Perl vs. REBOL
Message-Id: <3813471A.ED36D535@yahoo.com>
> If that isn't helping to prevent you making the same mistake when you
> need to know the respective strengths of Basic vs. C or Pythin s. tcl,
> then I don't know any more.
>
If you don't know any more, then don't butt in. I'm asking for help from people
who DOES know any more.
> `mean' implies intent.
> `spirit' implies the belief in something ethereal.
> `arrogance' implies more than two syllables.
>
> I feel thoroughly rebuked. Thank you.
Thoroughly rebuked, huh? How could that be? "arrogance" doesn't imply any
number of syllables. Those two are completely unrelated clauses in the English
language.
------------------------------
Date: Sun, 24 Oct 1999 20:33:26 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl vs. REBOL
Message-Id: <Pine.HPP.3.95a.991024203306.3949H-100000@hpplus01.cern.ch>
On Sun, 24 Oct 1999, Billy Zhao wrote:
> If you don't know any more, then don't butt in.
Go away, troll.
------------------------------
Date: Sun, 24 Oct 1999 12:15:23 -0500
From: Steve Chapel <schapel@cs.uiowa.edu>
Subject: Re: Regular Expression...to remove last Field!!!!
Message-Id: <38133EAB.7B5985B5@cs.uiowa.edu>
Govindaraj wrote:
>
> Hi,
>
> I don't know how difficult/easy this question would be...!!!
>
> I have input like below:
>
> R:|6||3EB-04-24190||CLAMP||2||||||||2501
> R:|6||3EB-04-24190||CLAMP||2||||||||test2501
>
> How can I remove the last field (i.e |2501 and |test2501) from the above
> line with the Reqular expression. I don't want to use
> the Array/split options for this one... I really want to achieve this
> with our great Regular Expersion.
>
> I try to match like this below:
>
> $_ =~ s/(.*?)\|(.*?)$/$1/;
Instead of matching any character at the end of the string, match
all characters but |. Using ? to get non-maximal munch seems error
prone; use a "regular" regular expression instead.
$_ =~ s/(.*)\|[^|]*$/$1/;
------------------------------
Date: Sun, 24 Oct 1999 10:58:55 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Regular Expression...to remove last Field!!!!
Message-Id: <mbudash-2410991058550001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <38133EAB.7B5985B5@cs.uiowa.edu>, Steve Chapel
<schapel@cs.uiowa.edu> wrote:
>Govindaraj wrote:
>>
>> Hi,
>>
>> I don't know how difficult/easy this question would be...!!!
>>
>> I have input like below:
>>
>> R:|6||3EB-04-24190||CLAMP||2||||||||2501
>> R:|6||3EB-04-24190||CLAMP||2||||||||test2501
>>
>> How can I remove the last field (i.e |2501 and |test2501) from the above
>> line with the Reqular expression. I don't want to use
>> the Array/split options for this one... I really want to achieve this
>> with our great Regular Expersion.
>>
>> I try to match like this below:
>>
>> $_ =~ s/(.*?)\|(.*?)$/$1/;
>
>
>Instead of matching any character at the end of the string, match
>all characters but |. Using ? to get non-maximal munch seems error
>prone; use a "regular" regular expression instead.
>
>$_ =~ s/(.*)\|[^|]*$/$1/;
we know the string is a list of fields delimited by '|'. and we will
assume that no field has a '|' in it, just for now. hence, once the '(.*)'
has gotten its bite (the longest string of any characters up to a '|'),
the rest of the string will be the last field. so the negated class and
end-of-line metacharacter are unnecessary, and this:
$_ =~ s/(.*)\|.*/$1/;
will work fine. it would, of course, break if the last field *did* have a
'|' in it, which would of course have to have been escaped thusly '\|',
right? in that case, this will work:
$_=~s/(.*)(?<!\\)\|.*$/$1/;
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sun, 24 Oct 1999 17:43:56 +0100
From: Thomas Nunn <tom@no-spam.tnunn.demon.co.uk>
Subject: removing newlines from a string.
Message-Id: <9pp0jAAMdzE4Ews1@tnunn.demon.co.uk>
Hello,
I'm writing a cgi that interacts with a database in mySQL. I'm currently
stuck on a little problem.
The cgi takes data from an HTML form and puts it into the database. The
problem is that there are some textarea bits in the form and if the
person entering the data happens to press enter, mySQL gets confused.
So I thought I'd write a small routine that removed the newlines. My
routine basically said @whatever = split('\n',$string); and then it put
the array back together as a string again.
This left behind some funny little box characters. I seem to remember
reading ages ago that the carriage return actually consists of two
characters. Is this true?
Anyway, I believe there's a much simpler way to do this using something
like s/\n/\s; but I'm quite new to perl and I'm still confused about
some of the little regular expressions.
Any help would be much appreciated.
Thank you..
--
Thomas Nunn
Remove the no-spam bit from my address to reply.
-
------------------------------
Date: 24 Oct 1999 17:14:43 GMT
From: g@cw3.net (Gordon Clemmons)
Subject: Re: removing newlines from a string.
Message-Id: <7uveq3$bra$1@fu-berlin.de>
tom@no-spam.tnunn.demon.co.uk (Thomas Nunn) wrote in
<9pp0jAAMdzE4Ews1@tnunn.demon.co.uk>:
>So I thought I'd write a small routine that removed the newlines. My
>routine basically said @whatever = split('\n',$string); and then it put
>the array back together as a string again.
You were right to think that there was a better way.
(Just as I am sure there is a better way than mine;)
This is the ideal time to use th s/// operator.
$string =~ s/\n|\r/ /g;
works for me in such an instance.
I suggest trying perldoc perlop to learn more.
Hope this helps
-- Gordon --
------------------------------
Date: 24 Oct 1999 17:41:09 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: removing newlines from a string.
Message-Id: <7uvgbl$5v5$1@rguxd.viasystems.com>
Gordon Clemmons <g@cw3.net> wrote:
:>You were right to think that there was a better way.
:>(Just as I am sure there is a better way than mine;)
:>This is the ideal time to use th s/// operator.
ideal may be a bit strong.
:>$string =~ s/\n|\r/ /g;
:>works for me in such an instance.
:>I suggest trying perldoc perlop to learn more.
While reading 'perlop', see the transliteration operator.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Sun, 24 Oct 1999 11:02:40 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: removing newlines from a string.
Message-Id: <mbudash-2410991102400001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <9pp0jAAMdzE4Ews1@tnunn.demon.co.uk>, Thomas Nunn
<tom@no-spam.tnunn.demon.co.uk> wrote:
>Hello,
>
>I'm writing a cgi that interacts with a database in mySQL. I'm currently
>stuck on a little problem.
>
>The cgi takes data from an HTML form and puts it into the database. The
>problem is that there are some textarea bits in the form and if the
>person entering the data happens to press enter, mySQL gets confused.
>
your regex question aside, tell me in what way does mysql get confused? i
put data containing newlines into mysql fields every day. can we see some
code? (since most of the folks here could care less about mysql-specific
banter, feel free to email me directly...)
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sun, 24 Oct 1999 19:30:41 +0100
From: Thomas Nunn <tom@no-spam.tnunn.demon.co.uk>
Subject: Re: removing newlines from a string.
Message-Id: <FZxGcOARB1E4EwIH@tnunn.demon.co.uk>
Since writing that last message I came up with this little sub:
sub strip_newlines{
undef $/;
$_ = $_[0];
s/\n/ /gso;
my $string = $_;
return $string;
}
it seems to work nicely, although I don't really have a clue how it
works. I took the code from something I found on the net. Is this a good
way to do it?
Can someone explain how it works?
--
Thomas Nunn
Remove the no-spam bit from my address to reply
------------------------------
Date: Sun, 24 Oct 1999 19:57:05 +0100
From: Thomas Nunn <tom@tnunn.demon.co.uk>
Subject: Re: removing newlines from a string.
Message-Id: <fZVAcLABa1E4Ewqu@tnunn.demon.co.uk>
In article <7uveq3$bra$1@fu-berlin.de>, Gordon Clemmons <g@cw3.net>
writes
>You were right to think that there was a better way.
>(Just as I am sure there is a better way than mine;)
>This is the ideal time to use th s/// operator.
>
>$string =~ s/\n|\r/ /g;
>
>works for me in such an instance.
>
Thanks, that's a lot shorter and neater than my little sub.
>I suggest trying perldoc perlop to learn more.
>Hope this helps
>
I just did that, and I'm already feeling slightly more enlightened.
>-- Gordon --
--
Thomas Nunn
------------------------------
Date: Sun, 24 Oct 1999 16:53:37 GMT
From: "Archie Warnock" <warnock@home.com>
Subject: Text::Template and -T
Message-Id: <lQGQ3.19261$HO5.116859@news.rdc1.md.home.com>
Hi all,
I'm using the Text::Template module in a CGI script to insert some
dynamically-generated text into an HTML page. When I add the -T taint flag
to the script, it croaks, complaining about an insecure variable in the
module.
Two questions - is there a fix for this, or is there another module (like
embperl?) that is taint-clean?
TIA
------------------------------
Date: Sun, 24 Oct 1999 12:49:23 -0400
From: "Dutch McElvy" <dutch@mindspring.com>
Subject: Re: uninitialized value on ftp subroutine
Message-Id: <7uvcjq$ms3$1@nntp8.atl.mindspring.net>
Thanks for your reply Steve, but even after I try moving the $newdir and
$newname from the line to another I still get the same error. Any ideas?
Thanks again,
Dutch
----------
In article <7ut91n$7a4$1@nntp6.atl.mindspring.net>, "Dutch McElvy"
<dutch@mindspring.com> wrote:
> I am using the following script to upload all files in a certain directory
> and place them on the remote machine under a new name and a new directory
> created from a portion of the file name. This could probably be done more
> cleanly but it seems to work ok only I get an error when I use -w of
> "uninitialized value" at the lines containing $newname and $newdir. What
> could I do to elimante this warning?
>
> Thanks for the help,
>
> Dutch
>
>
>
> #!/usr/bin/perl -w
>
> #Main program
>
> use Net::FTP;
> $ftp = Net::FTP->new("somemachine.com.somewhere");
> $ftp->login("usr",'passwd');
> $ftp->binary;
> $ftp->cwd("/somedir");
> rename();
> $ftp->quit;
>
> sub rename {
> $dir = "/somedir";
> opendir(DIR, $dir ) || die "can't opendir $dir: $!";
>
> (@filenames, $newname, $newdir) = readdir(DIR);
> closedir DIR;
>
> foreach ( @filenames ) {
>
> $_ =~ s/(...)(.......)(.....)(....)(...........)/$1$2$3$4$5/;
>
> $newname .= "$2$3";
> $newdir = "$1";
> }
>
> $ftp->put("$newdir/$newname") or die "Could not ftp";
>
> }
------------------------------
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 V9 Issue 1167
**************************************