Package: perltidy
Version: 20090616-1
Severity: minor

Hi Don

I have a small sample.pl showing the problem, running perltidy on it,
causes the hash to 'de-align':

---(sample.pl)--------------------------------------------------------
#!/usr/bin/perl

use 5.010;
use feature "switch";

my $self;

open( FH, '<', '/tmp/foo.txt' ) or die "Cannot open file: $!\n";
while ( my $line = <FH> ) {
    given ($line) {
        when (/^#/) {
            $self = {
                what => 'comment',
                help => 'help',
            };
        }
        when (/^foo/) {
            $self = {
                what => 'foo',
                help => 'bar',
            };
        }
    }
}
----------------------------------------------------------------------

Now running 'perltidy -pbp' on sample.pl, causes following output:
---(output)-----------------------------------------------------------
#!/usr/bin/perl

use 5.010;
use feature "switch";

my $self;

open( FH, '<', '/tmp/foo.txt' ) or die "Cannot open file: $!\n";
while ( my $line = <FH> ) {
    given ($line) {
        when (/^#/) {
            $self = {
                what     => 'comment',
                    help => 'help',
            };
        }
        when (/^foo/) {
            $self = {
                what     => 'foo',
                    help => 'bar',
            };
        }
    }
}
----------------------------------------------------------------------

The diff now shows the problem (I evne had an example where a
semicolon was added, but I need to find first a smaller example to
reproduce that.
---(diff)-------------------------------------------------------------
--- sample.pl   2010-01-08 20:26:50.000000000 +0100                             
                           
+++ sample.perltidyfied 2010-01-08 20:27:22.000000000 +0100
@@ -10,14 +10,14 @@
     given ($line) {
         when (/^#/) {
             $self = {
-                what => 'comment',
-                help => 'help',
+                what     => 'comment',
+                    help => 'help',
             };
         }
         when (/^foo/) {
             $self = {
-                what => 'foo',
-                help => 'bar',
+                what     => 'foo',
+                    help => 'bar',
             };
         }
     }
----------------------------------------------------------------------

Many thanks in case for looking into it,
Bests
Salvatore

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages perltidy depends on:
ii  perl                          5.10.1-8   Larry Wall's Practical Extraction 

perltidy recommends no packages.

perltidy suggests no packages.

-- no debconf information
#!/usr/bin/perl

use 5.010;
use feature "switch";

my $self;

open( FH, '<', '/tmp/foo.txt' ) or die "Cannot open file: $!\n";
while ( my $line = <FH> ) {
    given ($line) {
        when (/^#/) {
            $self = {
                what => 'comment',
                help => 'help',
            };
        }
        when (/^foo/) {
            $self = {
                what => 'foo',
                help => 'bar',
            };
        }
    }
}

Reply via email to