ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i'm currently going totally nuts about this stupid datatype i'm trying to use. i'm so so so sure that the data is being put into the nested arrays properly, as i can instantly recall it on assignment, and pull certain values out using hardcoded array references, BUT the array's length is always being reported back as 1, using "$#array" + 1 "or scalar @array". i'm at a complete loss right now...
Code:
for my $this_vts (1..$dvd->{vts}[0])
{
$dvd->{vts}[$this_vts]=[];
open (IFO, "ifo_dump $DVD_DEVICE $this_vts 2> /dev/null |") or die "error running ifo_dump! maybe it's not on your path?\n";
IFO: while (<IFO>)
{
if ($_=~/Program \(PGC\): *(\d*)/) {$this_ttn=$1; $dvd->{vts}[$this_vts][$this_ttn]=[]}
elsif ($_=~/Playback time: (\d\d:\d\d:\d\d)/) {$dvd->{vts}[$this_vts][$this_ttn][0]=$1}
elsif ($_=~/Cell:\s+(\d+)\s+(\d\d:\d\d:\d\d)/) {$dvd->{vts}[$this_vts][$this_ttn][$1]=$2; print $1, $2, "\n";}
elsif ($_=~/Menu PGCI Unit table/) {last IFO;}
}
}
right, that is where the values become assigned, inparticular the highlighted line, which also includes print lines, which DO print the data i expect.
but it's when i come to interogate the data later with:
Code:
sub show_dvd ($)
{
my $dvd = shift;
for my $this_track (1..$dvd->{track}[0])
{
my $this_ttn = $dvd->{track}[$this_track]{ttn};
my $this_vts = $dvd->{track}[$this_track]{vts};
print scalar $dvd->{vts}[$this_vts][$this_ttn];
print "NO. $this_track, VTS $this_vts, TTN $this_ttn, LEN $dvd->{vts}[$this_vts][$this_ttn][0], $dvd->{vts}[$this_vts][$this_ttn][1]\n";
}
}
now, the second print statement DOES print the data in those given positions IF it exists, if not, it will complain about an unitialiased value, which is fair enough. But the first statement, or any permutation i can think of it (e.g. assign the scalar to a $ and then print it later) will always return 1.... always. nryagg!
perfect. spot on, thanks. I know all the documentation is out there, but the problems i'm falling over all seem so hard to describe, let alone search for general information... brilliant, well that saves creating even more variables... super.
(= I'm just glad to be of help.. when I first started reading this thread, I didn't think I'd be able to help.
But, the only reason I knew this was because I have struggled with this same thing before. References can be tricky... but, you've got a really good grasp on it.. I'm impressed with how quickly you've taken to perl.
well i've got a degree in computer engineering, once you know one langauge you know half of all the others... you just learn what you should be able to demand and do and find out how to do it. Onl real exceptions i've found are functional languages like ML, which did make my head spin...
ML.. hehe.. yea.. there are a few that I don't want to get near, ML is one, and lisp/scheme is another.. I'm sure there are many more, but I'll stick with perl/c/python/java thank you very much. (=
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.