Perl portability

Perl portability

am 14.09.2005 22:45:27 von Hendry Taylor

I wrote a perl script and tested it on windows and it works fine. I then
moved it onto a solaris machine and now it says that there is a syntax
error with the following line of code:

$user1 = "User name: ".$rec1[0];

the line of code just before that is:

@rec1 = split(/@/, $autotrack[$records]);


any ideas?
I can't see that there is anything uniquely windows about that. There is
a difference in the version of perl in that on the windows box I have
active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
something like that.

Re: Perl portability

am 15.09.2005 02:31:51 von Jim Gibson

In article , Hendry
Taylor wrote:

> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:
>
> $user1 = "User name: ".$rec1[0];
>
> the line of code just before that is:
>
> @rec1 = split(/@/, $autotrack[$records]);
>
>
> any ideas?
> I can't see that there is anything uniquely windows about that. There is
> a difference in the version of perl in that on the windows box I have
> active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
> something like that.

I see nothing wrong with those two lines, either. They compile fine on
my non-windows machine also running 5.8.6. It probably has more to do
with the very old version of Perl running on your Solaris system, but
the line in question would seem to be acceptable Perl 4, so I have no
idea what the problem is.

Since this newsgroup is defunct, you have a much higher probability of
getting your problem solved if you pose your question to
comp.lang.perl.misc. It is best to post a complete, short program that
illustrates your problem.

What does 'perl -v' produce on your Solaris system?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Re: Perl portability

am 15.09.2005 02:31:51 von Jim Gibson

In article , Hendry
Taylor wrote:

> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:
>
> $user1 = "User name: ".$rec1[0];
>
> the line of code just before that is:
>
> @rec1 = split(/@/, $autotrack[$records]);
>
>
> any ideas?
> I can't see that there is anything uniquely windows about that. There is
> a difference in the version of perl in that on the windows box I have
> active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
> something like that.

I see nothing wrong with those two lines, either. They compile fine on
my non-windows machine also running 5.8.6. It probably has more to do
with the very old version of Perl running on your Solaris system, but
the line in question would seem to be acceptable Perl 4, so I have no
idea what the problem is.

Since this newsgroup is defunct, you have a much higher probability of
getting your problem solved if you pose your question to
comp.lang.perl.misc. It is best to post a complete, short program that
illustrates your problem.

What does 'perl -v' produce on your Solaris system?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Re: Perl portability

am 15.09.2005 02:49:03 von Sherm Pendley

Jim Gibson writes:

> In article , Hendry
> Taylor wrote:
>
>> I wrote a perl script and tested it on windows and it works fine. I then
>> moved it onto a solaris machine and now it says that there is a syntax
>> error with the following line of code:
>>
>> $user1 = "User name: ".$rec1[0];
>>
>> the line of code just before that is:
>>
>> @rec1 = split(/@/, $autotrack[$records]);
>>
> Since this newsgroup is defunct, you have a much higher probability of
> getting your problem solved if you pose your question to
> comp.lang.perl.misc.

He did - it's cross-posted. (I've removed the defunct group from the list
for this message.)

I can't see anything wrong with the posted code either - but it's been so
long since I've used 5.003 that I'm basically just guessing. :-(

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Re: Perl portability

am 15.09.2005 02:49:03 von Sherm Pendley

Jim Gibson writes:

> In article , Hendry
> Taylor wrote:
>
>> I wrote a perl script and tested it on windows and it works fine. I then
>> moved it onto a solaris machine and now it says that there is a syntax
>> error with the following line of code:
>>
>> $user1 = "User name: ".$rec1[0];
>>
>> the line of code just before that is:
>>
>> @rec1 = split(/@/, $autotrack[$records]);
>>
> Since this newsgroup is defunct, you have a much higher probability of
> getting your problem solved if you pose your question to
> comp.lang.perl.misc.

He did - it's cross-posted. (I've removed the defunct group from the list
for this message.)

