[18172] in Perl-Users-Digest
Perl-Users Digest, Issue: 340 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 23 00:05:32 2001
Date: Thu, 22 Feb 2001 21:05:09 -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: <982904709-v10-i340@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 22 Feb 2001 Volume: 10 Number: 340
Today's topics:
Re: Re: Reading from __DATA__ lee_spam_this@yahoo.com
[OT]: Newsreader config (was: Re: Question.about s///) <mischief@velma.motion.net>
Re: Array length (Damian James)
Re: Array length (Logan Shaw)
Re: Array length <joe+usenet@sunstarsys.com>
Re: Array length (Gwyn Judd)
Re: Difficult Split Question <bertilow@chello.se>
Re: Disabling debugging support in Perl? <mischief@velma.motion.net>
Re: Execution Problem <whataman@home.com>
Help! <o.bullittiii@worldnet.att.net>
Re: Help! <o.bullittiii@worldnet.att.net>
Re: How can I detect if program is run by cron? (David Efflandt)
Re: How can I detect if program is run by cron? (Logan Shaw)
newbie question <laclac@global2000.net>
Re: newbie question (Damian James)
Outlook Express (was Re: Help!) egwong@netcom.com
Re: perl-mode in emacs: nested sub's <ivo.welch@yale.edu>
Re: question about arrays <wyzelli@yahoo.com>
Re: question about arrays <wyzelli@yahoo.com>
Re: question about arrays (Damian James)
Re: question about arrays (Damian James)
Re: question about arrays <kstep@pepsdesign.com>
Re: Trying to use Mysql and insert egwong@netcom.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Feb 2001 03:22:28 GMT
From: lee_spam_this@yahoo.com
Subject: Re: Re: Reading from __DATA__
Message-Id: <UHkl6.140303$47.2077656@news.bc.tac.net>
> Dmitry Epstein (mitiaNOSPAM@northwestern.edu.invalid) wrote on MMDCCXXXII
> September MCMXCIII in <URL:news:3A957A8C.A8A9C70C@northwestern.edu.invalid>:
> ][ How can I read read the entire __DATA__ block several times? Opening
> ][ and closing DATA filehandle doesn't do the job. I tried seek:
> ][
> ][ seek(DATA, 0, 0)
> ][
> ][ but that rewinds to the top of the module, that is next time I read from
> ][ DATA it starts reading from the first line of the file, rather than from
> ][ the first line after __DATA__
>
>
> After the seek, do:
>
> 1 until <> eq "__DATA__\n";
>
Looks like it would work just fine.
I can't help but prematurely optimize here though. What about
saving the result of "tell DATA" prior to the first read
and then using that with the seek for future "rewinds"?
I cringed a bit after writing this thinking there might
be some Perl magic waiting to bite me, but a quick search
of the pod directory and a simple test revealed no holes
in this approach.
Observe:
ksh: cat x.pl
#!/usr/local/bin/perl -w
my $datapos = tell DATA;
print while <DATA>;
print "take 2\n";
seek DATA, $datapos, 0;
print while <DATA>;
__DATA__
some data
some more data
---eof---
ksh: ./x.pl
some data
some more data
take 2
some data
some more data
==================================
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: Fri, 23 Feb 2001 02:11:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: [OT]: Newsreader config (was: Re: Question.about s///)
Message-Id: <t9bhmh473qna7b@corp.supernews.com>
egwong@netcom.com wrote:
> [had to delete high-characters, tin won't let me post with 'em]
Ä Å á â ä à å É æ Æ é ë ê è í ï î ì ò ô ö ó ü û ù ú ÿ Ö Ü ç Ñ ñ º ¿
This isn't the whole set and some may appear different than I see them at the
moment since I'm in a Putty windows on Windows to a Linux box, but my keyboard
mapping doesn't produce these, so I had to alt-key them in, so please forgive
any omissions. This is a work PC and I don't want to screw around with
keyboard layouts here. ;-)
The point is, I'm using tin, and I can post these. You just have to set your
tin configuration to post in a charset that supports it.
Chris
--
Christopher E. Stith
Product shown enlarged to make you think you're getting more.
------------------------------
Date: 23 Feb 2001 03:04:26 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Array length
Message-Id: <slrn99bkok.ipd.damian@puma.qimr.edu.au>
Thus spake Craig Berry on Fri, 23 Feb 2001 00:48:46 -0000:
> % perl -e '@foo = qw(a b c d); $n++ foreach @foo; print $n'
> 17
>
ROTFL
It seems so cruel, we can't even say something like:
%perl -e '@bleh = (1..10); $n=$_ for 0..@bleh; print $n'
55
Cheers,
Damian
--
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker
------------------------------
Date: 22 Feb 2001 21:25:17 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Array length
Message-Id: <974l6t$rj1$1@boomer.cs.utexas.edu>
In article <slrn99bkok.ipd.damian@puma.qimr.edu.au>,
Damian James <damian@qimr.edu.au> wrote:
>Thus spake Craig Berry on Fri, 23 Feb 2001 00:48:46 -0000:
>> % perl -e '@foo = qw(a b c d); $n++ foreach @foo; print $n'
>> 17
>
>%perl -e '@bleh = (1..10); $n=$_ for 0..@bleh; print $n'
>55
The functional way:
$ perl -le '@bar = qw{ a b c d }; $n = length join "", map 1, @bar; print $n'
- Logan
--
my your his her our their *its*
I'm you're he's she's we're they're *it's*
------------------------------
Date: 22 Feb 2001 23:17:04 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Array length
Message-Id: <m3wvai2fun.fsf@mumonkan.sunstarsys.com>
Keywords: violet fungus, woodstock, the blue pill
logan@cs.utexas.edu (Logan Shaw) writes:
> In article <slrn99bkok.ipd.damian@puma.qimr.edu.au>,
> Damian James <damian@qimr.edu.au> wrote:
> >Thus spake Craig Berry on Fri, 23 Feb 2001 00:48:46 -0000:
> >> % perl -e '@foo = qw(a b c d); $n++ foreach @foo; print $n'
> >> 17
> >
> >%perl -e '@bleh = (1..10); $n=$_ for 0..@bleh; print $n'
> >55
>
> The functional way:
>
> $ perl -le '@bar = qw{ a b c d }; $n = length join "", map 1, @bar; print $n'
>
> - Logan
I get 29 with that on linux 0.9 with perl3.14; but I found that
putting the length() call within a HERE doc tricks perl into
revealing the array's true size:
#!/usr/bin/perl -l
@bar = qw(a b c d);
print @bar << "__END__";
length @bar;
__END__
--
Joe Schaefer "When the end of the world comes, I want to be in Cincinnati.
Everything happens ten years later there."
--Mark Twain
------------------------------
Date: Fri, 23 Feb 2001 05:04:29 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Array length
Message-Id: <slrn99brqs.kli.tjla@thislove.dyndns.org>
I was shocked! How could Joe Schaefer <joe+usenet@sunstarsys.com>
say such a terrible thing:
>I get 29 with that on linux 0.9 with perl3.14; but I found that
>putting the length() call within a HERE doc tricks perl into
>revealing the array's true size:
That bug is fixed in the development versions.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Her kisses left something to be desired -- the rest of her.
------------------------------
Date: Fri, 23 Feb 2001 02:10:55 GMT
From: "Bertilo Wennergren" <bertilow@chello.se>
Subject: Re: Difficult Split Question
Message-Id: <PEjl6.640$bX.6360@nntp1.chello.se>
"Godzilla!":
> > a,b,c,xyz(p,q,r),d
> > a,def(x,y,z),b,pqr(m,n)
> > I wish to split the line based on all ','
> > characters that are not between '(' and ')'.
> [...]
> You boys should turn off your computers, go outside
> and workout each and everyday like I do. You just
> don't have what it takes to challenge me, even at
> six to one odds.
> #!perl
>
> print "Content-type: text/plain\n\n";
>
> use Benchmark;
>
> timethese (100000,
> {
> 'name1' =>
> '$text = "a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz";
> do
> {
> $start = index ($text, "(", $start);
> $stop = index ($text, ")", $start);
> $temp1 = substr ($text, $start, $stop - $start);
> $temp1 =~ tr/,/¿/;
> substr ($text, $start, $stop - $start, $temp1);
> $start++;
> }
> until (index ($text, "¿", rindex ($text, "(")) > -1);
> @Array = split (/,/, $text);
> foreach (@Array) { $_ =~ tr/¿/,/; }',
>
> 'name2' =>
> '$text = "a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz";
> push @new, $+ while
> $text =~ m/([^(,]*\([^\)\\]*(?:\\.[^\)\\]*)*\)),?|([^,]+),?|(),/gx;',
> }
> );
>
> exit;
>
> PRINTED RESULTS:
> ________________
>
> Benchmark: timing 100000 iterations of name1, name2...
> name1: 9 wallclock secs ( 8.68 usr + 0.00 sys = 8.68 CPU) @
11520.74/s
> name2: 13 wallclock secs (13.62 usr + 0.00 sys = 13.62 CPU) @ 7342.14/s
Well, put this in you pipe and smoke it!:
----------------------------------------------------------------------------
#!perl
$_ = q!a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz!;
$_ .= ",";
(@Array) = m/[^(,]*?\([^)]*?\),|[^,]*?,/g;
for (@Array) {chop}
----------------------------------------------------------------------------
Now let's benchmark all three, sissy boy!
----------------------------------------------------------------------------
#!perl
print "Content-type: text/plain\n\n";
use Benchmark;
timethese (30000,
{
'name1' =>
'$text = "a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz";
do
{
$start = index ($text, "(", $start);
$stop = index ($text, ")", $start);
$temp1 = substr ($text, $start, $stop - $start);
$temp1 =~ tr/,/¿/;
substr ($text, $start, $stop - $start, $temp1);
$start++;
}
until (index ($text, "¿", rindex ($text, "(")) > -1);
@Array = split (/,/, $text);
foreach (@Array) { $_ =~ tr/¿/,/; }',
'name2' =>
'$text = "a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz";
push @new, $+ while
$text =~ m/([^(,]*\([^\)\\]*(?:\\.[^\)\\]*)*\)),?|([^,]+),?|(),/gx;',
'name3' =>
'$_ = q!a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz!;
$_ .= ",";
(@Array) = m/[^(,]*?\([^)]*?\),|[^,]*?,/g;
for (@Array) {chop}'
}
);
exit;
PRINTED RESULTS:
________________
Benchmark: timing 30000 iterations of name1, name2, name3...
name1: 17 wallclock secs (16.25 usr + 0.00 sys = 16.25 CPU) @ 1846.15/s
name2: 25 wallclock secs (25.00 usr + 0.00 sys = 25.00 CPU) @ 1200.00/s
name3: 11 wallclock secs (12.53 usr + 0.00 sys = 12.53 CPU) @ 2394.25/s
^^
Now who's the man, huh?
--
#####################################################################
Bertilo Wennergren
<http://purl.oclc.org/net/bertilo>
<bertilow@chello.se>
#####################################################################
------------------------------
Date: Fri, 23 Feb 2001 04:28:53 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Disabling debugging support in Perl?
Message-Id: <t9bpo5e81lvi6f@corp.supernews.com>
Greg Bacon <gbacon@hiwaay.net> wrote:
> In article <3A9542C9.8449F753@Compaq.com>,
> Joshua Cope <Joshua.Cope@Compaq.com> wrote:
> : I have a site requirement to disable debugging support in all compilers and
> : interpreters, including Perl. Is there a simple way to disable the Perl
> : debugger in a runtime environment (that is, without recompiling the Perl
> : executable)?
> It's crude, but you could remove perl5db.pl. Keep in mind that there's
> nothing stopping the lusers from providing their own copies.
Perhaps I'm confused again, but I thought that was just _a_ Perl debugger.
I know it's the one run by 'perl -d', but it interfaces into many other
parts of the core distribution to get at much of its data. Its status
makes it "the" Perl debugger, but it doesn't have to be the only way to
debug Perl.
I know at least that the entire B family of modules, O.pm, strict.pm,
diagnostics.pm, Data::Dumper, Dumpvalues.pm, sigtrap.pm, dumpvar.pl,
Fatal.pm, assert.pl, Safe.pm, Config.pm, Devel::Peek, Carp.pm, and
Opcode.pm can all be at least marginally useful in stringing together a
customized Perl debugger. I tried my hand at one (which I most certainly
DO NOT consider good enough to put up against the standard Perl debugger,
but it was fun), and I used most of these for parts of the functionality
and considered the remaining couple. These are all part of at least one
or the other of my installations (5.005_03 and 5.6.0). These might not
all be of entirely obvious use in debugging at a glance, but you may
notice a few used by the canonical debugger, too.
Chris
--
Christopher E. Stith
It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc
------------------------------
Date: Fri, 23 Feb 2001 04:39:02 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Execution Problem
Message-Id: <3A95E9DA.7DDB1298@home.com>
Nevermind, I just figured it out. --Dennis
"What A Man !" wrote:
>
> This is a perl and CGI problem. BTW, the CGI ng has been
> down now for over a week.
>
> I have a program on a webhost that allows people to input
> a URL and it processes their file into several other
> directories and files. The problem is that some of these
> files turn out to be executable files. I thought by
> changing the .cgi, .pl, or .exe to .txt that this would
> prevent them from being executed on my server, and
> hopefully prevent any likelihood of possible damage.
> Wrong!
>
> This doesn't seem to be a good solution. I've discovered
> that a file can still be executable even if it has no file
> extension. Further, my server seems to want to even
> execute .txt files.
>
> I've set the user directory at 705, in order for users to
> read their processed files. Should I umask the directory
> also? If so, what should the permission and umask values
> be? And how do I find out what umask value my host has
> set? (because perldoc -f umask says that a umask value
> subtracts from your chmod value).
>
> Thanks,
> Dennis
------------------------------
Date: Fri, 23 Feb 2001 03:55:58 GMT
From: "Orville Bullitt III" <o.bullittiii@worldnet.att.net>
Subject: Help!
Message-Id: <ibll6.1615$rL4.118858@bgtnsc04-news.ops.worldnet.att.net>
I hope that this is the correct NG to ask this question:
I'm using Microsoft's Outlook Express 5.50.
How do I "personalize" a message that is sent to many people using the
BCC address. In otherwords, if I send the SAME message to three people (to
make it short in this example) - John, Jill and Rick - using the BCC address
line, I want to have the message start, "Hi John" in the message is sent to
John, "Hi Jill" in the message sent Jill, and "Hi Rick" in the message sent
to Rick; but only have to compose and send ONE message.
Thank you,
Orville
------------------------------
Date: Fri, 23 Feb 2001 05:03:35 GMT
From: "Orville Bullitt III" <o.bullittiii@worldnet.att.net>
Subject: Re: Help!
Message-Id: <Haml6.1659$rL4.126691@bgtnsc04-news.ops.worldnet.att.net>
ERic <egwong@netcom.com> wrote:
> Orville Bullitt III <o.bullittiii@worldnet.att.net> wrote:
>>
>> I hope that this is the correct NG to ask this question:
>>
>> I'm using Microsoft's Outlook Express 5.50.
>>
> No, it is not. I can't even, in my wildest dreams,
> being to imagine why you think it might be. You might try
> news://microsoft.public.outlook.usage or asking tech support at
> www.microsoft.com
I wrote in this NG because a friend of mine told me that he **THOUGHT**
perl could do it but he had no idea how to do it. He's over 85 years old and
I'm over 90.
I guess that this NG is NOT the place where one can get help.
>> How do I "personalize" a message that is sent to many people using the
>> BCC address. In otherwords, if I send the SAME message to three people
(to
>> make it short in this example) - John, Jill and Rick - using the BCC
address
>> line, I want to have the message start, "Hi John" in the message is sent
to
>> John, "Hi Jill" in the message sent Jill, and "Hi Rick" in the message
sent
>> to Rick; but only have to compose and send ONE message.
>
> I doubt very much that this can be done with Outlook Express. If
> you want to *learn* perl, this is trivial with something like
> Mail::Send (perhaps combined with Template Toolkit or Text::Template).
>
> You can start with the book, "Learning Perl" (the Llama), or going
> to www.perl.com and read the excellent on-line docs.
>
> Good luck,
> ERic
>
>[ followups set ]
------------------------------
Date: Fri, 23 Feb 2001 02:24:33 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How can I detect if program is run by cron?
Message-Id: <slrn99bieq.9kv.efflandt@efflandt.xnet.com>
On Thu, 22 Feb 2001 16:06:11 +0800, John Lin <johnlin@chttl.com.tw> wrote:
>How to detect whether the program is run by cron?
Since there is minimal env and no controlling terminal I imagine there
would be no $ENV{TERM} in cron.
Easy enough to test (log the whole %ENV).
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 22 Feb 2001 21:21:08 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How can I detect if program is run by cron?
Message-Id: <974kv4$qui$1@boomer.cs.utexas.edu>
In article <slrn99bieq.9kv.efflandt@efflandt.xnet.com>,
David Efflandt <efflandt@xnet.com> wrote:
>On Thu, 22 Feb 2001 16:06:11 +0800, John Lin <johnlin@chttl.com.tw> wrote:
>>How to detect whether the program is run by cron?
>
>Since there is minimal env and no controlling terminal I imagine there
>would be no $ENV{TERM} in cron.
>
>Easy enough to test (log the whole %ENV).
Yes, easy to test.
$ echo 'env > foo' | batch
commands will be executed using /bin/ksh
job 982898145.b at Thu Feb 22 21:15:45 2001
$ grep TERM foo
TERM=xterm
$
The thing is, cron stores all your environment variables in the job
that you submit, so that when your job is run, everything is as it was
when you submitted it. Here's another example to make that clearer:
$ FOO=bar
$ export FOO
$ echo 'env > foo' | batch
commands will be executed using /bin/ksh
job 982898256.b at Thu Feb 22 21:17:36 2001
$ grep FOO foo
FOO=bar
$
So, that's not a great way of determining whether something is being
run from cron or not.
Has anyone mentioned running the "tty" program as a way of telling
whether the program is being run interactively or not?
- Logan
--
my your his her our their *its*
I'm you're he's she's we're they're *it's*
------------------------------
Date: Fri, 23 Feb 2001 03:44:56 GMT
From: "Joseph M. Suprenant" <laclac@global2000.net>
Subject: newbie question
Message-Id: <3A95E3F4.B3A457D5@global2000.net>
Hi I am trying to learn perl, and i was wondering is someone could help
me with it. I will attach some code which i can't seem to get to work
properly. If someone could please help me i would be greatly
appreciated.
My situation is this, the code that i have works the way it should
when displaying the first form, but when I submit the data, i get the
error message "The document contains no data" What i want to see for now
,is just the values of the variables. This seems like such a petty task,
it works fine when i use multiple cgi files, but when i use just one
like in this case, it does not work.
The following is my code:
#!/usr/bin/perl
##
## Turns off buffering
$| = 1;
print "Content-type: text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
$i=0;
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ( $contents{$name} eq "" )
{
$contents{$name} = $value;
}
else
{
$contents{$name} .= ";$value";
}
$i=$i+$value;
}
if($ENV{'CONTENT_LENGTH'}eq "")
{
print"<head><title>Getting Info</head></title>";
print"<br>";
print"$contents<br>";
print"$ENV{'QUERY_STRING'}";
print"HomeWork 5";
print"<input type=\"hidden\" name=\"cols\" value=-1>";
print"<form method=\"post\" action=\"test3.cgi\">";
print"Please enter in a starting value: ";
print"<input type=\"text\" name=\"start\"size=2 maxlength=3>";
print"<br>";
print"Please enter in an increment value: ";
print"<input type=\"text\" name\"inc\" size=2 maxlength=3>";
print"<br>";
print"Please enter in the number of values: ";
print"<input type=\"text\" name=\"num\" size=3 maxlength=3>";
print"<br>";
print"<input type=\"submit\"value=\"Submit\" >";
print"<input type=\"reset\"value=\"reset\">";
}
print"$contents{'inc'}";
------------------------------
Date: 23 Feb 2001 04:43:14 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: newbie question
Message-Id: <slrn99bqhs.och.damian@puma.qimr.edu.au>
Thus spake Joseph M. Suprenant on Fri, 23 Feb 2001 03:44:56 GMT:
>Hi I am trying to learn perl
Lots of luck! The best resources for learning about Perl features are the
documents that come with Perl itself, and should be installed on your
machine. If you're running some sort of *nix, these can be accessed via the
man program, or through a utility called perldoc, which will have been
installed with perl (if you're stuck on windows, perldoc is your only
hope). If you type 'perldoc perltoc' at your shell prompt, you will see a
list of the documents available. If you don't like reading stuff in this
format, there is also a pod2html utility.
>...
>
>The following is my code:
>#!/usr/bin/perl
>##
You should really use the -w command line switch (or the 'warnings' pragma
under perl 5.6.0), and the 'strict' pragma.
use warnings;
use strict;
>
>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>...
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
You will really be saving yourself a lot of bother if you use the CGI
module, which comes with the standard Perl distribution (and has done for a
long time), rather than implementing your own CGI parsing code. Below is a
short program that does what you were trying to do, using the CGI module.
#!/usr/bin/perl -w
use strict;
use CGI;
my $cgi = CGI->new();
print $cgi->header,
$cgi->start_html;
if ($cgi->param()) {
print $cgi->dump()
}
else {
# Your fill-out form
# printing code should
# go here. Do check the
# methods provided by
# CGI for generating
# the markup for this.
print "test";
};
print $cgi->end_html;
__END__
One other thing I noticed in your code -- you were finding it necessary to
escape a lot of '"'s. You should read 'perldoc perlop' and go over the
section on perl's "Quote and Quotelike Operators", which you should find
saves you a bit of hassle there.
HTH,
Cheers,
Damian
--
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker
------------------------------
Date: 23 Feb 2001 04:46:10 GMT
From: egwong@netcom.com
Subject: Outlook Express (was Re: Help!)
Message-Id: <974puh$4o1e$1@newssvr06-en0.news.prodigy.com>
Orville Bullitt III <o.bullittiii@worldnet.att.net> wrote:
> I hope that this is the correct NG to ask this question:
>
> I'm using Microsoft's Outlook Express 5.50.
No, it is not. I can't even, in my wildest dreams,
being to imagine why you think it might be. You might try
news://microsoft.public.outlook.usage or asking tech support at
www.microsoft.com
> How do I "personalize" a message that is sent to many people using the
> BCC address. In otherwords, if I send the SAME message to three people (to
> make it short in this example) - John, Jill and Rick - using the BCC address
> line, I want to have the message start, "Hi John" in the message is sent to
> John, "Hi Jill" in the message sent Jill, and "Hi Rick" in the message sent
> to Rick; but only have to compose and send ONE message.
I doubt very much that this can be done with Outlook Express. If
you want to *learn* perl, this is trivial with something like
Mail::Send (perhaps combined with Template Toolkit or Text::Template).
You can start with the book, "Learning Perl" (the Llama), or going
to www.perl.com and read the excellent on-line docs.
Good luck,
ERic
[ followups set ]
------------------------------
Date: Thu, 22 Feb 2001 21:25:53 -0500
From: ivo welch <ivo.welch@yale.edu>
Subject: Re: perl-mode in emacs: nested sub's
Message-Id: <3A95CA31.3522403B@yale.edu>
looks like I need cperl. I found version 4.24. It loads fine (and works
indeed much better), but when I try to byte-compile it, I get
Compiling file /tmp/cperl-mode.el at Thu Feb 22 21:17:03 2001
** reference to free variable cperl-nonoverridable-face
While compiling toplevel forms:
!! End of file during parsing
and for the non-emacs-wizard dumb question of the day (apologies):
the code says that prior to 20.3, one should put
;; (autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl
programs" t)
but what do I say in 20.7.1? Just putting it into my
/usr/lib/emacs/site-lisp/ directory and hoping for autoinvokation does
not do it.
ivo welch wrote:
> emacs 20.7.1 (standard distribution on redhat 7.0). Problem Example:
>
> {
> print "something\n";
> sub printnothing {
> print "hi\n";
> }
> print "end\n";
> }
>
> The 'print "end\n";' statement is misindented, as are all statements
> thereafter. Is there a better or fixed emacs perl-mode somewhere
> available?
>
> /iaw
> --
--
Ivo Welch, Professor of Finance/Economics, Yale/SOM + NBER
http://welch.som.yale.edu/
------------------------------
Date: Fri, 23 Feb 2001 11:50:31 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: question about arrays
Message-Id: <WCjl6.23$M01.3636@vic.nntp.telstra.net>
"John Hamm" <johnhamm@wpi.edu> wrote in message
news:Pine.OSF.4.30.0102222015030.26728-100000@grover.WPI.EDU...
> Hi there,
> I'm using GD for creating images and for some weird reason it won't
accept
> an array that I create like:
>
> for ($i=0;$i<10;$i++)
> {
> $myarray[$i] = $i;
> }
That creates an array with 10 elements.
> it has to be created like:
>
> @myarray = [
> 0,
> 1,
> 2,
> 3,
> 4,
> 5,
> 6,
> 7,
> 8,
> 9,
> ];
>
That creates an array with 1 element, that element being a list of 10
items.
To access the individual elements, you would do:
for my $i (0..9){
print $myarray[0][$i];
}
> Anyone know what the difference between creating an array these two
> different ways? Thanks in advance for any help!!!
you could also use
@myarray = (0..9);
Which duplicates the former, not the latter.
I suspect GD is referencing the list of lists, rather than the array.
You might want to read up on perllol
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Fri, 23 Feb 2001 11:53:31 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: question about arrays
Message-Id: <KFjl6.24$M01.3708@vic.nntp.telstra.net>
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:WCjl6.23$M01.3636@vic.nntp.telstra.net...
>
> you could also use
>
> @myarray = (0..9);
>
> Which duplicates the former, not the latter.
>
To duplicate the latter, you could do :
@myarray = [0..9];
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: 23 Feb 2001 02:21:27 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: question about arrays
Message-Id: <slrn99bi81.ipd.damian@puma.qimr.edu.au>
Thus spake John Hamm on Thu, 22 Feb 2001 20:18:48 -0500:
>Hi there,
>I'm using GD for creating images and for some weird reason it won't accept
>an array that I create like:
>
>for ($i=0;$i<10;$i++)
>{
> $myarray[$i] = $i;
>}
This is equivalent to: @myarray = 0..9;
>
>it has to be created like:
>
>@myarray = [ 0,1,2,3,4,5,6,7,8,9 ];
>
This equivalent to: $myarray[0] = [ 0..9 ];
See below, but since the RHS is a (scalar) reference to an anonymous array,
you are only assigning to the fist element of @myarray. You probably want
to say $myarrayref = [ 0..9 ];
>
>Anyone know what the difference between creating an array these two
>different ways? Thanks in advance for any help!!!
>
You have stumbled onto the syntax for creating a reference to an anonymous
array. Many modules require array references as arguments rather than
actual arrays. If you have already defined an array, you can take a
reference to it by saying: $myref = \@myarray;
You should read the following manual pages:
perldoc perlref
perldoc perldsc
perldoc perllol
and
perldoc -q "How can I pass/return a {Function, FileHandle,
Array, Hash, Method, Regex}?"
for futher details.
Cheers,
Damian
--
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker
------------------------------
Date: 23 Feb 2001 02:23:52 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: question about arrays
Message-Id: <slrn99bici.ipd.damian@puma.qimr.edu.au>
Thus spake Damian James on 23 Feb 2001 02:21:27 GMT:
>
>This is equivalent to: @myarray = 0..9;
> ^^^^^^
Of course I meant @myarray = (0..9);
Cheers,
Damian
--
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker
------------------------------
Date: Thu, 22 Feb 2001 21:24:23 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: question about arrays
Message-Id: <974hg5$m28$1@slb6.atl.mindspring.net>
"John Hamm" <johnhamm@wpi.edu> wrote in message
news:Pine.OSF.4.30.0102222015030.26728-100000@grover.WPI.EDU...
> Hi there,
> I'm using GD for creating images and for some weird reason it won't accept
> an array that I create like:
>
> for ($i=0;$i<10;$i++)
> {
> $myarray[$i] = $i;
> }
>
> it has to be created like:
>
> @myarray = [
> 0,
> 1,
> 2,
> 3,
> 4,
> 5,
> 6,
> 7,
> 8,
> 9,
> ];
>
>
> Anyone know what the difference between creating an array these two
> different ways? Thanks in advance for any help!!!
>
> John Hamm
There's a big difference between the () list constructor and the [] array
reference constructor. Read perldata and perlref for details.
The syntax @myarray = [0, 1, 2, 3] constructs a two dimensional array;
@myarray contains a single element, a reference to the anonymous array [0,
1, 2, 3]. This is the same as saying:
for my $i (0, 1, 2, 3) {
$myarray[0][$i] = $i;
}
You didn't give enough information to say exactly what you are trying to do,
but I would guess that the function that you are calling expects to see an
array ref rather than an array. Calling $gd->some_func(@myarray) evaluates
@myarray in a list context, passing the single array reference in a somewhat
convoluted manner. You should probably use something like:
my @array = (0, 1, 2, 3);
$gd->some_func(\@array);
# or
my $arrayref = [0, 1, 2, 3];
$gd->some_func($arrayref);
HTH
Kurt Stephens
BTW, how's the old alma mater? Been to Ralph's lately?
------------------------------
Date: 23 Feb 2001 02:26:43 GMT
From: egwong@netcom.com
Subject: Re: Trying to use Mysql and insert
Message-Id: <974hp3$1scs$1@newssvr06-en0.news.prodigy.com>
Victor Prasad <vivekvp@spliced.com> wrote:
> Below is a dbitrace of my insert script - why isn't it working? I am not
> sure where the error is or how to correct it. I am not getting an error
> when I run the perl script (ie perl <file_name> but no insert happens:
I didn't look at your dbitrace because it all looks like line noise
to me. Surely you don't expect anyone to be able to reconstruct what
you're doing in perl based on it? If you want help, it's always more
profitable to post the relevant portions of the actual code doing the
work, not just the results. That'd be like pointing to an oil slick
in your driveway and asking a mechanic what's wrong with your car.
But, if I were you, the first thing I'd do is make sure that your SQL
is good by doing an INSERT manually from the mysql command-line client.
Then, I'd make sure that your perl is building the proper SQL statement
by using "print" or "warn" before the $dbh->prepare( $sql ) and
$dbh->execute( $a, $b, $c ).
ERic
------------------------------
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 V10 Issue 340
**************************************