Permalink
Browse files

Add examples/ directory.

  • Loading branch information...
1 parent 666917c commit f0da650bc0cbe0b38ce3edc9dacace38436848ce @tupinek committed May 15, 2012
Showing with 260 additions and 0 deletions.
  1. +12 −0 MANIFEST
  2. +1 −0 META.yml
  3. +40 −0 examples/ex1.pl
  4. +21 −0 examples/ex10.pl
  5. +22 −0 examples/ex11.pl
  6. +20 −0 examples/ex12.pl
  7. +20 −0 examples/ex2.pl
  8. +15 −0 examples/ex3.pl
  9. +15 −0 examples/ex4.pl
  10. +15 −0 examples/ex5.pl
  11. +15 −0 examples/ex6.pl
  12. +14 −0 examples/ex7.pl
  13. +24 −0 examples/ex8.pl
  14. +26 −0 examples/ex9.pl
View
@@ -1,4 +1,16 @@
CHANGES
+examples/ex1.pl
+examples/ex10.pl
+examples/ex11.pl
+examples/ex12.pl
+examples/ex2.pl
+examples/ex3.pl
+examples/ex4.pl
+examples/ex5.pl
+examples/ex6.pl
+examples/ex7.pl
+examples/ex8.pl
+examples/ex9.pl
inc/Module/Install.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
View
@@ -21,6 +21,7 @@ meta-spec:
name: Indent
no_index:
directory:
+ - examples
- inc
- t
requires:
View
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent;
+
+# Indent object.
+my $indent = Indent->new(
+
+ # Begin indent.
+ 'indent' => '->',
+
+ # Next indent.
+ 'next_indent' => "->"
+);
+
+# Print example.
+print $indent->get;
+print "Example\n";
+
+# Add indent and print ok.
+$indent->add;
+print $indent->get;
+print "Ok\n";
+
+# Remove indent and print nex example.
+$indent->remove;
+print $indent->get;
+print "Example2\n";
+
+# Reset.
+$indent->reset;
+
+# Output:
+# ->Example
+# ->->Ok
+# ->Example2
View
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Data;
+
+# Indent::Data object.
+my $i = Indent::Data->new(
+ 'line_size' => '10',
+ 'next_indent' => ' ',
+ 'output_separator' => "|\n",
+);
+
+# Print indented text.
+print $i->indent('text text text text text text', '<->', 1)."|\n";
+
+# Output:
+# <->text text text text text text|
View
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Block;
+
+# Object.
+my $i = Indent::Block->new(
+ 'line_size' => 2,
+ 'next_indent' => '',
+);
+
+# Print in scalar context.
+print $i->indent(['text', 'text', 'text'])."\n";
+
+# Output:
+# text
+# text
+# text
View
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Word;
+
+# Object.
+my $i = Indent::Word->new(
+ 'line_size' => 20,
+);
+
+# Indent.
+print $i->indent(join(' ', ('text') x 7))."\n";
+
+# Output:
+# text text text text
+# <--tab->text text text
View
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::String;
+
+# Object.
+my $i = Indent::String->new(
+ 'line_size' => 20,
+);
+
+# Indent.
+print $i->indent(join(' ', ('text') x 7))."\n";
+
+# Output:
+# text text text text
+# <--tab->text text text
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Utils qw(reduce_duplicit_ws);
+
+my $input = 'a b';
+reduce_duplicit_ws(\$input);
+print "$input|\n";
+
+# Output:
+# a b|
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Utils qw(remove_first_ws);
+
+my $input = ' a';
+remove_first_ws(\$input);
+print "$input|\n";
+
+# Output:
+# a|
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Utils qw(remove_last_ws);
+
+my $input = 'a ';
+remove_last_ws(\$input);
+print "$input|\n";
+
+# Output:
+# a|
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Utils qw(remove_ws);
+
+my $input = ' a ';
+remove_ws(\$input);
+print "$input|\n";
+
+# Output:
+# a|
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Utils qw(string_len);
+
+# Print string length.
+print string_len("\tab\t")."\n";
+
+# Output:
+# 18
View
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Data;
+
+# Indent::Data object.
+my $i = Indent::Data->new(
+ 'line_size' => '10',
+ 'next_indent' => ' ',
+ 'output_separator' => "|\n",
+);
+
+# Print indented text.
+print $i->indent('text text text text text text')."|\n";
+
+# Output:
+# text text |
+# text tex|
+# t text t|
+# ext|
View
@@ -0,0 +1,26 @@
+#!/usr/bin/env perl
+
+# Pragmas.
+use strict;
+use warnings;
+
+# Modules.
+use Indent::Data;
+
+# Indent::Data object.
+my $i = Indent::Data->new(
+ 'line_size' => '10',
+ 'next_indent' => ' ',
+ 'output_separator' => "|\n",
+);
+
+# Print indented text.
+print $i->indent('text text text text text text', '<->')."|\n";
+
+# Output:
+# <->text te|
+# <-> xt te|
+# <-> xt te|
+# <-> xt te|
+# <-> xt te|
+# <-> xt|

0 comments on commit f0da650

Please sign in to comment.