Re: How to provide editor environment on STDIN

2009-09-23 Thread Chas. Owens
On Tue, Sep 22, 2009 at 23:10, Harry Putnam rea...@newsguy.com wrote:
 Chas. Owens chas.ow...@gmail.com writes:

 How big of a chore would it be to include code into the script that
 creates some kind of editor like environment and allows bash style
 completion?

 I'm a very low level perl coder.. and will need pointers to some clues
 about how to get this done, and incorporated into my scripts.

 In shell scripting, at least with bash, taking input from user is done
 with `read line' but you can say 'read -e line' and the input is
 suddenly done with bash completion.. and I think a few other niceties.

 Is there something similar in perl?
 snip

 Take a look at [Term::Readline][1], [Term::Readline::GNU][2], and
 [Term::Readline::Perl][3].

 I'm sad to say after installing Term::ReadLine::Gnu and looking at the
 the 1014 lines of perldoc Term::ReadLine::Gnu..
snip

Term::Readline is more for writing programs with prompts (e.g. bash).
If you want to give the user a full editor, why not just drop them
into vi:

#!/usr/bin/perl

use strict;
use warnings;

use File::Temp qw/tempfile/;

#this is the safest way to get a temporary filename
my $tmpfile = do {
my ($fh, $filename) = tempfile();
close $fh;
$filename;
};

my $editor = $ENV{EDITOR} || /usr/bin/vi;

system($editor, $tmpfile) == 0
or die error occured while trying to run editor\n;

my $contents = do {
local $/;
open my $fh, , $tmpfile
or die could not open $tmpfile: $!\n;
$fh;
};

unlink $tmpfile
or die could not delete $tmpfile: $!;

print you wrote: [$contents]\n;


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: mbtomh in perl?

2009-09-23 Thread Shlomi Fish
Hi Alexey!

On Tuesday 22 Sep 2009 16:56:42 Mishustin Alexey wrote:
 Hello,
 
 Is there a perl tool for converting mbox files to MH directories?
 
 Google found only a tool on tcl [1] and a perl tool for converting mbox
 to Maildir [2].
 
 [1] - http://wiki.tcl.tk/15276
 [2] - http://batleth.sapienti-sat.org/projects/mb2md/
 
 If there isn't such a tool 'out of the box', evidently, I will need
 some help to rewrite the tcl script on perl...
 

Try the Mail::Box module:

http://search.cpan.org/dist/Mail-Box/

It seems to still be the best of breed in this regard from what some 
authoritative sources in the Perl Email Project told me. It is large and 
complicated, but gets the job done.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

Chuck Norris read the entire English Wikipedia in 24 hours. Twice.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: mbtomh in perl?

2009-09-23 Thread Alexey Mishustin

9/23/2009, Shlomi Fish shlo...@iglu.org.il вы писали:

 Is there a perl tool for converting mbox files to MH directories?
[snip]

Try the Mail::Box module:

http://search.cpan.org/dist/Mail-Box/

It seems to still be the best of breed in this regard from what some
authoritative sources in the Perl Email Project told me. It is large and
complicated, but gets the job done.

Thank you, I'll try!

--
Regards,
Alex

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Burnt Camel Club

2009-09-23 Thread Tim Bowden
On Tue, 2009-09-22 at 09:59 -0500, Bryan R Harris wrote:
  On Mon, Sep 21, 2009 at 10:09 PM, Randal L. Schwartz
  mer...@stonehenge.comwrote:
  
  
  Yup.  I care when it might harm others.  Otherwise, I tend not to
  talk... plenty of other people here to give answers.  I only doublecheck
  answers anymore.
  
  Yes, that is why this list gets 5 emails on average per day and other
  comparable language lists gets 40.
 
 Remember, correlation does not imply causality.
 
 Maybe people get answers faster here.  Or the archives already answer most
 questions.  Or perl is easy enough to use that people don't have to ask a
 lot of questions.
 
 I've gotten some seriously impressive responses to my questions and am 10x
 the programmer I'd be without this list (though that may not be saying
 much).
 
 
  Keep it up and the hollier-than-though's will have the list to
  themselves eventually.
 
 The respect is earned.  It wouldn't surprise me if Einstein didn't have
  much patience for criticism from those with short resumes...
 
 - B

Volume isn't always quality.  There are some lists around where a
significant portion of the volume is the blind leading the blind.  The
rest is experts trying to clean up the mess.  Here the emphasis seems to
be a little more on not making a mess in the first place (ie,
discouraging less than helpful answers).  Both approaches have their
place.  FWIW, as a perl newbie I'm happy with the way things are done
here.

Given FOSS is supposed to be all about having fun, why don't we have a
'Friday Fun' challenge aimed at beginners?  A once a week small coding
challenge (posted by 'those that know'?) that should take no more than
5-10 mins covering 'Programming 101 in Perl' type material (ie, no deep
magic!).  Brownie points for any decent/reasonable solution posted by a
beginner within 24 hours.  Rotten eggs for those who do an 'elephant
drowned in custard' type solution.  With a bit of luck it might help
those paddling in the baby pool to venture out a bit further.

Another $0.02,
Tim Bowden


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Burnt Camel Club

2009-09-23 Thread Goke Aruna
I enjoyed writing my script in perl despite not being a computer
programmer, I get my need done without much stress, hence no need to
increase the mail volume on the list.

Perl6 definitely will take me higher to programming.

Perl is still the best for beginers at least you can write your novice
script and even get a sample script on the web to solve your problem.

On 9/23/09, Tim Bowden tim.bow...@mapforge.com.au wrote:
 On Tue, 2009-09-22 at 09:59 -0500, Bryan R Harris wrote:
  On Mon, Sep 21, 2009 at 10:09 PM, Randal L. Schwartz
  mer...@stonehenge.comwrote:
 
 
  Yup.  I care when it might harm others.  Otherwise, I tend not to
  talk... plenty of other people here to give answers.  I only
  doublecheck
  answers anymore.
 
  Yes, that is why this list gets 5 emails on average per day and other
  comparable language lists gets 40.

 Remember, correlation does not imply causality.

 Maybe people get answers faster here.  Or the archives already answer most
 questions.  Or perl is easy enough to use that people don't have to ask a
 lot of questions.

 I've gotten some seriously impressive responses to my questions and am 10x
 the programmer I'd be without this list (though that may not be saying
 much).


  Keep it up and the hollier-than-though's will have the list to
  themselves eventually.

 The respect is earned.  It wouldn't surprise me if Einstein didn't have
  much patience for criticism from those with short resumes...

 - B

 Volume isn't always quality.  There are some lists around where a
 significant portion of the volume is the blind leading the blind.  The
 rest is experts trying to clean up the mess.  Here the emphasis seems to
 be a little more on not making a mess in the first place (ie,
 discouraging less than helpful answers).  Both approaches have their
 place.  FWIW, as a perl newbie I'm happy with the way things are done
 here.

 Given FOSS is supposed to be all about having fun, why don't we have a
 'Friday Fun' challenge aimed at beginners?  A once a week small coding
 challenge (posted by 'those that know'?) that should take no more than
 5-10 mins covering 'Programming 101 in Perl' type material (ie, no deep
 magic!).  Brownie points for any decent/reasonable solution posted by a
 beginner within 24 hours.  Rotten eggs for those who do an 'elephant
 drowned in custard' type solution.  With a bit of luck it might help
 those paddling in the baby pool to venture out a bit further.

 Another $0.02,
 Tim Bowden


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/




-- 
Sent from my mobile device

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Friday Fun [was: Burnt Camel Club]

2009-09-23 Thread Balázs Botond
Tim,

 Given FOSS is supposed to be all about having fun, why don't we have a
 'Friday Fun' challenge aimed at beginners?

I would absolutely LOVE such a challenge!

Regards,
Botond

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: Testing with Selenium

2009-09-23 Thread Bob McConnell
From: Steve Bertrand
 Steve Bertrand wrote:
  Bob McConnell wrote:

 I have begun the task of automating functional tests for some of our
web
 servers. I have had some success using Selenium IDE in Firefox to
 capture input sequences, exporting them to Perl scripts, then using
the
 Se remote control server to execute them. But I have run into one
minor
 problem.

 A basic test is to verify the error message returned when an invalid
 password is entered. This test script is shown below. I can run this
as
 a simple test, or it can be part of a suite. The command line to
 manually run the suite is normally:

 perl -MTest::Harness -e @ARGV= map glob, @ARGV \
   if  $^O =~ /^MSWin/; runtests @ARGV; test/*.pl

 Unfortunately, yes this is running on a WinXP system.

 My problem is that we have multiple virtual hosts on that server,
and I
 need to select a specific host for each run. So when I run the
harness I
 need some way to pass the tst12.dev portion of the URL into each
of
 the test scripts. I can't see any way with Test::Harness or
Test::More
 to do this. If I can, then I have other parameters that need to be
 passed in as well.
 
 Do I understand you correctly in believing that you are trying to run
 specific tests against numerous hosts within a single test file?
 
 Appears as though I've totally misunderstood what you are after...
 
 After re-reading, it looks as though you are trying to execute
multiple
 test 'files', and want to supply the hostname (and perhaps other
params)
 into them. Yes?

Yes, I have a 'tests' directory with a growing number of Selenium
scripts that will become an automated regression test. Each time I run
those scripts with Test::Harness I need to pass a server name to each
script. There are other variables I would also like to control.

On my test server there are three hosts that I maintain, which normally
have the current and two previous builds of the application. After I add
or modify a test script, or make a change to the current version, if
there is a test failure I can then run the same test on the previous
versions to find out if they produce the same failure. These test
scripts will be checked into our SCM so the QA and production teams have
access to them as well. In addition, those teams should be able to
record and add scripts that recreate problems they find or any that are
reported by clients. Once fixed, those tests will also become part of
the regression suite.

This reduces the time to run a reasonably complete regression test from
most of a man-week to a couple of hours.

Paul's suggestion of environment variables appears to be the only viable
option I have seen so far.

Bob McConnell

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Burnt camel etc. etc

2009-09-23 Thread ANJAN PURKAYASTHA
I've been reading these posts with a great deal of interest.
I don't know what much of the fuss is about (having joined this forum about
2 years back), but I will say that I have had some VERY helpful responses
from experts and beginners alike.
For the most part this list does a great job in helping newbies. It would be
a shame to change things.
JMTC,
Anjan

-- 
=
anjan purkayastha, phd
bioinformatics analyst
whitehead institute for biomedical research
nine cambridge center
cambridge, ma 02142

purkayas [at] wi [dot] mit [dot] edu
703.740.6939


Re: Burnt camel etc. etc

2009-09-23 Thread Chas. Owens
On Wed, Sep 23, 2009 at 08:46, ANJAN PURKAYASTHA
anjan.purkayas...@gmail.com wrote:
 I've been reading these posts with a great deal of interest.
 I don't know what much of the fuss is about (having joined this forum about
 2 years back), but I will say that I have had some VERY helpful responses
 from experts and beginners alike.
 For the most part this list does a great job in helping newbies. It would be
 a shame to change things.
 JMTC,
 Anjan
snip

There is a continuum of help from here, I did your homework for you
to RTFM.  In the past, Perl mailing lists and irc tended toward
RTFM.  To combat this perceived unfriendliness, this list was
created.  Its charter is to be [closer to here, I did your homework
for you][1] than RTFM in the hopes that this will cause timid
newbies to stick around and join the larger community.

This causes a predictable backlash from people who believe that giving
a man a fish instead of teaching him to fish is wrong.  There is also
backlash from people who become frustrated or get their buttons pushed
(such as the whole legal boilerplate at the bottom of emails thread
that started recently).  The backlash causes another predictable
backlash from the people who want to keep the list clear of the
earlier backlash and people who, ironically enough, oppose backlash at
all.  And so on.

Here are the rules I try to live by on this list (note, I don't always succeed):

1. A starving man or woman can't pay attention to the lesson you are
giving him or her.  Give him or her a fish and teach him or her.
2. If someone keeps asking for fish and never pays attention to the
lesson, let him or her starve.
3. It is better to not post than to post angry.
4. Bad advice and answers must be corrected, but try to do it nicely.
5. Ask questions, don't make assumptions (I am really bad at this one).
6. Answer the [real question][2], but beware of number 5.

[1] : without devolving into here, I did your homework for you
[2] : this one is tricky, if some one asks how to write mergesort in
Perl, they probably want the builtin sort function instead, but it
might be that they need to sort something that won't fit in memory.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




decimal to binary?

2009-09-23 Thread Bryan R Harris


I need to convert a number like this:   -3205.0569059
... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a bc 93
d3  (I just made up those 8 byte values).

Is this easy in perl?  Are long and short ints easy as well?

Thanks!

- Bryan




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: decimal to binary?

2009-09-23 Thread Bob McConnell
From: Bryan R Harris
 
 I need to convert a number like this:   -3205.0569059
 ... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a
bc 93
 d3  (I just made up those 8 byte values).
 
 Is this easy in perl?  Are long and short ints easy as well?

The sprintf() family is your friend.

Bob McConnell

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Uri Guttman
 BM == Bob McConnell r...@cbord.com writes:

  BM From: Bryan R Harris
   
   I need to convert a number like this:   -3205.0569059
   ... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a
  BM bc 93
   d3  (I just made up those 8 byte values).
   
   Is this easy in perl?  Are long and short ints easy as well?

  BM The sprintf() family is your friend.

that will only generate text (hex and other formats). he needs pack
which does exactly what he wants. read perlpacktut for a tutorial on
pack/unpack and then perlfunc -f pack for the reference on it.

pack can take a perl float and make a string of the internal
representation in either endian order.

for some real world examples of doing that, check out the code in
Sort::Maker which packs floats into strings and deals with endian issues
too.

uri

-- 
.signature_stem

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Bryan R Harris


 I need to convert a number like this:   -3205.0569059
 ... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a
 bc 93
 d3  (I just made up those 8 byte values).
 
 Is this easy in perl?  Are long and short ints easy as well?
 
 The sprintf() family is your friend.


I see %x (unsigned integer, in hexadecimal) and %f (floating-point number,
in fixed decimal notation), but nothing about doubles, endianness, etc.

I checked both my perl bookshelf and perldoc on this so far with no luck...

- Bryan



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread John W. Krahn

Bryan R Harris wrote:


I need to convert a number like this:   -3205.0569059
... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a bc 93
d3  (I just made up those 8 byte values).

Is this easy in perl?  Are long and short ints easy as well?


$ perl -le'print unpack H*, pack d, -3205.0569059'
e626c5221d0aa9c0



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.   -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: decimal to binary?

2009-09-23 Thread Bob McConnell
From: Uri Guttman

 BM == Bob McConnell r...@cbord.com writes:
 
   BM From: Bryan R Harris

I need to convert a number like this:   -3205.0569059
... into an 8-byte double (big and little endian), e.g. 4f 3e 52
00 2a
   BM bc 93
d3  (I just made up those 8 byte values).

Is this easy in perl?  Are long and short ints easy as well?
 
   BM The sprintf() family is your friend.
 
 that will only generate text (hex and other formats). he needs pack
 which does exactly what he wants. read perlpacktut for a tutorial on
 pack/unpack and then perlfunc -f pack for the reference on it.

That statement just confuses me. His initial value of -3205.0569059 is
also text. It is the human readable representation of the number, and is
not anything like what it looks like inside the computer. He just asked
for a different format for that text. Why is sprintf not a reasonable
way to do that?

Bob McConnell

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Bryan R Harris

 From: Uri Guttman
 
 BM == Bob McConnell r...@cbord.com writes:
 
   BM From: Bryan R Harris
 
 I need to convert a number like this:   -3205.0569059
 ... into an 8-byte double (big and little endian), e.g. 4f 3e 52
 00 2a
   BM bc 93
 d3  (I just made up those 8 byte values).
 
 Is this easy in perl?  Are long and short ints easy as well?
 
   BM The sprintf() family is your friend.
 
 that will only generate text (hex and other formats). he needs pack
 which does exactly what he wants. read perlpacktut for a tutorial on
 pack/unpack and then perlfunc -f pack for the reference on it.
 
 That statement just confuses me. His initial value of -3205.0569059 is
 also text. It is the human readable representation of the number, and is
 not anything like what it looks like inside the computer. He just asked
 for a different format for that text. Why is sprintf not a reasonable
 way to do that?

The 8 bytes is an IEEE 754-2008 formatted number -- see here for an
explanation:

  http://en.wikipedia.org/wiki/Double_precision

It's not just a simple hex of a decimal...  You've got an exponent and a
sign encoded in there too.

I'm still reading the perlpacktut, but I'm hoping it'll get me to that.

- Bryan



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Uri Guttman
 BM == Bob McConnell r...@cbord.com writes:

  BM From: Uri Guttman
   BM == Bob McConnell r...@cbord.com writes:
   
  BM From: Bryan R Harris

I need to convert a number like this:   -3205.0569059
... into an 8-byte double (big and little endian), e.g. 4f 3e 52
  BM 00 2a
  BM bc 93
d3  (I just made up those 8 byte values).

Is this easy in perl?  Are long and short ints easy as well?
   
  BM The sprintf() family is your friend.
   
   that will only generate text (hex and other formats). he needs pack
   which does exactly what he wants. read perlpacktut for a tutorial on
   pack/unpack and then perlfunc -f pack for the reference on it.

  BM That statement just confuses me. His initial value of -3205.0569059 is
  BM also text. It is the human readable representation of the number, and is
  BM not anything like what it looks like inside the computer. He just asked
  BM for a different format for that text. Why is sprintf not a reasonable
  BM way to do that?

he said number. perl will automatically convert a string number to a
float. but he wants access to the bytes in that float (hence his
mentioning of endian). perl can store a float, integer or string in a
scalar. but the float can only be used as a number, you can't get at its
bytes. pack solves that problem.

uri

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Uri Guttman
 BRH == Bryan R Harris bryan_r_har...@raytheon.com writes:

   From: Uri Guttman
   
   BM == Bob McConnell r...@cbord.com writes:
   
  BM From: Bryan R Harris
   
   I need to convert a number like this:   -3205.0569059
   ... into an 8-byte double (big and little endian), e.g. 4f 3e 52
   00 2a
  BM bc 93
   d3  (I just made up those 8 byte values).
   
   Is this easy in perl?  Are long and short ints easy as well?
   
  BM The sprintf() family is your friend.
   
   that will only generate text (hex and other formats). he needs pack
   which does exactly what he wants. read perlpacktut for a tutorial on
   pack/unpack and then perlfunc -f pack for the reference on it.
   
   That statement just confuses me. His initial value of -3205.0569059 is
   also text. It is the human readable representation of the number, and is
   not anything like what it looks like inside the computer. He just asked
   for a different format for that text. Why is sprintf not a reasonable
   way to do that?

  BRH The 8 bytes is an IEEE 754-2008 formatted number -- see here for an
  BRH explanation:

  BRH   http://en.wikipedia.org/wiki/Double_precision

  BRH It's not just a simple hex of a decimal...  You've got an exponent and a
  BRH sign encoded in there too.

  BRH I'm still reading the perlpacktut, but I'm hoping it'll get me to that.

pack will do it. as i said, i am doing that very thing in
Sort::Maker. it packs floats into strings for using in a string
comparison for sorting.

uri

-- 
.signature_stem

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: How to provide editor environment on STDIN

2009-09-23 Thread Harry Putnam
Chas. Owens chas.ow...@gmail.com writes:

 On Tue, Sep 22, 2009 at 23:10, Harry Putnam rea...@newsguy.com wrote:
 Chas. Owens chas.ow...@gmail.com writes:

 How big of a chore would it be to include code into the script that
 creates some kind of editor like environment and allows bash style
 completion?

 I'm a very low level perl coder.. and will need pointers to some clues
 about how to get this done, and incorporated into my scripts.

 In shell scripting, at least with bash, taking input from user is done
 with `read line' but you can say 'read -e line' and the input is
 suddenly done with bash completion.. and I think a few other niceties.

 Is there something similar in perl?
 snip

 Take a look at [Term::Readline][1], [Term::Readline::GNU][2], and
 [Term::Readline::Perl][3].

 I'm sad to say after installing Term::ReadLine::Gnu and looking at the
 the 1014 lines of perldoc Term::ReadLine::Gnu..
 snip

