[15847] in Perl-Users-Digest
Perl-Users Digest, Issue: 3260 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 5 21:10:40 2000
Date: Mon, 5 Jun 2000 18:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960253817-v9-i3260@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 5 Jun 2000 Volume: 9 Number: 3260
Today's topics:
Problem with oracle cursors kudaravalliraghuram@my-deja.com
Re: Problem with oracle cursors <makarand_kulkarni@My-Deja.com>
Re: Problem with oracle cursors <makarand_kulkarni@My-Deja.com>
Re: problem with parsing data!! <makarand_kulkarni@My-Deja.com>
Re: RegExp Help, I Think (Tad McClellan)
Re: s?printf and format output feature <lr@hpl.hp.com>
Re: Still a little puzzled (Was Re: Globbing with Activ (Tad McClellan)
Stupid Question: scripts won't recognize opening line <mauddib@hotmail.com>
Re: Stupid Question: scripts won't recognize opening li <tony_curtis32@yahoo.com>
Re: Stupid Question: scripts won't recognize opening li <lauren_smith13@hotmail.com>
Re: time/date calculation <lr@hpl.hp.com>
Re: Transposing classification numbers in SGML file (Tad McClellan)
Re: use DBI <atrus@atrustrivalie.eu.org>
Re: use DBI <red_orc@my-deja.com>
Re: use DBI <atrus@atrustrivalie.eu.org>
Re: use DBI beer_girl@bigfoot.com
Re: use DBI <makarand_kulkarni@My-Deja.com>
Re: use DBI <red_orc@my-deja.com>
Re: use DBI beer_girl@bigfoot.com
use strict <bitman2@my-deja.com>
Re: use strict (Neil Kandalgaonkar)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 05 Jun 2000 22:55:26 GMT
From: kudaravalliraghuram@my-deja.com
Subject: Problem with oracle cursors
Message-Id: <8hhb4o$qc0$1@nnrp1.deja.com>
Hi,
I am getting following error
"Can't call method "bind_param" without a package or object reference
at test3.pl line 22."
while running following code.
#!/opt/gnu/bin/perl
use Oraperl;
use Getopt::Std;
use DBI;
use DBD::Oracle qw(:ora_types);
$BUSCOL_DB = test;
$BUSCOL_USER = testdb;
$BUSCOL_PASS = testdb;
$ermis_conn = &ora_login( "$BUSCOL_DB", "$BUSCOL_USER", "$BUSCOL_PASS")
|| die "Login Error", $ora_errstr;
$sth1 = $conn->prepare(q{
BEGIN OPEN :cursor FOR
SELECT table_name, tablespace_name
FROM user_tables WHERE tablespace_name = :space
END;
});
$sth1->bind_param(":space", "USERS"); my $sth2;
$sth1->bind_param_inout(":cursor", \$sth2, 0, { ora_type => ORA_RSET }
);
$sth1->execute(); # $sth2 is now a valid DBI statement handle for the
cursor
while ( @row = $sth2->fetchrow_array ) {
print "I am comming";
}
Please let me know if any one knows about this problem.
Thanks in advance,
Raghuram Kudaravalli.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 05 Jun 2000 16:26:07 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Problem with oracle cursors
Message-Id: <393C370F.A4A5467F@My-Deja.com>
> use Oraperl;
^^^^^^^^^^^
as you are sticking to the DBI api Oraperl usage is not required.
> $sth1->execute(); # $sth2 is now a valid DBI statement handle for the
> cursor
> while ( @row = $sth2->fetchrow_array ) {
> print "I am comming";
> }
>
I don't see anything by name $sth2 in this program. However, you are
trying to fetch rows from it!
------------------------------
Date: Mon, 05 Jun 2000 16:33:21 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Problem with oracle cursors
Message-Id: <393C38C1.8DFDEE6B@My-Deja.com>
> use Oraperl;
you are not using Oraperl API in your program.
Hence no use for it.
add error handling in your program by wrapping inside eval ()
eg (skeletal)
eval {
my $func = $dbh->prepare(q{
BEGIN ...
END;
});
$func->bind_param() ;
$func->execute;
$dbh->commit;
};
if( $@ ) {
warn "Execution of stored procedure failed: $DBI::errstr\n";
$dbh->rollback;
}
$dbh->disconnect;
also I am feeling that you are assuming that the
Oracle cursor and the cursors returned from prepare or
prepare_cached are equivalent. They may not be. It may
not be possible to call execute on the sth2 like you
are trying to do.
------------------------------
Date: Mon, 05 Jun 2000 15:44:07 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: problem with parsing data!!
Message-Id: <393C2D37.D5D63043@My-Deja.com>
> I tried following code to parse data submitted through a form, but it
> doesn't work.doesn't give errrors but doesn't do
> anygood either. can anybody point out what's the problem???
time to move to CGI.pm.
--
------------------------------
Date: Mon, 5 Jun 2000 07:43:27 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: RegExp Help, I Think
Message-Id: <slrn8jn83f.oo.tadmc@maxim.metronet.com>
On Sun, 04 Jun 2000 22:08:30 -0600, scott thomason
<scott@industrial-linux.org> wrote:
>..or
"or" implies an alternative.
An alternative to _what_?
Please quote the text that you referring to...
>you could just do this:
>$path =~ /\\(.*?)$/;
>my $file = $1;
You should _never ever_ do that!
The dollar-digit variables are set only on a _successful_
pattern match, so you should never use them unless you have
first checked to see if the match succeeded or not:
my $file = $1 if $path =~ /\\(.*?)$/;
That fails if there are no backslashes.
It fails on Unix.
It fails on Mac.
>...or maybe:
>my @chunk = split(/\\/, $path);
^^^^^^
>my $file = $chunk[$#chunk];
Why introduce a temporary variable?
It is just one more opportunity to introduce errors.
Just get the last list item via a list slice:
my $file = (split(/\\/, $path))[-1];
>...seems like importing a module would be a bit much for what you need.
Seems like importing a module will work correctly and be portable.
Something that most folks want...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 5 Jun 2000 15:04:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: s?printf and format output feature
Message-Id: <MPG.13a5c3c78208775698ab23@nntp.hpl.hp.com>
In article <8hg1av$1f2e$1@is.inar.ru> on 5 Jun 2000 11:01:51 GMT,
Michael Kichanov <mike@mix.nordlink.ru> says...
> Please explain how to fix this floating point rounding feature
> while using sprintf,printf and format (.##) output:
> sprintf("%.2f", 1.555) == 1.55 (should be 1.56)
> sprintf("%.2f", 0.555) == 0.56 (everything here is correct)
>
> by growing precission to 20 we got
> sprintf("%.20f", 1.555) == 1.55499999999999993783
> that explains everything.
Yes, it does. The internal representatin of the value that you 'think'
is 1.555 is less than that, so it rounds down.
> How to resolve this problem?
What problem?
> I did it this way:
> $f = 1.555;
> $f = sprintf("%.3f", $f) * 1000;
> $f = $f%10 >= 5 ? (int($f/10)+1)/100 : int($f/10)/100;
> $f_rounded = sprintf("%.2f", $f); # == 1.56
>
> Does a better solution exist?
Sure it does.
$f = 1.555;
$f_rounded = 1.56;
Before you dismiss my method as flippant, you should ask yourself what
problem you are trying to solve? How did the floating-point variable
that you 'think' has the value 1.555 get that way? What was it
calculated from? What makes you think the result 'should be 1.56',
while the result of rounding a number that *approximates* 0.555 is
'correct' if you get 0.56?
If you are trying to solve a serious problem here, use integer units of
1000 times your current units, then round on output.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 5 Jun 2000 18:18:49 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Still a little puzzled (Was Re: Globbing with ActivePerl)
Message-Id: <slrn8jodap.107.tadmc@maxim.metronet.com>
On Mon, 5 Jun 2000 21:28:59 +0800, Swee Heng <sweeheng@usa.net> wrote:
>Swee Heng <sweeheng@usa.net> wrote in message
>news:8hg76k$quk$1@mawar.singnet.com.sg...
>> > while ( <> ) {
>> > print "Scanning file $ARGV ...\n";
>>
>> What is $ARGV doing there? @ARGV has nothing to do with $ARGV.
>I started with later versions of Perl and does
>not know about the $ARGV variable in older versions.
There is no old/new version difference re $ARGV.
It has worked find for years. It works fine today.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 05 Jun 2000 16:49:58 -0700
From: Charles Petersen <mauddib@hotmail.com>
Subject: Stupid Question: scripts won't recognize opening line
Message-Id: <393C3CA3.E020F3FD@hotmail.com>
Ok, there is probably a very simple solution to this, but I can't seem
to solve it.
I'm running perl on Redhat 6..2. I have one script that works just
fine, it's debugged and I start it by simply typing
./simulation.pl
it then executes and works fine.
I have another script which works fine when i type "perl test.pl" but
doesn't work when i type
./test.pl
the permissions are chmod 755 and the permissions are the same as the
previous. the opening line is:
#!/usr/bin/perl -w
the error it gives me is:
bash: ./index.pl: No such file or directory
suggestions?
Charles Petersen
------------------------------
Date: 05 Jun 2000 18:52:22 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Stupid Question: scripts won't recognize opening line
Message-Id: <8766rnptxl.fsf@limey.hpcc.uh.edu>
>> On Mon, 05 Jun 2000 16:49:58 -0700,
>> Charles Petersen <mauddib@hotmail.com> said:
> ./test.pl
> bash: ./index.pl: No such file or directory
test.pl or index.pl ?
Can't give much help if you don't post the real error
messages.
Is perl really in /usr/bin/perl on your system? What does
"which perl" say?
--
"Trying is the first step towards failure"
Homer Simpson
------------------------------
Date: Mon, 5 Jun 2000 17:00:23 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Stupid Question: scripts won't recognize opening line
Message-Id: <8hhf18$8hn$1@brokaw.wa.com>
Charles Petersen <mauddib@hotmail.com> wrote in message
news:393C3CA3.E020F3FD@hotmail.com...
>
> I have another script which works fine when i type "perl test.pl" but
> doesn't work when i type
>
> ./test.pl
>
> the permissions are chmod 755 and the permissions are the same as the
> previous. the opening line is:
>
> #!/usr/bin/perl -w
>
> the error it gives me is:
>
> bash: ./index.pl: No such file or directory
>
> suggestions?
Maybe you are typing 'index.pl' instead of 'test.pl'?
Lauren
------------------------------
Date: Mon, 5 Jun 2000 15:38:22 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: time/date calculation
Message-Id: <MPG.13a5cbbb55b01a1398ab24@nntp.hpl.hp.com>
In article <8hgra9$an5$1@solti3.sdm.de> on 5 Jun 2000 18:25:13 GMT,
Steffen Beyer <sb@muccpu1.muc.sdm.de> says...
> In article <393BE8A7.FFB5CA9B@skynet.be>, carex <bachelart.pierre@skynet.be> wrote:
>
> > I have to add 2 min to a date/time value
> > eg. 06/03/2000 23h56 + 2min = 06/03/2000 23h58
> > 06/03/2000 23h58 + 2min = 06/04/2000 00h00
> > 06/30/2000 23h58 + 2min = 07/01/2000 00h00
> > and so on.
>
> > Which perl module is the best suited for this task ?
>
> You might want to take a look at Date::Calc at
> http://www.perl.com/CPAN/modules/by-module/Date/Date-Calc-4.3.tar.gz
Serious overkill whenever the date parses into components trivially.
> There are probably also solutions involving the built-in function
> "localtime()" (see "man perlfunc"), but people in this newsgroup
> tend to disagree whether these solutions do or do not handle
> daylight savings time and/or leap seconds correctly. ;-)
>
> Maybe you should ask Larry Rosler about the correct answer, he
> seems to know. :-)
To avoid Summer Time problems, use timegm and gmtime. (But timelocal
and locatime would work too, because they each know about the
corrections.)
To avoid leap-seconds problems, ignore them. They don't exist in the
Unix epoch time scale.
> Note that there are other Date modules around (e.g. like Date::Manip)
> which might suit you also. Have a look!
Time::Local, which is part of the standard perl distribution.
#!/usr/local/bin/perl -w
use strict;
use Time::Local;
while (<DATA>) {
my ($mon, $day, $year, $hour, $min) = split /\D+/;
(undef, $min, $hour, $day, $mon, $year) =
gmtime 2 * 60 + timegm 0, $min, $hour, $day, $mon - 1, $year;
printf "%.2d/%.2d/%.2d %.2dh%.2d\n",
$mon + 1, $day, $year + 1900, $hour, $min;
# Or replace the above four lines by:
# use POSIX 'strftime';
# print strftime "%m/%d/%Y %Hh%M\n",
# gmtime 2 * 60 + timegm 0, $min, $hour, $day, $mon - 1, $year;
}
__END__
06/03/2000 23h56
06/03/2000 23h58
06/30/2000 23h58
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 5 Jun 2000 10:56:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Transposing classification numbers in SGML file
Message-Id: <slrn8jnjd3.oo.tadmc@maxim.metronet.com>
On Mon, 05 Jun 2000 03:22:01 GMT, Jim Main <j.main2@sympatico.ca> wrote:
>I have to write a program that searches an SGML file for an element
>containing a three-level classification number in the form:
>
>uc Roman.Arabic.lc Roman
You have not really given enough information.
Pattern matching is very dependent on the string that you are
matching against, and you haven't shown us what your data looks
like.
So we can only give you an approximate answer:
/([IVX]+\.\d+\.[ivx]+)/ # add more Roman chars as needed
If the SGML is not controlled by you, then you really ought to
be parsing it rather than pattern matching:
<!--
II.2.ii not really a string to replace...
-->
>The program then maps the old number to a new classification scheme in
>the same form. For example,
>
>II.13.iii becomes I.5.i
my %xref;
$xref{'II\.13\.iii'} = quotemeta('I.5.i'); # make an entry in the xref hash
or
$xref{"\QII.13.iii"} = "\QI.5.i"; # escape regex metacharacters
>The new number is then inserted into the SGML document in a new
>element.
See the Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
>Does anyone have any suggestions about how to map the old number to
>the new, generally speaking?
Use a hash to map old to new.
Make a big old pattern to match all of the keys:
my $key_pattern = join '|', reverse sort keys %xref;
...
s/($key_pattern)/$xref{$1}/go; # replace with new value from xref
See also the Perl FAQ, part 6:
"How do I efficiently match many regular expressions at once?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 05 Jun 2000 15:04:38 -0700
From: Yann Ramin <atrus@atrustrivalie.eu.org>
Subject: Re: use DBI
Message-Id: <393C23F6.ECA99E2@atrustrivalie.eu.org>
1. You're sure you are running it through perl not sh? Is there a magic
line in the file?
#!/usr/bin/perl -w
2. I see you are missing a ' on the other end of the connect call. It
should be:
$db = DBI->connect("DBI:mysql:DatabaseName, $dbusername");
Yann
beer_girl@bigfoot.com wrote:
>
> I wrote a perl script that accesses mySQL and the script is executed
> through a web browser (and it works great). Now I need to run it from
> the command line and I get all kinds of syntax errors. Some of them
> are:
>
> here's the code:
>
> use DBI;
> ($db) = DBI->connect('DBI:mysql:DatabaseName, $dbusername);
>
> here's the corresponding errors:
> syntax error in file ParseEmail.cgi at line 66, next 2 tokens "use DBI"
> syntax error in file ParseEmail.cgi at line 82, next 2 tokens "->"
>
> All this works just great if it's run through a web browser. What's
> going on?!?
>
> It's running on FreeBSD using Perl5
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
--------------------------------------------------------------------
Yann Ramin atrus@atrustrivalie.eu.org
Atrus Trivalie Productions www.atrustrivalie.eu.org
irm.it.montereyhigh.com
Monterey High IT www.montereyhigh.com
ICQ 46805627
AIM oddatrus
Marina, CA
"All cats die. Socrates is dead. Therefore Socrates is a cat."
- The Logician
# fortune
"To be responsive at this time, though I will simply say, and therefore
this is a repeat of what I said previously, that which I am unable to
offer in response is based on information available to make no such
statement."
--------------------------------------------------------------------
------------------------------
Date: Mon, 05 Jun 2000 22:41:11 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: use DBI
Message-Id: <8hhaa5$pku$1@nnrp1.deja.com>
In article <393C23F6.ECA99E2@atrustrivalie.eu.org>,
Yann Ramin <atrus@atrustrivalie.eu.org> wrote:
> 1. You're sure you are running it through perl not sh? Is there a
magic
> line in the file?
>
> #!/usr/bin/perl -w
>
> 2. I see you are missing a ' on the other end of the connect call. It
> should be:
> $db = DBI->connect("DBI:mysql:DatabaseName, $dbusername");
er,
$db = DBI->connect('DBI:mysql:DatabaseName', $dbusername): ??
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 05 Jun 2000 15:57:54 -0700
From: Yann Ramin <atrus@atrustrivalie.eu.org>
Subject: Re: use DBI
Message-Id: <393C3072.2E360CE3@atrustrivalie.eu.org>
I meant to say that
>
> er,
>
> $db = DBI->connect('DBI:mysql:DatabaseName', $dbusername): ??
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
--------------------------------------------------------------------
Yann Ramin atrus@atrustrivalie.eu.org
Atrus Trivalie Productions www.atrustrivalie.eu.org
irm.it.montereyhigh.com
Monterey High IT www.montereyhigh.com
ICQ 46805627
AIM oddatrus
Marina, CA
"All cats die. Socrates is dead. Therefore Socrates is a cat."
- The Logician
# fortune
"To be responsive at this time, though I will simply say, and therefore
this is a repeat of what I said previously, that which I am unable to
offer in response is based on information available to make no such
statement."
--------------------------------------------------------------------
------------------------------
Date: Mon, 05 Jun 2000 22:51:06 GMT
From: beer_girl@bigfoot.com
Subject: Re: use DBI
Message-Id: <8hhasm$q1t$1@nnrp1.deja.com>
With a colon on the end??
In my script it is
($db) = DBI->connect('DBI:mysql:Mydatabase', $dbusername);
This works if the script is called through a browser...
In article <8hhaa5$pku$1@nnrp1.deja.com>,
Rodney Engdahl <red_orc@my-deja.com> wrote:
> In article <393C23F6.ECA99E2@atrustrivalie.eu.org>,
> Yann Ramin <atrus@atrustrivalie.eu.org> wrote:
> > 1. You're sure you are running it through perl not sh? Is there a
> magic
> > line in the file?
> >
> > #!/usr/bin/perl -w
> >
> > 2. I see you are missing a ' on the other end of the connect call.
It
> > should be:
> > $db = DBI->connect("DBI:mysql:DatabaseName, $dbusername");
>
> er,
>
> $db = DBI->connect('DBI:mysql:DatabaseName', $dbusername): ??
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 05 Jun 2000 16:03:32 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: use DBI
Message-Id: <393C31C4.98650DD0@My-Deja.com>
>
> use DBI;
> ($db) = DBI->connect('DBI:mysql:DatabaseName, $dbusername);
^^^^^^^^
why ( $db) and not $db.
connect () returns a scalar and not an array.
also there is a ' missing.
--
------------------------------
Date: Mon, 05 Jun 2000 23:22:22 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: use DBI
Message-Id: <8hhcmu$rbv$1@nnrp1.deja.com>
In article <8hhasm$q1t$1@nnrp1.deja.com>,
beer_girl@bigfoot.com wrote:
> With a colon on the end??
colon was typo. should be semi-colon.
>
> In my script it is
>
> ($db) = DBI->connect('DBI:mysql:Mydatabase', $dbusername);
any reason for the parens around the $db?
>
> This works if the script is called through a browser...
>
> In article <8hhaa5$pku$1@nnrp1.deja.com>,
> Rodney Engdahl <red_orc@my-deja.com> wrote:
> > In article <393C23F6.ECA99E2@atrustrivalie.eu.org>,
> > Yann Ramin <atrus@atrustrivalie.eu.org> wrote:
> > > 1. You're sure you are running it through perl not sh?
> > > Is there a magic line in the file?
> > >
> > > #!/usr/bin/perl -w
> > >
This is still a good question.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 06 Jun 2000 00:19:34 GMT
From: beer_girl@bigfoot.com
Subject: Re: use DBI
Message-Id: <8hhg28$ts1$1@nnrp1.deja.com>
In article <393C31C4.98650DD0@My-Deja.com>,
Makarand Kulkarni <makarand_kulkarni@My-Deja.com> wrote:
> >
> > use DBI;
> > ($db) = DBI->connect('DBI:mysql:DatabaseName, $dbusername);
>
> ^^^^^^^^
> why ( $db) and not $db.
> connect () returns a scalar and not an array.
> also there is a ' missing.
> --
It makes no difference.
(The missing ' is a typo from when I copied the code here, it exists in
my real code)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 05 Jun 2000 23:21:29 GMT
From: Bit-Man <bitman2@my-deja.com>
Subject: use strict
Message-Id: <8hhcla$rbf$1@nnrp1.deja.com>
Hi all,
I'm working recently with Perl and discovered a strange behavior in
Perl 5.
When executed the next code, there's no complains, although $a and $b
are not defined. I interpreted that $a and $b are variables local to
each loop, so no explicit declaration was needed, but $c could be
interpreted in the same scenario, but it's declaration was needed.
Any clue ?
Am I missing something ?
---------------------- test.pl --------------------
#!/usr/bin/perl
use strict;
require triang.pl;
my $c;
for( $a=-10; $a <= 10; $a++ ) {
for( $b=-10; $b <= 10; $b++ ) {
for( $c=-10; $c <= 10; $c++ ) {
my $result = triangle( $a, $b, $c ), "\n";
print "$a $b $c $result\n";
}
}
}
---------------------- triang.pl --------------------
#!/usr/bin/perl
use strict;
sub triangle($$$) {
my @side = @_;
if ( ($side[0] <= 0) or ($side[1] <= 0) or ($side[2] <= 0) ) {
return "ERROR";
}
if ( ($side[0] + $side[1] < $side[2]) or
($side[2] + $side[1] < $side[0]) or
($side[2] + $side[0] < $side[1]) ) {
return "ERROR";
}
if ( $side[0] == $side[1] and $side[1] == $side[2] ) {
return "EQUILATERO";
}
if ( $side[0] != $side[1] and $side[1] != $side[2] and $side[0] !=
$side[2] ) {
return "ESCALENO";
}
return "ISOSCELES";
}
1;
---------------------- END OF FILES --------------------
Thanks in advance.
--
Victor A. Rodriguez (http://www.bit-man.com.ar)
El bit Fantasma (Bit-Man)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 5 Jun 2000 23:49:30 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: use strict
Message-Id: <8hheaa$kel$1@newsflash.concordia.ca>
In article <8hhcla$rbf$1@nnrp1.deja.com>, Bit-Man <bitman2@my-deja.com> wrote:
>When executed the next code, there's no complains, although $a and $b
>are not defined.
from man strict (or perldoc strict):
Because of their special use by sort(), the vari
ables $a and $b are exempted from this check.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
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 V9 Issue 3260
**************************************