Last active
December 26, 2015 08:39
-
-
Save hernan604/7123681 to your computer and use it in GitHub Desktop.
quick perl code generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#quick perl code generator, im pretty sure mst mentioned this tip, so here it is | |
use strict; | |
use warnings; | |
use IO::All; | |
use Encode qw/decode encode/; | |
use v5.10; | |
use Path::Class; | |
my $config = { | |
site => "perldelux", | |
domain => "perldelux.com.br", | |
base_path => "/home/hernan/perl/", | |
img_logo => "http://perldelux.com.br/logo.png", | |
}; | |
##Create my base path if does not exists | |
io->dir( $config->{ base_path } )->mkpath; | |
##Creates a file named: filename1.htm with the following content | |
io->file( file( $config->{ base_path } ,'filename1.htm' ) )->print(<<END); | |
<ul> | |
<li class="imagem"> | |
<a href="$config->{ domain }"> | |
<img src="$config->{ img_logo }" alt="$config->{ site }" title="$config->{ site }" /> | |
</a> | |
</li> | |
</ul> | |
END | |
##Creates another file, however this time write everything in utf8, but saves the file as iso-8859-1 | |
io->file( file( $config->{ base_path } ,'filename2.htm' ) )->print( encode( "iso-8859-1", decode( "utf8" , <<END ) ) ); | |
this file is saved as iso-8859-1 but was converted from utf8 input | |
bla bla bla bla bla lalalala | |
some accents: ãéíóú | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment