#!/usr/bin/perl

# Idiom #267 Pass string to argument that can be of any type
# https://p...content-available-to-author-only...s.org/idiom/267/pass-string-to-argument-that-can-be-of-any-type

use v5.10;

use Scalar::Util 'looks_like_number';

sub foo {
    my ($x) = @_;
    return 'Nothing' if ref $x ne '' or looks_like_number($x);   
    # return 'x is a reference' if ref $x ne '';   
    # return 'x looks like a number' if looks_like_number($x);   
    # return 'x is a string';
    return $x;
}

say foo( [] );
say foo( 42 );
say foo( 'Hello World' );