I can't see anything wrong with the posted code either - but it's been so
long since I've used 5.003 that I'm basically just guessing. :-(

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Re: Perl portability

am 15.09.2005 03:29:15 von 1usa

Sherm Pendley wrote in
news:m2r7brrw8w.fsf@Sherm-Pendleys-Computer.local:

> Jim Gibson writes:
>
>> In article ,
>> Hendry Taylor wrote:
>>
>>> I wrote a perl script and tested it on windows and it works fine. I
>>> then moved it onto a solaris machine and now it says that there is a
>>> syntax error with the following line of code:
>>>
>>> $user1 = "User name: ".$rec1[0];
>>>
>>> the line of code just before that is:
>>>
>>> @rec1 = split(/@/, $autotrack[$records]);
>>>
>> Since this newsgroup is defunct, you have a much higher probability
>> of getting your problem solved if you pose your question to
>> comp.lang.perl.misc.
>
> He did - it's cross-posted. (I've removed the defunct group from the
> list for this message.)
>
> I can't see anything wrong with the posted code either - but it's been
> so long since I've used 5.003 that I'm basically just guessing. :-(

Well, I think it is quite necessary for the OP to try and produce the
proverbial shortest script that still exhibits the problem. Frequently,
syntax error messages are caused by somewhere other than the lines
reported.

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines .html

Re: Perl portability

am 15.09.2005 03:29:15 von 1usa

Sherm Pendley wrote in
news:m2r7brrw8w.fsf@Sherm-Pendleys-Computer.local:

> Jim Gibson writes:
>
>> In article ,
>> Hendry Taylor wrote:
>>
>>> I wrote a perl script and tested it on windows and it works fine. I
>>> then moved it onto a solaris machine and now it says that there is a
>>> syntax error with the following line of code:
>>>
>>> $user1 = "User name: ".$rec1[0];
>>>
>>> the line of code just before that is:
>>>
>>> @rec1 = split(/@/, $autotrack[$records]);
>>>
>> Since this newsgroup is defunct, you have a much higher probability
>> of getting your problem solved if you pose your question to
>> comp.lang.perl.misc.
>
> He did - it's cross-posted. (I've removed the defunct group from the
> list for this message.)
>
> I can't see anything wrong with the posted code either - but it's been
> so long since I've used 5.003 that I'm basically just guessing. :-(

Well, I think it is quite necessary for the OP to try and produce the
proverbial shortest script that still exhibits the problem. Frequently,
syntax error messages are caused by somewhere other than the lines
reported.

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines .html

Re: Perl portability

am 15.09.2005 13:16:36 von Hendry Taylor

The perl -v on solaris produced the following:

This is perl, version 5.005_03 built for sun4-solaris

Copyright 1987-1999, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.


Jim Gibson wrote:
> In article , Hendry
> Taylor wrote:
>
>
>>I wrote a perl script and tested it on windows and it works fine. I then
>>moved it onto a solaris machine and now it says that there is a syntax
>>error with the following line of code:
>>
>>$user1 = "User name: ".$rec1[0];
>>
>>the line of code just before that is:
>>
>>@rec1 = split(/@/, $autotrack[$records]);
>>
>>
>>any ideas?
>>I can't see that there is anything uniquely windows about that. There is
>>a difference in the version of perl in that on the windows box I have
>>active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
>>something like that.
>
>
> I see nothing wrong with those two lines, either. They compile fine on
> my non-windows machine also running 5.8.6. It probably has more to do
> with the very old version of Perl running on your Solaris system, but
> the line in question would seem to be acceptable Perl 4, so I have no
> idea what the problem is.
>
> Since this newsgroup is defunct, you have a much higher probability of
> getting your problem solved if you pose your question to
> comp.lang.perl.misc. It is best to post a complete, short program that
> illustrates your problem.
>
> What does 'perl -v' produce on your Solaris system?
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com

Re: Perl portability

am 15.09.2005 14:01:46 von anno4000

[Newsgroups trimmed]

Sherm Pendley wrote in comp.lang.perl.misc:
> Jim Gibson writes:
>
> > In article , Hendry
> > Taylor wrote:
> >
> >> I wrote a perl script and tested it on windows and it works fine. I then
> >> moved it onto a solaris machine and now it says that there is a syntax
> >> error with the following line of code:
> >>
> >> $user1 = "User name: ".$rec1[0];
> >>
> >> the line of code just before that is:
> >>
> >> @rec1 = split(/@/, $autotrack[$records]);
> >>
> > Since this newsgroup is defunct, you have a much higher probability of
> > getting your problem solved if you pose your question to
> > comp.lang.perl.misc.
>
> He did - it's cross-posted. (I've removed the defunct group from the list
> for this message.)
>
> I can't see anything wrong with the posted code either - but it's been so
> long since I've used 5.003 that I'm basically just guessing. :-(

I happen to have a 5.003 around. No syntax error with the two lines
above.

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

Re: Perl portability

am 15.09.2005 14:40:28 von axel

In comp.lang.perl.misc Hendry Taylor wrote:

[On something Perlish]

But the subject line got me thinking... Perl portability... why
not Perl potability in the shape of a Perl beer mug? I have a vi
mug, so it is clearly achievable.

Axel

Re: Perl portability

am 15.09.2005 14:40:28 von axel

In comp.lang.perl.misc Hendry Taylor wrote:

[On something Perlish]

But the subject line got me thinking... Perl portability... why
not Perl potability in the shape of a Perl beer mug? I have a vi
mug, so it is clearly achievable.

Axel

Re: Perl portability

am 15.09.2005 16:50:53 von xhoster

axel@white-eagle.invalid.uk wrote:
> In comp.lang.perl.misc Hendry Taylor
> wrote:
>
> [On something Perlish]
>
> But the subject line got me thinking... Perl portability... why
> not Perl potability in the shape of a Perl beer mug? I have a vi
> mug, so it is clearly achievable.

Is your vi mug turing complete?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

Re: Perl portability

am 15.09.2005 18:11:38 von Darren Dunham

In comp.lang.perl.misc Hendry Taylor wrote:
> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:

> $user1 = "User name: ".$rec1[0];

> the line of code just before that is:

> @rec1 = split(/@/, $autotrack[$records]);

Is that code within a BLOCK? What is the exact error string that you're
getting?

--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >

Re: Perl portability

am 15.09.2005 18:11:38 von Darren Dunham

In comp.lang.perl.misc Hendry Taylor wrote:
> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:

> $user1 = "User name: ".$rec1[0];

> the line of code just before that is:

> @rec1 = split(/@/, $autotrack[$records]);

Is that code within a BLOCK? What is the exact error string that you're
getting?

--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >

Re: Perl portability

am 15.09.2005 18:18:48 von Hendry Taylor

Well here is the entire code it is rather long. It just says syntax
error on line 55 near $user1


#!/usr/bin/perl
use Tie::File;
use Switch;
sub trimwhitespace($);
sub nslookup();
$debug = 0;
chdir("/usr/local/home/autosys/seos_autotrack");
$auditrecords = 0;
$n = 0;
$srecords = 0;
$arecords = 0;
$index = 0;
$totalmatched = 0;
$totalunmatched = 0;
my @monthnames = (qw(dummy Jan Feb Mar Apr May Jun Jul Aug Sep Nov Dec));
open FILEREAD, " $runday = ;
close FILEREAD;
$logfilename = "autotrack-seos-compare".$runday.".log";
use Fcntl 'O_RDWR', 'O_CREAT';
my $o = tie @logfile, 'Tie::File', $logfilename, mode => O_RDWR |
O_CREAT, dw_size => 512;
$logrecords = @logfile;
if ($logrecords > 0) {splice @logfile, 0, $logrecords;}
$o->STORE($n, "Debug mode set to: ".$debug);
open FILEREAD, " $rundate = ;
close FILEREAD;
tie @servers, 'Tie::File', 'servers' || die "Can't open: $!\n";
foreach $server (@servers)
{
$iplist = nslookup($server, 'Address');
$serverlist{$iplist} = sprintf "%s",$server;
$serverlist1{$server} = sprintf "%s",$iplist;
print FILEWRITE "$server $iplist\n";
}
untie @servers;
local $now = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$o->STORE(++$n, "Start time = ".$hour.":".$min.":".$sec);
@files = ;
foreach $arrayfiles(@files) #foreach autotrack file
{
$records = 1;
$line = 1;
tie @autotrack, 'Tie::File', $arrayfiles || die "Can't open: $!\n";
$o->STORE(++$n, "Processing autotrack file: ".$arrayfiles);
foreach $item (@autotrack) #foreach autotrack record
{
switch ($line)
{
case 1
{
$rec1 = $autotrack[$records];
@rec1 = split(/@/, $autotrack[$records]);
$user1 = "User name: ".$rec1[0];
$user = $rec1[0];
$terminal = $rec1[1];
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "user = ".$rec1[0]);
$o->STORE(++$n, "terminal = ".$rec1[1]);
}
++$line;
} #Close case 1
case 2
{
@datetime = split(/ /, $autotrack[$records]);
@rec21 = split(/\//, $datetime[0]);
$edate = sprintf "$rec21[0] $monthnames[$rec21[1]] $rec21[2]";
$edate1 = sprintf "Date: $rec21[0] $monthnames[$rec21[1]] $rec21[2]";
@rec22 = split(/:/, $datetime[1]);
$etime = sprintf "$rec22[0]:$rec22[1]";
$etime1 = sprintf "Time: $rec22[0]:$rec22[1]";
$edatetime = sprintf "$edate $etime";
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "date = ".$edate);
$o->STORE(++$n, "time = ".$etime);
$o->STORE(++$n, "date time = ".$edatetime);
}
++$line;
} #Close case 2
case 3
{
$event = $autotrack[$records];
@rec3 = split(/ /, $event);
$command = trimwhitespace($rec3[0]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "event = ".$event);
$o->STORE(++$n, "command = ".$command);
}
++$line;
} #Close case 3
case 4 { ++$line }
case 5
{
@rec5 = split(/:/, $autotrack[$records]);
$rec5[0] = trimwhitespace($rec5[0]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, $rec5[0]." = ".$rec5[1]);
}
++$line;
} #Close case 5
case 6
{
@rec6 = split(/:/, $autotrack[$records]);
$rec6[0] = trimwhitespace($rec6[0]);
$rec6[1] =~ s/^\s+//;
@rec61 = split(/ /, $rec6[1]);
foreach $array_element(@rec61)
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "rec61: ".$rec61[$index]);
}
$rec61[$index] =~ s/\"//g;
switch ($rec61[0])
{
case "sendevent"
{
switch ($rec61[2])
{
case "SET_GLOBAL"
{
$class1 = "Class: as-gvar";
$class = "as-gvar";
}
case "FORCE_STARTJOB"
{
$class1 = "Class: as-job";
$class = "as-job";
}
else
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "unmatched sendevent type");
}
}
}
}
else
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "unmatched command");
}
}
}
++$index;
} #Close foreach specific array_element
@rec62 = split(/\=/, $rec61[4]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, $rec6[0]." = ".$rec6[1]);
$o->STORE(++$n, "rec62 = ".$rec62[0].", ".$rec62[1]);
}
$index = 0;
++$line;
} #Close case 6
else
{
if ($autotrack[$records] eq
"::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::")
{
++$auditrecords;
$search = sprintf
"$edatetime.*$class.*$command.*$terminal|$serverlist1[$termi nal]";
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "Search value = ".$search);
$o->STORE(++$n, "Class = ".$class1.", resource = ".$rec62[0].", user
= ".$user1.", terminal = ".$terminal1.", date = ".$edate1.", time =
".$etime1);
}
$match = 0;
$array_files = "seosauditsuccess_".$terminal."_".$runday.".out";
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "connecting to file: ".$array_files);
}
tie @seosaudit, 'Tie::File', $array_files || die "Can't open: $!\n";
foreach $array_element(@seosaudit)
{
++$srecords;
if ($array_element =~ m/Total Records Displayed.*/)
{
next;
} #Close if
if($array_element =~ m/($search)/)
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "Class = ".$class1.", resource = ".$rec62[1].",
user = ".$user1.", terminal = Terminal: ".$terminal.", date =
".$edate1.", time = ".$etime1);
}
if ($match >= 6)
{
$found = 1;
$match = 0;
next;
}
} #Close if
if ($array_element =~ m/($class1)/)
{
++$match;
} #close if array_element
if ($array_element =~ m/Resource: ($rec62[0])\..*/)
{
++$match;
} #close if array_element
if ($array_element =~ m/($user1)/)
{
++$match;
} #close if array_element
if ($array_element =~
m/Terminal\:.*($terminal|$serverlist1[$terminal])/)
{
++$match;
} #close if array_element
if ($array_element =~ m/Program\:.*($command)/)
{
++$match;
} #close if array_element
if ($array_element =~ m/($edate1)/)
{
++$match;
} #close if array_element
if ($array_element =~ m/($etime1)/)
{
++$match;
} #close if array_element
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "SeosAudit record = ".$array_element);
}
} #Close foreach
if ($found == 1)
{
$o->STORE(++$n, "Record found in the seosdb audit file: ".$array_files);
$found = 0;
$match = 0;
++$totalmatched;
}
elsif ($found == 0)
{
$o->STORE(++$n, "Record not found in the seosdb audit file!!!!
".$array_files);
$o->STORE(++$n, "Autotrack Data:\n\t".$class1.",\n\tResource:
".$rec62[0].",\n\t".$user1.",\n\t".$terminal1.",\n\tProgram:
".$command.",\n\t".$edate1.",\n\t".$etime1);
$found = 0;
$match = 0;
++$totalunmatched;
}
$line = 1;
untie @seosaudit;
} #Close if Last record of autotrack
elsif ($autotrack[$records] eq "")
{
$o->STORE(++$n, "\n\n");
} #Close else if
else
{
@recdef = split(/:/, $autotrack[$records]);
$recdef[0] = trimwhitespace($recdef[0]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, $recdef[0]." = ".$recdef[1]);
}
++$line;
} #Close else of last record if
} #Close of switch else for autotrack
} #Close of switch for autotrack

