![]() |
| ||
| How to pass a shell variable to a perl command I have defined a variable in bash $ MYDATESTAMP="2009-06-25 21:57:18" I would like to pass this to perl to perform a simple date conversion. If I enter the date manually it works. $ perl -MDate::Parse -le'print str2time("2009-06-25 21:57:18");'My attempts to pass the variable MYDATESTAMP into this command it returns nothing. $ perl -MDate::Parse -le'print str2time("$MYDATESTAMP");'How can this be done? |
| ||
| Re: How to pass a shell variable to a perl command Ok, I figured out a way to do this. It's not elegant, but it managed to get the job done. What I did was echo the $MYDATESTAMP variable from bash into a file named mydatestamp.txt and had a tiny perl script which I named "foo.pl" read that file and then perform the date format conversion. bash #echo the datestamp to a text file. foo.pl (perl) #!/usr/bin/perl |
| ||
| Re: How to pass a shell variable to a perl command export the variable and use $ENV: sk@sk:~$ export MYDATESTAMP="2009-06-25 21:57:18" |
| ||
| Re: How to pass a shell variable to a perl command Thanks! That's much better than my caveman solution. |
| All times are GMT -4. The time now is 1:24 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC