Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

Re: returning values from a sub

by fauria (Deacon)
on Jan 06, 2005 at 14:57 UTC ( [id://420069]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to returning values from a sub

Hi!

Maybe this way is useful for you:

use strict; use Data::Dumper; sub getServices{ my $file = "/etc/services"; open SVCS, $file or die "Error opening $file: $!"; my $services; while( <SVCS> ){ my %hash; next if $_ =~ /^\#/ or $_ =~ /^\s/; my ($name, $port_proto) = split /\s+/, $_; my ($port, $proto) = split /\//, $port_proto; %hash = ( protocol => $proto, port => $port ); $services->{$name} = \%hash; } close SVCS; return $services; } my $returned = &getServices; print Dumper $returned; print "Protocol for service FTP: $returned->{ftp}->{protocol}\n";


Regards

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://420069]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.