Haa... yes of course a much smarter approach thanks..

I guess there would be serious portability problems on any of the
windows os's though.  Thankfully I don't use this script there.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Chas. Owens
On Wed, Sep 23, 2009 at 15:32, Bob McConnell r...@cbord.com wrote:
 From: Uri Guttman

 BM == Bob McConnell r...@cbord.com writes:

   BM From: Bryan R Harris
   
    I need to convert a number like this:   -3205.0569059
    ... into an 8-byte double (big and little endian), e.g. 4f 3e 52
 00 2a
   BM bc 93
    d3  (I just made up those 8 byte values).
   
    Is this easy in perl?  Are long and short ints easy as well?

   BM The sprintf() family is your friend.

 that will only generate text (hex and other formats). he needs pack
 which does exactly what he wants. read perlpacktut for a tutorial on
 pack/unpack and then perlfunc -f pack for the reference on it.

 That statement just confuses me. His initial value of -3205.0569059 is
 also text. It is the human readable representation of the number, and is
 not anything like what it looks like inside the computer. He just asked
 for a different format for that text. Why is sprintf not a reasonable
 way to do that?
snip

Because sprintf %16x, .5 returns  and you can't
recover .5 from that.  On the other hand you can say:
#!/usr/bin/perl

use strict;
use warnings;

