#!/usr/bin/perl -w use strict; my ($user,$pass) = get_secret(); do_something($user,$pass) if ($user) && ($pass); sub do_something { my ($user,$pass) = @_; print "USER: $user\nPASS: $pass\n\n"; } sub get_secret { my $config = $ENV{'HOME'} . '/.passwd3'; if (-e $config) { my ($pass,$user); my $perms = (stat ($config))[2] & 07777; die "ERROR: File permissions not 700.\n" unless $perms == 0700; open INP, $config or die "ERROR: Couldn't open file: $!\n"; chomp ($user = ); chomp ($pass = ); close(INP); return($user,$pass); }else{ die "ERROR: No config file.\n"; } }