[12863] in Perl-Users-Digest
Perl-Users Digest, Issue: 273 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 27 17:07:17 1999
Date: Tue, 27 Jul 1999 14:05:19 -0700 (PDT)
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, 27 Jul 1999 Volume: 9 Number: 273
Today's topics:
Re: 3 dimensional array <gwynne@utkux.utk.edu>
Re: 3 dimensional array (Larry Rosler)
Re: Beginner-friendly group as cultural adaptation? <jbc@shell2.la.best.com>
Re: Beginner-friendly group as cultural adaptation? <dparrott@ford.com>
Re: Controlling page size/orientation in PS and PDFs <H.Blischke@srz-berlin.de>
Re: converting net address... <gemal@dk.net>
Re: converting net address... <jhi@alpha.hut.fi>
Re: Getting Height and Width of GIF/JPEG in PERL? <cassell@mail.cor.epa.gov>
Re: Help or possibly stupid syntax suggestion re: forea (Larry Rosler)
Re: How do I redirect STDERR to STDOUT in a system() on <cassell@mail.cor.epa.gov>
How to use a module <yli15@lucent.com>
Re: How to use a module <emschwar@rmi.net>
Re: Korn Shell or Perl? (Donn Cave)
Little Puzzle I can't solve . . . <lenny@avv.com>
Re: Little Puzzle I can't solve . . . <arnej@fc.hp.com>
module for Oracle? bing-du@tamu.edu
Re: module for Oracle? <yli15@lucent.com>
newby rename problem (help) <stoli@netzero.net>
Re: Open and Pipes (Tad McClellan)
Perl Anonymity Question (gulp!) <simsi@hotmail.com.nospam>
Re: platform independent perl advice <sklivvz@tiscalinet.it>
Re: POSIX module <sariq@texas.net>
Re: Simple form problem <jwbarry@ibm.net>
Re: stopping email overflow on failure <laurens@bsquare.com>
Re: Terminal Emulation with CGI Script? Please... <dparrott@ford.com>
Re: Using perl to ftp non interactively <davidk@netscape.com>
Re: Which group is appropriate? (I R A Darth Aggie)
Re: Which group is appropriate? (Larry Rosler)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Jul 1999 15:19:13 -0400
From: Robert Gwynne <gwynne@utkux.utk.edu>
Subject: Re: 3 dimensional array
Message-Id: <379E0631.E6E6D641@utkux.utk.edu>
See:
http://www.perl.com/pub/doc/manual/html/pod/perldsc.html
Bob
Arnabnil Bhattacharjee wrote:
> Hi !!
> I am a perl novice and need some urgent help. I need to create a 3
> dimensional array in perl 5 . constraints the ranges of the dimensions are
> not known ( but of course begin from 0 ) and the elements are not inserted
> in any kind of order. Could somebody write me some sample code please...
> Thanks,
> Arnab.
>
> --------------------------------------------------------------------------------
> Arnabnil Bhattacharjee 104 S. 40th. St. 3 Fr.
> Graduate Student CIS Philadelphia , PA - 19104
> 057A Moore,SEAS Ph: R - (215) 222 6526
> 200 South 33rd St. Univ. of Penn. O - (215) 898 8116
> Philadelphia - PA - 19104 L - (215) 898 8090
>
> Preferred Email: arnabnil@saul.cis.upenn.edu
>
> Web : http://www.seas.upenn.edu/~arnabnil/
>
> "Those are my principles. If you dont like them I have others"
> ----- Groucho Marx
> --------------------------------------------------------------------------------
------------------------------
Date: Tue, 27 Jul 1999 12:27:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 3 dimensional array
Message-Id: <MPG.1207a7e6781b344989d54@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <Pine.GSO.3.95.990727143135.7813A-100000@saul.cis.upenn.edu>
on Tue, 27 Jul 1999 14:33:47 -0400, Arnabnil Bhattacharjee
<arnabnil@saul.cis.upenn.edu> says...
> I am a perl novice and need some urgent help. I need to create a 3
> dimensional array in perl 5 . constraints the ranges of the dimensions are
> not known ( but of course begin from 0 ) and the elements are not inserted
> in any kind of order. Could somebody write me some sample code please...
Surely somebody could, but surely nobody should. Why not learn how to
do it yourself?
There are many examples in perllol and perldsc. And perlref supplies
some detail of the underpinnings. You may actually need to use hashes
instead of arrays, if 'the elements are not inserted in any kind of
order'.
Go and learn, 'Graduate Student CIS'!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 27 Jul 1999 20:20:14 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Beginner-friendly group as cultural adaptation?
Message-Id: <379e147e$0$218@nntp1.ba.best.com>
Larry Rosler <lr@hpl.hp.com> wrote:
> I would characterize c.l.p.moderated as a failure, as its goal relative
> to c.l.p.misc hasn't been met. I think c.l.p.newbies or whatever would
> be the same. The 'friendly troops' want to be where the action is --
> and where the other 'friendly troops' are.
In reflecting on this more, and considering the responses I've seen,
I've admitted to myself that you all are probably right, and that
c.l.p.novice (or whatever) would not succeed in solving the problems I
hoped for it to solve.
While I initially thought c.l.p.moderated was a failure, too, now I'm
not so sure. It certainly has the kind of traffic that the old-timers
here approve of, just not that much of it. It may just need time. One
scenario would be that as the newbie problem gets worse here, more of
the hard-core curmudgeons may end up going to the moderated group,
leading to reduced stress levels all around.
Or maybe not. Anyway, I'll shut up about creating a newbie group.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Tue, 27 Jul 1999 10:01:23 -0400
From: "Dennis M. Parrott" <dparrott@ford.com>
Subject: Re: Beginner-friendly group as cultural adaptation?
Message-Id: <379DBBB3.15EB0BB5@ford.com>
John Callender wrote:
>
> I realize that proposing a group specifically for Perl newbies is a
> dicey proposition. It runs the risk of raising political correctness
> hackles, and being opposed as representing creeping cultural
> relativism. Even if such land mines could be avoided, I doubt I'd be the
> best person to propose it, given the amount of negative karma I've
> probably accumulated in past clashes over the newbie issue.
rather than creating a specific 'newbies' group, maybe the way to
cut down the volume is to create a group dedicated to "web programming
and/or CGI using Perl...". It seems that the naive posters who get
the hardest noggin thumps are the ones who come draggin' their poor
bedraggled attempts at reasonable Perl CGI scripts.
I realize that comp.infosystems.www.authoring.cgi exists (and I don't
generally read it but had in the past) but maybe people want a group
that is particularly devoted to Perl & CGI...
just a thought.
--
-----------------------------------------------------------------------
Dennis M. Parrott | Unix: dparrott@ford.com
PCSE Webmaster | PROFS: DPARROTT
Ford Motor Company | VAX: EEE1::PARROTT
Dearborn, Michigan USA | public Internet: dparrott@ford.com
-----------------------------------------------------------------------
Voice: 313-322-4933 Fax: 313-248-1234 Pager: 313-851-2958
------------------------------
Date: Tue, 27 Jul 1999 21:13:58 +0200
From: Helge Blischke <H.Blischke@srz-berlin.de>
Subject: Re: Controlling page size/orientation in PS and PDFs
Message-Id: <379E04F6.7486@srz-berlin.de>
nichols@blarg.net wrote:
>
> I had the same problem that a person on the poscript newsgroup had:
>
> "Using ps2pdf, I converted serveral ps files to pdf, however when I view
> them in Acrobat the page orientation is wrong. Instead of Landscape
> mode, the reader defaults to portrait. Thus, the text is sideways. I
> have tried using distiller and distiller does it correctly. However,
> for my purposes I need to use ps2pdf. Does anyone have any ideas.
> Documentation on ps2pdf is terse. Is there, someway I could modify the
> pdf file? Adding a bytecodeor editing something? Something that would
> change the orientation."
>
> Does anyone have an existing perl script that will rotate a pdf or
> poscript landscape file so it will display properly (not sideways)?
> Or is there a parameter that can be used with the ps2pdf that makes this
> adjustmemt during the conversion?
>
> FYI: I tried the perl script that was listed on the Postscript
> newsgroup but it was broken. I also tried inserting the ps code (<<
> /PageSize [792 612] >> setpagedevice) into the ps file but there was no
> change after it was run thru ps2pdf again.
>
> Thanks for your help,
>
> Frankie
Try to insert the following PostScript code
---snip---
[{ThisPage} /Rotate 90 /PUT pdfmark
---snip---
on the first landscape page
and
---snip---
[{ThisPage} /Rotate 0 /PUT pdfmark
---snip---
on the first page that should be portrait again.
If gs digests the pdfmark correctly, that should work (I never used gs
to
produce PDF).
Let us know if it really works.
Helge
--
H.Blischke@srz-berlin.de
H.Blischke@srz-berlin.com
H.Blischke@acm.org
------------------------------
Date: Tue, 27 Jul 1999 22:26:52 +0200
From: Henrik Gemal <gemal@dk.net>
Subject: Re: converting net address...
Message-Id: <379E160C.9DFAE6F8@dk.net>
Actually after I looked at txt2html I came up with this:
$str =~ s/ftp:[\w\/\.:+\-~\%#?]+[\w\/]/<A HREF=\"$&\"
TARGET=\"_blank\">$&<\/A>/ig;
$str =~ s/http:[\w\/\.:+\-~\%#?]+[\w\/]/<A HREF=\"$&\"
TARGET=\"_blank\">$&<\/A>/ig;
$str =~ s/news:[\w\/\.:+\-~\%#?]+[\w\/]/<A HREF=\"$&\"
TARGET=\"_blank\">$&<\/A>/ig;
$str =~ s/([^\w\-\/\.:\@>])([a-zA-Z][\w+\-]+(\.[\w+\-]+)+\.[a-zA-Z]{2,})/$1<A
HREF=\"http:\/\/$2\">$2<\/A>/ig;
$str =~
s/([^\w\-\/\.:\@>])([a-zA-Z][\w\.+\-]+\.[a-zA-Z]{2,}):(\s*)([\w\d+\-\/\.]+)/$1<A
HREF=\"ftp:\/\/$2\/$4\">$2:$4<\/A>$3/ig;
$str =~ s/([^\w\-\/\.:\@])(\d{2,}\.\d{2,}\.\d+\.\d+):([\w\d+\-\/\.]+)/$1<A
HREF=\"ftp:\/\/$2\/$3\">$2:$3<\/A>/ig;
$str =~
s/(^|[^\w\d\-\/\.:!])(([a-zA-Z][\w+\-]*)?ftp[\w+\-]*\.[\w\.+\-]+\.[a-zA-Z]{2,})([^\w\d\-\/\.:!])/$1<A
HREF=\"ftp:\/\/$2\/" T
ARGET=\"_blank\">$2<\/A>$4/ig;
$str =~
s/(^|[^\w\d\-\/\.:!])(([a-zA-Z][\w+\-]*)?www[\w+\-]*\.[\w\.+\-]+\.[a-zA-Z]{2,})([^\w\d\-\/\.:!])/$1<A
HREF=\"http:\/\/$2\/\"
TARGET=\"_blank\">$2<\/A>$4/ig;
$str =~
s/(anonymous\@)([a-zA-Z][\w\.+\-]+\.[a-zA-Z]{2,}):(\s*)([\w\d+\-\/\.]+)/$1<A
HREF=\"ftp:\/\/$2\/$4\">$2:$4<\/A>$3/ig;
$str =~ s/(ftp\@)([a-zA-Z][\w\.+\-]+\.[a-zA-Z]{2,}):(\s*)([\w\d+\-\/\.]+)/$1<A
HREF=\"ftp:\/\/$2\/$4\">$2:$4<\/A>$3/ig;
$str =~ s/[a-zA-Z0-9_\+\-\.]+\@([a-zA-Z0-9][\w\.+\-]+\.[a-zA-Z]{2,})/<A
HREF=\"compose.cgi?to=$&\">$&<\/A>/ig;
$str =~ s/ftp ([a-zA-Z][\w+\-]+(\.[\w\.+\-]+)+\.[a-zA-Z]{2,})/ftp <A
HREF=\"ftp:\/\/$1\/">$1<\/A>/ig;
I the only thing I miss is to convert the following type of addresses:
www.gemal.dk/test
--
Henrik Gemal, gemal@dk.net
Network Innovator
Tele Danmark Internet
------------------------------
Date: 27 Jul 1999 23:56:30 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: converting net address...
Message-Id: <oee6735x14x.fsf@alpha.hut.fi>
Henrik Gemal <gemal@dk.net> writes:
> Actually after I looked at txt2html I came up with this:
> $str =~ s/ftp:[\w\/\.:+\-~\%#?]+[\w\/]/<A HREF=\"$&\"
> TARGET=\"_blank\">$&<\/A>/ig;
> $str =~ s/http:[\w\/\.:+\-~\%#?]+[\w\/]/<A HREF=\"$&\"
> TARGET=\"_blank\">$&<\/A>/ig;
> $str =~ s/news:[\w\/\.:+\-~\%#?]+[\w\/]/<A HREF=\"$&\"
> TARGET=\"_blank\">$&<\/A>/ig;
> $str =~ s/([^\w\-\/\.:\@>])([a-zA-Z][\w+\-]+(\.[\w+\-]+)+\.[a-zA-Z]{2,})/$1<A
> HREF=\"http:\/\/$2\">$2<\/A>/ig;
> $str =~
> s/([^\w\-\/\.:\@>])([a-zA-Z][\w\.+\-]+\.[a-zA-Z]{2,}):(\s*)([\w\d+\-\/\.]+)/$1<A
> HREF=\"ftp:\/\/$2\/$4\">$2:$4<\/A>$3/ig;
[etc]
Oh my. Please lie down and breathe slowly. It will pass.
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Tue, 27 Jul 1999 14:03:23 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Getting Height and Width of GIF/JPEG in PERL?
Message-Id: <379E1E9B.D356D1AD@mail.cor.epa.gov>
Wayne Venables wrote:
> [snip]
> I (the person who asked the orginal question) did do a search on
> CPAN for a module to do this. I just searched for "GIF JPEG" /
> "GIF JPG" (on the description) assuming that it would find any modules
> related to image processing. I don't know why it didn't find the
> Image::Size module.
>
> But since searching CPAN is a logical thing to do (even for a
> someone as unfamiliar with Perl as me - I've only been using it for
> about 3 months), it probably doesn't need a FAQ entry.
Wayne, let me just say good work. I'm not being a smart@$$ here.
You use Perl for 3 months and don't consider yourself a master
[we regularly get people here who have used it for a day].
You searched CPAN, and considered that a logical thing to do.
If more people did as you do, the volume on this newsgroup
would plummet, and Abigail would have to pick on me instead of
the clue-challenged visitors we see. Since most people with
problems like yours don't seem to think of CPAN, questions like
this end up in the FAQ. You probably noticed that there are
a few FAQ answers which are little more than a 'go to CPAN and
get the Glarb::Bralg module, which does this for you'. If you
don't believe me, look up this FAQ:
"How can I output Roman numerals?"
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 27 Jul 1999 12:18:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help or possibly stupid syntax suggestion re: foreach
Message-Id: <MPG.1207a5d2c2f42f9d989d53@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7nkta3$kbv$1@watserv3.uwaterloo.ca> on 27 Jul 1999 18:20:51
GMT, Adrian Pepper <arpepper@math.uwaterloo.ca> says...
> If what you want to do is:
>
> foreach ($a,$b) (@list) {
> ...
> }
>
> must you instead do something like?
>
> @temp = @list;
> while (@temp) {
> $a = shift @temp;
> $b = shift @temp;
> ...
> }
>
> Is there an elegant way to do it instead?
If I understand what you are after, a slightly more compact way of doing
that is:
my ($a, $b) = splice @temp, 0, 2;
If you want to avoid copying the original array, then:
for (my $i = 0; $i < @list; $i += 2) {
my ($a, $b) = @list[$i, $i + 1];
...
}
I'll let you worry about an array with an odd number of elements.
Or, relying on order of evaluation (as I was brought up *not* to):
for (my $i = 0; $i < @list; ) {
my ($a, $b) = @list[$i++, $i++];
...
}
'Elegance' is in the eye of the beholder.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 27 Jul 1999 13:55:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How do I redirect STDERR to STDOUT in a system() on WinNT?
Message-Id: <379E1CA5.891AB6E0@mail.cor.epa.gov>
Armin Faltl wrote:
>
> Hi!
>
> My problem is to find an equivalent to
>
> @out = qx(some_prog 2>&1);
>
> or
>
> system(some_prog >>$::Log 2>&1);
>
> on Windows NT 4.0 and I use command.com as command interpreter.
>
> I use ActivPerl build 509, and tried to read the FAQ
> on the subject of redirecting STDERR to STDOUT (and both to a file),
> but I found only UNIX answers.
>
> If this question has been answered before, pleas hint
> me to a search engine of the newsgroup (do it anyway!).
Let's see... You used qx// when you were supposed to. You
read the FAQ. You're interested in searching for answers
instead of being spoon-fed. Welcome! Glad to have you here.
This is a bit of a problem if you really need to send
everything through command.com or cmd.com, as they just
don't cut it as shells. But there are alternatives.
You'll probably want to read Tom Christiansen's
"FMTEYEWTK about open() but were afraid to ask", which is
also known as 'perlopentut' IIRC. This is available at
www.perl.com , as well as in the archives of this group
at deja.com . If you go to deja.com , look for a post
by Tom Christiansen with the Subject line starting with
"FMTEYEWTK", and it was posted early May I think.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 27 Jul 1999 14:43:56 -0400
From: Yvonne Li <yli15@lucent.com>
Subject: How to use a module
Message-Id: <379DFDEC.730E9BB3@lucent.com>
Forgive me asking this stupid question. I am very new to perl and trying to
write a program which will login to a gateway and telnet to another machine. An
expert told me to use module ::telnet to do this job, but how do I put it in my
code. I mean there is no doc on CPAN telling me how to use a module. Do I need
download the module first and then what?
Can any one give me an example? Is there any other way to do the relogin and
telnet except using modules?
Many many thanks to your help.
Yvonne
------------------------------
Date: 27 Jul 1999 14:35:14 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: How to use a module
Message-Id: <xkfu2qpltkt.fsf@valdemar.col.hp.com>
Yvonne Li <yli15@lucent.com> writes:
> An expert told me to use module ::telnet to do this job,
That would be Net::Telnet, most likely. I haven't heard of this
'::telnet' module before.
> but how do I put it in my code.
use Net::Telnet;
> I mean there is no doc on CPAN telling me how to use a module. Do I need
> download the module first and then what?
There's a README for the module on CPAN that explains what you have to do
to install it. It's in the same directory as the module itself.
> Can any one give me an example? Is there any other way to do the relogin and
> telnet except using modules?
No; you can do it yourself by directly manipulating sockets and reading
and writing to them as appropriate. But I really wouldn't recommend you
trying.
-=Eric
------------------------------
Date: 27 Jul 1999 19:28:47 GMT
From: donn@u.washington.edu (Donn Cave)
Subject: Re: Korn Shell or Perl?
Message-Id: <7nl19f$13ss$1@nntp6.u.washington.edu>
damercer@mmm.com (Dan Mercer) writes:
| In article <x7wvvmu9n7.fsf@home.sysarch.com>,
| Uri Guttman <uri@sysarch.com> writes:
|> this is more a demonstration of the inefficiency of your programming
|> skills. this can't be done easily in shell but it is trivial in perl if
|> you think correctly. as this is not spec'ed fully my code may not work
|> but it will give you an idea of how to do it. and STOP with the do{}
|> blocks. very rarely are they needed and you seem to think they are the
|> only way to do things in perl.
|>
| [[ DELETED ]]
|>
|>
|> if ( $opt_d ne 'all' ) {
|>
|> @yp_data = split(/,\s*/, $opt_d);
|> }
|> else {
|>
|> foreach $source ( split( /,/, $opt_b) ) {
|>
|> push( @yp_data, keys %::beeper_byname ) && next
|> if $source eq 'local'
|>
|> if ( $source eq 'yp' ) {
|>
|> @beepers = `ypcat -k beeper.byname` ;
|> push( @yp_data, map( /(\w+)/, @beepers ) ) ;
|> }
|> }
|> }
|>
|> foreach $yp ( @yp_data ) {
|>
|> next if $yp =~ /^YP_/ ;
|>
|> ($k, @devnull)=get_pin("0", "1", "0", $opt_b, $j);
|> $exit_status+=$k;
|> }
|>
|>
|> now isn't that simpler and clearer than the crap you wrote below. and NO
|> do blocks are needed. STOP THAT HABIT NOW!!!!
|>
|> uri
|
|
| I think the above helps to make one thing clear in this discussion
| and that is a shell script will be fairly clear to anyone familiar
| with a command line interface and the Unix utilities. A Perl script
| will be clear only to someone who knows Perl. So deciding on which
| to use, Perl or shell, will determine who has to support it in the
| future.
Point taken. ``now isn't that simpler and clearer'', he says, and
the scary thing is that he's probably right. I learned a little
Perl years ago, but I don't follow this. What's with the "if $source
eq 'local'"? Does it go with something?
Another thing that seems to be going on here - I've seen a couple of
these ``why can't Perl do this'' articles from the original poster,
and it seems to me that he feels he needs parallel filter threads,
because a serial processing model would gag on the bulk. This is
something that can be done with the utmost ease on UNIX, using the
shell, and for practical purposes it's the only way to do it. The
same solution can be engineered in Perl, C, Python or what have you,
using pipe() and fork(), but the shell does it easier and better.
This is not a defect of Perl, just a fact of life. It can also be
done as a single process with multiple threads, but at considerable
engineering expense. Many programming problems don't require this
parallelism, and some require features the shell lacks or supports
in an awkward way. There's no reasonable answer to the generic question.
But I agree, when solving problems that are at all suited to the shell,
it's important to remember that to some approximation everyone knows it.
Donn Cave, University Computing Services, University of Washington
donn@u.washington.edu
------------------------------
Date: Tue, 27 Jul 1999 15:40:03 -0400
From: Chris Lentz <lenny@avv.com>
Subject: Little Puzzle I can't solve . . .
Message-Id: <379E0B13.F31F2423@avv.com>
Can't seem to figure out why this is happening.
Basic question: why doesn't the "if" statement evaluate to true when the
variable begins with a zero?
Any answers would be greatly appreciated:
Here's the code:
---------------------------begin code-----------------------------------
print "FIRST TRY WITH (0,17) as the string\n";
local(@vin);
$vin[0] = "0,17";
print "HERE'S THE VALUE OUTSIDE THE IF:(", $vin[0], ")\n";
if ( $vin[0] != "") {
print "HERE'S THE VALUE INSIDE IN IF 1:(", $vin[0], ")\n";
}
print "\n\n\nNOW TRY WITH (1,17) as the string\n";
local(@vin);
$vin[0] = "1,17";
print "HERE'S THE VALUE OUTSIDE THE IF:(", $vin[0], ")\n";
if ( $vin[0] != "") {
print "HERE'S THE VALUE INSIDE IN IF 2:(", $vin[0], ")\n";
}
print "WHY THE DIFFERENCE?\n";
print "\n\n\nNEXT TRY WITH (0,17) as the string and a variable instead of an arr
ay\n";
local($vin);
$vin = "0,17";
print "HERE'S THE VALUE OUTSIDE THE IF:(", $vin, ")\n";
if ( $vin != "") {
print "HERE'S THE VALUE INSIDE IN IF 3:(", $vin, ")\n";
}
-----------------------------end code-----------------------------------
Here's the output:
----------------------------begin output--------------------------------
FIRST TRY WITH (0,17) as the string
HERE'S THE VALUE OUTSIDE THE IF:(0,17)
NOW TRY WITH (1,17) as the string
HERE'S THE VALUE OUTSIDE THE IF:(1,17)
HERE'S THE VALUE INSIDE IN IF 2:(1,17)
WHY THE DIFFERENCE?
NEXT TRY WITH (0,17) as the string and a variable instead of an array
HERE'S THE VALUE OUTSIDE THE IF:(0,17)
------------------------------end output--------------------------------
Thanks in advance. Emails would be appreciated.
--
************************
* Christopher J. Lentz *
* AVV Inc. *
* lenny@avv.com *
* 614-487-1436 *
* 614-487-1955 (Fax) *
* http://www.avv.com/ *
************************
------------------------------
Date: Tue, 27 Jul 1999 14:18:03 -0600
From: Arne Jamtgaard <arnej@fc.hp.com>
Subject: Re: Little Puzzle I can't solve . . .
Message-Id: <379E13FB.5AE3@fc.hp.com>
Chris Lentz wrote:
> Can't seem to figure out why this is happening.
> Basic question: why doesn't the "if" statement evaluate to true
> when the variable begins with a zero?
>
> Any answers would be greatly appreciated:
Chris-
The trick is that perl has two sets of comparison operators -
one for numbers and one for strings. You're using the numeric ones
on strings. Perl sees ("0,17" != "") and says "Aha! Two numbers."
and converts the "0,17" to 0 and the "" to 0, so the test fails.
Check out "ne" in the perl docs.
Arne
------------------------------
Date: Tue, 27 Jul 1999 19:55:18 GMT
From: bing-du@tamu.edu
Subject: module for Oracle?
Message-Id: <7nl2r2$kpv$1@nnrp1.deja.com>
Hello there,
I am using Perl 5.005_02. In this version, is there any
embedded standard module that can be used to access Oracle database?
What is the name of the module? Thanks.
Bing
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 27 Jul 1999 16:00:23 -0400
From: Yvonne Li <yli15@lucent.com>
Subject: Re: module for Oracle?
Message-Id: <379E0FD7.1404BCE5@lucent.com>
There is a module called DBD and a DBI Oracle. You should install both to access
Oracle. You can find them at
http://www.iru.missouri.edu/perldbi/dbiinstall.html
Good luck
bing-du@tamu.edu wrote:
>
> Hello there,
>
> I am using Perl 5.005_02. In this version, is there any
> embedded standard module that can be used to access Oracle database?
> What is the name of the module? Thanks.
>
> Bing
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: Tue, 27 Jul 1999 07:31:48 -0800
From: stoli <stoli@netzero.net>
Subject: newby rename problem (help)
Message-Id: <933089512.26802@www.remarq.com>
I am needing to rename a file that has been uploaded using
a script, however, I keep getting internal server errors.
the filename that has been uploaded is stored as the
variable %cgi_cfn{'upload'} which
contains "c:\windows\desktop\file.exe"
the file is renamed on the server (someone else wrote this
script) and the name is stored as %cgi_sfn{'upload'} which
contains "/home/username/upload/upload.12343.3"
I need to retain the orignal name form the users computer
(file.exe) but every iteration of rename gives me errors..
please help
stoli
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 27 Jul 1999 10:07:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Open and Pipes
Message-Id: <7eekn7.gml.ln@magna.metronet.com>
adougall@netscape.net wrote:
: In the following bits of code, my modified version of Register 1.2
: fails.
What is Register 1.2?
: My problem is that I am not sure what it does.
My problem is that I am not sure what "it" your "it" above is :-)
Do you mean "what the open() call does"?
: Can someone
: explain it to me?
I think the Standard Docs for open() do that, but let's repeat
it here for the too lazy.
: $htpasswd ="htpasswd.pl";
: # Call htpasswd.pl and encrypt the password then enter username and
: # password into passfile
: # What is this doing?
: open(HTPASSWD, "|$htpasswd $passfile $contents{'username'} >/dev/null
: 2>&1");
Connects the filehandle 'HTPASSWD' to the STDINput of the
program named in $htpasswd.
Provides 2 command line arguments for the program named in $htpasswd.
Redirects output from the program named in $htpasswd
to the bit bucket (discards all output).
: How does it write to the password file?
"it" doesn't write to the password file.
The program 'htpasswd.pl' writes to the password file (I guess.
Can't really say because you haven't shown the code for htpasswd.pl.)
: print HTPASSWD "$contents{'password'}\n";
Write some stuff to the STDIN of the htpasswd.pl program.
The code never checks for the success or failure of the program
named in the $htpasswd variable.
That is a Very Bad Thing.
See Perl FAQ, part 8:
"Why doesn't open() return an error when a pipe open fails?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 27 Jul 1999 20:22:37 +0100
From: "Simmo" <simsi@hotmail.com.nospam>
Subject: Perl Anonymity Question (gulp!)
Message-Id: <oFnn3.84$uO1.7590@news.enterprise.net>
Hi,
Ok, i know this group can be a bit, ahem, *sensitive* to issues of anonymity
but it's a straight up project i'm doing where i have been asked by an
organisation if i can increase traffic to a site over a short but defined
period to effectively stress test the build, but due to politics (I'm
agency, webmaster/configurator isn't), i need to change the IP address/host
of the Perl script calling the headers each visit.....is there a way to do
this with Perl?
If you think this is "Can of Worms" time, you can email me direct if you
prefer.
Thanks (tentatively) and in anticipation
Ian
simsi@hotmail.com
------------------------------
Date: Tue, 27 Jul 1999 21:50:31 +0200
From: "Marco Cecconi" <sklivvz@tiscalinet.it>
Subject: Re: platform independent perl advice
Message-Id: <7nl2ka$s03$1@aquila.tiscalinet.it>
>1) How and what do ya need for crossplatform perl cgi.
Perl is meant to be x-platform, and it is, except for a few "minor"
glitches.
The first that spring to mind are:
-Are you using file locking (flock())? It is not available on Windows.
-What about process spawning (fork())? It is not available on Windows,
either.
-What about some system calls like `ls -lR` have to be changed to `dir /s`
and also may imply changes in the source code.
-Is your progam sending mail through sendmail? You'll need to change that,
possibly with a solution using Socket for platform independance.
>2) are the CPAN modules available
AFAIK 99% of the CPAN modules work on both platforms, of course you'll need
to
compile them... Be warned that some features might be disabled on Windows...
Cheers
Marco Cecconi
Inferentia S.p.A.
perl -e 'use Standard::Disclaimer;'
------------------------------
Date: Tue, 27 Jul 1999 14:35:14 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: POSIX module
Message-Id: <379E09F2.71B25A1C@texas.net>
Tim Cull wrote:
>
> > For a module called 'Module::Foo', all you need to do is:
> >
> > man Module::Foo
> >
> > Amazing, isn't?
> >
>
> Yes, thank you for stating the obvious.
> Does anyone have any more constructive advice, like a URL for a web site
> that lists the contents of modules, ideally in a searchable format?
>
> --Tim Cull
Calm the heck down...the answers Tom and Abigail gave were perfectly
reasonable.
If you must try a web page, perhaps:
http://theory.uwinnipeg.ca/CPAN/
will be of some help.
- Tom
------------------------------
Date: Tue, 27 Jul 1999 16:21:05 -0400
From: The Barry Family <jwbarry@ibm.net>
Subject: Re: Simple form problem
Message-Id: <379E14B1.7AEBE13A@ibm.net>
I copied the code from a tutorial at
http://www.speakeasy.org/~cgires/cgi-tour.html directly to a test file
on my web page.
here is the code for that:
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
&ReadParse;
print "<title>The Response</title><h1>The Response</h1><hr>";
print "Here is the form data:<ul>";
foreach $key (keys %in) {
print "<li>$key: $in{$key}";
}
print "</ul>";
print "and here are all the environment variables:<ul>";
foreach $key (keys %ENV) {
print "<li>$key: $ENV{$key}";
}
print "</ul>";
# Adapted from cgi-lib.pl by S.E.Brenner@bioc.cam.ac.uk
# Copyright 1994 Steven E. Brenner
sub ReadParse {
local (*in) = @_ if @_;
local ($i, $key, $val);
if ( $ENV{'REQUEST_METHOD'} eq "GET" ) {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
} else {
# Added for command line debugging
# Supply name/value form data as a command line argument
# Format: name1=value1\&name2=value2\&...
# (need to escape & for shell)
# Find the first argument that's not a switch (-)
$in = ( grep( !/^-/, @ARGV )) [0];
$in =~ s/\\&/&/g;
}
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
$in[$i] =~ s/\+/ /g;
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val;
}
return length($in);
}
And I had a form executing it with this code:
<FORM ACTION="test.cgi" METHOD=POST>
<INPUT TYPE="text" NAME="testtext" SIZE=26 MAXLENGTH=100 >
<SELECT NAME="testselect">
<OPTION selected>A
<OPTION> B
<OPTION> C
</SELECT>
<INPUT TYPE="submit" VALUE="Submit">
<INPUT TYPE="reset" VALUE="Reset">
</FORM>
When I filled in the form and pressed submit, it listed all the
enviromental variables fine, but it didn't show anything for the
variables from the form. Does anyone know what the problem with this
could be?
Mike
------------------------------
Date: Tue, 27 Jul 1999 12:26:09 -0700
From: "Lauren Smith" <laurens@bsquare.com>
Subject: Re: stopping email overflow on failure
Message-Id: <7nl14u$6od$1@brokaw.wa.com>
Steve . wrote in message <379cd3c9.286008804@news.enteract.com>...
>On 26 Jul 1999 16:04:34 -0500, abigail@delanet.com (Abigail) wrote:
>>Well, you could put two big aquaria in the server room. Put a goldfish
>>in the right one. If the program finds a problem, it first looks where
>>the goldfish is; if it's in the right aquarium, it sends out a message,
>>and puts the goldfish in the left aquarium. If the goldfish is already
>>in the left aquarium, doesn't do anything else anymore.
>>
>>If there's no problem to be found, it also checks where the goldfish is.
>>If it's in the left aquarium, it puts the goldfish back in the right
>>aquarium.
>>
>Whatever you looser. And I say looser cause you have no clue what you
>are talking about and just wrote a page of crap. Get a life.
Give a man a fish and he will eat for a day.
Teach a man how to fish and he will get mad and likely call you names.
Lauren
------------------------------
Date: Tue, 27 Jul 1999 10:06:25 -0400
From: "Dennis M. Parrott" <dparrott@ford.com>
To: Tyler Arrigoni <tarrigoni@arrigoni.com>
Subject: Re: Terminal Emulation with CGI Script? Please...
Message-Id: <379DBCE1.1AB48421@ford.com>
Tyler Arrigoni wrote:
>
> Hello,
>
> My company owns two CalComp Laser plotters that each require a "terminal" be
> connected to control various operating parameters. Presently, I control
> them with a single linux box's ttyS0 and ttyS1 ports using minicom at
> 9600-8-n-1/VT100. I can then telnet into the box from anywhere and change
> settings on the plotter...What I would like to do is let the drafters do
> this via their web browsers.
I'd take a real hard look at the Telnet:: module. A book that would be
helpful, _Web Client Programming with Perl_ by Clinton Wong, O'Rielly.
Building such stuff into a CGI wouldn't be awfully hard, the only
problem would be making sure that only one person was dorking around
with the device at a time...
Sounds like a fun project... Want to contract it out?
>
> Question: How do I read and write from/to a serial device requiring the
> above emulation?
>
> Most of the plotters operations are controlled by single commands with no
> prompts from the plotter unless there is an error in syntax. So...I am
> imagining a couple rows of submit buttons and a few pulldown boxes for "roll
> a"/"roll b" scenarios. Simple enough if I could figure out the IO method.
> Also, there are a few commands issued at the plotter command line that makes
> the plotter print the plot queue status every 10 secs. Would server push
> into a dedicated html frame work here? How?
>
> Any help would be greatly appreciated...I don't know where to start with
> this IO type...
>
> Thanks,
>
> Tyler M. Arrigoni, VP Arrigoni & Associates, Inc.
> Network Design & Integration Consulting Electrical Engineers
>
> tarrigoni@n-o-s-p-a-m.arrigoni.com
> (Remove "n-o-s-p-a-m" from above address)
--
-----------------------------------------------------------------------
Dennis M. Parrott | Unix: dparrott@ford.com
PCSE Webmaster | PROFS: DPARROTT
Ford Motor Company | VAX: EEE1::PARROTT
Dearborn, Michigan USA | public Internet: dparrott@ford.com
-----------------------------------------------------------------------
Voice: 313-322-4933 Fax: 313-248-1234 Pager: 313-851-2958
------------------------------
Date: Tue, 27 Jul 1999 13:21:00 -0700
From: dave keefer <davidk@netscape.com>
To: Keith <keithcp@yahoo.com>
Subject: Re: Using perl to ftp non interactively
Message-Id: <379E14AC.D9C63CF3@netscape.com>
try using the Net::FTP module from CPAN . I have used this across 9 different
platforms.
d.
Keith wrote:
> Can anyone tell me if there is a way to use ftp in a perl script.
> I believe that I might need to use a Here Document type of syntax but am not
> positive.
> Any help would be appreciated.
> Thanks.
------------------------------
Date: 27 Jul 1999 19:35:11 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Which group is appropriate?
Message-Id: <slrn7ps2jj.c49.fl_aggie@thepentagon.com>
On 27 Jul 1999 18:26:42 GMT, John Callender <jbc@shell2.la.best.com>, in
<379df9e2$0$218@nntp1.ba.best.com> wrote:
+ I R A Darth Aggie <fl_aggie@thepentagon.com> wrote:
+
+ > It took several cases of open() jumping up and biting me on the butt
+ > (by not opening) before I got the idea that maybe 'open() or die $!'
+ > was a better way to do things. It is now habit.
+ Thus you demonstrate the value of giving newbies an opportunity to make
+ their own mistakes - so they can learn from them, just as you did. This
+ is why natural languages let you do useful work with babytalk:
One could make the argument that perl's open() is broken, and it should
halt with an error message, ala c/c++/fortran, warp the local time-space
continuum and chide you until you fix it.
But it doesn't and that's good because then it gives you freedom to
do things these other languages would not, could not, do. But as with
every freedom, there comes a responsibility.
I can also see why a newbie would be exasperated by perl's behaviour.
+ if every
+ toddler who said, "Dada, ball?" was greeted with a blank stare and
+ "Syntax error, son. There's no verb in that sentence," how many people
+ do you think would ever learn English? Probably about the same
+ proportion as learned to program using traditional programming
+ languages: a few percent of the general population, if that.
That explains the relative few who learn a foreign (human) language,
and almost none bother to learn English as a second language.
+ Perl's easygoing attitude towards babytalk represents an evolutionary
+ step *forward* for computer languages.
And this obviates the necessity of learning about the rather rich
document set _how_? in your opinion, do you think that the typical
newbie questions are answered in the existing documents?
+ done in the process, and ascending (ever so slowly) up the same
+ learning curve that led you to where you are today.
At least I had a Pink Llama to guide my initial steps.
+ about it here. Sure, you can spend your energy herding them into line,
+ but it's a bit like herding cats -- and every time you get one of these
+ cats trained two more untrained cats appear.
So, the answer isn't to train them at all, eh?
+ Maybe the newbie group isn't the solution. But without *some* new
+ approach, I don't see any way that things aren't going to continue to
+ worsen.
And that approach is?
I see things a bit differently. I see the newbie flood peaking
evenutally, then plateauing, and eventually reaching a managable
equilibrium. And for every 'trained cat' we get, that's one more set
of hands to help train the next wave of newbies. To paraphrase JC:
newbies will always be with you.
However, if these new comers to perl are bound and determined to get
spoonfed, I can always offer them my rate card. Alternatively,
someone can offer them the Global Perl Killfile, and then they could
ignore all the Usual Suspects.
James - but likely you'd have to teach 'em how to use the killfile...
------------------------------
Date: Tue, 27 Jul 1999 13:28:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Which group is appropriate?
Message-Id: <MPG.1207b639594fff19989d55@nntp.hpl.hp.com>
In article <slrn7ps2jj.c49.fl_aggie@thepentagon.com> on 27 Jul 1999
19:35:11 GMT, I R A Darth Aggie <fl_aggie@thepentagon.com> says...
...
> One could make the argument that perl's open() is broken, and it should
> halt with an error message, ala c/c++/fortran, warp the local time-space
> continuum and chide you until you fix it.
I won't comment on the B&D characteristics of the other two languages,
but the swipe at C is unwarranted. C's fopen() behaves like Perl's
open(). You can use the null pointer returned on failure just as well
or as poorly as you can use Perl's unopened filehandle. The results may
indeed be more spectacular, though. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 273
*************************************