[14061] in Perl-Users-Digest
Perl-Users Digest, Issue: 1471 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 23 21:06:03 1999
Date: Tue, 23 Nov 1999 18:05:18 -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: <943409118-v9-i1471@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Nov 1999 Volume: 9 Number: 1471
Today's topics:
Re: [JOB]: Web Developer/Senior Web Developer: SGML, XM <cassell@mail.cor.epa.gov>
Re: Best book on Perl <cassell@mail.cor.epa.gov>
Re: Best book on Perl <lr@hpl.hp.com>
Re: Calc.pm <cassell@mail.cor.epa.gov>
can a "cookie-monster" mess with my cookies? (BLIMP8)
Re: change directories in system (Sam Holden)
Re: change directories in system (Brett W. McCoy)
determining file date with Perl on Linux sirron@mail.mcoe.k12.ca.us
Re: determining file date with Perl on Linux <lr@hpl.hp.com>
Re: Error using tar from cgi <cassell@mail.cor.epa.gov>
Re: How do I set timeout for socket on STDIN? <rgerharz@not.erols.com>
Re: How do I set timeout for socket on STDIN? <rgerharz@not.erols.com>
Re: How do I set timeout for socket on STDIN? (Brian StJohn)
Re: How to send a bitmap as part of an HTML mail messag <john.saylor@cybertrust.gte.com>
Re: How to send a bitmap as part of an HTML mail messag <cassell@mail.cor.epa.gov>
Re: How write records to ASCII file <cassell@mail.cor.epa.gov>
Re: Initialize Variables (Greg Bacon)
Re: Initialize Variables <uri@sysarch.com>
Re: Initialize Variables lee.lindley@bigfoot.com
Re: Initialize Variables (Abigail)
Re: Initialize Variables (Martien Verbruggen)
need help with regular expr. venkatmohan@my-deja.com
need help with regular expr. venkatmohan@my-deja.com
Re: need help with regular expr. <slanning@bu.edu>
Re: need help with regular expr. <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Nov 1999 16:37:28 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: [JOB]: Web Developer/Senior Web Developer: SGML, XML, PERL5, LINUX
Message-Id: <383B3348.963613FD@mail.cor.epa.gov>
Craig Berry wrote:
>
> Kenneth Bandes (kbandes@home.com) wrote:
> : As for this group, comp.lang.perl.misc, the charter (posted
> : frequently as a mini-FAQ by Nathan Torkington) says:
> : "comp.lang.perl.misc is for questions on the Perl language."
> :
> : Period.
> :
> : What's your question on the Perl language?
>
> Dropping into devil's advocate mode, one could argue that "Would you like
> me to pay you for using the Perl language?" is a topical way to post a
> help-wanted ad. :)
[Note: I saw the smiley.]
But if you're making a case that adding the words 'in Perl'
is sufficient to make a post on-topic, then I sincerely hope
your post isn't read by most readers of this newsgroup.
Otherwise we'll get...
Subject: MAKE $$$ FAST!!! WITH PERL!!!
Subject: FOAD you loosers! And use Perl to do it!
Subject: Portuguese Whaling Songs in Perl
Subject: can I rite a yahoo thing in PERL? Huh?
.
.
.
Oh wait, we already get these.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 23 Nov 1999 16:51:50 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Best book on Perl
Message-Id: <383B36A6.AEABAA33@mail.cor.epa.gov>
John wrote:
>
> What's the best Book to Learn Perl for the web..
There is no best book to learn Perl for the web.
I'm not being flippant. There are some good books to learn
Perl. I recommend different ones depending on the background
of the querent, but if you have no programming background
[HTML doesn't count] then you should probably get "Elements
of Programming with Perl" by Andrew Johnson. And there are
some good books on web programming. But I have yet to see
a book which [1] teaches Perl from the ground up, and [2]
teaches how to write CGI scripts using Perl, at the same time.
Do *not* buy any book with the word 'dummies', 'unleashed',
or 'idiot' if you really want to learn some Perl.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 23 Nov 1999 17:47:01 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Best book on Perl
Message-Id: <MPG.12a4e36d7774e4c598a268@nntp.hpl.hp.com>
In article <383B36A6.AEABAA33@mail.cor.epa.gov> on Tue, 23 Nov 1999
16:51:50 -0800, David Cassell <cassell@mail.cor.epa.gov> says...
> John wrote:
> >
> > What's the best Book to Learn Perl for the web..
>
> There is no best book to learn Perl for the web.
>
> I'm not being flippant. There are some good books to learn
> Perl. I recommend different ones depending on the background
> of the querent, but if you have no programming background
> [HTML doesn't count] then you should probably get "Elements
> of Programming with Perl" by Andrew Johnson.
Are you getting a kickback for all these ads?
Seriously, on your recommendation I bought a copy of the book, and
though I haven't read everything yet, I haven't found anything to
criticize yet either.
Any book (for beginners, yet!) that includes Abigail's prime-number
generator can't be anything but exceptional.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Nov 1999 16:32:13 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Calc.pm
Message-Id: <383B320D.45C54BE0@mail.cor.epa.gov>
Jerry Preston wrote:
>
> Hi!
Howdy!
> Where can I find a copy of Calc.pm that can be down loaded to a system?
Since you're posting from an NT box, you may be using ActiveState
Perl. If so, use their 'ppm' program to automatically install
what I presume is the Date::Calc module.
C:\>ppm search calc
Packages available from http://www.ActiveState.com/packages:
Date-Calc
C:\>ppm install Date-Calc
And voila!
Read about ppm in the ActiveState HTML docs which come with
the install and sit on your OS's Start Menu.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 24 Nov 1999 00:26:20 GMT
From: blimp8@aol.com (BLIMP8)
Subject: can a "cookie-monster" mess with my cookies?
Message-Id: <19991123192620.10949.00001217@ng-bj1.aol.com>
if a cgi script sets a cookie that will expire on exiting the browser , can
this cookie be changed by a hacker ? will the browser be able to tell the
difference between a cookie created by the hacker and a legitimate one created
by a cgi script ?
thanks a ton
sam
blimp8@aol.com
------------------------------
Date: 23 Nov 1999 23:25:15 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: change directories in system
Message-Id: <slrn83m8ji.iik.sholden@pgrad.cs.usyd.edu.au>
On Tue, 23 Nov 1999 14:54:53 -0800,
natureboy <robert.castellowNOroSPAM@s1.com.invalid> wrote:
>is there a method to track the directory paths after
>executing a system("cd ..") for example? i know the system
>command will start and kill a process after completion and
>return the status. therefore once system executes a cd ..
>the process will die and the parent does'nt seem to have any
>information of the current directory path. any ideas?
You could try telling perl to change the current directory.
You'll have to read the documentation in 'perldoc perlfunc' to
find out how.
--
Sam
Just don't create a file called -rf. :-)
--Larry Wall
------------------------------
Date: Tue, 23 Nov 1999 23:19:10 GMT
From: bmccoy@news.lan2wan.com (Brett W. McCoy)
Subject: Re: change directories in system
Message-Id: <slrn83m8h1.qri.bmccoy@dragosani.lan2wan.com>
Also sprach natureboy <robert.castellowNOroSPAM@s1.com.invalid>:
>is there a method to track the directory paths after
>executing a system("cd ..") for example? i know the system
>command will start and kill a process after completion and
>return the status. therefore once system executes a cd ..
>the process will die and the parent does'nt seem to have any
>information of the current directory path. any ideas?
Why would you use system for changing directories instead of the Perl
function chdir()? And you can get information about the current directory
from the Cwd module (which also has a version of chdir() as well).
--
Brett W. McCoy
http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
Women aren't as mere as they used to be.
-- Pogo
------------------------------
Date: Tue, 23 Nov 1999 23:14:34 GMT
From: sirron@mail.mcoe.k12.ca.us
Subject: determining file date with Perl on Linux
Message-Id: <81f74l$mbg$1@nnrp1.deja.com>
Hello group,
When I do an ls -l on a file I get (as you all know):
-rw-r--r-- 1 sirron 501 39820 Nov 22 17:12 log_10_151
I would like to know how to get the date of this file using Perl.
I have played with the stat atime and mtime... Do have to do
something with data produced by stat to get this Month day
stamp or is there another way.
Thanks.
#Joseph Norris (Perl - what else is there?/HP3000/Linux/CGI/Msql)
print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-
68,12,1,14,8,
-68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 Nov 1999 15:40:52 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: determining file date with Perl on Linux
Message-Id: <MPG.12a4c5da49a2f7ba98a264@nntp.hpl.hp.com>
In article <81f74l$mbg$1@nnrp1.deja.com> on Tue, 23 Nov 1999 23:14:34
GMT, sirron@mail.mcoe.k12.ca.us <sirron@mail.mcoe.k12.ca.us> says...
> When I do an ls -l on a file I get (as you all know):
>
> -rw-r--r-- 1 sirron 501 39820 Nov 22 17:12 log_10_151
>
> I would like to know how to get the date of this file using Perl.
> I have played with the stat atime and mtime...
You can also use the file-test operators -A, -C, and -M.
perldoc -f -X
> Do have to do
> something with data produced by stat to get this Month day
> stamp or is there another way.
perldoc -f localtime
or look at the function POSIX::strftime
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Nov 1999 16:24:24 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Error using tar from cgi
Message-Id: <383B3038.7277B9F7@mail.cor.epa.gov>
rbj wrote:
>
> I have a cgi script creating some text files. After the files are
> created the script executes
>
> $cmd = "tar -cvf $tmp_dir"."test.tar $tmp_dir"."*.txt";
> $rc = system($cmd);
>
> Which failes (256), creating test.tar size 0.
You might get more help here if you asked Perl to give you
more info. Something like:
system($cmd) && die "system $cmd failed: $?";
Or better yet, put your command into an array:
@cmd = ('tar', '-cvf', "$tmp_dir", 'yadda-yadda-yadda');
system(@cmd) && die "system @cmd failed: $?";
The return value is going to be the exit status of tar,
as returned by the wait(2) call. To get the *actual*
exit value, divide by 256. The lower 8 bits get used
when the process dies from a signal.
For more highlights, type:
perldoc -f system
> Running same tar command in telnet works fine.
> Running script in telnet runs fine.
>
> All text files have owner 'nobody nobody' with read for all.
> The perl cgi has 'my-id my-grp' ownership.
>
> Is this a priviledge problem?
Possibly. Or a security issue. Many webservers limit the
capabilities of nobody, so that 'nobody' will refrain from
su'ing or running 'rm / -rf' or whatever.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 23 Nov 1999 18:08:50 -0500
From: "Reinhold J. Gerharz" <rgerharz@not.erols.com>
Subject: Re: How do I set timeout for socket on STDIN?
Message-Id: <s3m7k4a2rrp21@corp.supernews.com>
"Scott Lanning" <slanning@bu.edu> wrote in message
news:kus903orjhu.fsf@strange.bu.edu...
> "Reinhold J. Gerharz" <rgerharz@not.erols.com> writes:
> > I need to detect timeout or disconnection in my input function,
> > when STDIN is a socket.
>
> The C-like (4-parameter) version of select().
> But it can get ugly..
Sure can!
------------------------------
Date: Tue, 23 Nov 1999 18:14:30 -0500
From: "Reinhold J. Gerharz" <rgerharz@not.erols.com>
Subject: Re: How do I set timeout for socket on STDIN?
Message-Id: <s3m7unt7rrp36@corp.supernews.com>
> Regardless of anything else, this is a huge mistake. Never use any of the
> development releases (_50 through _99) for anything except work on perl
> itself. They're all, in some form or fashion, broken. (That's why they're
> development releases after all) Perl 5.6, which 5.005_58 is a development
> release for, isn't even in beta yet.
Woa! Thanks. I thought I had the latest _stable_ version. Musta' clicked the
wrong link.
Thanks!
--
Reinhold J. Gerharz
"The only good spammer is a DEAD spammer!" - Anonymous
------------------------------
Date: 23 Nov 1999 23:51:49 GMT
From: bsj@fc.hp.com (Brian StJohn)
Subject: Re: How do I set timeout for socket on STDIN?
Message-Id: <81f9al$7oo$1@fcnews.fc.hp.com>
: I need to detect timeout or disconnection in my input function, when STDIN
: is a socket.
: I am writing a mini-server in Perl 5.005_58 on Linux (RedHat 5.2). The
: service runs under inetd, so it starts up with inetd having setup STDIN as a
: socket to the client. I cannot find a way to set the timeout for an already
: created socket. I would be grateful for some suggestions.
I'm sure you've already been warned about using a development version
of perl already, so I won't warn you again. ;)
use a timeout catch, like in this code:
sub ProcessReturn {
my $MAXLEN = 512; #max packet size for ethernet
my $TIMEOUT = 5; #5 second timeout - almost too much
eval {
local $SIG{ALRM} = sub { die "alarm time out - no data!" };
alarm $TIMEOUT;
while (defined($socket->recv($msg, $MAXLEN))) {
alarm 0;
chomp($msg);
if ($msg =~ m/=>/) {
return 1;
}
if ($msg =~ m/\?>/) {
#print dumps this to the client, because of the dup earlier.
print "I don't understand that message.\n";
return 1;
}
#print dumps this to the client, because of the dup earlier.
print "$msg\n";
}
} or die "timeout after $TIMEOUT seconds...\n";
}
As you can see, the SIG{ARLM} is tied to the timeout. If no data
is recieved in 5 seconds, it times out. As for the disconnection,
couldn't you just check on $socket? I'm not too sure, but if the
other program closed the connection, would this socket be closed
as well?
Brian
------------------------------
Date: Tue, 23 Nov 1999 23:09:39 GMT
From: John Saylor <john.saylor@cybertrust.gte.com>
Subject: Re: How to send a bitmap as part of an HTML mail message?
Message-Id: <xki7lj8vm8c.fsf@dazzler.ndhm.gtegsc.com>
Hi
>>>>> "JA" == Jack Alexander <Jack.Alexander@digital.com> writes:
JA> I'm using Windows NT4 SP6 and Perl 5.004. My Perl program
JA> creates an HTML formatted mail message and sends it using the
JA> SMTP package. I'd like to add a bitmap image to the mail
JA> content, but I don't know how to do this.
Ahhh! What's wrong with text mail?
<sarcasm>
Why don't you just add a full motion video of you picking your navel
[if you do that kind of thing].
</sarcasm>
You need to use a multipart/mixed mime type, base64 encode everything,
and reference the content-ID as the href for the img in the email.
But think about using plain text; unless there is no content, then I
guess you need all the flash you can get.
--
\js
Don't SANFORIZE me!!
------------------------------
Date: Tue, 23 Nov 1999 16:39:16 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to send a bitmap as part of an HTML mail message?
Message-Id: <383B33B4.1721EF52@mail.cor.epa.gov>
Jack Alexander wrote:
>
> I'm using Windows NT4 SP6 and Perl 5.004.
> My Perl program creates an HTML formatted mail message and sends it using
> the SMTP package.
I hope all your recipients *want* HTML mail. It totally mucks
up my non-NT mailreader.
> I'd like to add a bitmap image to the mail content, but I don't know how to
> do this.
> Could someone give me a pointer where to look?
Sure. If you want to add attachments, that's MIME. So
get the MIME::Lite module. It comes with plenty of
docs and examples.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 23 Nov 1999 16:40:15 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How write records to ASCII file
Message-Id: <383B33EF.9F149289@mail.cor.epa.gov>
Scott Lanning wrote:
>
> jad@edekamapson.dk (Jan Andersen) writes:
> > What is "on 2275 September 1993" ? Is it in the documentation ;-)
>
> hehe, it'll *ALWAYS* be Sept. '93 for some people on Usenet.
> Sadly, their minds couldn't handle the trauma..
Unfortunately, it's eternally September on Usenet for all the
rest of us too.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 23 Nov 1999 23:30:24 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: Initialize Variables
Message-Id: <81f82g$2lt$2@info2.uah.edu>
In article <x7u2mcn8vo.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> writes:
: don't use undef on aggregates.
=item undef EXPR
=item undef
Undefines the value of EXPR, which must be an lvalue. Use only on a
scalar value, an array (using "C<@>"), a hash (using "C<%>"), a
subroutine (using "C<&>"), or a typeglob (using "<*>").
Patches, anyone?
: it does work but not in the way newbies
: think. assigning () to clear aggregates is the correct solution.
Don't say "doesn't work". :-) Please clarify.
: if you really want to initialize all those vars in one statement use
: this:
:
: ($a, $b, $c, @A, @B) = () ;
High marks for elegance!
Greg
--
Just because I don't care doesn't meant I don't understand.
-- H.J.S.
------------------------------
Date: 23 Nov 1999 18:53:13 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Initialize Variables
Message-Id: <x7g0xwn4t2.fsf@home.sysarch.com>
>>>>> "GB" == Greg Bacon <gbacon@ruby.itsc.uah.edu> writes:
GB> In article <x7u2mcn8vo.fsf@home.sysarch.com>,
GB> Uri Guttman <uri@sysarch.com> writes:
GB> : it does work but not in the way newbies
GB> : think. assigning () to clear aggregates is the correct solution.
GB> Don't say "doesn't work". :-) Please clarify.
undef @foo does the job but more than needed. it removes all storage
allocated to the aggregate and deletes its name from the symbol
table. that is overkill when all you want is to remove all entries in
the hash/array.
so it is slower, not clean looking IMO and encourages the use of defined
on aggregates which should be even more deprecated than using undef on
them. defined on an aggregate only checks for symbol definition and
storage allocation. an empty hash is still defined. hashes and arrays do
the right thing when used in scalars contexts which is returning the
number of elements.
so we should patch the docs to state that undef $foo is ok but undef
@bar should be done with @bar = (). i also think that it should show
$foo = undef rather than undef $foo. i think they are subtly different
too (ilya will jump in somewhere).
GB> : ($a, $b, $c, @A, @B) = () ;
GB> High marks for elegance!
seemed pretty obvious.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 23 Nov 1999 23:44:21 GMT
From: lee.lindley@bigfoot.com
Subject: Re: Initialize Variables
Message-Id: <81f8sl$k03$1@rguxd.viasystems.com>
Sanjay Krishna <krishnasanjay@hotmail.com> wrote:
:>I want to intialize a bunch of variables(with nothing) after they have
:>already been
:>declared. So I am using
:>undef($a, $b, $c, @A, @B)
:>This don't seem to be working in some cases. Although seperate undef
:>statements for each variable does. Is there an alternative ??
$a = $b = $c = undef;
$#A = $#B = -1;
--
// 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: 23 Nov 1999 19:31:28 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Initialize Variables
Message-Id: <slrn83mg5l.m2v.abigail@alexandra.delanet.com>
Brett W. McCoy (bmccoy@foiservices.com) wrote on MMCCLXXV September
MCMXCIII in <URL:news:slrn83lunq.bke.bmccoy@moebius.foiservices.com>:
## Also Sprach Sanjay Krishna <krishnasanjay@hotmail.com>:
##
## >I want to intialize a bunch of variables(with nothing) after they have
## >already been
## >declared. So I am using
## >undef($a, $b, $c, @A, @B)
Uhm, uhm, what's the point, assuming they haven't been assigned to yet?
But if you really want to:
($a, $b, $c, @A, @B) = ();
## Not gonna happen. It's a unary operator.
##
## If you have $a, @a, $B, %B, you can do typeglobbing:
##
## undef *a;
## undef *B;
reset 'aB'; # ;-)
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
-----------== 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: Wed, 24 Nov 1999 02:02:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Initialize Variables
Message-Id: <gHH_3.456$6Y1.4265@nsw.nnrp.telstra.net>
On 23 Nov 1999 19:31:28 -0600,
Abigail <abigail@delanet.com> wrote:
> Brett W. McCoy (bmccoy@foiservices.com) wrote on MMCCLXXV September
> MCMXCIII in <URL:news:slrn83lunq.bke.bmccoy@moebius.foiservices.com>:
> ## undef *a;
> ## undef *B;
>
>
> reset 'aB'; # ;-)
twice 'Eeek!' :)
But of course the reset version would potentially reset a few more
things than needed.
I think reset should be taken out of the documentation :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd. | but mean your mother.
NSW, Australia |
------------------------------
Date: Wed, 24 Nov 1999 01:21:28 GMT
From: venkatmohan@my-deja.com
Subject: need help with regular expr.
Message-Id: <81feig$rdv$1@nnrp1.deja.com>
Hi,
I need to parse out the following string
2323I am a 3343perl43progra!mer
In this string I want to extract only the white
space and alphabets (both
lower and upper case). Please help me with
forming the regular expr for
this.
I tried this
$a="2323I am a 3343perl43progra!mer";
$a=~ s/(?![a-zA-Z\s]+)//g;
but this doesn't works.
I verymuch appriciate your help in this regard.
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 24 Nov 1999 01:22:27 GMT
From: venkatmohan@my-deja.com
Subject: need help with regular expr.
Message-Id: <81fekc$re9$1@nnrp1.deja.com>
Hi,
I need to parse out the following string
2323I am a 3343perl43progra!mer
In this string I want to extract only the white space and alphabets
(both
lower and upper case). Please help me with forming the regular expr for
this.
I tried this
$a="2323I am a 3343perl43progra!mer";
$a=~ s/(?![a-zA-Z\s]+)//g;
but this doesn't works.
Thanks in advance.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 23 Nov 1999 20:48:37 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: need help with regular expr.
Message-Id: <kusd7t0oe16.fsf@strange.bu.edu>
venkatmohan@my-deja.com writes:
> $a="2323I am a 3343perl43progra!mer";
> $a=~ s/(?![a-zA-Z\s]+)//g;
>
> but this doesn't works.
[^a-zA-Z\s] ==> any character not an alphabetic or space character
--
"If there were gods, how could I bear to be no god?
Consequently there are no gods." --Nietzsche
------------------------------
Date: Tue, 23 Nov 1999 17:53:51 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: need help with regular expr.
Message-Id: <MPG.12a4e509b93bf35a98a269@nntp.hpl.hp.com>
In article <81fekc$re9$1@nnrp1.deja.com> on Wed, 24 Nov 1999 01:22:27
GMT, venkatmohan@my-deja.com <venkatmohan@my-deja.com> says...
[twice!]
> I need to parse out the following string
>
> 2323I am a 3343perl43progra!mer
>
> In this string I want to extract only the white space and alphabets
> (both
> lower and upper case). Please help me with forming the regular expr for
> this.
Yucky line wraps, what?
> I tried this
>
> $a="2323I am a 3343perl43progra!mer";
> $a=~ s/(?![a-zA-Z\s]+)//g;
>
> but this doesn't works.
I think you are confusing negative lookahead with a negated character
class.
The regex to do this is:
$a =~ s/[^a-zA-Z\s]+//g;
`perldoc perlre` for details.
But the 'right' (i.e., efficient) way to do it is:
$a =~ tr/a-zA-Z \t\n\r\f//cd;
`perldoc perlop` for details.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
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 1471
**************************************