Long line in perl script

S

Subra

Hi ,

I have very long line in perl script. I need to break it into
multiple lines. Some thing like below.

Present Code :-

if ($settings->{$service_name}-
{'pin_home_dir'} || $settings->{$service_type}->{'pin_home_dir'}) {

New code should be:
if ($settings-
{$service_name}->{'pin_home_dir'} ||

$settings->{$service_type}->{'pin_home_dir'}) {


Is there any special character like in C (\) which I should put at the
end of the broken line ????

As this script is suppose to run in many platforms so this info is
very imp for me.

thanks,
Subra...
 
G

Gunnar Hjalmarsson

Subra said:
I have very long line in perl script. I need to break it into
multiple lines. Some thing like below.

Present Code :-

if ($settings->{$service_name}-

New code should be:
if ($settings-

$settings->{$service_type}->{'pin_home_dir'}) {

Looks weird to me. How about:

if (
$settings->{$service_name}->{'pin_home_dir'}
||
$settings->{$service_type}->{'pin_home_dir'}
) {
Is there any special character like in C (\) which I should put at the
end of the broken line ????

No.
 
R

rthangam

Looks weird to me. How about:

if (
$settings->{$service_name}->{'pin_home_dir'}
||
$settings->{$service_type}->{'pin_home_dir'}
) {


No.

Did you using perl beautify ?
 
C

ccc31807

Hi ,

I have very long line in perl script. I need to break it into
multiple lines. Some thing like below.

Present Code :-

if ($settings->{$service_name}-


New code should be:
if ($settings-


$settings->{$service_type}->{'pin_home_dir'}) {

my ($test1, $test2);
$test1 = $settings->{$service_name}->{'pin_home_dir'};
$test2 = $settings->{$service_type}->{'pin_home_dir'};
if ($test1 or $test2)
{
#your code here
}

CC
 
C

comp.llang.perl.moderated

What's that? Anyway, I didn't use any such thing.

s/perl beautify/perltidy/ perhaps ... ?

eg, perltidy output:

if ( $settings->{$service_name}->{'pin_home_dir'}
|| $settings->{$service_type}->{'pin_home_dir'} )
{
 
J

Jürgen Exner

Petr Vileta said:
Subra wrote:
You can wrap line at any space in your long line. Example:

That is true. And even more than that: you can even place a line break
everywhere where you _could_ place a space, because Perl is a free format
language and all white spaces are treated the same.

jue
 
J

John W. Krahn

Petr said:
You can wrap line at any space in your long line. Example:

if ($settings->{$service_name}->{'pin_home_dir'} ||
$settings->{$service_type}->{'pin_home_dir'}) {

It doesn't even have to be at a space:

$ perl -MData::Dumper -le'$w->{x}->{y}->{z} = "hello"; print Dumper $w'
$VAR1 = {
'x' => {
'y' => {
'z' => 'hello'
}
}
};

$ perl -MData::Dumper -le'
$w
->
{x}
->
{y}
->
{z}
=
"hello";
print Dumper $w'
$VAR1 = {
'x' => {
'y' => {
'z' => 'hello'
}
}
};


John
 
S

Subra

Yes, of course, but wrapping line at space (or tab) is better readable for
human and for perl novice too ;-)
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to <petr AT practisoft DOT cz>

Thanks one and all for making it clear....
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top