Quantcast
Channel: openSUSE Forums
Viewing all articles
Browse latest Browse all 40713

store the output - instead of printing

$
0
0
hello dear Linux - experts


i am pretty new to per.l - and i want to do the first steps to store some values:
how to put the output of the request to the db

have perl :: DBI installed
also the mysql-db is up and running

see
https://metacpan.org/source/LBROCARD...rs-2.27/README

Code:

  use Parse::CPAN::Authors;
 
      # must have downloaded
      my $p = Parse::CPAN::Authors->new("01mailrc.txt.gz");
      # either a filename as above or pass in the contents of the file
      my $p = Parse::CPAN::Authors->new($mailrc_contents);
 
      my $author = $p->author('LBROCARD');
      # $a is a Parse::CPAN::Authors::Author object
      # ... objects are returned by Parse::CPAN::Authors
      print $author->email, "\n";  # leon@astray.com
      print $author->name, "\n";    # Leon Brocard
      print $author->pauseid, "\n"; # LBROCARD
 
      # all the author objects
      my @authors = $p->authors;

i want to store all the output in the mysql-db


regarding the db-things: well i am pretty new to perl-tasks.

but with the above mentioned module - i think i can learn alot - it is quite very simple. And with this i can play around - and try to find out how to store the data into a mysql db.


well could the results that i get be regarded as a perl object (reference to array of references) like the below:


Code:

my $a = [ [$a, $ab, $c ], [$a, $b, $c] ] ;
and need to store it on the DB then retrieve it.

i look for a good mechanism to serialize it and then store it on the DB?


hmm - if i want to store:
Code:


use Storable
use DBI;
 
# ... connect to database
# Store
my $data = [ [$a, $b, $c ], [ $a, $b, $c ] ];
my $bytestream = nfreeze $data;
$dbh->do('insert into table (field) values(?)', undef, $bytestream);

by the way: What about Data::Dumper?

Viewing all articles
Browse latest Browse all 40713

Trending Articles