[EMAIL PROTECTED] wrote:

"John W. Krahn" <[EMAIL PROTECTED]> 16/03/2005 11:47 AM

[EMAIL PROTECTED] wrote:

Is someone able to explain why I am getting the following error, & how I might correct it?
Sorry I'm a bit of a newbie to Perl....


I have recently updated the Perl package I am working with to ActivePerl 5.8.6 and am now getting this error:

"input_record_separator is not supported on a per handle basis at" ..file/linenum...?

Relevant lines of code:-

                $mif_fh->input_record_separator(undef);
                               $mif_header = $mif_fh->getline;
and

               $fh->input_record_separator(undef);
                       $data_stream = $fh->getline;
and

               $fh->input_record_separator(undef);
                               eval($fh->getline);

Any help/ advice would be greatly appreciated.

Which module(s) are $mif_fh and $fh an object of? What is the version number of the module(s)? Which version of Perl were you using before you updated? Did you update all your modules when you updated Perl?

> I've been taking a look at it and discovered a few things, but still can't
> quite make sense of it.
> Apparently this input_record_separator is a new line.

The Input Record Separator variable is described in the perlvar.pod document
and is usually a newline character and the perlport.pod document describes how
newlines work on different platforms.

perldoc perlvar
perldoc perlport


> To give some background.. I am testing an app' that works as a .xla > plugin, scripted in vba and perl, I didn't write it and the developer has > disappeared. I'm a perl newbie, but not a coding newbie, so I can see a > fair amount of what is going on. > > I updated from API517E to the latest 5.8.6.811 as the client was concerned > with slowness of the app. > I've performed testing and it all still works perfectly well, or so it > appears, except for the above error during processing. I tried just > commenting out the line of code, but I still get the error? ...I haven't > updated any of the modules, apart to add in some really basic commenting. > > Really, I just want to get rid of the error that occurs whilst processing, > and I guess take advantage of any IO, filehandling improvements that have > been built in since the earlier release. > > I'll attach the relevant file, to make it easier for you to see what's > happening.. just didn't want to send it to a list. > > > > In response to your questions: > > >>Which module(s) are $mif_fh and $fh an object of? > > These are filehandle objects

The FileHandle module was useful for earlier versions of Perl but the version
that you are currently using does not need this module.  Just use lexical
filehandles with open() like:

open my $fh, '<', $filename


The FileHandle module inherits from IO::Handle which describes the correct way to use the input_record_separator method.

perldoc IO::Handle


>>What is the version number of the module(s)? > > um,...not sure, how can i determine this

$ perl -MFileHandle -le'print $FileHandle::VERSION'
2.01


>>Which version of Perl were you using before you updated? > > 5.1.7

According to perlhist.pod there is no version 5.1.7 of Perl.

perldoc perlhist


------------------------------------------------------------------------

#!/bin/perl -w

It is usually recommended that you use the warnings pragma instead of the -w command line switch.

perldoc perllexwarn

It is also recommended that you use the strict pragma:

use warnings;
use strict;


#note added 16/3/5 by tsimon, ADG
#This package uses the mif template to build the mif file
#It is the main package which calls each of the others to put the pieces 
together
#This package calls MifPara,MifCell, MifTree and MifTable

BEGIN
{
        $local_dir = $0;
        $local_dir =~ s/(.*)\\([^\\]*)$/$1/;
        push(@INC, $local_dir);
}

The current way to do that is:

use FindBin;

use lib $FindBin::Bin;


use MifPara;
use MifCell;
use MifTree;
use MifTable;
use File::stat;
use Data::Dumper;
use FileHandle;

#-------------------------------------------------------------------------
# Globals

%default_column_widths = (
        'Gap' => 4.5,
        'Value' => 16,
        'Note' => 10
);

If you add the strict pragma then you will have to define all of these variables with my().

my %default_column_widths = (
    Gap   => 4.5,
    Value => 16,
    Note  => 10,
);


$leader_note_margin = 4.5;

# Percentage of colour for cell shading is 30%
# this coresponds to a fill value of 4

# 10% coresponds to 5
# Cell shading is now 10%
$cell_fill = '5';

$cell_margin_with_paren = [ 0.0, 2.0, 2.5, 0.0 ];

# Following list are the catalogues
# to be extracted from the FrameMaker
# template if required.

%required_catalogs = (
        'Units' => 1,
        'CharUnits' => 1,
        'ColorCatalog' => 1,
        'ConditionCatalog' => 1,
        'CombinedFontCatalog' => 1,
        'PgfCatalog' => 1,
        'FontCatalog' => 1,
        'RulingCatalog' => 1,
        'TblCatalog' => 1,
        'VariableFormats' => 1,
        'MarkerTypeCatalog' => 1,
        'XRefFormats' => 1,
        'MIFFile' => 1
);

# Init Paragraph tab list
%para_tab_list = ();

$base_dir = 'c:\ex2fmflt';

# Extracted MIF data file
$mif_header = $base_dir . '\telmhead';

# Para tab data file
$para_tab_file = $base_dir . '\paratabs';

# MIF template file
$mif_template = $base_dir . '\telstra_tpl.mif';

You don't need to use back-slashes as path separators as DOS/Windows will use slashes.

# Init Paragraph tab list
my %para_tab_list;

my $base_dir = 'c:/ex2fmflt';

# Extracted MIF data file
my $mif_header = "$base_dir/telmhead";

# Para tab data file
my $para_tab_file = "$base_dir/paratabs";

# MIF template file
my $mif_template = "$base_dir/telstra_tpl.mif";


#-------------------------------------------------------------------------

# Load in data file from excel output
my($file_name) = $ARGV[0];

my($heading_rows_data, $body_rows_data) = excel_data($file_name);

if (! $heading_rows_data)
{
        &message_error('No data extracted from data file');
        ^
In older versions of Perl the ampersand was required but it is not any more.


        exit
}

if (! &mif_template_capture($mif_template, $mif_header))
{
        &message_error('Problem with template file');
        exit
}

# Capture Paragraph Tab Data
%para_tab_list = &tab_data_capture($mif_header, $para_tab_file);

#-------------------------------------------------------------------------
# Prepare new table
my($table) = MifTable->New;
$table->SetTag('TelstraFin1');
$table->SetId(1);

# Determine number of columns for table
my($columns) = scalar(@{$heading_rows_data->[0]});

The parentheses around $columns forces list context so scalar() is required however if you remove the parentheses you force scalar context.

my $columns = @{$heading_rows_data->[0]};


#-------------------------------------------------------------------------
# Determine Column widths (millimeters)
# Widths will be dependent on column style

[snip code]




John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to