breaking a long arithmetic statement into multiple line

S

Sean

say I have a long expression:

$abassd = ($abassd - $old_abassd) / 1000 * $time .... - $abassd;

I want to write it into multiple lines (for readability), but it seems
that
perl interpretter does not recognize it as C++ compiler does.

Sean
 
P

Paul Lalli

Sean said:
say I have a long expression:

$abassd = ($abassd - $old_abassd) / 1000 * $time .... - $abassd;

I want to write it into multiple lines (for readability), but it seems
that
perl interpretter does not recognize it as C++ compiler does.

Perl is not C++. Why are you expecting them to be interpreted/compiled
the same way?

Whitespace is irrelevant in Perl. You can put newlines (almost)
anywhere you want. How were you breaking up the code? How is it not
working the way you want?

Why not show exactly what you were doing, so we can show you how you're
doing it wrong?

Paul Lalli
 
T

Tad McClellan

Sean said:
say I have a long expression:

$abassd = ($abassd - $old_abassd) / 1000 * $time .... - $abassd;


the .... is not Perl, so I'll ignore everything after that.

I want to write it into multiple lines (for readability),


$abassd
=
(
$abassd
-
$old_abassd
)
/
1000
*
$time


You can write that expression in anywhere from 1 to 11 non-empty lines.

(15 lines if you also split after the sigils.)


Choose the number that you like best.
 
J

Jürgen Exner

Sean said:
say I have a long expression:

$abassd = ($abassd - $old_abassd) / 1000 * $time .... - $abassd;

I want to write it into multiple lines (for readability),

Nice idea. Why don't you do it?
that
perl interpretter does not recognize it as C++ compiler does.

Why would you expect them to be the same?
It would be a coincidence if Perl and C++ had the same behaviour.

jue
 
A

Ala Qumsieh

Tad said:
the .... is not Perl, so I'll ignore everything after that.






$abassd
=
(
$abassd
-
$old_abassd
)
/
1000
*
$time


You can write that expression in anywhere from 1 to 11 non-empty lines.

(15 lines if you also split after the sigils.)


Choose the number that you like best.

I can do better:

$
{
abassd
}

etc... 23 lines total :)

--Ala
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top