03-02-2009
'vars' has been considered deprecated for years now. 'our' should be used unless your using an old version of perl or legacy perl programs.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
What is the difference between a shell variable that is exported and the one that is not exported? (1 Reply)
Discussion started by: JosephGerard
1 Replies
2. Shell Programming and Scripting
Hi
I have a file which has start time as my first line and End time in last line
start time: 23 May 2008 03:30:33
End time : 23 May 2008 04:30:00
I have to extract these two lines and find the time of execution for the script in PERl.
Any help appreciated
Thanks (1 Reply)
Discussion started by: usshell
1 Replies
3. Shell Programming and Scripting
I am using two shell scripts a.ksh and b.ksh
a.ksh
1. Sets the value
+++++++++++++++++
export USER1=abcd1
export PASSWORD=xyz
+++++++++++++++++
b.ksh
2. Second scripts calls sctipt a.ksh and uses the values set in a.ksh and pass to an executable demo... (2 Replies)
Discussion started by: kunalseth
2 Replies
4. Shell Programming and Scripting
Hi,
Is there any way I can get the difference between two dates in terms of days?
I have used this method so far, but I cant format it in terms of days.
@a=&DateCalc($date1,$date2,0);
The o/p that I am getting is sort of like this:
+0:0:0:4:0:0:0
I just want to get 4 days as an o/p.... (1 Reply)
Discussion started by: King Nothing
1 Replies
5. Shell Programming and Scripting
I having probelm in time difference output using Delta_YMDHMS, using below start date and enddate I get -30days. Any idea how to fix this issue.
output : 0,1,-30, 0,0,0
Thanks,
Bataf
use POSIX qw/strftime/;
use Date::Calc qw(Delta_YMDHMS);
use Time::Local;
$start_date =... (1 Reply)
Discussion started by: bataf
1 Replies
6. Shell Programming and Scripting
Hi,
I have 2 arrays:
@a=qw(19190289 18381856 12780546 10626296 9337410 8850557 7740161 8101063);
@b=qw(18309897 17612870 10626296 16871843 7740161 19947571 18062861);
$len=@a;
print "<br> length of array1: $len<br>";
$len1=@b;
print "<br> length of array2: $len1<br>";
The output... (3 Replies)
Discussion started by: vanitham
3 Replies
7. Shell Programming and Scripting
I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example:
$ mgenv.sh prod
This would set environment variables for prod
$ mgenv.sh test
This would set environment variables... (1 Reply)
Discussion started by: brtaylor73
1 Replies
8. Shell Programming and Scripting
I need to process a file line-by-line using some value from a shell variable
Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt
I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.)
I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies
9. Shell Programming and Scripting
Hi I have the following issue.
the headeer in the file contains as follows
IMAHDR tsmdsl01 EMBS_DAT 20120911 20120911
233656S000000000000000 001
So the fifth field in the header is a string that represents the file arrival date.(20120911) yyyyMMDD
I just need to compare... (1 Reply)
Discussion started by: ptappeta
1 Replies
10. Shell Programming and Scripting
Hi All,
I am using the below code to get the days difference between 2 dates
ddate="05/31/2018"
bdate="06/10/2018"
diff=$(perl -e 'use Time::Local;
my ($month1,$day1,$year1)=split /\W+/, $ENV{'ddate'};
my ($month2,$day2,$year2)=split /\W+/, $ENV{'bdate'};
my $time1 =... (5 Replies)
Discussion started by: jayadanabalan
5 Replies
LEARN ABOUT MOJAVE
strict
strict(3pm) Perl Programmers Reference Guide strict(3pm)
NAME
strict - Perl pragma to restrict unsafe constructs
SYNOPSIS
use strict;
use strict "vars";
use strict "refs";
use strict "subs";
use strict;
no strict "vars";
DESCRIPTION
If no import list is supplied, all possible restrictions are assumed. (This is the safest mode to operate in, but is sometimes too strict
for casual programming.) Currently, there are three possible things to be strict about: "subs", "vars", and "refs".
"strict refs"
This generates a runtime error if you use symbolic references (see perlref).
use strict 'refs';
$ref = $foo;
print $$ref; # ok
$ref = "foo";
print $$ref; # runtime error; normally ok
$file = "STDOUT";
print $file "Hi!"; # error; note: no comma after $file
There is one exception to this rule:
$bar = &{'foo'};
&$bar;
is allowed so that "goto &$AUTOLOAD" would not break under stricture.
"strict vars"
This generates a compile-time error if you access a variable that was neither explicitly declared (using any of "my", "our", "state",
or "use vars") nor fully qualified. (Because this is to avoid variable suicide problems and subtle dynamic scoping issues, a merely
"local" variable isn't good enough.) See "my" in perlfunc, "our" in perlfunc, "state" in perlfunc, "local" in perlfunc, and vars.
use strict 'vars';
$X::foo = 1; # ok, fully qualified
my $foo = 10; # ok, my() var
local $baz = 9; # blows up, $baz not declared before
package Cinna;
our $bar; # Declares $bar in current package
$bar = 'HgS'; # ok, global declared via pragma
The local() generated a compile-time error because you just touched a global name without fully qualifying it.
Because of their special use by sort(), the variables $a and $b are exempted from this check.
"strict subs"
This disables the poetry optimization, generating a compile-time error if you try to use a bareword identifier that's not a
subroutine, unless it is a simple identifier (no colons) and that it appears in curly braces or on the left hand side of the "=>"
symbol.
use strict 'subs';
$SIG{PIPE} = Plumber; # blows up
$SIG{PIPE} = "Plumber"; # just fine: quoted string is always ok
$SIG{PIPE} = &Plumber; # preferred form
See "Pragmatic Modules" in perlmodlib.
HISTORY
"strict 'subs'", with Perl 5.6.1, erroneously permitted to use an unquoted compound identifier (e.g. "Foo::Bar") as a hash key (before "=>"
or inside curlies), but without forcing it always to a literal string.
Starting with Perl 5.8.1 strict is strict about its restrictions: if unknown restrictions are used, the strict pragma will abort with
Unknown 'strict' tag(s) '...'
As of version 1.04 (Perl 5.10), strict verifies that it is used as "strict" to avoid the dreaded Strict trap on case insensitive file
systems.
perl v5.18.2 2014-01-06 strict(3pm)