[11688] in Perl-Users-Digest
Perl-Users Digest, Issue: 5288 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 2 23:05:05 1999
Date: Fri, 2 Apr 99 20:00:19 -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 Fri, 2 Apr 1999 Volume: 8 Number: 5288
Today's topics:
Re: Alternative for Perl (Abigail)
Re: Alternative for Perl (Abigail)
Brief questions about Module File:: sstarre@my-dejanews.com
can a program tell the difference between ..... fanxin@my-dejanews.com
Re: Can you return hashes in subroutines? <cassell@mail.cor.epa.gov>
determining the browser? (George)
Re: determining the browser? <ffchopin@worldnet.att.net>
Help! Perl5 Regex \b problem!? stuart@mohawk.net
here docs vs qq quote operator. Just personal preferenc (Bob Trieger)
How to include code to the script from other file? <sergeiga@hotpop.com>
Re: How to include code to the script from other file? (Bob Trieger)
Re: How to include code to the script from other file? (Abigail)
Re: How to remove repeated signs ? (Abigail)
How to set the Printer fonts using perl? agniora@usa.net
Is there any date/time types/manipulating functions? agniora@usa.net
Perl support for AIX large filesystems (files >2GB) <mrusoff@columbus.rr.com>
Please help. Netscape or CGI.pm not honoring wrap=physi dewitt23606@my-dejanews.com
Please help. Netscape or CGI.pm not honoring wrap=physi dewitt23606@my-dejanews.com
Re: Please help. Netscape or CGI.pm not honoring wrap=p <gregm@well.com>
Re: RegEx question (Tad McClellan)
Regular expression problem.. <rdiazmar@nova.es>
Re: Regular expression problem.. (Larry Rosler)
Re: Simple perl question (Abigail)
Re: test date <cassell@mail.cor.epa.gov>
Re: test date (Abigail)
Re: Testing Perl Scripts???? <gregm@well.com>
Re: Testing Perl Scripts???? somers1@my-dejanews.com
Why Perl does this... <propart@mediaone.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Apr 1999 02:27:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Alternative for Perl
Message-Id: <7e3ua2$rkt$5@client2.news.psi.net>
Frank de Bot (debot@xs4all.nl) wrote on MMXL September MCMXCIII in
<URL:news:3705182F.22C91229@xs4all.nl>:
.. Is there an other language to replace perl, which is much faster?
C. But only if you're good.
.. Currently I have a database and I think when It's grown bigger, it will
.. ask too much of my computers capicity.
Unless your database is written in Perl, replacing Perl with something
else won't speed up things.
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: 3 Apr 1999 02:29:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Alternative for Perl
Message-Id: <7e3uet$rkt$6@client2.news.psi.net>
I R A Aggie (fl_aggie@thepentagon.com) wrote on MMXL September MCMXCIII
in <URL:news:slrn7gagcl.eeg.fl_aggie@stat.fsu.edu>:
|| On Fri, 02 Apr 1999 13:58:59 -0800, David L. Cassell
|| <cassell@mail.cor.epa.gov> wrote:
||
|| + David Delikat wrote:
||
|| + > or you could get a faster computer.
|| + The *best* way to speed up the program.
||
|| Nah. More memory. Swapping is hell.
Buying more memory to speed up the program by reducing swapping only
makes sense if the OS is indeed swapping. And if it is, it's very likely
that happens because there's something else running on the system. In
which case, there's a zero-cost alternative: don't run anything else.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Sat, 03 Apr 1999 02:36:50 GMT
From: sstarre@my-dejanews.com
Subject: Brief questions about Module File::
Message-Id: <7e3us1$ja4$1@nnrp1.dejanews.com>
BEFORE you flame please read...
Honest I DID my homework! I just spent the past hour seaching the FAQ's for
details and came up with this sketchy info:
File::Copy - Copy files or filehandles
SYNOPSIS
DESCRIPTION
Special behavior if syscopy is defined (VMS and OS/2)
rmscopy($from,$to[,$date_flag])
RETURN
AUTHOR
*****************************************************************************
Just two multi-part questions please:
(1) What is "syscopy()"? I don't see it in Camel. Is it part of perl? Would it
be preferable to use it vs. File::Copy?
(2) Assuming that I'm using File::Copy (which I am) I wonder- does it behave
"safely"? If the copy fails for any reason (collision with another user,
process terminated, etc.) will it NOT do the copy? In other words does it
complete either (a) correctly, or (b) without disturbing the destination?
HUG,
S
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 03 Apr 1999 01:43:18 GMT
From: fanxin@my-dejanews.com
Subject: can a program tell the difference between .....
Message-Id: <7e3rnl$glu$1@nnrp1.dejanews.com>
an update notification email sending to 5000 subscriber
and a mail ads sending to 5000 radom email addresses ?
-t is useless if i don't append addresses
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 16:26:43 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Can you return hashes in subroutines?
Message-Id: <37056043.3FCD7E88@mail.cor.epa.gov>
Krusty276 wrote:
> Yeah , ok I tried it that was the problem, I though a multidemensional array
> was a hash, this is my second week of Perl programming, sorta a C guy.
> Thanks for your help
>
> >Now if what you are trying to do is manipulate multi-dimensional arrays,
> >that is a whole different kettle of fish.
Okay, in that case you might want to check up on the Perl docs for data
structures:
perldoc perldsc
perldoc perllol
and then look at the MLDBM module, which will help you do multi-dim structures.
A hash is just an 'associative array' [from awk]. A named list of key-value
*pairs*.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 02 Apr 1999 20:41:34 -0500
From: fred222@mauimail.com (George)
Subject: determining the browser?
Message-Id: <fred222-ya023580000204992041340001@news.bellatlantic.net>
I would really appreciate it if someone could tell me how to determine
which browser the user is .. using? Just a generic IE or Navigator sort
would be great.. I just hope I don't have to use JavaScript to do it,
because that would be ickie.
If anyone with some answers could respond to me at the following email
without the NOSPAM at the end, I'd appreciate it greatly:
yurtle@bellatlantic.netNOSPAM
Best regards,
George
------------------------------
Date: Fri, 2 Apr 1999 20:57:13 -0500
From: "Jason Simms" <ffchopin@worldnet.att.net>
Subject: Re: determining the browser?
Message-Id: <7e3suj$e6e$1@bgtnsc02.worldnet.att.net>
> I would really appreciate it if someone could tell me how to determine
> which browser the user is .. using? Just a generic IE or Navigator sort
> would be great.. I just hope I don't have to use JavaScript to do it,
> because that would be ickie.
Well, using CGI.pm, you can certainly do it. Here is a REALLY short
example:
#!usr/bin/perl -w
use CGI qw/:standard/;
print header, start_html('Browser Detection Example');
print "You are using IE" if user_agent()=~ /MSIE/;
print "You are using Netscape" if user_agent()=~ /Mozilla/;
print end_html;
# END SCRIPT
As you can see, there is a function (user_agent()) that returns the server
variable for the user's browser. You simply run a simple regular expression
on it to test for IE, Netscape, Windows, Mac, the version, etc., and then do
what you please. Try hitting the page just printing out user_aent() with
several different OS/browser combinations to see the text you have to work
with. Hope this helps!
Jason Simms
------------------------------
Date: Fri, 02 Apr 1999 23:57:46 GMT
From: stuart@mohawk.net
Subject: Help! Perl5 Regex \b problem!?
Message-Id: <7e3lhm$boj$1@nnrp1.dejanews.com>
Hi,
I am having trouble getting the following regex to work.
I need to add a special key word to non-booleans in a given key word string.
For example:
foo and bar or nil
should become:
special=foo and special=bar or special=nil
The original solution I was shown:
$my_str = "foo bar nil";
$spec_word = "special";
$my_str =~ s/(\b(?!and\b|n?or\b)\S+(?:\s|$))/$spec_word=$1/gi;
works great until one of the non-booleans is preceeded by punctuation. For
example:
foo and 'bar or nil
becomes:
special=foo and 'special=bar or special=nil
I've been over the "lookahead" and "non-capturing" parens part of Friedl's
great "Mastering Regular Expressions" (ISBN 1-56592-257-3)but I can't spot
the problem. Does anyone have any ideas how to get this regex to treat the
punctuation as part of the key word? Thanks aplenty!
-Stuart
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 03 Apr 1999 03:20:39 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: here docs vs qq quote operator. Just personal preference?
Message-Id: <7e41b8$dp1$1@fir.prod.itd.earthlink.net>
Many folks in c.l.p.* suggest/advise using "here docs" instead of multiple
print statements. I stopped using here docs when I found the qq & q quote
operators and it has made life for this fat fingered hacker a lot easier.
With here docs there is always the chance of the extraneous space at the end
making your script fail. The more here docs in the script, the higher your
risk of failure and if you use the same delimiting sequence the much bigger
headache finding this error.
Using here docs is suggested a lot more than simple quote operators and I was
wondering if there is an advantage or just out of habit?
Thanks,
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: Fri, 02 Apr 1999 19:57:57 -0500
From: Sergei Gnezdov <sergeiga@hotpop.com>
Subject: How to include code to the script from other file?
Message-Id: <37056795.77A10CD9@hotpop.com>
I want to decrease the size of the script file, so I want to use
something like #include in C. How can I do this?
Thank you
------------------------------
Date: Sat, 03 Apr 1999 01:53:45 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: How to include code to the script from other file?
Message-Id: <7e3s82$3ls$3@fir.prod.itd.earthlink.net>
Sergei Gnezdov <sergeiga@hotpop.com> wrote:
$>I want to decrease the size of the script file, so I want to use
$>something like #include in C. How can I do this?
perldoc -f require
perldoc -f use
HTH
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: 3 Apr 1999 02:31:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to include code to the script from other file?
Message-Id: <7e3uhc$rkt$7@client2.news.psi.net>
Sergei Gnezdov (sergeiga@hotpop.com) wrote on MMXLI September MCMXCIII in
<URL:news:37056795.77A10CD9@hotpop.com>:
&& I want to decrease the size of the script file, so I want to use
&& something like #include in C. How can I do this?
With either 'do', 'require', 'use' or -P.
See the manual for the details.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: 3 Apr 1999 02:33:33 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to remove repeated signs ?
Message-Id: <7e3ult$rkt$8@client2.news.psi.net>
Larry Rosler (lr@hpl.hp.com) wrote on MMXL September MCMXCIII in
<URL:news:MPG.116e915e86439ee998981a@nntp.hpl.hp.com>:
!! In article <htt1e7.6sb.ln@magna.metronet.com> on Fri, 2 Apr 1999
!! >
!! > 1 while s/(.)\1/$1/;
!!
!! What an odd way to write the 'g' modifier!
Actually, it's not quite the same. s/(.)\1/$1/g won't remove all the
following duplicate chars; only half of them. It is however a silly way
of combining /g and +.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Sat, 03 Apr 1999 03:30:45 GMT
From: agniora@usa.net
Subject: How to set the Printer fonts using perl?
Message-Id: <7e4216$m28$1@nnrp1.dejanews.com>
Hi fellas, Is there any ways to change the default text font when writing
plain text files in perl? cuz usually the font that it prints gets really big
and then i cant use perl to create nice-looking reports or invoices. thanks
in advance. Nayeem Programmer, Agni Systems Ltd.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 03 Apr 1999 03:25:58 GMT
From: agniora@usa.net
Subject: Is there any date/time types/manipulating functions?
Message-Id: <7e41nu$ln2$1@nnrp1.dejanews.com>
When dealing with date/times in perl it gets very difficult cuz i have to
manually recreate these types and their corresponding functions.
if anyone has any clues please let me know
thanks in advance.
Nayeem
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 21:18:10 -0500
From: "M. Rusoff" <mrusoff@columbus.rr.com>
Subject: Perl support for AIX large filesystems (files >2GB)
Message-Id: <37057A61.C516AAB@columbus.rr.com>
While there appears to be some support for long longs in the latest dev
release, it does not seem to be able to hande files larger than 2GB when
WRITING.
A. what could be the problem and if I wanted to stick in "long longs"
and lfopens, where would I do it?
------------------------------
Date: Sat, 03 Apr 1999 00:09:06 GMT
From: dewitt23606@my-dejanews.com
Subject: Please help. Netscape or CGI.pm not honoring wrap=physical attribute.
Message-Id: <7e3m6s$c7n$1@nnrp1.dejanews.com>
This is just a simple test case. I have a form with a textarea defined
and the wrap is set to physical. On page 325 of the koala book states:
With wrap set to physical, the text is wrapped within the text area
and is transmitted to the server as if the user hadactually typed it
that way. This [is] the most useful way to use word wrap, since the text
is transmitted exactly as the user sees it in the text area.
But, it appear to me that either netscape or Cgi.pm is not compling. The
source code follows:
#!/usr/local/bin/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$q = new CGI;
print $q->header; print $q->start_html('Test Page'); print
$q->start_form(-action=>'http://devweb.cebaf.gov/cgi-bin/TestPlans/test/test.
pl');
if ($q->param()) {
$q->import_names('Z');
print $q->h3("Test Plan Type is:", $Z::TestPlanTitle);
print $q->h3("Text is:", "<pre>", $Z::Text1, "</pre>");
print $q->h3("Text is:", $Z::Text1);
}
else {
print $q->h3("Select a Test Plan ", $q->blink('Type'));
}
print $q->radio_group(-name=>'TestPlanTitle',
-value=>['HLA','LLA','FEL','SYSTEM'],
-cols=>'2');
print $q->textarea(-name=>'Text1',
-cols=>'40',
-rows=>'5',
-wrap=>physical);
print $q->submit;
print $q->reset;
print $q->end_form;
print $q->end_html;
I need for the textareas to maintain those newlines, otherwise it will
mess up printing. I have tried numerous different ways to no avail, but
the textarea some how losses the newlines unless I physically enter
them. Any help would greatly be appreciated.
tia.
--
Shane Dewitt Email: dewitt@jlab.org
TR 53C Phone: 757-269-7592
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 03 Apr 1999 00:09:09 GMT
From: dewitt23606@my-dejanews.com
Subject: Please help. Netscape or CGI.pm not honoring wrap=physical attribute.
Message-Id: <7e3m71$c7t$1@nnrp1.dejanews.com>
This is just a simple test case. I have a form with a textarea defined
and the wrap is set to physical. On page 325 of the koala book states:
With wrap set to physical, the text is wrapped within the text area
and is transmitted to the server as if the user hadactually typed it
that way. This [is] the most useful way to use word wrap, since the text
is transmitted exactly as the user sees it in the text area.
But, it appear to me that either netscape or Cgi.pm is not compling. The
source code follows:
#!/usr/local/bin/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$q = new CGI;
print $q->header; print $q->start_html('Test Page'); print
$q->start_form(-action=>'http://devweb.cebaf.gov/cgi-bin/TestPlans/test/test.
pl');
if ($q->param()) {
$q->import_names('Z');
print $q->h3("Test Plan Type is:", $Z::TestPlanTitle);
print $q->h3("Text is:", "<pre>", $Z::Text1, "</pre>");
print $q->h3("Text is:", $Z::Text1);
}
else {
print $q->h3("Select a Test Plan ", $q->blink('Type'));
}
print $q->radio_group(-name=>'TestPlanTitle',
-value=>['HLA','LLA','FEL','SYSTEM'],
-cols=>'2');
print $q->textarea(-name=>'Text1',
-cols=>'40',
-rows=>'5',
-wrap=>physical);
print $q->submit;
print $q->reset;
print $q->end_form;
print $q->end_html;
I need for the textareas to maintain those newlines, otherwise it will
mess up printing. I have tried numerous different ways to no avail, but
the textarea some how losses the newlines unless I physically enter
them. Any help would greatly be appreciated.
tia.
--
Shane Dewitt Email: dewitt@jlab.org
TR 53C Phone: 757-269-7592
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 17:04:13 -0800
From: Greg McCann <gregm@well.com>
Subject: Re: Please help. Netscape or CGI.pm not honoring wrap=physical attribute.
Message-Id: <3705690D.14AF9C8F@well.com>
Valid WRAP values are OFF, HARD, and SOFT. See NetScape's TEXTAREA
documentation at
http://developer.netscape.com/docs/manuals/htmlguid/tags10.htm#1340340.
You want HARD, not "physical".
Greg
dewitt23606@my-dejanews.com wrote:
>
> This is just a simple test case. I have a form with a textarea defined
> and the wrap is set to physical. On page 325 of the koala book states:
>
> With wrap set to physical, the text is wrapped within the text area
> and is transmitted to the server as if the user hadactually typed it
> that way. This [is] the most useful way to use word wrap, since the text
> is transmitted exactly as the user sees it in the text area.
>
> But, it appear to me that either netscape or Cgi.pm is not compling. The
> source code follows:
>
> #!/usr/local/bin/perl -w
>
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
>
> $q = new CGI;
>
> print $q->header; print $q->start_html('Test Page'); print
> $q->start_form(-action=>'http://devweb.cebaf.gov/cgi-bin/TestPlans/test/test.
> pl');
>
> if ($q->param()) {
> $q->import_names('Z');
> print $q->h3("Test Plan Type is:", $Z::TestPlanTitle);
> print $q->h3("Text is:", "<pre>", $Z::Text1, "</pre>");
> print $q->h3("Text is:", $Z::Text1);
>
> }
> else {
> print $q->h3("Select a Test Plan ", $q->blink('Type'));
> }
>
> print $q->radio_group(-name=>'TestPlanTitle',
> -value=>['HLA','LLA','FEL','SYSTEM'],
> -cols=>'2');
>
> print $q->textarea(-name=>'Text1',
> -cols=>'40',
> -rows=>'5',
> -wrap=>physical);
>
> print $q->submit;
> print $q->reset;
> print $q->end_form;
> print $q->end_html;
>
> I need for the textareas to maintain those newlines, otherwise it will
> mess up printing. I have tried numerous different ways to no avail, but
> the textarea some how losses the newlines unless I physically enter
> them. Any help would greatly be appreciated.
>
> tia.
>
> --
> Shane Dewitt Email: dewitt@jlab.org
> TR 53C Phone: 757-269-7592
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
======================
Gregory McCann
http://www.calypteanna.com
"Be kind, for everyone you meet is fighting a great battle." Saint
Philo of Alexandria
------------------------------
Date: Fri, 2 Apr 1999 14:38:32 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: RegEx question
Message-Id: <ob63e7.g0g.ln@magna.metronet.com>
Andrew Perrin (aperrin@mcmahon.qal.berkeley.edu) wrote:
: [posted & sent via e-mail]
: Not sure exactly what you're looking for...
: If all your lines really are exactly the same, you can do something like:
: if ($response=~ /<TD><FONT SIZE=-1\ COLOR=black\ FACE=\"Times\ New\
: Roman\"><(.*)><\/FONT><\/TD>/) {
: $value = $1;
: }
You have 6 unnecessary backwacks there (the pattern matches
exactly the same strings without them).
All of them are unnecessary if you use an alternate delimiter:
m#<TD><FONT SIZE=-1 COLOR=black FACE="Times New Roman"><(.*)></FONT></TD>#
Much easier to read.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 2 Apr 1999 16:02:41 +0200
From: Roberto Diaz <rdiazmar@nova.es>
Subject: Regular expression problem..
Message-Id: <Pine.LNX.4.04.9904021600050.1974-100000@localhost.localdomain>
Hi!
I'm trying to match a mail heading storing all the message into a variable
an then matching the heading using a regular expression..
I was trying the following:
$message=3D~/(From:.*)\n\n.*/s;
$head=3D$1;
but is not working.. can you help me please?
Saludos, adeu
---------------------------------------------------------
Roberto D=EDaz
rdiazmar@nova.es www.roberto.nova.es
---------------------------------------------------------
------------------------------
Date: Fri, 2 Apr 1999 18:06:18 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regular expression problem..
Message-Id: <MPG.116f1775120d1582989821@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <Pine.LNX.4.04.9904021600050.1974-
100000@localhost.localdomain> on Fri, 2 Apr 1999 16:02:41 +0200, Roberto
Diaz <rdiazmar@nova.es >says...
> I'm trying to match a mail heading storing all the message into a variable
> an then matching the heading using a regular expression..
>
> I was trying the following:
>
> $message=3D~/(From:.*)\n\n.*/s;
> $head=3D$1;
>
> but is not working.. can you help me please?
I assume those =3D things are just =.
You are probabbly eating up too much with the regex, which will capture
up to the *last* "\n\n" in the message, while you want the *first*.
Just make it non-greedy. (The trailing .* does nothing.)
$message =~ /(From:.*?)\n\n/s;
$head = $1;
Another way would be to use split():
$head = (split /\n\n/, $message, 2)[0];
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 3 Apr 1999 03:43:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Simple perl question
Message-Id: <7e42of$s40$1@client2.news.psi.net>
Raymond C. Jender (rcj@lucent.com) wrote on MMXL September MCMXCIII in
<URL:news:370501A3.7B9A4E99@lucent.com>:
@@
@@ Ok, I have done something like the following:
@@
@@ read input name/value pairs into %in
@@
@@ @tmp = %in
@@
@@
@@ I can print $tmp[0] just fine but if I do
@@ $name = $tmp[0] printing $name returns zilch!!
And how are you doing that? Show us some code.....
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Fri, 02 Apr 1999 16:41:07 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: test date
Message-Id: <370563A3.E857DA8E@mail.cor.epa.gov>
David Cooper wrote:
> Hello I am using a perl script to input data into a mySQL table. Before
> the data is submitted I want to test it's validity.
>
> 1) How do I test that the date is in the format yyyy-mm-dd?
A regular expression. Look up the perlre section, either by
typing 'perldoc perlre' at the command line or by using the html
version of the docs if you have that.
You'll have to decide how specific you want to make the regex.
/(\d{4})-(\d{2})-(\d{2})/
might do, but it will accept 1994-11-88 too. Oops.
The parens above would let you save the results into other variables
and test further. Or you could write a more stringent regex.
Your call.
> 2) How do I test that the date has not already past?
time() gets the current time [in seconds since the Epoch].
localtime() converts from something like time() to a list containing
the time info, corrected for your local time zone.
Time::Local has a timelocal() function which lets you convert
from what you have above to something you can use for comparisons.
> Thanks David
>
> --
> David Cooper, BA, CNA --- mailto:cooper@ITology.com
> ------------ http://www.itology.com --------------
> ------- Information Technology Developers --------
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 3 Apr 1999 03:45:13 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: test date
Message-Id: <7e42s9$s40$2@client2.news.psi.net>
David Cooper (admin@itology.com) wrote on MMXL September MCMXCIII in
<URL:news:37054731.8D9E0E84@itology.com>:
:: Hello I am using a perl script to input data into a mySQL table. Before
:: the data is submitted I want to test it's validity.
::
:: 1) How do I test that the date is in the format yyyy-mm-dd?
You use a regex.
:: 2) How do I test that the date has not already past?
You use a Date or Time module from CPAN.
Abigail
--
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
for (??;(??)x??;??)
{??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'
------------------------------
Date: Fri, 02 Apr 1999 16:09:52 -0800
From: Greg McCann <gregm@well.com>
Subject: Re: Testing Perl Scripts????
Message-Id: <37055C50.335EAE04@well.com>
Maybe this *should* be a faq - I think I've seen this question three
times this week.
One solution is to install a mini-server on your Win95 pc. If you look
through recent messages here, you'll find some recommendations.
Otherwise, if you just want to test the output of a simple script you
can redirect the output to a text file (perl my_test.cgi>test.html) and
open the file from your browser. (If you don't want to see the HTTP
header in your browser, make a temporary change to your script or open
test.html in your text editor and remove the HTTP header).
If you want to do something a little more complicated like form
processing, see
http://www.troubleshooters.com/codecorn/littperl/perlcgi.htm.
Greg
Steve Somerville wrote:
>
> I have Perl on my personal computer... running Windows 95, and I
> need a way to test Perl scripts before I FTP them to my ISP.
>
> Is there a way to have the output from Perl.exe go to my netscape or
> IE browser? If not... then, how do you guys handle this situation?
>
> This has been holding me up for three days now, and I think I've
> read every FAQ online.
>
> Appreciate the help in getting over this hurdle.
>
> Please feel free to E-Mail me at somers@nucleus.com
>
> Thanks Steve
--
======================
Gregory McCann
http://www.calypteanna.com
"Be kind, for everyone you meet is fighting a great battle." Saint
Philo of Alexandria
------------------------------
Date: Sat, 03 Apr 1999 00:44:18 GMT
From: somers1@my-dejanews.com
Subject: Re: Testing Perl Scripts????
Message-Id: <7e3o90$dpq$1@nnrp1.dejanews.com>
In article <37056023.F3139A07@nucleus.com>,
Steve Somerville <somers@nucleus.com> wrote:
> I think I've found a way around it in this forum, by installing Apache, or
by writing a bat file.
>
>
> Thanks Steve
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 22:21:38 -0500
From: PropART <propart@mediaone.net>
Subject: Why Perl does this...
Message-Id: <37058942.70F8E405@mediaone.net>
Thanks, Brian... I did find the error message listed in the man pages. Should have
looked there, but I'm still figuring out where all the Perl documentation lives.
But, it still seems weird to me that an array mentioned in a print statement *after* a
sub-routine call which initializes the array, isn't automatically interpolated when
double quotes are used.
--WmC.
# --- below from the manpages --- #
Error message: In string, @%s now must be written as \@%s
(F) It used to be that Perl would try to guess whether you wanted an array interpolated
or a literal @. It did this when the string was first used at runtime. Now strings are
parsed at compile time, and ambiguous instances of @ must be disambiguated, either by
prepending a backslash to indicate a literal, or by declaring (or using) the array
within the program before the string (lexically). (Someday it will simply assume that
an unbackslashed @ interpolates an array.)
brian d foy wrote:
> In article <37053A8D.FE843864@mediaone.net>, PropART <propart@mediaone.net> posted:
>
> > What's up with this? Program 2 won't compile and gives me an error
> > message:
> > "in string, @foo must be written as \@foo at line.."
>
> see the perldiag man page for fuller explanations of perl
> warnings.
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5288
**************************************