++$records;
# if ($records == 50)
# {
# $o->STORE(++$n, "Total unique Audit records read = ".$auditrecords);
# $o->STORE(++$n, "Total records matched = ".$totalmatched);
# $o->STORE(++$n, "Total records not matched = ".$totalunmatched);
# $now = time - $now;
# ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
# $o->STORE(++$n, "End time = ".$hour.":".$min."$:".$sec);
# $o->STORE(++$n, "It took ".int($now / 3600).":".int(($now % 3600) /
60).":".int($now % 60). "to process ".$arecords." Autotrack records and
".$srecords." Seoasdb records");
# exit;
# }
}
untie @seosaudit;
untie @autotrack;
$arecords = $arecords + $records;
}
$o->STORE(++$n, "Total unique Audit records read = ".$auditrecords);
$o->STORE(++$n, "Total records matched = ".$totalmatched);
$o->STORE(++$n, "Total records not matched = ".$totalunmatched);
$now = time - $now;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$o->STORE(++$n, "End time = ".$hour.":".$min.":".$sec);
$o->STORE(++$n, "It took ".int($now / 3600).":".int(($now % 3600) /
60).":".int($now % 60)." to process ".$arecords." autotrack records and
".$srecords." Seosaudit records");
untie @logfile;
# Function to remove whitespace from the begining and the end of a string.
sub trimwhitespace($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+//;
return $string;
}

sub nslookup() {
my ($host, $word) = @_;
open(NSLOOKUP, "nslookup $host 2>&1 |") || die "nslookup error";
while () {
if (/Name:.*$host\.eur\.nsroot\.net/) {
$found = 1;
}
last if (/$word/ & $found == 1);
if (/\*\*\*/) {
print "nslookup says: $_";
die "*** nslookup error";
}
}
close(NSLOOKUP);
s/$word:\s*//;
chomp;
$found = 0;
return $_;
}


Darren Dunham wrote:
> In comp.lang.perl.misc Hendry Taylor wrote:
>
>>I wrote a perl script and tested it on windows and it works fine. I then
>>moved it onto a solaris machine and now it says that there is a syntax
>>error with the following line of code:
>
>
>>$user1 = "User name: ".$rec1[0];
>
>
>>the line of code just before that is:
>
>
>>@rec1 = split(/@/, $autotrack[$records]);
>
>
> Is that code within a BLOCK? What is the exact error string that you're
> getting?
>

Re: Perl portability

am 15.09.2005 18:30:34 von xhoster

Hendry Taylor wrote:
> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:
>
> $user1 = "User name: ".$rec1[0];
>
> the line of code just before that is:
>
> @rec1 = split(/@/, $autotrack[$records]);

This line by itself seems fine in perl -c, but deparse chokes on it:

[]$ perl -MO=Deparse,-p
@rec1 = split(/@/, $autotrack[$records]);
Can't call method "isa" without a package or object reference at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/B/Deparse.pm line 1081. CHECK
failed--call queue aborted.

I don't know if this is somehow related to your problem or not.

I suspect your problem may stem from your use of Switch.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

Re: Perl portability

am 15.09.2005 18:30:34 von xhoster

Hendry Taylor wrote:
> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:
>
> $user1 = "User name: ".$rec1[0];
>
> the line of code just before that is:
>
> @rec1 = split(/@/, $autotrack[$records]);

This line by itself seems fine in perl -c, but deparse chokes on it:

[]$ perl -MO=Deparse,-p
@rec1 = split(/@/, $autotrack[$records]);
Can't call method "isa" without a package or object reference at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/B/Deparse.pm line 1081. CHECK
failed--call queue aborted.

I don't know if this is somehow related to your problem or not.

I suspect your problem may stem from your use of Switch.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

Re: Perl portability

am 15.09.2005 18:32:20 von axel

xhoster@gmail.com wrote:
> axel@white-eagle.invalid.uk wrote:
>> In comp.lang.perl.misc Hendry Taylor
>> wrote:

>> [On something Perlish]

>> But the subject line got me thinking... Perl portability... why
>> not Perl potability in the shape of a Perl beer mug? I have a vi
>> mug, so it is clearly achievable.

> Is your vi mug turing complete?

No idea. But it holds cider or wine quite happily.

Axel

Re: Perl portability

am 15.09.2005 18:34:23 von Hendry Taylor

Is it possible that the switch is not fully supported.

If i were to take the switch out my code suddenly become alot more
complicated and I prefer KISS.


xhoster@gmail.com wrote:
> Hendry Taylor wrote:
>
>>I wrote a perl script and tested it on windows and it works fine. I then
>>moved it onto a solaris machine and now it says that there is a syntax
>>error with the following line of code:
>>
>>$user1 = "User name: ".$rec1[0];
>>
>>the line of code just before that is:
>>
>>@rec1 = split(/@/, $autotrack[$records]);
>
>
> This line by itself seems fine in perl -c, but deparse chokes on it:
>
> []$ perl -MO=Deparse,-p
> @rec1 = split(/@/, $autotrack[$records]);
> Can't call method "isa" without a package or object reference at
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi/B/Deparse.pm line 1081. CHECK
> failed--call queue aborted.
>
> I don't know if this is somehow related to your problem or not.
>
> I suspect your problem may stem from your use of Switch.
>
> Xho
>

Re: Perl portability

am 15.09.2005 18:34:23 von Hendry Taylor

Is it possible that the switch is not fully supported.

If i were to take the switch out my code suddenly become alot more
complicated and I prefer KISS.


xhoster@gmail.com wrote:
> Hendry Taylor wrote:
>
>>I wrote a perl script and tested it on windows and it works fine. I then
>>moved it onto a solaris machine and now it says that there is a syntax
>>error with the following line of code:
>>
>>$user1 = "User name: ".$rec1[0];
>>
>>the line of code just before that is:
>>
>>@rec1 = split(/@/, $autotrack[$records]);
>
>
> This line by itself seems fine in perl -c, but deparse chokes on it:
>
> []$ perl -MO=Deparse,-p
> @rec1 = split(/@/, $autotrack[$records]);
> Can't call method "isa" without a package or object reference at
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi/B/Deparse.pm line 1081. CHECK
> failed--call queue aborted.
>
> I don't know if this is somehow related to your problem or not.
>
> I suspect your problem may stem from your use of Switch.
>
> Xho
>

Re: Perl portability

am 16.09.2005 01:35:58 von Darren Dunham

Hendry Taylor wrote:
> Well here is the entire code it is rather long. It just says syntax
> error on line 55 near $user1

I couldn't get that message at all when I tried to run the code. I
checked it under 5.8.7, so it may be something to do with perl or one of
the modules (like Switch) between our versions.

> #!/usr/bin/perl
> use Tie::File;
> use Switch;
> sub trimwhitespace($);
> sub nslookup();

Now I got a lot of whining about that. You don't need this line at all,
and you probably want to remove the parentheses where you define the
subroutine.

> sub nslookup() {

to

sub nslookup {

Of course, you could just use gethostent instead of calling nslookup,
but that's not causing your syntax error.

After changing those two lines...
$ perl -w article
Useless use of localtime in void context at article line 289.
Possible precedence problem on bitwise & operator at article line 326.
Name "main::user" used only once: possible typo at article line 58.
Name "main::rundate" used only once: possible typo at article line 27.
Name "main::item" used only once: possible typo at article line 49.
Name "main::serverlist" used only once: possible typo at article line 33.
Name "main::FILEWRITE" used only once: possible typo at article line 35.
readline() on closed filehandle FILEREAD at article line 17.
Use of uninitialized value in concatenation (.) or string at article line 19.
readline() on closed filehandle FILEREAD at article line 27.
Use of uninitialized value in concatenation (.) or string at article line 42, <$fh> line 16.
untie attempted while 1 inner references still exist at article line 309, <$fh> line 16.

No syntax errors...

--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >

Re: Perl portability

am 16.09.2005 02:16:30 von 1usa

Hendry Taylor wrote in
news:dgc6t8$gdb$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com:

> Well here is the entire code it is rather long. It just says syntax
> error on line 55 near $user1

This is just plain rude. Post the shortest possible script that still
exhibits the problem.

By the way, who wrote this crap?

> #!/usr/bin/perl

use warnings;
use strict;

missing.

> use Tie::File;
> use Switch;
> sub trimwhitespace($);
> sub nslookup();

What, can you tell me, is the purpose of declaring that a sub called
nslookup takes no arguments?

#!/usr/bin/perl
use strict;
use warnings;

sub sub_with_empty_prototype () { print "@_\n" }

sub_with_empty_prototype(qw'pass some args');

__END__

Run that script and see what happens.

Now, if I copy and paste your script, I get:

D:\Home\asu1\UseNet\clpmisc> perl -c c.pl
Too many arguments for main::nslookup at c.pl line 32, near "'Address')"
BEGIN not safe after errors--compilation aborted at c.pl line 42.

So, I do not believe you when you say your script runs fine on a later
version of Perl.

Seeing code like this makes me respect people who work in the real
world, who have to fix messes like this to make things right.

> $debug = 0;
> chdir("/usr/local/home/autosys/seos_autotrack");
> $auditrecords = 0;
> $n = 0;
> $srecords = 0;
> $arecords = 0;
> $index = 0;
> $totalmatched = 0;
> $totalunmatched = 0;

What are all these global variables. Declare variables in the smallest
applicable scope.

> my @monthnames = (qw(dummy Jan Feb Mar Apr May Jun Jul Aug Sep Nov
> Dec));

Cute.

open FILEREAD, "
open FILEREAD, '<', 'seos_autotrack_day'
or die "Cannot open seos_autotrack_day: $!";

> $runday = ;
> close FILEREAD;
> $logfilename = "autotrack-seos-compare".$runday.".log";

my $logfilename = "autotrack-seos-compare$runday.log";

> use Fcntl 'O_RDWR', 'O_CREAT';
> my $o = tie @logfile, 'Tie::File', $logfilename, mode => O_RDWR |
> O_CREAT, dw_size => 512;
> $logrecords = @logfile;
> if ($logrecords > 0) {splice @logfile, 0, $logrecords;}
> $o->STORE($n, "Debug mode set to: ".$debug);
> open FILEREAD, " > $rundate = ;
> close FILEREAD;
> tie @servers, 'Tie::File', 'servers' || die "Can't open: $!\n";

I don't think this will actually die on error.

> foreach $server (@servers)
> {
> $iplist = nslookup($server, 'Address');

What do you think this will return?

Why is $iplist a scalar?

> $serverlist{$iplist} = sprintf "%s",$server;

This is sick. What do you think is the difference between

sprintf "%s",$server;

and

"$server"

> $serverlist1{$server} = sprintf "%s",$iplist;

Ditto.

> print FILEWRITE "$server $iplist\n";
> }
> untie @servers;
> local $now = time;
> ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
> localtime(time);

I can't read any more.

Have you seen the posting guidelines?

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines .html

Re: Perl portability

am 16.09.2005 02:17:49 von tiltonj

[comp.lang.perl removed from newsgroups list]

Traditional Usenet reply style is to trim reply-quoted material to only
enough necessary to give context to your comments, and to interleave your
comments with the quoted material. clpm readers appreciate replies that
adhere to that tradition.

Hendry Taylor wrote:

: Is it possible that the switch is not fully supported.

Possible, yep. It's implemented by a source filter. Using it has created
problems for me before, though I can't remember particulars. I abandoned
its use after one special day of enthusiastic cursing.

You might verify that the two platforms are using the same version of
Switch.pm and its dependent modules.

Is there a way to see the code as altered by a source filter? I dunno.

: If i were to take the switch out my code suddenly become alot more
: complicated and I prefer KISS.

"Simple" and "portable" are often mutually exclusive choices.

Re: Perl portability

am 16.09.2005 02:17:49 von tiltonj

[comp.lang.perl removed from newsgroups list]

Traditional Usenet reply style is to trim reply-quoted material to only
enough necessary to give context to your comments, and to interleave your
comments with the quoted material. clpm readers appreciate replies that
adhere to that tradition.

Hendry Taylor wrote:

: Is it possible that the switch is not fully supported.

Possible, yep. It's implemented by a source filter. Using it has created
problems for me before, though I can't remember particulars. I abandoned
its use after one special day of enthusiastic cursing.

You might verify that the two platforms are using the same version of
Switch.pm and its dependent modules.

Is there a way to see the code as altered by a source filter? I dunno.

: If i were to take the switch out my code suddenly become alot more
: complicated and I prefer KISS.

"Simple" and "portable" are often mutually exclusive choices.

Re: Perl portability

am 16.09.2005 04:10:19 von Tad McClellan

axel@white-eagle.invalid.uk wrote:

> I have a vi
> mug


But how do you get it into "beep mode"?


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Re: Perl portability

am 16.09.2005 04:10:19 von Tad McClellan

axel@white-eagle.invalid.uk wrote:

> I have a vi
> mug


But how do you get it into "beep mode"?


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Re: Perl portability

am 16.09.2005 07:55:18 von axel

In comp.lang.perl.misc Tad McClellan wrote:
> axel@white-eagle.invalid.uk wrote:

>> I have a vi
>> mug


> But how do you get it into "beep mode"?

After two mugs of wine or four of cider I beep quite happily.

Axel

Re: Perl portability

am 19.09.2005 21:41:06 von Hendry Taylor

Hendry Taylor wrote:
> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:
>
> $user1 = "User name: ".$rec1[0];
>
> the line of code just before that is:
>
> @rec1 = split(/@/, $autotrack[$records]);
>
>
> any ideas?
> I can't see that there is anything uniquely windows about that. There is
> a difference in the version of perl in that on the windows box I have
> active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
> something like that.

Just as some feedback, I upgraded the perl from 5.00.5 to 5.8.4 and it
now works fine. The older version did not like my switch and case.