LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 04-13-2010, 02:34 PM   #1
nikole
LQ Newbie
 
Registered: Apr 2010
Posts: 13

Rep: Reputation: 0
perl xs error: Bareword found where operator expected at ./Makefile.PL line 10, near


Hi
I am trying the example 4 of http://search.cpan.org/dist/perl/pod....pod#EXAMPLE_4. For perl XS in RHEL 5.
but i am getting this error

[root@localhost Mytest2]# cat Makefile.PL
use 5.008008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Mytest2',
VERSION_FROM => 'lib/Mytest2.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Mytest2.pm', # retrieve abstract from module
AUTHOR => 'nikole <root@localdomain>') : ()),
LIBS => [''], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
INC => '-I.', # e.g., '-I. -I/usr/include/other'
MYEXTLIB => 'mylib/libmylib$(LIB_EXT)',
);
if (eval {require ExtUtils::Constant; 1}) {
# If you edit these definitions to change the constants used by this module,
# you will need to use the generated const-c.inc and const-xs.inc
# files to replace their "fallback" counterparts before distributing your
# changes.
my @names = (qw(TESTVAL));
ExtUtils::Constant::WriteConstants(
NAME => 'Mytest2',
NAMES => \@names,
DEFAULT_TYPE => 'IV',
C_FILE => 'const-c.inc',
XS_FILE => 'const-xs.inc',
);

}
else {
use File::Copy;
use File::Spec;
foreach my $file ('const-c.inc', 'const-xs.inc') {
my $fallback = File::Spec->catfile('fallback', $file);
copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
}
}
sub MY:ostamble {
'
$(MYEXTLIB): mylib/Makefile
cd mylib && $(MAKE) $(PASSTHRU)
';
}
[root@localhost Mytest2]#

[root@localhost Mytest2]# ls
Changes fallback lib Makefile.PL MANIFEST mylib Mytest2.xs ppport.h README t typemap
[root@localhost Mytest2]# cat t/Mytest2.t
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Mytest2.t'

#########################

# change 'tests => 2' to 'tests => last_test_to_print';

use Test::More tests => 2;
BEGIN { use_ok('Mytest2') };


my $fail = 0;
foreach my $constname (qw(
TESTVAL)) {
next if (eval "my \$a = $constname; 1");
if ($@ =~ /^Your vendor has not defined Mytest2 macro $constname/) {
print "# pass: $@";
} else {
print "# fail: $@";
$fail = 1;
}

}

ok( $fail == 0 , 'Constants' );
#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

[root@localhost Mytest2]#
[root@localhost Mytest2]# cat Mytest2.xs
#include "mylib/mylib.h"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <./Mytest2/mylib/mylib.h>

#include "const-c.inc"

MODULE = Mytest2 PACKAGE = Mytest2

INCLUDE: const-xs.inc

double
foo(a,b,c)
int a
long b
const char * c
OUTPUT:
RETVAL
[root@localhost Mytest2]#
[root@localhost Mytest2]#
[root@localhost Mytest2]# cat lib/Mytest2.pm
package Mytest2;

use 5.008008;
use strict;
use warnings;
use Carp;

require Exporter;
use AutoLoader;

our @ISA = qw(Exporter);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration use Mytest2 ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
TESTVAL
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

#our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }, qw(
# TESTVAL
#) );

our @EXPORT = qw(
TESTVAL
);

our $VERSION = '0.01';

sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function.

my $constname;
our $AUTOLOAD;
($constname = $AUTOLOAD) =~ s/.*:://;
croak "&Mytest2::constant not defined" if $constname eq 'constant';
my ($error, $val) = constant($constname);
if ($error) { croak $error; }
{
no strict 'refs';
# Fixed between 5.005_53 and 5.005_61
#XXX if ($] >= 5.00561) {
#XXX *$AUTOLOAD = sub () { $val };
#XXX }
#XXX else {
*$AUTOLOAD = sub { $val };
#XXX }
}
goto &$AUTOLOAD;
}

require XSLoader;
XSLoader::load('Mytest2', $VERSION);

# Preloaded methods go here.

# Autoload methods go after =cut, and are processed by the autosplit program.

1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

Mytest2 - Perl extension for blah blah blah

=head1 SYNOPSIS

use Mytest2;
blah blah blah

=head1 DESCRIPTION

Stub documentation for Mytest2, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.

=head2 EXPORT

None by default.

=head2 Exportable constants

TESTVAL



=head1 SEE ALSO

Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.

If you have a mailing list set up for your module, mention it here.

If you have a web site set up for your module, mention it here.

=head1 AUTHOR

nikole, E<lt>root@localdomainE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010 by nikole

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.


=cut
[root@localhost Mytest2]#



[root@localhost Mytest2]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Bareword found where operator expected at ./Makefile.PL line 10, near "all ::"
(Do you need to predeclare all?)
Bareword found where operator expected at ./Makefile.PL line 12, near "pure_all ::"
(Do you need to predeclare pure_all?)
Bareword found where operator expected at ./Makefile.PL line 14, near "static ::"
(Do you need to predeclare static?)
Bareword found where operator expected at ./Makefile.PL line 14, near "$(LIB_EXT"
(Missing operator before LIB_EXT?)
Semicolon seems to be missing at ./Makefile.PL line 15.
Bareword found where operator expected at ./Makefile.PL line 16, near "$(LIB_EXT"
(Missing operator before LIB_EXT?)
Bareword found where operator expected at ./Makefile.PL line 16, near "$(O_FILES"
(Missing operator before O_FILES?)
Scalar found where operator expected at ./Makefile.PL line 17, near ")
$("
(Missing operator before $(?)
Bareword found where operator expected at ./Makefile.PL line 17, near "$(AR"
(Missing operator before AR?)
Bareword found where operator expected at ./Makefile.PL line 17, near ") cr"
(Missing operator before cr?)
Bareword found where operator expected at ./Makefile.PL line 17, near "$(LIB_EXT"
(Missing operator before LIB_EXT?)
Scalar found where operator expected at ./Makefile.PL line 17, near ") $("
(Missing operator before $(?)
Bareword found where operator expected at ./Makefile.PL line 17, near "$(O_FILES"
(Missing operator before O_FILES?)
Scalar found where operator expected at ./Makefile.PL line 18, near ")
$("
(Missing operator before $(?)
Bareword found where operator expected at ./Makefile.PL line 18, near "$(RANLIB"
(Missing operator before RANLIB?)
Bareword found where operator expected at ./Makefile.PL line 18, near ") libmylib"
(Missing operator before libmylib?)
Bareword found where operator expected at ./Makefile.PL line 18, near "$(LIB_EXT"
(Missing operator before LIB_EXT?)
String found where operator expected at ./Makefile.PL line 20, at end of line
(Missing semicolon on previous line?)
ERROR from evaluation of /home/nikole/perlcode/Mytest2/mylib/Makefile.PL: Can't find string terminator "'" anywhere before EOF at ./Makefile.PL line 20.
[root@localhost Mytest2]#

Does anyone have idea abt this ??
 
Old 04-13-2010, 02:41 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
We really can't help you with this written as it is, put the code in a [ code ] block so its actually readable (no random smiley faces and such) and generally you'll want to do the same with any pre-formated text like stuff from the console.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: unary operator expected ?? Lynda_M Programming 3 11-29-2008 08:03 PM
unary operator expected error! Lynda_M Programming 3 11-29-2008 12:04 PM
Binary operator expected - error mike9287 Linux - Newbie 9 07-17-2006 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration