[8598] in Perl-Users-Digest
Perl-Users Digest, Issue: 2215 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 31 10:07:34 1998
Date: Tue, 31 Mar 98 07:00:37 -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 Tue, 31 Mar 1998 Volume: 8 Number: 2215
Today's topics:
Re: A problem for Perlxs or Perlxstut (Ken Fox)
accessing variables EXPORTed then "use"d <Richard.Schofield@fmr.com>
Re: Anon Scalar Expression (was: Evaluate expression in <jdporter@min.net>
cgi: works form cmd line only (Mike Collins)
File copy in WINDOWS95 <dennis.kowalski@daytonoh.ncr.com>
Re: file trees <jdporter@min.net>
Re: File::Find vs. File::Recurse (was Re: file trees) <jdporter@min.net>
Re: filecopy on Windows <mikolas@works.fi>
Re: Macperl tchurch@gmu.edu
Re: Number Sorting (Gabor)
Re: Odd or even function (Gabor)
Re: Odd or even function <tchrist@mox.perl.com>
Re: Odd or even function (Jeffrey R. Drumm)
Re: Odd or even function <ckc@dmi.dk>
Re: perl - Interchange?? <jdporter@min.net>
Re: Perl BNF/Perl parser <jdporter@min.net>
PERL/SAP/OLE <Pierre.Laplante@pwc.ca>
Question: Sybperl routine to configure packet size <varanasi@worldnet.att.net>
Script Headers <diop3@cae.uwm.edu>
Re: small letters into capital letter <barnett@houston.Geco-Prakla.slb.com>
TIP: good head() function <tchrist@mox.perl.com>
Untainting an e-mail (Bart Lateur)
Re: Untainting an e-mail <tchrist@mox.perl.com>
User Interface Question (Kevin Murphy)
Re: Variable Interpolation inside regular expression <dboorstein@shopcfn.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Mar 1998 14:51:06 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: A problem for Perlxs or Perlxstut
Message-Id: <6fqvsq$3md3@eccws1.dearborn.ford.com>
tye@fohnix.metronet.com (Tye McQueen) writes:
> nisy <ni@aoe.vt.edu> writes:
>
> ) I am using C routines called from Perl. I am wondering if arrays
> ) can be shared across the Perl/C barrier ... which means that arrays
> ) (double or float) pass from Perl to C and then from C back to Perl
> ) with new values.
>
> Some "facts":
No, these are your opinions. They also happen to be mostly wrong.
> Perl deals with structures that it doesn't create itself as
> strings (Perl strings are just continguous chunks of memory).
This is one way to do it. Other options include creating a tied
hash or object to represent your structure.
> Perl _insists_ of being the one to malloc(), realloc(), and
> free() the memory blocks where it stores it strings.
Partially true. You can easily allocate memory and return it back to
perl as a scalar (IV). Just remember to release it in your DESTROY
method. You can also easily tie your own data structures.
> Perl uses pack() to create these strings and unpack() to
> pull the data our of them.
No. *You* might use pack() but perl doesn't.
> A C array of doubles is stored like the output of Perl's
> pack("d*",@array) ["f*" for floats].
No. *You* might do it this way. A better implementation would use
a tied array or native perl arrays.
> One opinion:
>
> Avoid the temptation of having your XS code expect native
> Perl data structures and using C code to translate that
> data into a C-friendly format.
Aiee! This is the whole point of XS! The input to XS code *must*
be built-in Perl data types. The XS code converts these to the
types required by your C code through either hand-coded conversion
in your XS code, or through automatic conversion with a typemap.
> Every case of such code I have seen doesn't scale well:
> They usually introduce some arbitrary size limits (as
> dynamic allocation is relatively hard in C, especially when
> it must talk to Perl).
You might be looking at poor examples. Simple, general typemaps
can be easily written for arrays. I've posted a few to this
group already. Here's one:
------------------------------
int * T_int_array
INPUT
T_int_array
if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
AV *av = (AV *)SvRV($arg);
int i = 0, len = AvFILL(av) + 1;
SV **sv;
$var = alloca(len * sizeof(int));
while (i < len) {
sv = av_fetch(av, i, 0);
if (sv && SvIOK(*sv)) {
${var}[i] = SvIV(*sv);
}
else {
${var}[i] = 0;
}
++i;
}
}
else {
croak(\"$var is not an array reference\");
}
------------------------------
If you don't have alloca(), you can allocate a temporary scalar and
perl will garbage collect it.
The main trouble with this is that "int *" is ambiguous. I usually
use a typedef "int_array" for arrays and reserve "int *" for an
OUTPUT argument.
> They usually add a costly layer of translation that could be
> skipped much of the time if a different design was used.
> They usually are easy to use for simple cases but just
> plain don't support more complex operations. They are
> also harder to debug and to enhance.
You're use of pack() and unpack() might add more! Translation isn't
that costly -- certainly not a big worry for most Perl scripts.
Besides, if speed is such an issue, why not just use objects? That
way you can completely control the memory allocation and the programming
interface.
> So, use Perl code to generate C-friendly data structures as
> Perl strings and have your XS code be simple yet robust.
No! This is the worst of all possible solutions. pack() and unpack()
are clumsy to use and tough to debug. You're "simplifying" the XS
writer's job, but making the user's job *much* harder. You're also
making it nearly impossible to enable perl to validate any of the data
going into your XS code. Script writers generally don't like it when
perl dumps core...
> If the C code insists on giving back pointers to memory that
> it allocated, then there is no simple way to interface Perl
> to it. So let Perl allocate all structures.
>
> The Perl code would look something like:
>
> @perl_array= ( 1.2, 3.4, 5.6 );
> $packed_array= pack( "d*", @perl_array );
> some_XS_routine( $packed_array );
> # Elements of $packed_array can be overwritten by above.
> @new_array= unpack( "d*", $packed_array );
You've got to be kidding.
How about this code:
@new_array = some_XS_routine(1.2, 3.4, 5.6);
That sure is a lot easier to use.
The XS code for this is not trivial, but certainly not hard.
You can write a typemap or use macros to make it even easier.
Here's some code I wrote for the X11 Toolkit XS module. The
interface for this function is almost identical to the one
above.
void
priv_XtGetValues(self, ...)
Widget self
PREINIT:
ArgList arg_list = 0;
XtOutArgList arg_info_list = 0;
Cardinal arg_list_len = 0;
Cardinal i;
PPCODE:
arg_list_len = xt_build_output_arg_list(&arg_list, &arg_info_list, &ST(1), items - 1);
if (arg_list) {
XtGetValues(self, arg_list, arg_list_len);
for (i = 0; i < arg_list_len; ++i) {
XPUSHs(xt_convert_OutArg(self, XtClass(self), arg_info_list[i]));
}
free(arg_list);
free(arg_info_list);
}
The function xt_build_output_arg_list() is pretty simple too:
Cardinal xt_build_output_arg_list(ArgList *arg_list_out, XtOutArgList *arg_info_list_out,
SV **sp, int items)
{
Cardinal arg_count = 0;
ArgList arg_list = 0;
XtOutArgList arg_info_list = 0;
if (items > 0) {
int i = 0;
arg_list = malloc(items * sizeof(Arg));
arg_info_list = malloc(items * sizeof(XtOutArg));
while (i < items) {
if (SvROK(sp[i]) && sv_derived_from(sp[i], "X::Toolkit::OutArg")) {
XtOutArg out = (XtOutArg)SvIV(SvRV(sp[i]));
char *res_name = SvPV(out->res_name, na);
out->dst = (XtArgVal)malloc(out->res_size);
XtSetArg(arg_list[arg_count], res_name, out->dst);
arg_info_list[arg_count] = out;
++arg_count;
}
++i;
}
}
*arg_list_out = arg_list;
*arg_info_list_out = arg_info_list;
return arg_count;
}
I wish I had time to throw together an example for an array of floats
instead of these complex X Toolkit structures.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: Tue, 31 Mar 1998 08:47:49 -0500
From: Rick Schofield <Richard.Schofield@fmr.com>
Subject: accessing variables EXPORTed then "use"d
Message-Id: <3520F404.AA679BFC@fmr.com>
This is a generic question but I'll use a specific example to
illustrate my problem.
(the following fragment is paraphrased from the chat2.pl as
bundled with 5.002)
use Socket;
...
if ( defined(PF_INET) ) {
$pf_inet = PF_INET;
$sock = SOCK_STREAM;
}
print "pf_inet = $pf_inet\n";
OUTPUT:
pf_inet = PF_INET
My question: How do I form the proper syntax to look into the
value of PF_INET?
Or any of the other constants from the Socket.pm module? Every
attempt I've made
to peek into the constant has returned only the symbol (i.e.
"PF_INET). I need to
see the value of that constant in order to confirm it's being
defined correctly on my
system.
My problem is that my scripts need to run on both AIX
(sock_stream = 2), and Solaris
(sock_stream = 1), and the logic in the ftp.pl and chat2.pl that
bundle with 5.002 do not
seem to be translating the symbols properly. (Not to mention
that the modules are of the
perl4 vintage - but that's another problem).
The machines I'm running on are production systems and migrating
up to 5.004 is not
going to happen. I can dub around in chat2 and ftp all I want,
but I can't easily get the
libnet kit or 5.004 anytime soon.
Rick
------------------------------
Date: Tue, 31 Mar 1998 09:01:12 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Anon Scalar Expression (was: Evaluate expression inside print "")
Message-Id: <3520F728.2756@min.net>
Stuart McDow wrote:
>
> $scalar_ref = \'default value';
>
> will work. Or did I misunderstand the question?
Yes; we want to create a reference to an anonymous scalar
value which is calculated, as in:
\( $var * 3 - 1 )
which is the best way I've seen. Thanks, Andrew Johnson.
John Porter
------------------------------
Date: Tue, 31 Mar 1998 14:35:22 GMT
From: mike@w3z.com (Mike Collins)
Subject: cgi: works form cmd line only
Message-Id: <3521fd88.7725928@news.tiac.net>
This was cross posted to comp.infosystems.www.authoring.cgi
Looking for some help. It looks like perl to me.
The following code runs a succession of scripts, to build webpages. It
succeeds from the command line and appears to do so when called from a
webpage interface, but the generated webpages only update if the
following code is executed from the command line. Why?
#! /usr/local/bin/perl5 -w
$|=1;
print "Content-type ...hdr, etc. #BREVITY
system(`perl /export/httpd/cgi-bin/id.pl`);
system(`perl /export/httpd/cgi-bin/intro.pl`);
#etc., etc. Above outputs to /htdocs/whatver
# but only if called from the command line.
print "\nCONGRATULATIONS! You did it.\n";
print "</html> #BREVITY
------------------------------
Date: Tue, 31 Mar 1998 09:04:18 -0500
From: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: File copy in WINDOWS95
Message-Id: <3520F7E2.71D4@daytonoh.ncr.com>
Try this, it works for me
use File::Copy;
copy("filea","fileb");
------------------------------
Date: Tue, 31 Mar 1998 09:24:43 -0500
From: John Porter <jdporter@min.net>
Subject: Re: file trees
Message-Id: <3520FCAB.FDF@min.net>
Earl Hood wrote:
>
> I do not think it is in the FAQ.
You're right. Sorry about that. But it is mentioned in several
other docs, as well as being part of the standard distribution.
> And File::Find is somewhat kludgy to just get a list of files.
Really? Your wheel-reinventing code ...
> sub files_to_list {
> [40 lines snipped]
> }
is somehow less kludgy than A.Langmead's example?
find(sub {push @found, $File::Find::name if -f $_;}, @_);
John Porter
------------------------------
Date: Tue, 31 Mar 1998 09:25:39 -0500
From: John Porter <jdporter@min.net>
Subject: Re: File::Find vs. File::Recurse (was Re: file trees)
Message-Id: <3520FCE3.38AB@min.net>
Jonathan Feinberg wrote:
>
> Does anyone care to pontificate on why you'd choose one of File::Find
> and File::Recurse over the other?
(Not sure if this qualifies as pontification, but:)
I always use File::Find for the simple reason that it is
included in the standard distribution.
John Porter
------------------------------
Date: Tue, 31 Mar 1998 14:18:02 +0300
From: "Mikko Hdmdldinen" <mikolas@works.fi>
Subject: Re: filecopy on Windows
Message-Id: <6fqjbu$3l9@idefix.eunet.fi>
Emile Schenk wrote in message <3520BA82.4F50814A@siemens.at>...
>Question from a newbie:
>
>How do I copy a file in PERL (Windows)? I tried
>system("copy a.a b.b")
>but this doesn't work.
>
copy is an internal command in the Command Processor so you should use
either:
Windows NT:
system("cmd.exe /c copy a.a b.b");
Windows 95:
system("command.com /c copy a.a b.b");
I'm not sure about the latter since I haven't used Windows 95 for ages...
-Mikko
------------------------------
Date: Tue, 31 Mar 1998 07:03:32 -0600
From: tchurch@gmu.edu
Subject: Re: Macperl
Message-Id: <6fqpdd$hp1$1@nnrp1.dejanews.com>
> Quite possibly. Look on the other machine for the telltale signs of
> AppleScript. Look for a Scripting Additions folder in the Extension
> folder (or in the System Folder itself in System 8.x), and use FindFile to
> see if there's an AppleScriptLib on the disk. If not, then AppleScript
> either never existed or has been removed.
>
> I don't remember if you said why you're using AppleScript, but you might
> look into using Apple Events directly. Take a look at the draft chapters
> of Vicki Brown and Chris Nandor's MacPerl book, which you can find by
> starting at <http://www.ptf.com/macperl/>
>
I am using Applescript to handle the case of a doubleclick on the program
icon. It is intended to be used as a drag-and-drop target, but users have a
mind of their own. I was using Applescript because I found a script in my
reading of various FAQs that brought up the choose file screen. Being lazy
and new to Mac developement, I used it. It did work fine on my machine, but
not on one without Macperl. I will download the AppleScript draft chapter ( I
have most of the rest already) and see if I can get AppleEvents to work for
me.
Thanks for your help.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 31 Mar 1998 12:10:11 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Number Sorting
Message-Id: <slrn6i1ncm.88m.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Dan Serban <judas@interprice.com> wrote :
# I am creating a script which needs to output a set of numbers in human
# readable sortation.
#
# eg.
#
while(<DATA>) {
chop;
push @arr,$_;
}
@arr = sort {$a <=> $b} @arr;
print "@arr\n";
__END__
32
11
992
321
# computers sort it to:
#
# 321
# 992
# 11
# 32
#
# need to be sorted as:
#
# 11
# 32
# 321
# 992
#
# so my dillema is that all of these entries need to be read into an array,
# then sorted whithin the array and output from lowest to highest amount,
# could someone either throw me some simple pseudo code or actual perl5 code
# my way? Any help would be appreciated.
#
# Dan Serban
# judas@interprice.com
# http://www.interprice.com
#
#
#
#
#
------------------------------
Date: 31 Mar 1998 12:06:14 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Odd or even function
Message-Id: <slrn6i1n59.88m.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Dan Serban <judas@interprice.com> wrote :
# Is there an odd or even perl function that could be used as a boolean
# operator? ie
#
if($num % 2) { # odd
}
what could be simpler?
# if odd(variable)
# {
# }
#
# etc...
#
# meaning that when the variable is operated on the if statement is only true
# (executable) when the number whithin the variable at the time is odd...
#
# same for the even part of it.
#
# Thanks
# Dan Serban
# judas@interprice.com
# http://www.interprice.com
#
#
#
------------------------------
Date: 31 Mar 1998 12:06:53 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Odd or even function
Message-Id: <6fqm8t$hm2$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Dan Serban" <judas@interprice.com> writes:
:Is there an odd or even perl function that could be used as a boolean
:operator?
You've just asked if there's a function to tell whether something is
a multiple of 2. It requires only the most remedial understanding
of mathematics to do. I don't know why people keep asking this.
It's like they never went to math class or something. Here are two
trivial solutions. The first is slow. Use the second.
if ($number % 2) { print "$number is odd" } # silly way
if ($number & 1) { print "$number is odd" } # good way
unless ($number % 2) { print "$number is even" } # silly way
unless ($number & 1) { print "$number is even" } # good way
This can be extended to other numbers like this:
if ($number % 10) { print "$number not multiple of 10" }
unless ($number % 10) { print "$number is multiple of 10" }
Actually, with 10, you can be smarter:
if (substr($,-1)) { print "$number not multiple of 10" }
unless (substr($,-1)) { print "$number is multiple of 10" }
Which leads to the obvious
chomp($number); # integer divide by 10
and also
$log10i = length($number);
--tom
If you enjoy math puzzles, you will enjoy programming.
If you do not enjoy math puzzles, you will not enjoy programming.
If you enjoy something, it will seem like fun, not work.
If you do not enjoy something, you will never be any good at it.
If you are not going to be good at something, find someone who is.
--
Tom Christiansen tchrist@jhereg.perl.com
In general, if you think something isn't in Perl, try it out, because it
usually is. :-)
--Larry Wall in <1991Jul31.174523.9447@netlabs.com>
------------------------------
Date: Tue, 31 Mar 1998 12:36:59 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Odd or even function
Message-Id: <3520e145.489971882@news.mmc.org>
On Tue, 31 Mar 1998 02:11:23 -0800, "Dan Serban" <judas@interprice.com> wrote:
>Is there an odd or even perl function that could be used as a boolean
>operator? ie
>
>if odd(variable)
>{
>}
>
>etc...
>
>meaning that when the variable is operated on the if statement is only true
>(executable) when the number whithin the variable at the time is odd...
>
>same for the even part of it.
>
>Thanks
>Dan Serban
>judas@interprice.com
>http://www.interprice.com
>
The bitwise "and" operator is your friend here; see the perlop pod/page.
if ($var & 1)
{
do odd stuff;
} else {
do even stuff;
}
This assumes, of course, that you think undef and 0 are even ;-)
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: 31 Mar 1998 16:40:36 +0200
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Odd or even function
Message-Id: <wvp3efyylcr.fsf@pratt.ejoper.dmi.min.dk>
Tom Christiansen <tchrist@mox.perl.com> writes:
> Which leads to the obvious
>
> chomp($number); # integer divide by 10
Obvious, yes, but hardly efficient:
,-----
| ckc@pratt:~> perl -e '$_=1087;chomp;print;print "\n";'
| 1087
| ckc@pratt:~> perl -e '$_=1087;chop;print;print "\n";'
| 108
`----->8
chomp() is much more useful than chop(); so much so, apparently, that
even our own Tom C. has forgotten about chop()!
Kvan, not one to miss pointing out the obvious.
--
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- | unattempted is impossible.'
Lokal 544 |
I do not speak for DMI, just me. | - Lord Mhoram, Son of Variol.
------------------------------
Date: Tue, 31 Mar 1998 09:51:36 -0500
From: John Porter <jdporter@min.net>
Subject: Re: perl - Interchange??
Message-Id: <352102F8.2FF@min.net>
Morten Fischer wrote:
>
> does a perl-script programmed, say on a Win95 machine also work on a Unix?
It's too bad the first perl resource you found on the internet
was this newsgroup, instead of the web site, http://www.perl.com
There you will find the answers to that and many more questions.
John Porter
------------------------------
Date: Tue, 31 Mar 1998 09:55:57 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl BNF/Perl parser
Message-Id: <352103FD.64CC@min.net>
Mike Hitchcock wrote:
>
> Is there any work going on out there in Perl-land on a
> Perl parser?
I think what we need is a mode for the perl executable
(indicated by a commandline switch) which makes it do
"front-end"ish things... for example, write the parse
tree to a file.
John Porter
------------------------------
Date: Tue, 31 Mar 1998 07:58:09 -0500
From: Pierre Laplante <Pierre.Laplante@pwc.ca>
Subject: PERL/SAP/OLE
Message-Id: <3520E860.2943F287@pwc.ca>
This is a multi-part message in MIME format.
--------------78657100E71FB2AA955BB19B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Did anybody has try perl to work with SAP using OLE?
Any examples would be appreciated...
--------------78657100E71FB2AA955BB19B
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Laplante, Pierre
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Pierre Laplante
n: Laplante;Pierre
org: Pratt&Whitney Canada
adr: 1000 Marie-Victorin;;;Longueuil;Quibec;J4G-1A1;Canada
email;internet: pierre.laplante@pwc.ca
title: Analyste
tel;work: 514-647-7801
tel;fax: 514-647-3855
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------78657100E71FB2AA955BB19B--
------------------------------
Date: Tue, 31 Mar 1998 08:33:19 -0500
From: Varanasi <varanasi@worldnet.att.net>
Subject: Question: Sybperl routine to configure packet size
Message-Id: <6fqr9c$mdk@bgtnsc03.worldnet.att.net>
I would like to know the name of the routine in Perl 5.0x (sybperl
libraries) that will allow me to configure the connection packet size.
The corresponding Sybase DBLib function is DBSETLPACKET(LOGINREC
*dbloginrec, int size).
Please let me know is there is a dedicated newsgroup that caters to such
queries.
Thanx in advance.
Hari
------------------------------
Date: Tue, 31 Mar 1998 08:07:25 -0600
From: Anthony Shawn Johnson <diop3@cae.uwm.edu>
Subject: Script Headers
Message-Id: <3520F89D.8FD123D6@cae.uwm.edu>
Hello, I trying to help a friend set-up his
secure server for his website business. When we
attempt to link to the cgi script linked written
in Perl we're informed that there is a internal server
error, which it given has a "premature end of script headers".
Does anyone know what script headers there talking about.
We have set the permission to 755 for both the file and the
directory cgi-bin. Thanks in advance for your help.
------------------------------
Date: Tue, 31 Mar 1998 07:53:08 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: small letters into capital letter
Message-Id: <3520F544.88686A20@houston.Geco-Prakla.slb.com>
Andre Vieth wrote:
>
> perl problem:
> I4d like to transform small letters (saved in a variable) into capital
> letters.
> Do I have to replace each and every single letter (26) by the following
> command: $Text =~ s/a/A/;/g; or is there an easier command to solve
I don't think that s/a/A/;/g; will do what you want. Perl should have
choked on that one. Maybe you meant something like s/a/A/g; ? Or how
about tr/a-z/A-Z/; or perhaps a look at perldoc -f uc would be in
order?
> this problem.
> (I4m not a professional programmer, I just try to write a small script
> for my webpage..)
> Thanking in advance
> Andre Vieth
HTH.
Dave
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
----------------------------------------------------------------------
Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com
----------------------------------------------------------------------
------------------------------
Date: 31 Mar 1998 12:20:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: TIP: good head() function
Message-Id: <6fqn33$hm2$3@csnews.cs.colorado.edu>
Why make users pipe things through something when you can do it for them?
This is like backgrounding yourself.
head(50); # pipe output through head -50
sub head {
return if my $pid = open(STDOUT, "|-");
die "cannot fork: $!" unless defined $pid;
my $count = shift || 10;
while (<STDIN>) {
last if --$count < 0;
print;
}
exit;
}
Similar tricks are useful with pager stuff.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Courage is the willingness of a person to stand up for his beliefs in the face
of great odds. Chutzpah is doing the same thing wearing a Mickey Mouse hat.
------------------------------
Date: Tue, 31 Mar 1998 11:25:51 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Untainting an e-mail
Message-Id: <3521d27f.1434695@news.tornado.be>
This is a variation to a FAQ: "How do I check the validity of e-mail
addresses?".
The normal answer is: "you can't." You just have to try it ands see if
it works.
However, I want a reduced solution, i.e. how do I test it's safe to use
a user-supplied e-mail address? Is there a reliable way to make it safe,
e.g. by extracting the basic address in the format "user@domain"?
This is a quote froim the Mail::Mailer module:
>TO DO
>
>Secure all forms of send_headers() against hacker attack and invalid
>contents. Especially "\n~..." in ...::mail::send_headers.
Now that is precisely what I'm worried about.
PS. Yes I'd like the solution in Perl, or in a Perl module. And no, I
don't need local addresses.
Bart.
------------------------------
Date: 31 Mar 1998 12:14:40 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Untainting an e-mail
Message-Id: <6fqmng$hm2$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
bart.mediamind@tornado.be (Bart Lateur) writes:
:However, I want a reduced solution, i.e. how do I test it's safe to use
:a user-supplied e-mail address? Is there a reliable way to make it safe,
:e.g. by extracting the basic address in the format "user@domain"?
The only reliable way to avoid shell escapes is trivial and complete:
NEVER CALL THE SHELL.
Use system with a list, and never use backticks. Use the pipeopen
trick with |- or -| instead. See perlsec.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
#define SIGILL 6 /* blech */
--Larry Wall in perl.c from the 4.0 perl source code
------------------------------
Date: Tue, 31 Mar 1998 08:01:25 EST
From: twtmjctn@superlink.net (Kevin Murphy)
Subject: User Interface Question
Message-Id: <6fqpf5$6h3$1@earth.superlink.net>
I am considering going to perl for Win95,
I have been using big perl 4.036 i think, to manipulate ascii files..
Do i still have to use a dos prompt to run my existing scripts if I go
to W95 ? Is there a better way to do this in W95 ? Like using the
send to feature in windows explorer ?
Any help would be appreciated..
tia
Kevin
------------------------------
Date: Tue, 31 Mar 1998 09:20:24 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: Variable Interpolation inside regular expression
Message-Id: <3520FBA8.38269794@shopcfn.com>
Ronald J Kimball wrote:
>
> [posted and mailed]
>
> ascendr wrote:
> >
> > Why will both of the scripts below work on Win32 but only the list one works
> > in UNIX, AIX specifically?
>
[SNIP]
>
> Try ftping the file from Windows to Unix in ASCII mode. Alternatively, run
> this command on the file on Unix:
>
> perl -pi -e 'tr/\r\n/\n/'
though i'm sure you meant:
perl -pi -e 's/\r\n/\n/'
i just thought it would be good to clarify.
--
# dan boorstein <dboorstein@shopcfn.com>
seek DATA,0,0;print scalar<DATA>,__END__
Just another Perl hacker,
------------------------------
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 2215
**************************************