|
|
How to setup when "Can't locate Date/Simple.pm in @INC"
Hi All
AIX 5.3
My ID is root id. Just Normal user.
j=$( perl <<-'EOF'
use strict;
use Date::Simple
my ($count) ;
$count=5;
print "$count";
EOF
)
with below error, How to setup @INC
Can't locate Date/Simple.pm in @INC (@INC contains: /usr/opt/perl5/lib/
5.8.8/aix-thread-multi /usr/opt/perl5/l
ib/5.8.8 /usr/opt/perl5/lib/site_perl/5.8.8/aix-thread-multi /usr/opt/
perl5/lib/site_perl/5.8.8 /usr/opt/perl5
/lib/site_perl .) at - line 3.
BEGIN failed--compilation aborted at - line 3.
|
|
0
|
|
|
|
Reply
|
moonhkt (146)
|
6/6/2011 2:52:29 PM |
|
moonhkt <moonhkt@gmail.com> wrote:
> use Date::Simple
Statements in Perl end with a semicolon.
> print "$count";
perldoc -q vars
What's wrong with always quoting "$vars"?
So that should be just:
print $count;
> How to setup @INC
perldoc -q INC
How do I add a directory to my include path (@INC) at runtime?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
|
|
0
|
|
|
|
Reply
|
tadmc (542)
|
6/6/2011 3:44:10 PM
|
|
On Jun 6, 11:44=A0pm, Tad McClellan <ta...@seesig.invalid> wrote:
> moonhkt <moon...@gmail.com> wrote:
> > =A0 =A0use Date::Simple
>
> Statements in Perl end with a semicolon.
>
> > =A0 print "$count";
>
> =A0 =A0 perldoc -q vars
>
> =A0 =A0 What's wrong with always quoting "$vars"?
>
> So that should be just:
>
> =A0 =A0 print $count;
>
> > How to setup @INC
>
> =A0 =A0 perldoc -q INC
>
> =A0 =A0 How do I add a directory to my include path (@INC) at runtime?
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
> The above message is a Usenet post.
> I don't recall having given anyone permission to use it on a Web site.
Thank for your suggestion. Also, Do you know how to parameter
parameter to perl script with below format ?
My perl script updated.
XVAL=3D$1 ; export XVAL
j=3D$( perl <<-'EOF'
use strict;
use POSIX qw( strftime );
use Getopt::Std;
my ($ymd,$i) ;
$i=3D$ENV{'XVAL'};
$ymd=3Dstrftime("%Y/%m/%d",localtime(time + $i *86400));
print $ymd;
EOF
)
|
|
0
|
|
|
|
Reply
|
moonhkt (146)
|
6/7/2011 12:58:44 AM
|
|
moonhkt schrieb:
> Thank for your suggestion. Also, Do you know how to parameter
> parameter to perl script with below format ?
>
> My perl script updated.
>
> XVAL=$1 ; export XVAL
> j=$( perl <<-'EOF'
> use strict;
> use POSIX qw( strftime );
> use Getopt::Std;
> my ($ymd,$i) ;
> $i=$ENV{'XVAL'};
> $ymd=strftime("%Y/%m/%d",localtime(time + $i *86400));
> print $ymd;
> EOF
> )
>
Hi moonhkt,
if you only want to get the date string returned into the bash variable,
then you can omit the whole set/read from environment stuff and strip
down the code block like this:
# See $1 near "*86400"
j=$( perl <<EOF
use strict;
use POSIX qw( strftime );
print strftime("%Y/%m/%d",localtime(time + $1 *86400));
EOF
)
Now $j holds the date string ;-)
|
|
0
|
|
|
|
Reply
|
peter.tuente1 (3)
|
6/8/2011 3:48:28 PM
|
|
On Jun 8, 11:48=A0pm, Peter Tuente <peter.tue...@materna.de> wrote:
> moonhkt schrieb:
>
>
>
>
>
>
>
> > Thank for your suggestion. Also, Do you know how to parameter
> > parameter to perl script with below format ?
>
> > My perl script updated.
>
> > XVAL=3D$1 ; export XVAL
> > j=3D$( perl =A0<<-'EOF'
> > =A0 use strict;
> > =A0 use POSIX qw( strftime );
> > =A0 use Getopt::Std;
> > =A0 my ($ymd,$i) ;
> > =A0 $i=3D$ENV{'XVAL'};
> > =A0 $ymd=3Dstrftime("%Y/%m/%d",localtime(time + $i *86400));
> > =A0 print $ymd;
> > EOF
> > )
>
> Hi moonhkt,
>
> if you only want to get the date string returned into the bash variable,
> then you can omit the whole set/read from environment stuff and strip
> down the code block like this:
>
> # See $1 near "*86400"
> j=3D$( perl <<EOF
> =A0 =A0use strict;
> =A0 =A0use POSIX qw( strftime );
> =A0 =A0print strftime("%Y/%m/%d",localtime(time + $1 *86400));
> EOF
> )
>
> Now $j holds the date string ;-)
Thank.
It works only. Why need changed "-"EOF" to EOF ?
|
|
0
|
|
|
|
Reply
|
moonhkt (146)
|
6/9/2011 2:37:13 PM
|
|
moonhkt schrieb:
> It works only. Why need changed "-"EOF" to EOF ?
Hi moonhkt,
when using $1 for the calculation, both flavours work.
But when using a bash variable OFFSET=$1 for the calculation, you'll see
the difference.
1) The shell variable $OFFSET inside the "here" document started with
<<EOF gets replaced by its value, before perl is called with the
resulting here document.
# OK, yields: Date string
OFFSET=$1
perl <<EOF
use strict;
use POSIX qw( strftime );
print strftime("%Y-%m-%d",localtime(time + $OFFSET *86400)) . "\n";
EOF
2) The shell variable $OFFSET does not get replaced by its value
# Error: Perl doesn't recognize variable $OFFSET
OFFSET=$1
perl <<'EOF'
use strict;
use POSIX qw( strftime );
print strftime("%Y-%m-%d",localtime(time + $OFFSET *86400)) . "\n";
EOF
HTH
PiT
|
|
0
|
|
|
|
Reply
|
peter.tuente1 (3)
|
6/9/2011 3:18:04 PM
|
|
|
5 Replies
83 Views
(page loaded in 0.121 seconds)
|
|
|
|
|
|
|
|
|