my $n= -3205.0569059;
my $packed   = pack d, $n;
my $hex  = unpack H*, $packed;
my $unpacked = unpack d, pack H*, $hex;
print
n= $n\n,
packed   = $packed\n,
hex  = $hex\n,
unpacked = $unpacked\n;

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: decimal to binary?

2009-09-23 Thread Bob McConnell
From: Bryan R Harris

 From: Uri Guttman
 
 BM == Bob McConnell r...@cbord.com writes:
 
   BM From: Bryan R Harris
 
 I need to convert a number like this:   -3205.0569059
 ... into an 8-byte double (big and little endian), e.g. 4f 3e 52
 00 2a
   BM bc 93
 d3  (I just made up those 8 byte values).
 
 Is this easy in perl?  Are long and short ints easy as well?
 
   BM The sprintf() family is your friend.
 
 that will only generate text (hex and other formats). he needs pack
 which does exactly what he wants. read perlpacktut for a tutorial on
 pack/unpack and then perlfunc -f pack for the reference on it.
 
 That statement just confuses me. His initial value of -3205.0569059
is
 also text. It is the human readable representation of the number, and
is
 not anything like what it looks like inside the computer. He just
asked
 for a different format for that text. Why is sprintf not a reasonable
 way to do that?
 
 The 8 bytes is an IEEE 754-2008 formatted number -- see here for an
 explanation:
  
   http://en.wikipedia.org/wiki/Double_precision
 
 It's not just a simple hex of a decimal...  You've got an exponent and
