In Perl you usually use modules that abstract away such things. From the ftok manual page it looks like you're dealing with System V message queues. If that's the case, maybe take a look at IPC::Msg or other ipc modules.
Comment on Re^3: Key for message queue creation...