1611 shaares
17 private links
17 private links
1 result
tagged
chomp
# Loading from __DATA__
my @hosts = <DATA>;
chomp @hosts;
# => ["coucou.com", "coco.com", "cici.com", "chichi.com", "cucu.com", "cece.com" ]
__DATA__
coucou.com
coco.com
cici.com
chichi.com
cucu.com
cece.com
# Loading from file ./hosts
use Mojo::File;
my $file = Mojo::File->new('hosts');
my @hosts = grep { $_ ne '' } grep { $_ !~ m/^#/ } split '\n', $file->slurp;
# => ["coucou.com", "coco.com", "cici.com", "chichi.com", "cucu.com", "cece.com" ]
# ./hosts
# Deals with comments and blank lines
coucou.com
coco.com
# More hosts
cici.com
chichi.com
cucu.com
cece.com