Pack and unpack localtime in perl script

Hi I have a code like this:

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;
 
}
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;
 
}

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?

i need to pack and unpack in EBSDIC format

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?

Have you looked at any of the Perl modules such as Encode::EBCDIC?

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??