panaman has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I would like to include a sound file with a program I am writing. Is ther some way that I can have the .wav file after the __DATA__ token? I have tried a few things that have not worked. To start Komodo will not read .wav files, it does not like the null character. So I used and editor that simply appeneded the .wav file to my code right after the DATA token. What I tried to do was read the DATA (94 k) and then write out a .wav file. It does it but the wav file I write is only 1k and will not play. I hope this is clear enough to understand. What I want to do is to distribute a sound file with my code. regards Angel

Replies are listed 'Best First'.
Re: sound file problem
by BrowserUk (Patriarch) on May 24, 2005 at 13:53 UTC

    Assuming you already have the code to play the .wav file once you have read it into memory, then you could embed the .wav into your script by converting it to base64. You would then convert it back before playing it.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
      base64 is a new word to me, I will read upon it. I do already have the .wav file, really just any ole warning sound will do.
      I also have the code to play the file and it works.
Re: sound file problem
by holli (Abbot) on May 24, 2005 at 13:45 UTC
    Do you use binmode(HANDLE)?


    holli, /regexed monk/
      I have not tried binmode, I will.