a
 sign encoded in there too.

OK, that I can understand. However, I don't see where that was expressed
or implied in the original query. Are you assuming that every current
architecture and Perl implementation uses that format to store double
precision numbers? Is that a safe assumption?

Bob McConnell

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Uri Guttman
 BM == Bob McConnell r...@cbord.com writes:

  BM OK, that I can understand. However, I don't see where that was
  BM expressed or implied in the original query. Are you assuming that
  BM every current architecture and Perl implementation uses that
  BM format to store double precision numbers? Is that a safe
  BM assumption?

ieee float format is about the only way anyone does floats today. but
pack actually doesn't even care about the float format. it just copies
the internal float to a place where it can be accessed as a string of
bytes (the string slot in the scalar). you can take any byte string you
want and unpack back into the float slot. the only restriction is the
size and that is usually 8 bytes (a double which is perl's standard
float size). pack supports single precision (4 bytes) as well as long
doubles if your machine supports them.

as for whether this is what the OP wanted, note that he since posted
that he is reading perlpacktut for his answers. someone else already
posted the pack format needed but i wanted him to rtfm and learn more
about pack.

uri

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Bryan R Harris

 Bryan R Harris wrote:
 
 I need to convert a number like this:   -3205.0569059
 ... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a bc 93
 d3  (I just made up those 8 byte values).
 
 Is this easy in perl?  Are long and short ints easy as well?
 
 $ perl -le'print unpack H*, pack d, -3205.0569059'
 e626c5221d0aa9c0


