Skip to content

Instantly share code, notes, and snippets.

@shalk
Created June 19, 2013 07:07
Show Gist options
  • Save shalk/5812214 to your computer and use it in GitHub Desktop.
Save shalk/5812214 to your computer and use it in GitHub Desktop.
a perl print problem
#./test.pl 2 4 5 8 12
# *
# *
# *
# *
# **
# **
# **
# ***
# ****
# ****
# *****
# *****
use 5.010;
use strict;
use warnings;
my @a = @ARGV;
unshift @a,0;
my @b =reverse map { $a[$_]-$a[$_-1] } 1..$#a ;
my $len = $ARGV[-1];
my $string ;
foreach my $t (@b)
{
$string .= '*';
next if $t == 0;
my $line = ' 'x($len - length $string );
print $line. $string ,"\n" for 1..$t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment