Pack and unpack localtime in perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pack and unpack localtime in perl script
# 1  
Old 06-22-2011
Pack and unpack localtime in perl script

Hi I have a code like this:

Code:
sub WriteEbcdicHeader
{
my $Htimestamp=localtime();#i need to pack and unpack this 
my $eheaderline = $Htimestamp;
#packing has to be done here
#unpacking has to be done after packing
print $EOUTFILE 
return $eheaderline;
 
}

Code:
sub WriteEbcdicTrailer
{
 
my $Ttimestamp = localtime();
my $etrailerline=$Ttimestamp.$ase_rowcnt ;#i need to pack and unpack 
 
#packing has to be done here
#unpacking has to be done after packing
 
return $etrailerline;
 
}


Last edited by pludi; 06-22-2011 at 09:25 AM..
# 2  
Old 06-22-2011
Ok, so you have some code? What's the problem? Is there even a problem? Are you stuck somewhere? Is it raining because a butterfly flapped it's wings?
# 3  
Old 06-22-2011
i need to pack and unpack in EBSDIC format
# 4  
Old 06-22-2011
Yes, that much is clear. What's not clear is
  • Have you read the descriptions for the pack and unpack functions in Perl?
  • What character set are you converting from?
  • What EDCBIC codepage are you converting to?

Also, are you aware that the conversion from ASCII to EBCDIC and vice versa isn't actually a pack/unpack operation, but a translation between character encodings that isn't based on simple functions but will most likely require a translation table?
# 5  
Old 06-22-2011
Have you looked at any of the Perl modules such as Encode::EBCDIC?
# 6  
Old 06-23-2011
Hi thank u for reponding. Actually i am very new to perl scripting.The requirement is to write the header in the file with the timestamp.I am assuming that we are packing the same by converting into EBCDIC format and print the same in file header.

Similarly the requirement is to write the trailer into the file with time stamp and the rowcount.

Please tell me how this can be achieved??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use a variable in perl localtime()?

Hi all, a=$1 ## b=`echo "86400 * $a"|bc` `perl -e 'use POSIX qw(strftime);$now_string = strftime "%d/%m/%Y", localtime(time-$b); print $now_string,"\n";' > date_file` but im always getting current date; can any one suggest me any the improvement the above works fine if i use some thing... (2 Replies)
Discussion started by: zozoo
2 Replies

2. Shell Programming and Scripting

Perl help LocalTime in New Format

Hi, I'm new to perl scripting and am trying it out. I have a file written in the following format: myfile-MMDDYY where MM is the number of the Month; DD the Day and YY the last two of the year... (Apologies for dumbing this down; I'm trying to be clear). There is a new file put onto my... (2 Replies)
Discussion started by: Astrocloud
2 Replies

3. Shell Programming and Scripting

what is the default return type of localtime() in perl?

Hi, I have given like this to get the time of the sub routine. my $start = localtime(); print "\n start time: $start \n"; Output start time: Fri Apr 29 01:01:31 2011 I want to know what is the format of the time. I am not able to follow is is HH:MM:SS or MM:HH:SS os... (2 Replies)
Discussion started by: vanitham
2 Replies

4. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I am using pack/unpack to encyrpt a file. syntax is below #!/bin/sh encrypt=`perl -e 'print unpack "H*","yourpassword"'` - echo $encrypt >/file/to/store/encrypted/password pass=`cat /file/to/store/encrypted/password` decrypt=`perl -e 'print pack "H*",$pass'` ... (2 Replies)
Discussion started by: erinlomo
2 Replies

5. Shell Programming and Scripting

date with perl localtime

Hi Experts, I know how to handle normal date changes in perl. Most of my requirement are full filled with following: $date1 = strftime "%Y%m%d",localtime; $date2 = strftime "%Y%m%d",localtime(time -24 * 60 * 60); $date3 = strftime "%Y%m%d",localtime(time +24 * 60 * 60); $date4 = strftime... (4 Replies)
Discussion started by: mtomar
4 Replies

6. Shell Programming and Scripting

PERL localtime Warning

Hello All, I am facing a warning "Argument "" isn't numeric in localtime at" what i m using is below my $timestamp = Timestamp(time); go_log("###############$timestamp###############"); can some one please suggest the way to avoid this message :confused: (6 Replies)
Discussion started by: NIMISH AGARWAL
6 Replies

7. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I have a file that contains user id and corresponding password. Lets say password is "help". The below command will create a hex value for string "help". perl -e 'print unpack "H*","help"' So now password is in encoded format. Then I decoded it in the script where am fetching the... (1 Reply)
Discussion started by: max_payne1234
1 Replies

8. Shell Programming and Scripting

Perl help!! (pack()?)

Hello everyone. I wrote a perl script to get the two answers from a value: x. By this, I want to do sqrt($x) in different precision. #!/usr/bin/perl print "Input the initial value x:\n"; chomp($x=<STDIN>); $comp=sqrt($x); $float_value=pack("f", $comp); $double_value=pack("d", $comp);... (2 Replies)
Discussion started by: Euler04
2 Replies

9. Shell Programming and Scripting

Perl + localtime()

ok here is a perl date question not asked befor. i know i am feeling small for not knowing. BUT!!!! $ENV{TZ}="US/Central"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(); how can i do the addition to year so i can get the current year w/o going $ntime=$year+1900;... (3 Replies)
Discussion started by: Optimus_P
3 Replies

10. Shell Programming and Scripting

Perl + pack() + spaceing question

ok guys and gals at the moment i am perplexed (prolly cuz i been looking at it to long) but here it is. OS: sol8 perlver: 5.8.0 shell: ksh answer must be in perl!! issue: when i use pack() it packs the data at the front of the requested field space. normally it wouldnt be a problem if... (1 Reply)
Discussion started by: Optimus_P
1 Replies
Login or Register to Ask a Question