The line my ($all_info) = shift(@_) assumes you are passing what you want to go into $all_info to C58MASTP, like C58MASTP("my_all_info").
You don't show us how you call C58MASTP, so I don't know what's going wrong. Perhaps you should print "all_info: $all_info X_Y: $X_Y X_NUM: $X_NUM\n"; before your select and make sure all is as you think.