[8334] in Perl-Users-Digest
Perl-Users Digest, Issue: 1951 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 22 09:07:41 1998
Date: Sun, 22 Feb 98 06:01:01 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 22 Feb 1998 Volume: 8 Number: 1951
Today's topics:
Re: Attatching files with sendmail <rcd@kiwi.net>
cannot {use Socket;} with IIS4 <prosser_ewa.net>
Re: CGI scripts and frames? (Mikael Skogstrom)
Cookies (Dutchie)
Re: DES compilation. (with stdarg.h) <jackklein@worldnet.att.net>
glob problem (Rob Duff)
Re: Help need with SQL into Access database from Perl (Jonathan Feinberg)
Re: help with global variables needed (Jonathan Feinberg)
Help: time a script in hundredth of second for Win32? <tkho@technologist.com>
Re: Help: Warning in string to number conversion. (Jonathan Feinberg)
Help: what is the simplest way to return the key of an <tkho@technologist.com>
Help: what is the simplest way to return the key of an <tkho@technologist.com>
How to get fractions of seconds <hanklem@ibm.net>
Re: Know Win32 and GD? Get a Free T-Shirt (Jonathan Feinberg)
Re: Need autoreply script for addresses buried in text (Jonathan Feinberg)
Re: Off-topic (Sorry, but I need your help) (Jonathan Feinberg)
Perl in the movie "Sphere"? (Sean McAfee)
Perl4 -> Perl5 warning turned fatal message on open() c <enaiman@ndsisrael.com>
Perlshop Account Software (Brian Kushner)
RegExp - To parse out dups in links pgm. (John R. Long)
Re: Regexp question... <B.A.McCauley@bham.ac.uk>
Re: SEND E-MAIL , HELP! <xxTony.Curtis@vcpc.univie.ac.at>
Re: SEND E-MAIL , HELP! (Mel Matsuoka)
Re: String Extraction and checkup <westxga@ptsc.slg.eds.com>
Re: time conversion under perl <westxga@ptsc.slg.eds.com>
What is the simpler way to find and erase duplicated ar <tkho@technologist.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Feb 1998 23:43:49 -0800
From: Craig <rcd@kiwi.net>
To: bill@astro.fccj.cc.fl.us
Subject: Re: Attatching files with sendmail
Message-Id: <34EFD734.88EE968D@kiwi.net>
Bill,
I did a search of dejanews and the only posting out of 53 that I found
with the keywords "Bill Jones Perl" was this message. Could you repost the
Perl code for emailing an attachment with Perl's sendmail program?
Bill Jones wrote:
> Yes, I have answered similar questions with complete source;
> in Perl even...
>
> So a search of http://www.dejanews.com should give plenty
> of answers :-)
>
> HTH,
> Bill
>
> Robert Barker wrote:
>
> > Can u attatch files with sendmail???
> >
> > I want the user to select a file a html pulldown menu, fill in their
> > email address and have the
> > file sent back to them.
> >
> > Must be possible (and probably quite simple).
> >
> > Thanks
> >
> > --
> > Robert Barker
> > System's Development Manager
> > Net7 Limited
> > http://www.net7.co.uk/
> >
> > Tel: +44 (0)1924 444007
> > Fax: +44 (0)1924 445507
> >
> > dataTRAK - Net7's Java Meta-Search Engine:
> > http://datatrak.net7.co.uk
------------------------------
Date: Sun, 22 Feb 1998 01:26:09 -0800
From: "Peter Rosser" <prosser_ewa.net>
Subject: cannot {use Socket;} with IIS4
Message-Id: <6coqr1$r3o@enews1.newsguy.com>
I am trying to use direct socket calls with IIS4 (to send email notification
when a script is called) and what I get back is this:
at d:\scripts\classsignup.pl line 5
BEGIN failed--compilation aborted at d:\scripts\classsignup.pl line 5.
...and here is the code in question on line 5:
use Socket;
Does anyone know why I am getting this?
Peter Rosser
http://www.ewa.net
prosser_ewa.net
To send me a message, replace the underscore with an "@" symbol.
------------------------------
Date: Sun, 22 Feb 1998 10:20:07 +0100
From: mikael@techtalk.se (Mikael Skogstrom)
Subject: Re: CGI scripts and frames?
Message-Id: <B115AC5796688F9EA@du12-3.ppp.algonet.se>
In article <34ee4166.174477446@news.btinternet.com>,
Gellyfish@btinternet.com (Jonathan Stowe) wrote:
>Deep down in your heart of hearts you know that this has nothing
>whatsoever to do with Perl, whatever language was used to produce your
>CGI program.
>
>However if you are using the CGI module (and I sincerely hope you are)
>I suggest that you read the section in the documentation entitled:
>
>WORKING WITH NETSCAPE FRAMES
>
>which provides several strategies for working with frames.
I haven't mentioned Perl. But I did write "Mime", which is tightly
connected with HTTP and therefor with _any_ scripting language. Since I
happen to use Perl for scripting, and the frame system I've designed works
with a plain page but not with a CGI call, I found it allright to post my
message here.
I am using the CGI module however. And your suggestion to use it to handle
Netscape frames right now sounds like a good one. Thanks for your help.
Mikael
------------------------------
Date: Sun, 22 Feb 1998 09:46:49 GMT
From: dutchie@dutch.nl (Dutchie)
Subject: Cookies
Message-Id: <34eff2b4.8209229@news.IAEhv.nl>
I'am searching how to make a cookie into a shopping programm, if the
visiter leaves the site (after making a order but canceled it) and
comes back in lets say 8 hours he/she becomes a cookie with the
question :
Would you like to continue your order yes or no.
I'am willing to pat for it
With kind regards
Jan
------------------------------
Date: 22 Feb 1998 05:43:07 GMT
From: "Jack Klein" <jackklein@worldnet.att.net>
Subject: Re: DES compilation. (with stdarg.h)
Message-Id: <6codtb$e9r@bgtnsc02.worldnet.att.net>
Rocko Pebcakio <yingyang@knob.com> wrote in article
<34EF7755.67368748@electriciti.com>...
> Hello,
> we are trying to use the DES.pm module, and when we compile
the C source
> code we find that we are missing a file. We are missing the
file
> "stdarg.h" This file is neccesary for the compilation of the
DES
> library. If anyone has it please send it along to
> davidu@electriciti.com. Also any information you have would
be
> appreciated.
> -Thank you,
> DavidU
>
--
<Jack>
What compiler are you trying to do this with? Every standard
conforming compiler (since the 1989 ANSI version of the
standard) should have this header, it is a required part of the
standard. This header provides some macros which are pretty
implementation specific, so the header from another compiler
might very well not work for you.
I would suggest you contact your compiler vendor. If your
compiler is really ancient and prestandard, you will probably
have a lot more problems with any code written to be compiler
with a conforming implementation.
</Jack>
------------------------------
Date: Sun, 22 Feb 1998 08:28:04 GMT
From: rduff@wimsey.com (Rob Duff)
Subject: glob problem
Message-Id: <34efe15b.25589954@news.istar.ca>
I recently installed Slackware 3.4 without tcsh, and tried to install
Tk403.004 and it failed. Can't find -lX11 anywhere. This turned out
to be a problem with glob(). I tried 'print glob("*")' and got
nothing. I installed tcsh manually, and got no improvement.
I re-installed 3.4, this time with tcsh and the glob() started
working,
Riddle me that.
------------------------------
Date: Sun, 22 Feb 1998 01:55:55 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Help need with SQL into Access database from Perl
Message-Id: <MPG.f599605a85b4196989725@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
ed@vtrad.com said...
: Can anybody help me with SQL into Access database from Perl?
:
: I would really appreciate a code snippet showing how it is done or
: even just useful comments/suggestions as to where I should start.
:
: Deadlines are killing me!
I'd seriously suggest bringing in a more experienced consultant for the job.
Failing that, you're going to need the perl ODBC module, and you'll have to
use the MS ODBC kit to set up a data source from your Access db. Begin your
research at http://www.roth.net/ . Good luck!
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sun, 22 Feb 1998 01:51:09 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: help with global variables needed
Message-Id: <MPG.f5994ea510f38d3989724@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
twv@rose.hp.com said...
: Could someone give me the short jargonless see-spot-jump course
: in using global variables?
: I've read the pertinent parts of
: the camel book, the Advanced Perl Programming book, and here and
: there on the web.
You're so close to having read the right documents. Have you tried the
documentation that comes with perl, particularly perlmod, perlfaq7 ("How do I
create a module?"), and perlfunc (package,use,require)? Also, every variable
that hasn't been lexically scoped with "my()" is "global." You may always
refer to variables in other packages by spelling their full names, thus:
$package_name::variable_name . I hope this is of some help to you.
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sun, 22 Feb 1998 02:14:56 -0800
From: Tommy <tkho@technologist.com>
Subject: Help: time a script in hundredth of second for Win32?
Message-Id: <34EFFAA0.FD931CC0@technologist.com>
I am try to build a stop watch that count the time (in hundredth of
second) for a script to finish. In Unix, I can use (times)[0], which
return second up to two decimal place. How to run times on Win32?
i.e
$[=0; # Start stopwatch
$start=(times)[0]; # -UNIX ONLY
.... # Script
$end= (times)[0]; # -UNIX ONLY
printf "Time taken %.2f seconds<BR>", $end - $start; # -UNIX ONLY
Thank you.
--
Tommy Ho
Email: tkho@technologist.com
------------------------------
Date: Sun, 22 Feb 1998 01:43:07 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Help: Warning in string to number conversion.
Message-Id: <MPG.f59930abcf948d0989723@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
zamboni@cs.purdue.edu said...
: I know, that's what -w is for. But is there a way to force Perl to
: take $fh as a number without complaining?
Check out perldata, in the section "Scalar Values," for several flavors of
detecting "numberish" SVs. HTH. (By the way, you have a cool userid.)
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sun, 22 Feb 1998 02:28:03 -0800
From: Tommy <tkho@technologist.com>
Subject: Help: what is the simplest way to return the key of an associated array?
Message-Id: <34EFFDB3.4B0F849C@technologist.com>
What is the simplest and fastest way to return the key of an associated
array?
i.e.
my %Array= ("A" => 65, "B"=> 66, "C" => 67, "D" => 68);
@ANS= &key(VALUE => 67, ARRAY= \%Array);
sub key {
my %Q= @_;
my (@ANS);
foreach $_ (keys(%{$Q{ARRAY}})) {
if (${$Q{ARRAY}}{$_} eq $Q{VALUE}) {
push(@ANS, $_);
last;
}
}
return @ANS if (@ANS)
}
--
Tommy Ho
Email: tkho@technologist.com
------------------------------
Date: Sun, 22 Feb 1998 02:28:53 -0800
From: Tommy <tkho@technologist.com>
Subject: Help: what is the simplest way to return the key of an associated array?
Message-Id: <34EFFDE5.8244ACC9@technologist.com>
What is the simplest and fastest way to return the key of an associated
array?
i.e.
my %Array= ("A" => 65, "B"=> 66, "C" => 67, "D" => 68);
@ANS= &key(VALUE => 67, ARRAY= \%Array);
sub key {
my %Q= @_;
my (@ANS);
foreach $_ (keys(%{$Q{ARRAY}})) {
if (${$Q{ARRAY}}{$_} eq $Q{VALUE}) {
push(@ANS, $_);
last;
}
}
return @ANS if (@ANS);
}
Thank you
--
Tommy Ho
Email: tkho@technologist.com
------------------------------
Date: Sun, 22 Feb 1998 01:02:55 -0700
From: Hank LeMieux <hanklem@ibm.net>
Subject: How to get fractions of seconds
Message-Id: <34EFDBAF.F26CD2F2@ibm.net>
Howdy,
In perl, how do you determine the time down to fractions of seconds?
My understanding is that time() only gives you the time down to
seconds. How do you get more precise than that?
Thanks,
Hank
--
Hank LeMieux New Media? NEW MEXICO!
Leading New Media and
the most beautiful place you'll ever live
(or snowboard, climb, mountain bike, etc.)
-- --
President NM Internet Professionals Assn.
77 dues-paying members
from 60 organizations
New Mexico, USA <http://www.nmipa.org>
-- --
President MERCHANT INTERACTIVE corporation
- Merchant Web Sites
- High-End Site Marketing
Santa Fe, New Mexico, USA
(505) 986-8166
------------------------------
Date: Sun, 22 Feb 1998 01:21:26 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Know Win32 and GD? Get a Free T-Shirt
Message-Id: <MPG.f598df1775b4ee2989721@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
nmcnelly@bu.edu said...
: but GD makes the script die without fail (at different steps).
Nancy - have you installed Gurusamy Sarathy's Win32 port of perl 5.004, which
comes with a working GD.pm? Odds are good that it will work for you just
fine. And don't forget to binmode your output filehandle...
You'll find it under authors/GSAR at CPAN.
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sun, 22 Feb 1998 01:08:41 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Need autoreply script for addresses buried in text & mail prog...
Message-Id: <MPG.f598af6ba41e7e8989720@news.concentric.net>
jp@glpbooks.BADMAIL.com said...
: Hi all...I'm just getting started but here's what I need.
: I'd appreciate any help/leads in solving this.
: I have email text files full of email addresses. I need
: to glean the addresses from the text then reply to them
: with a set message.
I'm going to save you some time and anxiety by giving it to you straight: you
must either learn Perl or hire someone who already knows it. Programming is
hard. It is also intensely rewarding and engaging. It's not for everyone,
though.
Hope this helps, and good luck. Oh, if you want to get started right away,
you should point your favorite web browser to http://www.perl.com .
: Jeff Potter jp@glpbooks.BADMAIL.com delete '.BADMAIL' to reply
: ***"Out Your Backdoor": Friendly Magazine of DIY Adventure and Culture
Out my backdoor? Hmmm.
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sun, 22 Feb 1998 01:39:45 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Off-topic (Sorry, but I need your help)
Message-Id: <MPG.f5992393ebcc6e8989722@news.concentric.net>
allie@icct.net said...
: I know this off-topic and I apologize, but I've been
: really impressed with the knowledge and helpfulness of
: the people in this NG and I thought you might be able
: to help.
I guess I shouldn't smoke the really strong shit before catching up on
c.l.p.m. I thought it would help.
: I'm new to the networking department in our company. My
: first project is to put together a packet for a
: prospective client running Groupwise who is interested
: in the benefits of Exchange.
Sometimes it's fun, and the munchies are cool if I've got the right kind of
junk in the fridge, but sometimes... man, I don't know.
: Our company really wants
: this client - if we hook him on networking we can
: probably sell him a lot of our other services.
Hdagen-Dazs is best, though I like the chunky Ben and Jerry's flavors. Also,
I'm really into Stevie Wonder and the Beatles, and they make the perfect
accompaniment to technical newsgroups such as this.
: Now I'm still learning the networking ropes so my knowledge
: here is limited. But I'd be really interested in
: learning anyone's experiences and opinions with these
: products.
Oh man, I totally missed Seinfeld tonight! Bummer!
I'm sorry, what were you saying?
: Obviously, if he doesn't switch, we don't get
Yes, I....
: his networking business so any information that can
Mm hmm...
: help me sell him Exchange is good. But I don't want to
Yes...
: be biased, either. I'd rather impress him with our
Well sure you...
: honest opinions on which product best serves his needs.
Oh, yeah well I...
: Unfortunately, I can't really go into detail at this
: point about his needs, so any pro/con information about
: these products and their differences would be great.
Did you ever *really* try to study the shape of a flame? What is flame,
anyway? Doesn't that totally trip you out?
: It's my understanding that Novell sales are drastically
: dropping and I've heard that MS Networking products are
: the "wave of the future". True?
Any defined scalar that isn't 0 or ''. Whoa, did I just say that? Wow.
: Any feedback appreciated. And again, I apologize for getting so
: off-topic (and at such great length.....) but I really
: think you guys are knowledgeable and very good about
: helping beginners. And it seems like there's a lot of
: networking gurus here. Anyway, thanks in advance, allie
I've been up for a week... but I'm coming down.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
Get thee behind me!
------------------------------
Date: Sun, 22 Feb 1998 09:01:43 GMT
From: mcafee@battlezone.rs.itd.umich.edu (Sean McAfee)
Subject: Perl in the movie "Sphere"?
Message-Id: <XPRH.2359$N4.14628776@news.itd.umich.edu>
I just got back from seeing the new movie "Sphere", and I think I saw part
of a Perl script on a computer screen at one point. Perhaps someone else
can verify this, having also seen it or looking for it in the future...
It's the scene where the crew is receiving a mysterious sequence of numbers
on a terminal from an unknown source. Just for a fraction of a second, one
screen flashes a Perlishly indented code-looking thing, and I'm almost
certain that one singly-indented line right after an unindented line
started with "local (something) =".
Further reinforcing this impression was the fact that the mysterious
numbers consisted of a simple substitution cypher, a code Perl is
ideally suited to decrypting.
The movie is extremely faithful to the book, so if you've read it you'll
know what to expect. The rest of the computer-related content was as
cheesy as any that comes out of Hollywood. I was amused to see one screen
in a deep-ocean habitat indicate that it was "Connecting to ossa.com..."
when in the book it was pointed out that one must use extremely long
wavelength radio waves to communicate that far underwater, resulting in a
bandwidth of some .1 - .2 characters per second. This was made even
funnier when the same terse three-letter codes were sent over the IP link
as were used in the book (where they had to be looked up in a table), but
then a program was invoked on the local machine to decode them.
--
Sean McAfee | GS d->-- s+++: a25 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 22 Feb 1998 10:16:02 GMT
From: "enaiman" <enaiman@ndsisrael.com>
Subject: Perl4 -> Perl5 warning turned fatal message on open() call
Message-Id: <01bd3f8a$aca9fc60$77140a0a@enaimanlt.ilndc.com>
Dear All,
Due to some server problems, please reply to my address as well as the
newsgroup (if appropriate).
Here's my question:
#!/usr/local/bin/perl -w
local($fh);
if(open($fh, "< no_such_file") == 0)
{
die("Could not open \"no_such_file"\" for reading: ", $!);
}
close($fh);
exit(0);
In Perl4, the open line would give a warning and in Perl5 it is fatal.
What gives? What is the official way to work with indirect filehandles?
I know that there are "use IO" modules that get around this problem by
creating more logical interfaces to open and close.
(I also know about using my instead of local, I just wanted a script that
ran in both 4 & 5.)
I'm working on upgrading a system written in Perl 4.036 to Perl5, and I
don't want to have to re-write everything. Where can I find a complete
list of CHANGES between Perl 4 and 5? I have read some of them and haven't
found a reference to the above problem.
Any help is appreciated.
Thanx,
Ephrayim "EJ" Naiman
NDS Technologies Israel Limited
enaiman@ndsisrael.com
------------------------------
Date: Sun, 22 Feb 1998 08:35:18 GMT
From: sales@tvmerch.com (Brian Kushner)
Subject: Perlshop Account Software
Message-Id: <34efe2f3.4790282@news.snip.net>
I currently have an online store using Perlshop. Does anyone know if a
way to take the file Perlshop creates when an order comes in and
importing it into a software program that will invoice and inventory?
Looking to automate and cut down on the number of steps.....
Thanks
Brian Kushner
------------------------------
Date: Sun, 22 Feb 1998 07:47:03 GMT
From: johnr@pacificnet.net (John R. Long)
Subject: RegExp - To parse out dups in links pgm.
Message-Id: <34efcdd4.46639032@dnews.pacificnet.net>
I have a Links.cgi that is being spammed big time right now. I fixed
all that but there are being input many dup front door pages thereby
tilting the viability of it..
data is:
<li><a href="http://www.svr.com/dir/default.htm" >Spamm1
</a>
<li><a href="http://www.svr.com/dir/index.htm" >Spamm2
</a>
<li><a href="http://svr.com/dir/default.htm" >Spamm3
</a>
<li><a href="http://svr1.svr.com/dir/default.htm" >Spamm4
</a>
I want to prevent, in order of preference, at least 2 and 3, 4 would
be frosting.. I need to takesvr.com/dir.... up to the last / and save
it. Do the same for the input url compare etc.. The regexp for this is
a little tough for me. Please Help :-)
I have so far:
foreach $line (@lines) {
if ($line =~ /\<li\>\<a href\=\"([^\"]+)\" >([^<]+)<\/a>/) {
# $1 =~ /(http:\/\/.*\/*)/;
# $url = $FORM{'url'};
# $url =~ Above expression...;
if ($url eq $1) {
&repeat_url;
}
}
}
Commented lines are to be added, Just need a proper regexp..
This links page is also being spammed by at least 39 different people
doing direct access to the cgi which I fixed except for a new type
that is spoofing the browser type and referer, has same ip. This makes
it near impossible to censor. I lock out ip's but they are still
getting thru.. I will take these routines and put in new type DB link
page.... 6 of these pgms are easy but the new spoofer is interesting.
I wish I knew where it originated from. getting 500+ links a day
added.
Thanks,
John R. Long
Star Systems
http://www.pacificnet.net/~johnr
Home of 654+ Aesop's Fables +
------------------------------
Date: 22 Feb 1998 13:19:03 +0000
From: Brian McCauley <B.A.McCauley@bham.ac.uk>
Subject: Re: Regexp question...
Message-Id: <tpvkfg4l4.fsf@wcl-l.bham.ac.uk>
fake.address@no.spam.com (Spencer Lu) writes:
>
> I'm writing a perl script, and one of the things it does is remove
> all trailing spaces from all lines of a text file. My initial attempt
> at this failed, and I'm not sure why. Here is the relevant code:
>
> while ($line = <FILE>) {
> $line =~ s/^(.*) *\n/$1\n/;
> $filestring = $filestring . $line;
> }
The "*" qualifier in regexp matches as many as possible of something.
Where there is abiguity the first one wins. Your pattern matches as
many as possible of any character followed by as many spaces as
possible. But spaces are also any character so the first part maches
the log and second part of the pattern always matches the null string.
I've seen some extened versions of regex that have a qualifer that
matches as few as possible of something. I don't think perl has this
but I may be wrong.
--
\\ ( ) No Bullshit! | Email: B.A.McCauley@bham.ac.uk
. _\\__[oo from | Phones: +44 121 471 3789 (home)
.__/ \\ /\@ /~) /~[ /\/[ | +44 121 627 2173 (voice) 2175 (fax)
. l___\\ /~~) /~~[ / [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
# ll l\\ ~~~~ ~ ~ ~ ~ | http://wcl-l.bham.ac.uk/~bam/
###LL LL\\ (Brian McCauley) | Finger: bam@wcl-rs.bham.ac.uk
------------------------------
Date: 22 Feb 1998 12:21:02 +0100
From: Remove xx to reply <xxTony.Curtis@vcpc.univie.ac.at>
Subject: Re: SEND E-MAIL , HELP!
Message-Id: <7xhg5rc2ch.fsf@beavis.vcpc.univie.ac.at>
Re: SEND E-MAIL , HELP!, Ed <ed@vtrad.com> said:
Ed> Alex,
Ed> I use Blat.exe, 'cause I had problems and this worked!
Ed> # Send mail using blat and the system command
Ed> ############
[snip]
my $w = new WHEEL;
$w->reinvent or die "why don't you use a module?";
perldoc Mail::Send
perldoc Mail::Mailer
hth
tony
------------------------------
Date: Sun, 22 Feb 1998 12:26:05 GMT
From: melorama@nospam.gov (Mel Matsuoka)
Subject: Re: SEND E-MAIL , HELP!
Message-Id: <34f018ce.33652639@news.lava.net>
On Sat, 21 Feb 1998 13:36:03 -0800, Alexander Kovalenko
<techsoft@abcpages.com> wrote:
>hey , how is it going?
>I have a problem with following procedure...
>sub send_mail
>{
> local($addressee, $subject, $message) = @_;
> local($sendmail) = "/usr/sbin/sendmail";
> open(SENDMAIL, "| $sendmail -t");
> print SENDMAIL "To: ", $addressee, "\n";
> print SENDMAIL "Subject: ", $subject, "\n\n",
> print SENDMAIL "$message\n";
> close(SENDMAIL);
>}
>it sends e-mail , ok... but it does not use a subject , so it just leave
>it blank...
>what's wrong am I doing ? thanks in advance!
Why are you putting in all those extra double quotes? Just do this:
print SENDMAIL "Subject: $subject\n\n";
Aloha
--
mel matsuoka <melSPAMSUCKS@hawaiianKILLSPAMFORDimage+com>
Editor, Hawaiian Image Video Productions
Reply-to: line altered to foil spammers. Remove capital letters from the
above address & replace plus sign with a dot to reply via e-mail
------------------------------
Date: Wed, 18 Feb 1998 09:15:29 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: String Extraction and checkup
Message-Id: <34EAA6B1.17C6@ptsc.slg.eds.com>
Evert Smit wrote:
>
> hello everyone...
>
> i am looking for a piece of perl script, that will look at a string, rip
> it appart, check if it is 8 digits long and make sure that there are 2
> numbers in it. I am sure someone has this one already and would be
> eternally thankful, if i could use it.
I assume you mean at least 8 characters long and contains at least 2
digits (password validation?):
#!/usr/bin/perl -w
@a=("abc3de7f", "aaaaaa", "abc345de", "3abc5def", '$23abcde');
foreach (@a) {
if (length < 8) {
print "$_ not 8 characters, ",length," !\n";
next;
}
if (! /^(\D*\d){2,}\D*$/) {
print "$_ doesn't contain at least 2 digits!\n";
next;
}
print "$_ passed!\n";
}
------------------------------
Date: Thu, 19 Feb 1998 15:18:20 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: time conversion under perl
Message-Id: <34EC4D3C.3DE6@ptsc.slg.eds.com>
Brassel Claude wrote:
>
> Hello,
>
> I need to convert the normal time format (like 02/01/1998) in to an
> standart unix format ( 88825589 secondes since 1970 ) and I can't found
> the perl command to do this.
>
> Can you help me ?
>
> Claude .
man Time::Local
------------------------------
Date: Sun, 22 Feb 1998 02:05:34 -0800
From: Tommy <tkho@technologist.com>
Subject: What is the simpler way to find and erase duplicated array?
Message-Id: <34EFF86E.8B251088@technologist.com>
What is the simpler way to find and erase duplicated array?
For example:
my @Array= (1..10, 3, 6);
@Ans1= &Unique(@Array);
@Ans2= &Duplicate(@Array);
sub Unique {
my @A= @_;
my (%B);
foreach $_ (@A) {
$B{$_}= "Anything";
}
return keys(%B);
}
sub Duplicate {
# No idea yet
return @Ans
}
--
Tommy Ho
Email: tkho@technologist.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1951
**************************************