Maybe this is just my own ignorance on big-endian vs. little endian, but
this code:

  print big-endian: , unpack(H*, pack(d, -3205.0569059)), \n;
  print little-endian:  , unpack(h*, pack(d, -3205.0569059)), \n;

prints:

  big-endian: e626c5221d0aa9c0
  little-endian:  6e625c22d1a09a0c

... when I expected the little endian to look more like:

  c0 a9 0a 1d 22 c5 26 e6   (spacing for readability)

Did I do it wrong (i.e. is h* the wrong string?), or am I confused on how
big vs. little endian works?

Thanks again for the help!!  This list is terrific!

- Bryan




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Chas. Owens
On Wed, Sep 23, 2009 at 17:00, Bryan R Harris
bryan_r_har...@raytheon.com wrote:

 Bryan R Harris wrote:

 I need to convert a number like this:   -3205.0569059
 ... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a bc 93
 d3  (I just made up those 8 byte values).

 Is this easy in perl?  Are long and short ints easy as well?

 $ perl -le'print unpack H*, pack d, -3205.0569059'
 e626c5221d0aa9c0


 Maybe this is just my own ignorance on big-endian vs. little endian, but
 this code:

  print big-endian:     , unpack(H*, pack(d, -3205.0569059)), \n;
  print little-endian:  , unpack(h*, pack(d, -3205.0569059)), \n;

 prints:

  big-endian:     e626c5221d0aa9c0
  little-endian:  6e625c22d1a09a0c

 ... when I expected the little endian to look more like:

  c0 a9 0a 1d 22 c5 26 e6   (spacing for readability)

 Did I do it wrong (i.e. is h* the wrong string?), or am I confused on how
 big vs. little endian works?
snip

h* and H* have nothing to do with endianness.  From the docs:

   h   A hex string (low nybble first).
   H   A hex string (high nybble first).

Endianness occurs at the byte level, not the nybble level.


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Uri Guttman
 BRH == Bryan R Harris bryan_r_har...@raytheon.com writes:

  BRH Maybe this is just my own ignorance on big-endian vs. little endian, but
  BRH this code:

  BRH   print big-endian: , unpack(H*, pack(d, -3205.0569059)), \n;
  BRH   print little-endian:  , unpack(h*, pack(d, -3205.0569059)), \n;

  BRH prints:

  BRH   big-endian: e626c5221d0aa9c0
  BRH   little-endian:  6e625c22d1a09a0c

note that those are the same bytes but each byte is printed with
different ordering for the hex digits.

the docs say this:

   h   A hex string (low nybble first).
   H   A hex string (high nybble first).

and a nybble (or nibble) is a single hex digit of 4 bits and there are
two in a byte. the h vs H only changes the nibble order in a byte. this
has nothing to do with endian issues which are a byte ordering thing.

pack doesn't have a direct way to deal with endians with floats. you can
just use reverse on the byte string to control that. that is what i do
in Sort::Maker for this. did you look at that module yet? as i keep
saying it does exactly what you are trying to do so you can learn from it.

uri

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread John W. Krahn

Bryan R Harris wrote:

John W. Krahn wrote:

Bryan R Harris wrote:


I need to convert a number like this:   -3205.0569059
... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a bc 93
d3  (I just made up those 8 byte values).

Is this easy in perl?  Are long and short ints easy as well?

$ perl -le'print unpack H*, pack d, -3205.0569059'
e626c5221d0aa9c0



Maybe this is just my own ignorance on big-endian vs. little endian, but
this code:

  print big-endian: , unpack(H*, pack(d, -3205.0569059)), \n;
  print little-endian:  , unpack(h*, pack(d, -3205.0569059)), \n;

prints:

  big-endian: e626c5221d0aa9c0
  little-endian:  6e625c22d1a09a0c

... when I expected the little endian to look more like:

  c0 a9 0a 1d 22 c5 26 e6   (spacing for readability)

Did I do it wrong (i.e. is h* the wrong string?), or am I confused on how
big vs. little endian works?


The difference between 'h' and 'H' has nothing to do with endianness:

perldoc -f pack
[ SNIP ]
   h   A hex string (low nybble first).
   H   A hex string (high nybble first).


A nybble is half of a byte so the only thing exchanged is the order of 
each byte's two halves.


AFAIK floating point numbers don't have endianness (but I may be wrong.)
(Besides, in the above example, endianness would be on the pack('d') 
side of the equation.)




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.   -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Uri Guttman
 JWK == John W Krahn jwkr...@shaw.ca writes:

  JWK AFAIK floating point numbers don't have endianness (but I may be wrong.)
  JWK (Besides, in the above example, endianness would be on the pack('d')
  JWK side of the equation.)

floats are no different than integers in that you must select the
ordering of their bytes when stored in ram. this is done naturally at
the machine level but if you want to control endianess with floats in
perl you need to use reverse at some point.

uri

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Shawn H Corey

Bryan R Harris wrote:

Bryan R Harris wrote:

I need to convert a number like this:   -3205.0569059
... into an 8-byte double (big and little endian), e.g. 4f 3e 52 00 2a bc 93
d3  (I just made up those 8 byte values).

Is this easy in perl?  Are long and short ints easy as well?

$ perl -le'print unpack H*, pack d, -3205.0569059'
e626c5221d0aa9c0



Maybe this is just my own ignorance on big-endian vs. little endian, but
this code:

  print big-endian: , unpack(H*, pack(d, -3205.0569059)), \n;
  print little-endian:  , unpack(h*, pack(d, -3205.0569059)), \n;

prints:

  big-endian: e626c5221d0aa9c0
  little-endian:  6e625c22d1a09a0c

... when I expected the little endian to look more like:

  c0 a9 0a 1d 22 c5 26 e6   (spacing for readability)

Did I do it wrong (i.e. is h* the wrong string?), or am I confused on how
big vs. little endian works?

Thanks again for the help!!  This list is terrific!


From `perldoc -f pack`:

Real numbers (floats and doubles) are in the native machine format only; 
due to the multiplicity of floating formats around, and the lack of a 
standard network representation, no facility for interchange has been 
made.  This means that packed floating point data written on one machine 
may not be readable on another - even if both use IEEE floating point 
arithmetic (as the endian-ness of the memory representation is not part 
of the IEEE spec).  See also perlport.




--
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Chas. Owens
On Wed, Sep 23, 2009 at 15:53, Bob McConnell r...@cbord.com wrote:
snip
 OK, that I can understand. However, I don't see where that was expressed
 or implied in the original query. Are you assuming that every current
 architecture and Perl implementation uses that format to store double
 precision numbers? Is that a safe assumption?

 Bob McConnell
snip

No, it is not safe to assume that the value you get from pack will
work on another platform.  The pack function claims that d creates a
native-floating point number as a string of bytes.  This means you are
dependent on the native implementations of floating point numbers
being the same between systems.  However, a quick sample of OS X 10.5
(x86), a variety of Linuxes (x86), Win32 (x86), and FreeBsd (x86)
shows that it works across a wide swath of what one generally works
with.  The Power PC machine machine I have access to (running OS X)
works if you reverse the bytes.


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Burnt Camel Club

2009-09-23 Thread Mike McClain
On Tue, Sep 22, 2009 at 08:55:32AM -0500, Ian wrote:
 On Mon, Sep 21, 2009 at 10:09 PM, Randal L. Schwartz
 mer...@stonehenge.comwrote:
 
  Yup.  I care when it might harm others.  Otherwise, I tend not to
  talk... plenty of other people here to give answers.  I only doublecheck
  answers anymore.
 
 
 Yes, that is why this list gets 5 emails on average per day and other
 comparable language lists gets 40.
 Keep it up and the hollier-than-though's will have the list to themselves
 eventually.

