veerubiji has asked for the wisdom of the Perl Monks concerning the following question:
hi actuvally i posted how to create module after careful reading i create one module but i have some errors can tel me how to modify
Original content below restored by GrandFather
hi actuvally i posted how to create module after careful reading i create one module but i have some errors can tel me how to modify
my code#!/usr/bin/perl use warnings; use strict; use XML::LibXML::Reader; #Reading XML with a pull parser my $file; open( $file, 'formal.xml'); my $reader = XML::LibXML::Reader->new( IO => $file ) or die ("unable t +o open file"); my %nums; while ($reader->nextElement( 'Data' ) ) { my $des = $reader->readOuterXml(); $reader->nextElement( 'Number' ); my $desnode = $reader->readInnerXml(); $nums{$desnode}= $des; print( " NUMBER: $desnode\n" ); print( " Datainfo: $des\n" ); }
i created lik this
#!/usr/bin/perl package Mymodule; use warnings; use strict; use Exporter qw(import); use Carp; use XML::LibXML::Reader; our @EXPORT_OK(myFunction); sub MyFunction { my $fh = shift; my $reader = XML::LibXML::Reader->new( IO => $fh ) or die ("u +nable to open file"); my %nums; while ($reader->nextElement( 'Data' ) ) { my $des = $reader->readOuterXml(); $reader->nextElement( 'Number' ); my $desnode = $reader->readInnerXml(); $nums{$desnode}= $des; } return %nums; } 1; my main function #!/usr/bin/perl use warnings; use strict; use Mypackage qw(myFunction); my $file; open( $file, 'formal.xml'); my %returnedHash = myFunction($file);
but i am getting errors like sysntax error at line 9 @export_ok in mypackage.pm and compilation error in main function line 4 (use mypackage qw(myfunction). i used right sysntax for export but i dnt know how to clear this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help me with errors in perl module.
by davido (Cardinal) on Oct 13, 2011 at 08:12 UTC | |
by veerubiji (Sexton) on Oct 13, 2011 at 09:06 UTC | |
|
Re: help me with errors in perl module.
by choroba (Cardinal) on Oct 13, 2011 at 08:15 UTC | |
by veerubiji (Sexton) on Oct 13, 2011 at 09:07 UTC | |
|
Re: help me with errors in perl module.
by perl_lover (Chaplain) on Oct 13, 2011 at 08:15 UTC | |
by veerubiji (Sexton) on Oct 13, 2011 at 09:09 UTC | |
|
Re: help me with errors in perl module.
by marscld (Beadle) on Oct 13, 2011 at 08:40 UTC | |
by davido (Cardinal) on Oct 13, 2011 at 14:54 UTC |