Hi,
I have a small piece of code that I am trying to improvise. I see that when I remove the
$item->read($libfile) the file is not processed at all. Can you explain why this is so as I am not able to figure out?
#!/usr/bin/perl
use strict;
use warnings;
package main;
#my $testObj = Disk::Collection->new();
#$testObj->read(Disk::FileInput->new("inputtextfile"));
#$testObj->print_dk_push_back;
my $testObj = Disk->new("inputtextfile");
package Disk;
sub new {
my ($class, $fname) = @_;
my $self = {
lib => undef
};
bless $self, $class;
my $lib = Disk::Collection->new();
my $libfile = Disk::FileInput->new($fname);
$lib->read($libfile);
($self->{lib}) = ($lib->get_list("JUNK"));
return $self;
}
package Disk::Collection;
sub new {
my $class = shift;
my $self = {
line => shift,
items => undef,
close => undef,
};
$self->{line} = "" unless $self->{line};
bless $self, $class;
}
sub read {
my ($self, $libfile) = @_;
...
...
my $item = Disk::Collection->new($line);
if ($line =~ /{/) {
die "syntax error:$lino: $line\n" if $line !~ /{\s*$/;
$item->read($libfile); ----> If I remove this line, the file p
+rocessing does not happen.
print $line, "\n";
}
...
...
}
...
...
Update: I just realized I accidentally posted the whole code.
Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.