#!/usr/bin/perl use strict; use warnings; sub func { my $context = wantarray; print "VOID" if not defined $context; return "SCALAR" if defined $context && !$context; return "LIST" if $context; } print "Context is: "; func (); print "\n"; print "Context is: ". func (); print "\n"; print "Context is: ", func (); print "\n"; __END__ Context is: VOID Context is: SCALAR Context is: LIST
Abigail
In reply to Re: context-sensitivity for selfwritten functions
by Abigail-II
in thread context-sensitivity for selfwritten functions
by tos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |