Here's another answer:
use strict;
use warnings;
use 5.020;
use autodie;
use Data::Dumper;
my $infile = 'rand.txt';
my $outfile = 'newrand.txt';
Here's another answer:
use strict;
use warnings;
use 5.020;
use autodie;
use Data::Dumper;
my $infile = 'rand.txt';
my $outfile = 'newrand.txt';
New example. I used a \t (tab) to separate the new column from the old text, but you can use whatever you want.
use strict;
use warnings;
use 5.020;
use autodie;
use Data::Dumper;
my @new_column = (
| func(X) -> | |
| CanProceed = (X =:= 2) or log_value(X), | |
| if | |
| CanProceed =:= true -> 10; | |
| CanProceed =:= false -> 20 | |
| end. | |
| log_value(X) -> | |
| io:format("The value of X was: ~w~n", [X]), | |
| false. %Will never determine the ultimate value of the boolean expression |
| data.txt: | |
| ------------------------------ | |
| <h1>1</h1> <!-- Level One --> | |
| <h4>1.1</h4> <!-- Level Two --> | |
| <div class='x'>1.1.1</div> <!-- Level Three --> | |
| <div class='x'>1.1.2</div> | |
| <div class='x'>1.1.3</div> | |
| <div class='x'>1.1.4</div> | |
| <h4>1.2</h4> | |
| <div class='x'>1.2.1</div> |