Error I am receiving is the following...
Can't locate object method "new" via package "IO::File" at ExampleForM
+onks.pl line 73, <FH> chunk 5.
Here is the code that is generating this error...
#!/usr/bin/perl-Tw
use strict;
use Text::ParseWords;
my $fname = "CommaSample2.dat";
my $toggle = ' ';
my @data;
my @PER_Data;
my @major_PER_Data;
BARE: {
open FH, "< $fname" or die "Cannot open datfile: ", $!;
while (<FH>) {
if (/"PER"/)
{
$toggle = 1, next if /^"PER"\s*$/;
}
last if /^"EOS"\s*$/;
die "Unknown or missing record tag: Got $_ on line $., datafil
+e $fname.$/" if $toggle eq '';
chomp;
@data = "ewords('\s+', 0, $_);
if ($toggle == 1)
{
{
$toggle = 0;
@PER_Data = ($data[0], $data[1], $data[2], $data[3]
+);
}
push @major_PER_Data, [@PER_Data];
}
$toggle = '';
}
}
my $i = 0;
my $Num_OF_PER = 0;
my @PER_Item;
my @PER_Entity;
my @PER_Name;
my @PER_Color;
my @PER_Date;
foreach my $PER_item (@major_PER_Data)
{
$i = 0;
foreach my $PER_subitem (@{$PER_item})
{
$PER_Item[$i] = $PER_subitem;
$i++
}
$PER_Entity[$Num_OF_PER] = $PER_Item[0];
$PER_Name[$Num_OF_PER] = $PER_Item[1];
$PER_Color[$Num_OF_PER] = $PER_Item[2];
$PER_Date[$Num_OF_PER] = $PER_Item[3];
$Num_OF_PER++;
}
my $r = 0;
print "Personal Info...\n";
while ($r < $Num_OF_PER)
{
print "$PER_Entity[$r] ";
print "$PER_Name[$r] ";
print "$PER_Color[$r] ";
print "$PER_Date[$r];\n ";
$r++
}
my $output = new IO::File(">xxx.xml");
my $writer = new XML::Writer( OUTPUT => $output, DATA_MODE => 1, DATA_
+INDENT =>4 );
$writer=>xmlDecl( "UTF-8", 1 );
$writer=>startTag( "application" );
$writer=>endTag ( "application" );
$writer=>end();
Here is line #73 Specifically,,,
my $output = new IO::File(">xxx.xml");
I realize that this code does not make total sense, but please just help me with this error and do not suggest that I take out any existing logic. I have trimmed this down quite a bit for purposes of posting this on the page and what I think I need help with IO file reading, but please help me out if you can.
peace, LOVE and ((code))
basicdez