#!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use html3; sub rndStr{ join'', @_[ map{ rand @_ } 1 .. shift ] } my $new_name = rndStr( 5, 'a'..'z', 1..9); my $ref_to_name = \$new_name; my $return_page = create_page($ref_to_name); say "page is $return_page"; email_link($return_page); sub email_link{ use strict; use 5.014; use Carp; use Net::SMTP; use config2; my $link = shift; my $sub_hash = "my_ftp"; my $host = $config{$sub_hash}->{'site'}; say "host is $host"; my $phone = $config{$sub_hash}->{'phone'}; say "phone is $phone"; if (exists $ENV{USER} && $ENV{USER}) { eval q^ use Net::SMTP; my $smtp = Net::SMTP->new(Host => $host, Debug => 2) or croak "Unable to connect to '$host'. $!"; $smtp->mail($ENV{USER}); $smtp->to($phone); $smtp->data(); $smtp->datasend("From: $ENV{USER}\n"); $smtp->datasend("Subject: This is your map link\n"); $smtp->datasend("\n"); $smtp->datasend($link); $smtp->dataend(); $smtp->quit(); ^; croak "Net::SMTP fatal error: $@" if $@; } else { say '$ENV{USER} does not exists or is not defined.'; } } __END__