Date: Mon, 10 Sep 2001 14:08:50 -0500 From: Michael Carman Subject: Re: Probelm with undefined atgumnets Message-Id: <3B9D0FC2.1E061C9E@home.com> Stan Brown wrote: > > A kind member of this group showed me a neat trick to print out the > arguments to a given function. It goes like this: > > join ', ', map { "Arg$_ ->$_[$_]<-" } 0 .. $#_; > > This works great _except_ when I pass in undef for an argumentm then > I get a warning about concatenating an unitliazed variable. > > How can I improve thsi to allow for this case? Two options: Disable warnings for just that block: { local $^W; print join ', ', map { "Arg$_ ->$_[$_]<-" } 0 .. $#_; } Or catch the undef and map it into something else: print join ', ', map {defined($_[$_]) ? "Arg$_ ->$_[$_]<-" : "Arg$_ ->*UNDEF*<-" } 0 .. $#_; -mjc