[18357] in Perl-Users-Digest
Perl-Users Digest, Issue: 525 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 19 06:05:44 2001
Date: Mon, 19 Mar 2001 03:05:11 -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: <984999910-v10-i525@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 19 Mar 2001 Volume: 10 Number: 525
Today's topics:
archives <todd@designsouth.net>
Re: archives <wyzelli@yahoo.com>
Re: archives <todd@designsouth.net>
Caugt a SIGSEGV - what does it mean? <iain_hosking@hotmail.com>
Die with 'use strict' <peter.sundstrom-eds@eds.com>
Re: Die with 'use strict' <uri@sysarch.com>
Re: Duplicate entry problem in mysql using DBI <peb@bms.umist.ac.uk>
Re: error =? (Anno Siegel)
Exception Handling , divide by zero , and compiler <cmon_209@hotmail.com>
Re: Exception Handling , divide by zero , and compiler <nospam@nospam.net>
Re: Help Putting data from an file that Perl reads into (Damian James)
Re: Help Putting data from an file that Perl reads into <bigrich318@yahoo.com>
Re: Print "tar" Success or Failure (Garry Williams)
Re: Print "tar" Success or Failure (BUCK NAKED1)
Re: Print "tar" Success or Failure <bart.lateur@skynet.be>
Re: Print "tar" Success or Failure (Anno Siegel)
push, pop file handles to deal with recursive #include <johnlin@chttl.com.tw>
Re: push, pop file handles to deal with recursive #incl (Anno Siegel)
Re: readdir out of memory (Tad McClellan)
Re: sub routine args, and using GD's newFromPng method (Martien Verbruggen)
too late for -T <ducateg@info.bt.co.uk>
Re: use Net::SMTP (Garry Williams)
Re: use Net::SMTP <jtjohnston@courrier.usherb.ca>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Mar 2001 07:56:52 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: archives
Message-Id: <8Zit6.17919$Q47.5360544@news1.rdc1.tn.home.com>
Where can I get the archives of this newsgroup, now that deja.com is down?
------------------------------
Date: Mon, 19 Mar 2001 17:46:12 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: archives
Message-Id: <T2jt6.1$OQ.602@vic.nntp.telstra.net>
"Todd Smith" <todd@designsouth.net> wrote in message
news:8Zit6.17919$Q47.5360544@news1.rdc1.tn.home.com...
> Where can I get the archives of this newsgroup, now that deja.com is
down?
What happens when you go to www.deja.com?
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: Mon, 19 Mar 2001 08:18:42 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: archives
Message-Id: <Chjt6.17964$Q47.5368191@news1.rdc1.tn.home.com>
well, google took it over but they don't have anywhere near the archives and
old messages that deja could come up with
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:T2jt6.1$OQ.602@vic.nntp.telstra.net...
> "Todd Smith" <todd@designsouth.net> wrote in message
> news:8Zit6.17919$Q47.5360544@news1.rdc1.tn.home.com...
> > Where can I get the archives of this newsgroup, now that deja.com is
> down?
>
> What happens when you go to www.deja.com?
>
> 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: Fri, 16 Mar 2001 17:43:57 +1100
From: "Iain Hosking" <iain_hosking@hotmail.com>
Subject: Caugt a SIGSEGV - what does it mean?
Message-Id: <99439j$3s8$1@thebe.syd.dav.net.au>
I've started noticing the occasional:
Caught a SIGSEGV at foo.pl line 0
$ = eval {...} called from file `foo.pl' line 0
I can't find any reference to this error in the perl doco (I'm using
ActiveState Perl 5.6 build 623) - the programs appear to run to completion
and the error doesn't appear till the program has finished. Has anyone any
idea where I should start looking in my code? Line 0 isn't much to go on.
Thanks in advance
Iain
------------------------------
Date: Mon, 19 Mar 2001 17:39:12 +1200
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Die with 'use strict'
Message-Id: <99462b$2sr$1@hermes.nz.eds.com>
I'm curious why 'use strict' complains about the following snippet
#!/usr/local/bin/perl -w
use strict;
my $result=`ls foobar` or die "Failed: $result\n";
$ ./foo
Global symbol "result" requires explicit package name at ./foo line 4.
Execution of ./foo aborted due to compilation errors.
Is the die considered to be out of scope?
------------------------------
Date: Mon, 19 Mar 2001 07:09:42 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Die with 'use strict'
Message-Id: <x7ofuy44ll.fsf@home.sysarch.com>
>>>>> "PS" == Peter Sundstrom <peter.sundstrom-eds@eds.com> writes:
PS> I'm curious why 'use strict' complains about the following snippet
PS> #!/usr/local/bin/perl -w
PS> use strict;
PS> my $result=`ls foobar` or die "Failed: $result\n";
PS> $ ./foo
PS> Global symbol "result" requires explicit package name at ./foo line 4.
PS> Execution of ./foo aborted due to compilation errors.
the use of $result is seen before the compiler processes the my
command. you can use the my'ed var in the same statement as the my.
my $result ;
$result = `ls foobar` or die "Failed: $result\n";
will work.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 19 Mar 2001 10:20:46 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Duplicate entry problem in mysql using DBI
Message-Id: <3AB5DD7E.32DB905B@bms.umist.ac.uk>
Garry Williams wrote:
> >> $dbh->do("INSERT INTO ED1 VALUES(date,2output,2op_strike,
> > ^^^^^^
> >don't you need this to come later? You are referring to columns not
> >values at this point.
>
> That's not true.
Isn't it? I'm pretty sure the OP isn't trying to insert the bareword
'date' or '2output' etc into the database.
>
> Although this is a bad technique because changes to table definitions
> can break this program, it is perfectly valid to insert values into a
> table without explicitly naming the columns as long as all of the
> columns are given values *and* the values are specified in the correct
> order.
sure. but in this case he *is* explicitly naming the columns but
calling them values.
>
> But this is really an SQL language or mysql issue -- not a Perl issue.
true so I'll shut up.
Paul
------------------------------
Date: 19 Mar 2001 10:20:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: error =?
Message-Id: <994mgl$865$2@mamenchi.zrz.TU-Berlin.DE>
According to <anjan50@home.com>:
> Response.pm: BEGIN not safe after errors--compilation aborted at
> GKGSRS/Response.pm l
When you have questions about an error message, consult perldiag.
You can even put "use diagnostics" near the top of your file. Perl
will show a detailed explanation for every error message or warning
that happens.
Anno
------------------------------
Date: Mon, 19 Mar 2001 06:16:52 GMT
From: Chandramohan Neelakantan<cmon_209@hotmail.com>
Subject: Exception Handling , divide by zero , and compiler
Message-Id: <ovht6.1190$94.1622@www.newsranger.com>
Hi.
I have a query regarding how the compiler works.Consider the following examples
Example 1:
#!/usr/bin/perl
1. eval
2. {
3. $result = 8/0;
4. };
5. if($@)
6. {
7. print "Exception Caught";
8. }
Output:
Illegal Division by zero at line 3
Example 2:
#!/usr/bin/perl
1. eval
2. {
3. $c=\8;
4. $d=\0;
5. $result = $$c/$$d;
6. };
7. if($@)
8. {
9. print "Exception Caught";
10. }
Output:
Exception caught
Example 3:
#!/usr/bin/perl
1. eval
2. {
3. $c=8;
4. $d=0;
5. $result = $c/$d;
6. };
7. if($@)
8. {
9. print "Exception Caught";
10. }
Output:
Exception caught
I am able to comprehend the output in all the cases ...but I do have some doubts
on the above.
1. In Example 1 , the compiler sees a divide by zero since constants are used
and immediately signals a compile time error.
Example 3 is used in situations where the value of the denominator can change
dynamically , so there the exception can be caught and handled.
Example 2 uses CONSTANT references.Why doesnt the compiler dereference the
CONSTANT references and generate a compile time error ?My argument is ...the
compiler knows that the values $c and $d are pointing to,cannot change...then
why should it allow compilation?
2.Is the value of $@ pre 'defined' ?...'cos when I use if(defined $@) I dont get
the expected results.
Thanx is advance
Chandramohan Neelakantan
------------------------------
Date: Mon, 19 Mar 2001 07:38:55 GMT
From: "David Ehrens" <nospam@nospam.net>
Subject: Re: Exception Handling , divide by zero , and compiler
Message-Id: <jIit6.286$587.23034@typhoon.ne.mediaone.net>
"Chandramohan Neelakantan" <cmon_209@hotmail.com> wrote in message
news:ovht6.1190$94.1622@www.newsranger.com...
..
I noticed the same thing in my sample program below. Basically, I think
that Perl knows that ($C = 100/0) is going to cause trouble at
compile-time and generates a message immediately. On the other hand, the
"catch" logic will be activated at run-time as in the example below
because Perl has no choice but to wait for ($c = $a / $b) to be
evaluated.
# TRY
eval {
$a = 100;
$b = 0;
($c = ($a / $b)) or die($!);
};
# CATCH
if ($@) {
print "Aha! Error $!: $@\n";
}
else {
print "I didn't find any errors? Did you?";
}
------------------------------
Date: 19 Mar 2001 05:21:15 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Help Putting data from an file that Perl reads into a JavaScript array
Message-Id: <slrn9bb5pq.sul.damian@puma.qimr.edu.au>
Falc2199 chose 19 Mar 2001 03:16:57 GMT to say this:
>...
>
>Can anyone help me figure this out? As of right now I am getting a syntax
error
>at the open command.
>
>...
>
>open (QUESTIONS, "questions.txt");
>
I don't see a syntax error there. What was the error message? You
should include some error-checking, anyway:
open(QUESTIONS, '<./questions.txt') || die "Can't open questions.txt: $!";
This will at least tell you whether and/or why open() is failing.
BTW, why aren't you using -w, strict, and CGI?
HTH,
Cheers
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@|,@;);push@|,shift@;if$;[0
]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: Mon, 19 Mar 2001 03:23:48 -0600
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: Help Putting data from an file that Perl reads into a JavaScript array
Message-Id: <tbbjtjtphigp4a@corp.supernews.com>
"Falc2199" <falc2199@aol.comNOJUNK> wrote in message
news:20010318221657.07323.00002080@ng-fn1.aol.com...
> I have been trying for the past week to get information from a file
that Perl
> reads into a JavaScript array.
>
> Can anyone help me figure this out? As of right now I am getting a syntax
error
> at the open command.
>
> #!/usr/bin/perl
>
> print "Content-type: text/html\n\n";
> print "<html><h1>Hello!</h1></html>\n";
Bad HTML, you use a closing HTML tag later also.
Not having a closing semicolon
> print <<ENDOFHTML
here--------------------^^^^,
means the print statement doesn't end until:
> script <language = "javascript" >
>
> var questions = [
>
> ENDOFHTML
>
> open (QUESTIONS, "questions.txt");
here-----------------------------------^^^.
<snip>
That's why you get the syntax error at "open()".
should be: print <<ENDOFHTML;
Try this,
#!/usr/bin/perl -wT
use strict;
my $html = q~<html>
<head>
<title>Test</title>
<script language="JavaScript" type="text/javascript">
~;
open(QFILE, 'questions.txt') || die "Could not open questions.txt: $!";
flock(QFILE, 2) unless ($^O =~ /MSWin32/);
my $cnt = 0;
my $array_vals;
while (<QFILE>) {
chomp;
$array_vals .= "questions[$cnt] = \"$_\"\;\n";
$cnt++;
}
close(QFILE);
$html .= qq~var questions = new Array($cnt)\;
$array_vals
function showArray() {
for (i=0;i<questions.length;i++) {
alert('The value of questions['+i+'] is '+questions[i]+'.')\;
}
}
</script>
</head>
<body>
<a href="javascript:showArray()\;">Show Array</a>
</body>
</html>~;
print "Content-type: text/html\n\n";
print $html;
------------------------------
Date: Mon, 19 Mar 2001 05:08:14 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Print "tar" Success or Failure
Message-Id: <slrn9bb51t.dd5.garry@zfw.zvolve.net>
On Sun, 18 Mar 2001 20:31:28 -0600 (CST), BUCK NAKED1
<dennis100@webtv.net> wrote:
>> bart.lateur@skynet.be (Bart Lateur)
>> > BUCK NAKED1 wrote:
>> > I've tried...
>> > if (system("tar -zxf $tmpfile -C $tmpdir 2>&1")==0) {
>> > print "SUCCESS";
>> > }
>> > else {print "FAILURE";
>> > };
>> > ..and this doesn't work. Why?
>
>> Probably because this tar doesn't return > a proper exit value.
>
> Hmmm... I thought I learned from the other thread where I asked about
> this that "tar" returned a value of "0" upon success, so why is an exit
> value of "0" wrong?
Run the command from the command line and examine the exit code.
>> But why are you using system()? What is
>> the output from tar to STDOUT good for?
>> Wouldn't it be better to capture it, by using
>> backticks ("`") instead of system(), and parsing
>> tar´s textual output? Plus, the user need > never see it.
>
> That was another question I had (whether I should've used backticks
> instead), but I didn't want to ask too many questions. Thanks for
> answering it. Here is my revised code replacing "system" with
> "backticks," and adding a "\n" after Extracted.
>
> mkdir $tmpdir, 0705;
> `tar -zxf $tmpfile -C $tmpdir 2>&1, Tarfile has been Extracted\n`==0 ||
This make no sense. qx// will return the *output* of the command, not
the exit code. I doubt that will ever be the number zero (at least
from the tar commands that I know). If you were running with warnings
enabled, perl would squawk about the numeric comparison.
See the perlop manual page for the qx// or backtick discussion. It
also tells you where to expect the exit code from the command run by
qx//.
I also pointed out (how did this thread get broken) in my previous
post that the stuff you expect the shell to execute is going to cause
a syntax error. Just run that stuff between the backticks on the
command line to see what happens.
If the output of the tar command is really something you want, then
why don't you assign it to a variable?
If the output of the command is not needed and you don't want it on
STDOUT, then redirect it to /dev/null *after* you have debugged your
problem.
[snip same code as I commented on before]
--
Garry Williams
------------------------------
Date: Mon, 19 Mar 2001 00:15:04 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Print "tar" Success or Failure
Message-Id: <11238-3AB5A3E8-10@storefull-246.iap.bryant.webtv.net>
By "zombies"... I meant a blank page. I thought a zombie was an empty
page. Sorry, I guess I need to learn what "zombie" means. BTW, I was
using -w, but not strict. I haven't got around to learning lexical
scoping yet.
Thanks, Gary and Bart. I put your suggestions together and got something
to work, but ... What was the "__END_" you suggested for? I left it off
because I have an END block at the end of this script, and I thought it
might mess that up.
Also... is there a way to do the below without using if/else? (I already
have too many if/else's in the script already)
mkdir $tmpdir, 0705 or die "Coudn't make $tmpdir: $!";
if ($rc = `tar -zxf $tmpfile -C $tmpdir 2>&1`) {
rmdir $tmpdir;
unlink $tmpfile;
print "un-tar failed\n";
}
else { print $done;
} ;
So much to learn. }-:
Thanks for your time and patience with this old man.
--Dennis
------------------------------
Date: Mon, 19 Mar 2001 10:18:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Print "tar" Success or Failure
Message-Id: <i6nbbt826jaip8h6t3iihfiocli627fn2p@4ax.com>
BUCK NAKED1 wrote:
>What was the "__END_" you suggested for? I left it off
>because I have an END block at the end of this script, and I thought it
>might mess that up.
It would.
The idea is that if people forgot to snip the rest of the message (the
sig if the post ends with code), and run it independently, that it would
still work because Perl would do the snip for you. Thus: the __END__ is
a marker that anything underneath isn't Perl.
--
Bart.
------------------------------
Date: 19 Mar 2001 10:29:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Print "tar" Success or Failure
Message-Id: <994n37$865$3@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> BUCK NAKED1 wrote:
>
> >What was the "__END_" you suggested for? I left it off
> >because I have an END block at the end of this script, and I thought it
> >might mess that up.
>
> It would.
>
> The idea is that if people forgot to snip the rest of the message (the
> sig if the post ends with code), and run it independently, that it would
> still work because Perl would do the snip for you. Thus: the __END__ is
> a marker that anything underneath isn't Perl.
If he indeed has an "END block", __END__ wouldn't interfer.
Anno
------------------------------
Date: Mon, 19 Mar 2001 17:24:08 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: push, pop file handles to deal with recursive #include
Message-Id: <994j4v$cdl@netnews.hinet.net>
Dear all,
I wrote a program to deal with recursive #include
by using a @stack to store file handles.
my @stack;
my $f;
open $f,'a.txt' or die $!;
do {
while(<$f>) {
if(/#include <(.*)>/) {
push @stack,$f;
open $f,$1 or die $!;
}
else { print }
}
} while defined ($f = pop @stack);
------------------------------------------- a.txt is
a-a
#include <b.txt>
a-c
------------------------------------------- b.txt is
b-b
#include <c.txt>
b-d
------------------------------------------- c.txt is
c-c
c-d
c-e
The result is
a-a
b-b
c-c
c-d
c-e
I expect it to be
a-a
b-b
c-c
c-d
c-e
b-d
a-c
What mistakes did I make?
By the way, my original version was "local *F", "open F",
"while(<F>)" and "push @stack,*F", "*F = pop @stack".
It could compile but didn't work at all.
What is the correct way for this bare word "F" version?
Thank you very much.
John Lin
------------------------------
Date: 19 Mar 2001 10:13:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: push, pop file handles to deal with recursive #include
Message-Id: <994m3c$865$1@mamenchi.zrz.TU-Berlin.DE>
According to John Lin <johnlin@chttl.com.tw>:
> Dear all,
>
> I wrote a program to deal with recursive #include
> by using a @stack to store file handles.
>
> my @stack;
> my $f;
> open $f,'a.txt' or die $!;
> do {
> while(<$f>) {
> if(/#include <(.*)>/) {
> push @stack,$f;
> open $f,$1 or die $!;
You're stacking away the filehandle but keeping it in $f anyhow,
so open() does its usual implicit close. When you pop it back from
the stack it's still closed. Insert "my $f" between "push" and
"open" (untested).
[snip]
Anno
------------------------------
Date: Sun, 18 Mar 2001 23:21:59 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: readdir out of memory
Message-Id: <slrn9bb2b7.3fd.tadmc@tadmc26.august.net>
mike at NOSPAM whatibelieve dot org <mikeatNOSPAMwhatibelievedotorg> wrote:
>
>Problem:
>this command causes machines to run out of memory.
>
>> perl -e 'opendir (SCF_DIR, "_SCF"); @scf_files=(readdir(SCF_DIR)); print @scf_files;'
>results in:
>Out of memory!
>The directory contains ~55,000 symbolic links that I need to read in
>and then do something to each file.
Why don't you read them one at a time instead of holding them
all in memory?
>I know I can patch it with a system call to `ls` and a split but
>that doesn't seem proper. Any help would be appreciated.
while ( $scr_file = readdir(SCF_DIR)) {
# process the "file"
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 19 Mar 2001 20:46:17 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: sub routine args, and using GD's newFromPng method
Message-Id: <slrn9bblb9.prj.mgjv@martien.heliotrope.home>
On Sun, 18 Mar 2001 04:39:00 -0500,
null <nospamplease@thankyou.com> wrote:
>
> I am a perl newbie and am writing my first prog.
Welcome. I hope you're enjoying it. :)
> I've written a subroutine that i am calling to create several images inside
> the script () from png image files. The images and parts of the images are
> pasted together later on in the script [using $image->copy(blahblah... ] to
> make a new image that I spit out for viewing.
>
> I've had a problem ... first here's the sub and the sub call that I am
> using now :
>
> sub createCompImages{
> my($filePath, $imgMoniker) = @_;
> open(PNG, "< ".$filePath) or die "Couldn't open $filePath for reading:
> $!\n";
> @_[1] = newFromPng GD::Image(\*PNG) || die "Couldn't create an image for
> $filePath for reading: $!\n";
> close PNG;
> }
>
> &createCompImages($componentPinkrectPath, $componentPinkrect);
Since you're not returning anything else from that subroutine, why don't
you simply return the value that you want to assign to
$componentPinkRect?
Oh, and you don't need to do all the work you do. GD::Image can be
instantiated from a file name. I also don't like having die messages in
subroutines. The main flow of code should die. A subroutine should only
die under exceptional circumstances.
sub create_comp_images
{
my $fn = shift;
return GD::Image->new($fn);
}
$componentPinkRect = create_comp_images($componentPinkrectPath);
die "Couldn't read $componentPinkrectPath"
unless defined $componentPinkRect;
Yes, leave off the & from the call. It's unnecessary, and some day the
use of it will bite you. Read perlsub to see what that does in certain
circumstances. You see it used in old code (pre-Perl 5) a lot, but it
really should only be used in Perl 5 code if its semantics are needed,
which is hardly ever, and certainly not in this case.
The above code is, of course, exactly equivalent to, and less readable
than:
$componentPinkRect = GD::Image->new($componentPinkrectPath);
die "Couldn't read $componentPinkrectPath"
unless defined $componentPinkRect;
Encapsulation of repetitive stuff in a sub, like you're doing, is good.
However, if the encapsulation is more work than the original, it's
probably not a bad idea to not do it. ou were probably not aware that
GD::Image objects don't _need_ a file handle, but now you are.
> further down in the script, I'm referencing the image created by this
> call to the sub through the variable $componentPinkrect.
[snip]
> My script works now, but I'd like to be able to use the var instead of
> the raw array element reference for obvious reasons. Note : if I
> paste $componentPinkrect in for @_[1], it also works. Running in
> strict mode, no errors except for when I try to use $imgMoniker
> instead of @_[1].
Since your question is about using references to the arguments in a sub:
You can only do that by using the elements of @_ directly, which, BTW,
are referred to as $_[0] etc., not @_[0]. If you had enabled warnings
with -w or 'use warnings', Perl would have told you. Using globals to
get around that is a bad idea. Just make your subroutine return what
needs to be returned.
Some documentaiton that you probably should read:
$ perldoc GD
$ perldoc perlsub
Martien
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Mon, 19 Mar 2001 10:23:18 -0000
From: "Géry" <ducateg@info.bt.co.uk>
Subject: too late for -T
Message-Id: <994mvq$dgb$1@pheidippides.axion.bt.co.uk>
I have tried to run a Perl script on Ms IIS server v4. I want to run with
the tainted security option -T. IIS complains about it and returns the
message "Too late for -T ...".
Does anyone know why?
--
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Géry Ducatel
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
------------------------------
Date: Mon, 19 Mar 2001 05:49:41 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: use Net::SMTP
Message-Id: <slrn9bb7fk.dd5.garry@zfw.zvolve.net>
On Sun, 18 Mar 2001 23:53:44 -0500, jtjohnston
<jtjohnston@courrier.usherb.ca> wrote:
> Whimper, I can't get this to work. it keeps crashing.
> Can anyone help me clean the lines up? There must be something real
> simple i'm not doing right. It keeps crashing my smtp. It used to work?
This may be harder than you think. I don't know what you mean by
"keeps crashing" and "keeps crashing my smtp".
The code below will produce some wonderful diagnostics. Didn't they
help? You could have included them in your post to help disambiguate
your problem/question.
I find it hard to believe that this code "used to work", but maybe I
don't know what kind of SMTP server you're using.
> An email reply & post would be helpful. My nntp erases posts before I
> can get back to them.
No problem.
> --snip--
> $email = "delete.jtjohnston\@courrier.usherb.ca";
> $recip = "delete.eslcafe\@interlinx.qc.ca";
> $url = "../me.htm";
>
> use Net::SMTP;
>
> $smtp = Net::SMTP->new('delete.interlinx.qc.ca', Debug => 1);
The Debug option prints this for me [line wrapped for posting]:
Net::SMTP=GLOB(0x11e8b8)>>> MAIL FROM:<garry>
Net::SMTP=GLOB(0x11e8b8)<<< 501 5.5.4 <garry>... Domain name required
for sender address garry
Net::SMTP=GLOB(0x11e8b8)>>> RCPT TO:<$email>
Net::SMTP=GLOB(0x11e8b8)<<< 503 5.0.0 Need MAIL before RCPT
Net::SMTP=GLOB(0x11e8b8)>>> DATA
Net::SMTP=GLOB(0x11e8b8)<<< 503 5.0.0 Need MAIL command
Net::SMTP=GLOB(0x11e8b8)>>> From: delete.eslcafe@interlinx.qc.ca
Net::SMTP=GLOB(0x11e8b8)>>> To: delete.jtjohnston@courrier.usherb.ca
Net::SMTP=GLOB(0x11e8b8)>>>
Net::SMTP=GLOB(0x11e8b8)>>> A simple test message
Net::SMTP=GLOB(0x11e8b8)>>> .
> $smtp->mail($ENV{USER});
Maybe you should comply with the SMTP standard and include the domain
name in the envelope. :-)
I would also at least check the return values from the mail() and to()
methods before blasting along. You might want to be even more
thorough than that.
> $smtp->to('$email');
> $smtp->data();
> $smtp->datasend("From: $recip\n");
> $smtp->datasend("To: $email\n");
> $smtp->datasend("\n");
> $smtp->datasend("A simple test message\n");
> $smtp->datasend(".");
> $smtp->dataend();
Huh? Sending a line with just a period is redundant (and may cause
problems). Check the Net::SMTP manual page examples. Ahh. I just
looked at it and this is where you got $ENV{USER}, eh?
> $smtp->quit;
>
> print "Location: $url\n\n";
A straggler? :-)
--
Garry Williams
------------------------------
Date: Mon, 19 Mar 2001 01:56:26 -0500
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: use Net::SMTP
Message-Id: <3AB5AD9A.ABCA7089@courrier.usherb.ca>
Thanks Garry.
I'm in over my head. I'm just looking for a simple way with Perl to send
email from a <form>. use Net::SMTP has been a bust so far. Any suggestions
for perl on a windows box?
I have tried Tod Sambar's mailit.exe,
http://www.sambar.com/syshelp/mailit.htm
But to be frank mailit will not work because it uses temporary files.
I'm running Perl on a mini-server from a cd rom:
http://www.indigostar.com/microweb.htm and need to send data from a
<textarea> which can include \r\n Sambar's mailit.exe requires temp files. I
cannot on a cd :)
Here is Sambar's code, if someone can make $env{'body'} work without temp
files: http://home.fuse.net/OoTOAoO/Mailit.pl
I've looked at blat. It was a bust.
I would really appreciate email posts and replies. My nntp often loses
messages faster than I get back to read them.
John
------------------------------
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 525
**************************************