in reply to Re^2: how to get alias name of anonymous sub?
in thread how to get alias name of anonymous sub?

That sounds like a task for AUTOLOAD. Consider:

use strict; use warnings; package news; my %news_sites = ( bbc => 'www.bbc.com', voanews => 'www.voanews.com', #more websites# ); sub new { ... } sub AUTOLOAD { my ($base, $site) = $news::AUTOLOAD =~ /::(\w+)_(\w+)/; return '' if $base ne 'get_from' || ! exists $news_sites{$site}; my $res = "got from $news_sites{$site}\n"; # or appropriate proces +sing return $res; } package main; print news::get_from_bbc();

Prints:

got from www.bbc.com
True laziness is hard work