Perl Script Syntax error in version 4


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl Script Syntax error in version 4
# 1  
Old 10-30-2008
Perl Script Syntax error in version 4

Hi , I use the following simple perl script to find the yesterday time

Code:
perl  -e ' use POSIX(strftime); print POSIX::strftime("%a %b %e %H:%M:%S %Y", localtime(time-86400*$ARGV[0]))' 1

However in the perl version 4 , it gives me the following error :
Quote:
syntax error in file /tmp/perl-eK4elEa at line 1, next 2 tokens "use POSIX"
syntax error in file /tmp/perl-eK4elEa at line 1, next 2 tokens "POSIX:"
Execution of /tmp/perl-eK4elEa aborted due to compilation errors.
Do the perl version 4 does not support use POSIX???
# 2  
Old 10-30-2008
Hammer & Screwdriver

Hi Dude,

This script is working fine for me,when I tried it in AIX box,having perl 5.8.2 version.

abcd4dev# perl -e ' use POSIX(strftime); print POSIX::strftime("%a %b %e %H:%M:%S %Y", localtime(time-86400*$ARGV[0]))' 1
Wed Oct 29 09:53:24 2008

abcd4dev# perl -v

This is perl, v5.8.2 built for aix-thread-multi
(with 2 registered patches, see perl -V for more detail)

Copyright 1987-2003, Larry Wall


But unfortunately I dont have an environment with Perl version 4 to test this.
# 3  
Old 10-30-2008
Version 4 does not support "use". You can try
Code:
BEGIN { require POSIX; }

but there's a good chance that won't work. The package probably uses too many perl5-specific mechanisms.
# 4  
Old 10-30-2008
Consider migrating to Perl 5. The Perl community no longer supports the version 4 for so long that you are unlikely to get too much feedback. You can often install perl at another directory (even as user-level) for running specific scripts that require a specific version so that the original system-wide perl installation is untouched. Then you can fully leverage what is on CPAN, and more.
# 5  
Old 10-30-2008
Out of curiosity, Is this an embedded system or such? What still runs perl4? Or did you find a UNIX system whilst on an archaeological dig in Montana?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Syntax error on script

Evening All (or morning for some), Could anyone have a look at the below and advise where i've going wrong with the syntax as i keep getting the below error while trying to run. Any help would be really apprecaited. ./testout: line 13: syntax error near unexpected token `else' ... (4 Replies)
Discussion started by: mutley2202
4 Replies

2. Shell Programming and Scripting

Need shell script version of below perl code

We are using AIX version 7100-03-05-1524 Please provide shell script version (bash or ksh) of below perl code,since we need to have line breaks in huge XML files #!/usr/bin/perl # # Purpose: Read an XML file and indent it for ease of reading # Author: RedGrittyBrick 2011. # Licence:... (11 Replies)
Discussion started by: vishwanath001
11 Replies

3. Programming

Syntax error in perl program.

Hi, i am running this code but i am getting syntax error #!/usr/bin/perl use warnings; use strict; use XML::LibXML; use XML::LibXML::Reader; use Data::Dumper; my $file; open( $file, 'DTC_Specification_transformed.xml'); my $reader = XML::LibXML::Reader->new( IO => $file ) or die... (1 Reply)
Discussion started by: veerubiji
1 Replies

4. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

5. Shell Programming and Scripting

perl version for syntax errors

All, Does it matter what perl verios your running when you get syntax errors? on version 5.6.1 the code works fine, but on 5.8.0 the code gets errors? #!/usr/bin/perl #use strict; #use warnings; my $mess = 'messages'; my $mess1 = 'messages.1'; my $mess2 = 'messages.2'; my... (13 Replies)
Discussion started by: bigben1220
13 Replies

6. Shell Programming and Scripting

Perl Grep Error - Possible Syntax?

Alrighty, I'm trying to get a perl script going to search through a bunch of files for me and compile it to a single location. I am currently having troubles on just getting the grep to work. Here is what I currently have: #!/usr/bin/perl open (LOG, "errors.txt") or die ("Unable to open... (2 Replies)
Discussion started by: adelsin
2 Replies

7. Shell Programming and Scripting

syntax error on script

Hello all, I am trying to write a little script to create a file and I keep getting the below error and cant see where my syntax mistake(s) is. please help... the script: FILE="/u/e477059/Unix_Machines/LISTS" for X in `cat ${FILE}/list` do ssh $X "echo $X; cd /var/tmp; ... (2 Replies)
Discussion started by: rookieuxixsa
2 Replies

8. Shell Programming and Scripting

Perl Script Syntax to Extract Everything After Special Character

Hi, I am writing a Perl script that reads in many lines, if a line meets the criteria I want to edit, it. For example, the script will return the following example line... test=abc123 All I want to do is strip off the "test=" and just be left with the abc123. In my script I can easily... (3 Replies)
Discussion started by: edrichard
3 Replies

9. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

10. Shell Programming and Scripting

Correct Syntax For Calling Shell Script in Perl Module

Problem: I have a shell script that will be called by a Perl module that will connect to a db and delete rows. The Perl module will be called by CRON. I am using a Perl module to call a shell script because I need to get the db connection from Perl. Here is the Perl pseudocode: ... (4 Replies)
Discussion started by: mh53j_fe
4 Replies
Login or Register to Ask a Question