Re: string and hash [quite long]
- From: usenet@xxxxxxxxxxxxxxx
- Date: 29 Nov 2005 16:02:35 -0800
No_name wrote:
> The string on the message starting with
> "our %lsdvd = ("
> and ending with
> "longest_track => 1,);"
> is the output of lsdvd program.
Oooohhhh! I thought that was an example of a Perl data structure that
you were trying to create from the program output. I thought you were
showing us what you wanted to get, not what you started out with.
Because this program output IS a Perl data structure (how convenient).
Then Paul Lali has already answered your question (ie, use "eval").
See the code below for an example. But how do you intend to use this
data structure? What do you want to do with it?
#!/usr/bin/perl
use warnings; use strict;
my $cmd = join " ", map {($_) =~ / *(.*)\n/} <DATA>;
my %dvd = eval $cmd;
use Data::Dumper; #to validate the effects
print Dumper(\%dvd); #is it really right??? Yes indeed!
__DATA__
device => '/dev/dvd',
title => 'DVDVOLUME',
vmg_id => 'DVDVIDEO-VMG',
provider_id => '',
track => [
{
ix => 1,
length => 5309.090,
vts_id => 'DVDVIDEO-VTS',
},
{
ix => 2,
length => 22.050,
vts_id => 'DVDVIDEO-VTS',
},
{
ix => 3,
length => 63.060,
vts_id => 'DVDVIDEO-VTS',
},
{
ix => 4,
length => 181.280,
vts_id => 'DVDVIDEO-VTS',
},
{
ix => 5,
length => 181.280,
vts_id => 'DVDVIDEO-VTS',
},
],
longest_track => 1,
.
- References:
- string and hash [quite long]
- From: No_name
- Re: string and hash [quite long]
- From: usenet
- Re: string and hash [quite long]
- From: No_name
- string and hash [quite long]
- Prev by Date: Re: Can Perl redirect STDOUT to file AND to command window?
- Next by Date: Re: Can Perl redirect STDOUT to file AND to command window?
- Previous by thread: Re: string and hash [quite long]
- Next by thread: How to modify a XML file using Perl?
- Index(es):
Relevant Pages
|