Don't kid your self as long as there are people like me who are
trying to get a handle on Perl, this list will stay active.
One of the best math teachers I had in high school was a birch and 
hadn't changed since she taught my ma. Mom and I both learned math
from her though.

 Ian

Mike
-- 
Satisfied user of Linux since 1997.
O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: best way to get number of elements in list value

2009-09-23 Thread Mike McClain
On Tue, Sep 22, 2009 at 05:09:26AM -0400, Shawn H Corey wrote:
 Roman Makurin wrote:
 Hi All!
 
 right now im doing it in following way:
 $size = @{[func_that_return_list_value]};
 
 is there any best way to do it ? 
 
 See `perldoc -f scalar`  http://perldoc.perl.org/functions/scalar.html

I read the perldoc on scaler and then tried every combination 
I could think of:

perl -le ' sub farr{ return qw( k l m ); }
$a = @{[farr]};
$b = scalar farr;
$c = scalar (farr);
$d = scalar [farr];
$e = scalar @{farr};
$f = scalar @{[farr]};
$g = () = farr;
print \n\$a = $a, \$b = $b, \$c = $c, \$d = $d, \$e = $e, \$f = $f, \$g = $g;'

$a = 3, $b = m, $c = m, $d = ARRAY(0x814f8e4), $e = 0, $f = 3, $g = 3

Unless there is a syntax I've missed, only a, f  g give the desired answer.
To my thinking a is clearly preferable to f but the winner has to be g.
=()= is much more legible than @{[]}, less prone to mistyping.

Thank you Paul Johnson for bringing this to my attention.

The original question was what's 'best'.
Does anyone know of a case where one of these expressions would fail?

TIA,
Mike
-- 
Satisfied user of Linux since 1997.
O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: best way to get number of elements in list value

2009-09-23 Thread Chas. Owens
On Wed, Sep 23, 2009 at 19:16, Mike McClain mike.j...@nethere.com wrote:
 On Tue, Sep 22, 2009 at 05:09:26AM -0400, Shawn H Corey wrote:
 Roman Makurin wrote:
 Hi All!
 
 right now im doing it in following way:
 $size = @{[func_that_return_list_value]};
 
 is there any best way to do it ?
 
 See `perldoc -f scalar`  http://perldoc.perl.org/functions/scalar.html

 I read the perldoc on scaler and then tried every combination
 I could think of:

 perl -le ' sub farr{ return qw( k l m ); }
 $a = @{[farr]};
 $b = scalar farr;
 $c = scalar (farr);
 $d = scalar [farr];
 $e = scalar @{farr};
 $f = scalar @{[farr]};
 $g = () = farr;
 print \n\$a = $a, \$b = $b, \$c = $c, \$d = $d, \$e = $e, \$f = $f, \$g = 
 $g;'

 $a = 3, $b = m, $c = m, $d = ARRAY(0x814f8e4), $e = 0, $f = 3, $g = 3

 Unless there is a syntax I've missed, only a, f  g give the desired answer.
 To my thinking a is clearly preferable to f but the winner has to be g.
 =()= is much more legible than @{[]}, less prone to mistyping.

 Thank you Paul Johnson for bringing this to my attention.

 The original question was what's 'best'.
 Does anyone know of a case where one of these expressions would fail?
snip

Both the a and g cases only work because the assignment provides
scalar context.  Failure to recognize this may cause you to write

my %h = (
a = @{[farr]},
g = () = farr,
);

which results in either an error (if farr returns an even number), or
worse, a very odd hash:

my %h = (
  'a' = 'k',
  'l' = 'm',
  'g' = undef
);

The solution is to force scalar context with scalar:

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

sub farr { return qw/k l m/ }

my %h = (
a = scalar @{[farr]},
g = scalar(() = farr),
);

print Dumper \%h;

Of course, the best solution is to make farr context aware with the
poorly named [wantarray][1]:
#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

sub farr {
my @a = qw/k l m/;
return wantarray ? @a : scalar @a;
}

my @list  = farr;
my $count = farr;

print [...@list] has $count items\n;

my %h = (
h = scalar farr,
);

print Dumper \%h;

[1] : http://perldoc.perl.org/functions/wantarray.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: decimal to binary?

2009-09-23 Thread Bryan R Harris

 BRH == Bryan R Harris bryan_r_har...@raytheon.com writes:
 
   BRH Maybe this is just my own ignorance on big-endian vs. little endian,
 but
   BRH this code:
 
   BRH   print big-endian: , unpack(H*, pack(d, -3205.0569059)),
 \n;
   BRH   print little-endian:  , unpack(h*, pack(d, -3205.0569059)),
 \n;
 
   BRH prints:
 
   BRH   big-endian: e626c5221d0aa9c0
   BRH   little-endian:  6e625c22d1a09a0c
 
 note that those are the same bytes but each byte is printed with
 different ordering for the hex digits.
 
 the docs say this:
 
h   A hex string (low nybble first).
H   A hex string (high nybble first).
 
 and a nybble (or nibble) is a single hex digit of 4 bits and there are
 two in a byte. the h vs H only changes the nibble order in a byte. this
 has nothing to do with endian issues which are a byte ordering thing.
 
 pack doesn't have a direct way to deal with endians with floats. you can
 just use reverse on the byte string to control that. that is what i do
 in Sort::Maker for this. did you look at that module yet? as i keep
 saying it does exactly what you are trying to do so you can learn from it.


