perl module to write on a var

Discussion in 'Perl Misc' started by Larry, Oct 25, 2008.

  1. Larry

    Larry Guest

    Hi,

    I've been using a perl module that writes binary data on a file...now
    I would like to save this binary data on a var insted of on a file...the
    following si the code:

    my $_mp3 = MP3::Tag->new($file);

    my $_id3v2 = $_mp3->new_tag("ID3v2");
    $_id3v2->add_frame($key, $value);
    $_id3v2->write_tag();

    I'd rather save the data on a var kept in memory (I must not save the
    data on a file!)

    so is there anyway to have my $_mp3 = MP3::Tag->new($file); point to a
    var?

    thanks
    Larry, Oct 25, 2008
    #1
    1. Advertising

  2. Larry

    Guest

    On Oct 25, 5:49 am, Larry <> wrote:
    > Hi,
    >
    > I've been using a perl module that writes binary data on a file...now
    > I would like to save this binary data on a var insted of on a file...the
    > following si the code:
    >
    > my $_mp3 = MP3::Tag->new($file);
    >
    > my $_id3v2 = $_mp3->new_tag("ID3v2");
    > $_id3v2->add_frame($key, $value);
    > $_id3v2->write_tag();
    >
    > I'd rather save the data on a var kept in memory (I must not save the
    > data on a file!)
    >
    > so is there anyway to have my $_mp3 = MP3::Tag->new($file); point to a
    > var?
    >
    > thanks


    Unfortunately you don't have much control with MP3 module, so you'd
    have to write the file first and then read it into a variable.
    , Oct 26, 2008
    #2
    1. Advertising

  3. Larry

    C.DeRykus Guest

    On Oct 25, 5:49 am, Larry <> wrote:
    > Hi,
    >
    > I've been using a perl module that writes binary data on a file...now
    > I would like to save this binary data on a var insted of on a file...the
    > following si the code:
    >
    > my $_mp3 = MP3::Tag->new($file);
    >
    > my $_id3v2 = $_mp3->new_tag("ID3v2");
    > $_id3v2->add_frame($key, $value);
    > $_id3v2->write_tag();
    >
    > I'd rather save the data on a var kept in memory (I must not save the
    > data on a file!)
    >
    > so is there anyway to have my $_mp3 = MP3::Tag->new($file); point to a
    > var?
    >

    Probably not unless MP3::Tags'
    docs hint otherwise. To be sure, you might want to look inside
    the constructor itself:

    perldoc -m MP3::Tag | perl -ne 'print if /^sub new/../^}/'

    --
    Charles DeRykus
    C.DeRykus, Oct 27, 2008
    #3
  4. Larry

    Guest

    "C.DeRykus" <> wrote:
    > On Oct 25, 5:49 am, Larry <> wrote:
    > > Hi,
    > >
    > > I've been using a perl module that writes binary data on a file...now
    > > I would like to save this binary data on a var insted of on a
    > > file...the following si the code:
    > >
    > > my $_mp3 = MP3::Tag->new($file);
    > >
    > > my $_id3v2 = $_mp3->new_tag("ID3v2");
    > > $_id3v2->add_frame($key, $value);
    > > $_id3v2->write_tag();
    > >
    > > I'd rather save the data on a var kept in memory (I must not save the
    > > data on a file!)
    > >
    > > so is there anyway to have my $_mp3 = MP3::Tag->new($file); point to a
    > > var?
    > >

    > Probably not unless MP3::Tags'
    > docs hint otherwise. To be sure, you might want to look inside
    > the constructor itself:
    >
    > perldoc -m MP3::Tag | perl -ne 'print if /^sub new/../^}/'


    The constructor hints that you can't, but it isn't exactly clear. All it
    does is stuff the name into a hash. The actual open of any filehandle
    based on the name passed to the constructor seems to be delegated 8 ways
    from Sunday.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    The costs of publication of this article were defrayed in part by the
    payment of page charges. This article must therefore be hereby marked
    advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
    this fact.
    , Oct 27, 2008
    #4
  5. Larry

    C.DeRykus Guest

    On Oct 25, 5:49 am, Larry <> wrote:
    > Hi,
    >
    > I've been using a perl module that writes binary data on a file...now
    > I would like to save this binary data on a var insted of on a file...the
    > following si the code:
    >
    > my $_mp3 = MP3::Tag->new($file);
    >
    > my $_id3v2 = $_mp3->new_tag("ID3v2");
    > $_id3v2->add_frame($key, $value);
    > $_id3v2->write_tag();
    >
    > I'd rather save the data on a var kept in memory (I must not save the
    > data on a file!)
    >
    > so is there anyway to have my $_mp3 = MP3::Tag->new($file); point to a
    > var?
    >


    If the MP3::Tag docs don't provide any hints, you can usually peek at
    the constructor to see what's
    possible:

    perldoc -m MP3::Tag |
    perl -ne'print if /^sub new/../^}/'

    --
    Charles DeRykus
    C.DeRykus, Oct 27, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alvin Bruney

    Threads.. Session var lost, App var ok

    Alvin Bruney, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    359
    rooster575
    Dec 2, 2003
  2. thomson
    Replies:
    10
    Views:
    2,493
    Eliyahu Goldin
    Jun 20, 2005
  3. thomson
    Replies:
    0
    Views:
    379
    thomson
    Jun 20, 2005
  4. Fred
    Replies:
    3
    Views:
    325
    Alf P. Steinbach
    Aug 10, 2003
  5. Alex Vinokur
    Replies:
    4
    Views:
    473
    Ron Natalie
    Sep 24, 2003
Loading...

Share This Page