This is because perl doesn't know where your variablename ends and guesses the :: are part of it.
Change your print "$typ::$dat>>\n"; to print "${typ}::${dat}>>\n"; and it should work.
The {}'s are to explicitly tell perl which bit of the characters following $ are part of the variablename.
Edit:
Perls package system allows you to access, from your main program, global variables defined in such a package using $package::variablename.
This is why perl tries to interpret the :: and then complains :)