Help me beef up my cruddy program

D

Dan Jacobson

Help me beef up my cruddy program. It should then even run on Microsoft,
by the way.

#!/usr/bin/perl -ws
#use strict; #can't use due to -s.
$, = "\t";
$\ = "\n";
my $A = 0.00001549;
my $B = 0.000006521;
my $C = 807.8;
my $D = 248.6;
if ( $I ) {
foreach my $i ( $A, $B, $C, $D ) { $i = -$i }
}
while (<>) {
my @F = split;
print $F[0] - $C - $A * $F[0] - $B * $F[1],
$F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
}
 
U

Uri Guttman

DJ> Help me beef up my cruddy program. It should then even run on Microsoft,
DJ> by the way.

DJ> #!/usr/bin/perl -ws
DJ> #use strict; #can't use due to -s.

wrong. use vars or our can fix that.

DJ> $, = "\t";
DJ> $\ = "\n";
DJ> my $A = 0.00001549;
DJ> my $B = 0.000006521;
DJ> my $C = 807.8;
DJ> my $D = 248.6;
DJ> if ( $I ) {
DJ> foreach my $i ( $A, $B, $C, $D ) { $i = -$i }
DJ> }
DJ> while (<>) {
DJ> my @F = split;
DJ> print $F[0] - $C - $A * $F[0] - $B * $F[1],
DJ> $F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
DJ> }

if you picked better var names and decribed what this is supposed to do,
someone might help. i won't waste my time on the above.

uri
 
U

Uri Guttman

DJ> Help me beef up my cruddy program. It should then even run on Microsoft,
DJ> by the way.

DJ> #!/usr/bin/perl -ws
DJ> #use strict; #can't use due to -s.

wrong. use vars or our can fix that.

DJ> $, = "\t";
DJ> $\ = "\n";
DJ> my $A = 0.00001549;
DJ> my $B = 0.000006521;
DJ> my $C = 807.8;
DJ> my $D = 248.6;
DJ> if ( $I ) {
DJ> foreach my $i ( $A, $B, $C, $D ) { $i = -$i }
DJ> }
DJ> while (<>) {
DJ> my @F = split;
DJ> print $F[0] - $C - $A * $F[0] - $B * $F[1],
DJ> $F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
DJ> }

if you picked better var names and decribed what this is supposed to do,
someone might help. i won't waste my time on the above.

uri
 
J

Jürgen Exner

Dan said:
Help me beef up my cruddy program. It should then even run on
Microsoft, by the way.

#!/usr/bin/perl -ws
#use strict; #can't use due to -s.
$, = "\t";
$\ = "\n";

What is this supposed to do?
my $A = 0.00001549;
my $B = 0.000006521;
my $C = 807.8;
my $D = 248.6;

By convention people use upper case variables for file descriptions only.
if ( $I ) {
foreach my $i ( $A, $B, $C, $D ) { $i = -$i }
}

Why the condition? The body will never be executed because $I will never be
true.
Didn't perl warn you about undefined value?
while (<>) {
my @F = split;
print $F[0] - $C - $A * $F[0] - $B * $F[1],
$F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
}

And what is this supposed to do versus what does it do?
You naming convention is ---shall we say--- suboptimal?

jue
 
U

Uri Guttman

JE> Why the condition? The body will never be executed because $I will
JE> never be true. Didn't perl warn you about undefined value?

conditional tests don't warn on undef. and his comment on strict and -s
tells me he was passing -I on the command line and -s would then set $I
which would negate the 4 values.
while (<>) {
my @F = split;
print $F[0] - $C - $A * $F[0] - $B * $F[1],
$F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
}

JE> And what is this supposed to do versus what does it do?
JE> You naming convention is ---shall we say--- suboptimal?

and he still hasn't responded so i guess a hit and run troll. notice his
other post which made some useless comment on sub locations.

uri
 
T

Tassilo v. Parseval

Also sprach Uri Guttman:
while (<>) {
my @F = split;
print $F[0] - $C - $A * $F[0] - $B * $F[1],
$F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
}

JE> And what is this supposed to do versus what does it do?
JE> You naming convention is ---shall we say--- suboptimal?

and he still hasn't responded so i guess a hit and run troll. notice his
other post which made some useless comment on sub locations.

It was a question about where to place subroutine-definitions. Looking
at other languages (where the place of the definition could matter; for
Perl it even does matter when using prototypes), it wasn't quite so
useless.

Tassilo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top