use constant HAS_LWP => eval "require LWP::UserAgent"; ...; update_cache() if HAS_LWP; my $data = read_cache();