Ah, this is the key I was missing!  Thanks.  Now I'm getting this:

value:  -3205.0569059
  big-endian: c0 a9 0a 1d 22 c5 26 e6
  little-endian:  e6 26 c5 22 1d 0a a9 c0

I'm not sure whether I have my endians switched, but I'm putting my chances
of being right here at a little better than 50%.  =)  (Actually, I see your
$IS_BIG_ENDIAN check at the beginning of Sort::Maker, and borrowing that, I
think my chances are much better now that I got it right.)

As for looking at Sort::Maker, I have to admit I was a little scared at
first.  It's not obvious to me why you'd need to be packing doubles for a
sort routine, and I feared I'd get lost in the code...  That said, I found
the reverse part and it looked easy, so that's what I needed.

I think I'm good.  Thanks again to all.  Hope this makes good list-archives
fodder.

- Bryan






-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Automating for the SNMPv3 query and trap

2009-09-23 Thread Rachit Gupta
HI All,
I want to write perl script to automate SNMPv3 query and traps. Is there any
module that can be use for the same? Also what are the different functions
for the query / MIB file compilation and traps?

Please suggest

-- 
Rachit Gupta
r.rac...@gmail.com
91-9873242190


Re: How to provide editor environment on STDIN

2009-09-23 Thread Harry Putnam

Harry wrote:
 In shell scripting, at least with bash, taking input from user is done
 with `read line' but you can say 'read -e line' and the input is
 suddenly done with bash completion.. and I think a few other niceties.

 Is there something similar in perl?

Chas O. answered
 snip
 Take a look at [Term::Readline][1], [Term::Readline::GNU][2], and
 [Term::Readline::Perl][3].

 I'm sad to say after installing Term::ReadLine::Gnu and looking at the
 the 1014 lines of perldoc Term::ReadLine::Gnu..
 snip

[...] snipped nifty code.

 Haa... yes of course a much smarter approach thanks..

I'm integrating this new stuff into my homeboy script.  In that usage
I really want to write to a final target file with a certain format.

Like:

Keywords: SOME KEY WORDS ON THIS LINE
  [Keydate:FORMATTED DATE]
any more content from the for the target file


So there is a `keyword' line followed by a formatted date line.
Followed by any other commentary, followed by a `' delimiter on a
line by itself.

The target file is a very basic data base where I keep snippets of info
I want to be able to find later.  The file is thousands of lines long
so not something I want load.

Another homeboy script does a few different kinds of search functions
on this flat file db and spits out the hits along with the whole keywords
and date entry.

Below I've included a test script where I try to integrate your
suggestions and a version of your code that I've seriously meddled
with.

This is an edited down version of what would really go in the main
script. 

I added the file extension only because I'll be using emacs as the
invoked editor and that extension will make emacs set a few handy
things that are useful in a plain text message, like line wrapping 
and abbrev completions.  

I tinkered around trying to use the notation you used in your example
on file opening:
( `open my $fh, , $tmpfile' ) and other places

but stumbled with it and finally reverted to something I'm used to.
Mainly to get this posted and have a chance to hear any other advice
you might have.

But on that notation point, when using a variable to represent the FH,
like in the notation you showed, how do you later refer to it in a
print statement when you want to direct the print to the FH? Like:

   print FH something\n;

= * = * = * =
 
Here is a test script trying to integrate what you've shown but aim it
at an intended target.  And format the input somewhat.  Using the
first line of input as the `Keywords' line.

It works in my tests and will be a welcome improvement in that much
used script... but wondering if there are better ways to accomplish 
the goal?

#!/usr/local/bin/perl

use strict;
use warnings;

use File::Temp qw/tempfile/;

my $ext = '.txt';

#this is the safest way to get a temporary filename
my $tmpfile = do {
   my ($fh, $filename) = tempfile();
   close $fh;
   $filename;
};

$tmpfile = $tmpfile . $ext;

my $editor = $ENV{EDITOR} || /usr/bin/vim;

system($editor, $tmpfile) == 0
   or die error occured while trying to run editor\n;

my @contents;
open(TMPFILE,$tmpfile)
or die could not open $tmpfile: $!\n;

## Where editor content is really headed
my $ActualTarget = './misc-snp';
open(ACTUAL_TARGET,$ActualTarget)
or die Can't open $ActualTarget : $!;

my $paddedds = '';
while(TMPFILE){
  if($. == 1){
print ACTUAL_TARGET Keywords: $_;
next;
  }
  if($. == 2){
print ACTUAL_TARGET  [Keydate: . PaddedDateStr() . ]\n$_;
$paddedds = TRUE;
next;
  }
  print ACTUAL_TARGET $_;
} 
## If the padded date string didn't get printed yet, do so now.
if(!$paddedds){
print ACTUAL_TARGET  [Keydate: . PaddedDateStr() . ]\n;
}
## Close the entry with double ampersands on a line by themselves.
print ACTUAL_TARGET  \n;
close(ACTUAL_TARGET);

unlink $tmpfile
   or die could not delete $tmpfile: $!;

sub PaddedDateStr {
  my ($mon,$mday,$year,$hour,$min,$sec,$wday) = 
(localtime(time))[4,3,5,2,1,0,6];
  $year -= 100;  
  $mon  += 1;
  my $PaddedDateStr = sprintf %02d%02d%02d%s%02d%02d%02d%s%d, $mon,
  $mday,$year,_,$hour,$min,$sec,_,$wday;
  return $PaddedDateStr;
}


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/