summaryrefslogtreecommitdiff
path: root/020/ch1.pl
blob: 0240d6a743c0c86a9d8c849c7b9cc577016fc0de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env perl
#
# Write a script to accept a string from command line and split it on change of
# character. For example, if the string is “ABBCDEEF”, then it should split like
# “A”, “BB”, “C”, “D”, “EE”, “F”.
################################################################################

use strict;
use warnings;

my $str = shift;

my @chunks;
push @chunks, $1 while $str =~ /((.)\2*)/g;
print "@chunks\n";