Daily Shaarli

All links of one day in a single page.

September 15, 2020

Note: loading lines to array from file or list
# 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