10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
This basic code works.
I have a very long list, almost 10000 lines that I am building into the array. Each line has either 2 or 3 fields as shown in the code snippit. The array elements are static (for a few reasons that out of scope of this question) the list has to be "built in".
It... (5 Replies)
Discussion started by: sumguy
5 Replies
2. Shell Programming and Scripting
Hi ,
I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code.
my $current_value=12345;
my @users=("bob","ben","tom","harry");
open DBLIST,"<","/var/tmp/DBinfo";
my @input = <DBLIST>;
foreach (@users)
{
my... (11 Replies)
Discussion started by: chidori
11 Replies
3. Shell Programming and Scripting
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies
4. Shell Programming and Scripting
Hi everyone
I have one question about using array in perl. let say I have several log file in one folder.. example
test1.log
test2.log
test3.log
and the list goes on..
how to make an array for this file? It suppose to detect log file in the current directory and all the log file will... (3 Replies)
Discussion started by: sayachop
3 Replies
5. Shell Programming and Scripting
Hi Everyone,
($total+=$_) for @record;
assume @record=(1,2,3), so the result is 6.
if @record=("1 3","2 3","3 3"), would like to sum up the 2nd field of this array, the result is 9.
i tried " ($total+=$) for @record ", cannot, please advice.
Thanks
---------- Post updated at 03:45... (1 Reply)
Discussion started by: jimmy_y
1 Replies
6. Shell Programming and Scripting
Hi Everyone,
Any simple code can simplify the code below, please advice. Thanks
# cat 2.pl
#!/usr/bin/perl
use warnings;
use strict;
my @aaaaa = <DATA>;
my @uids;
foreach (@aaaaa) {
my @ccccc = split (",", $_);
push @uids, $ccccc;... (3 Replies)
Discussion started by: jimmy_y
3 Replies
7. Shell Programming and Scripting
I'm trying to take the output of an environment that has multiple strings
ex.
# echo $SSH_CLIENT
192.168.1.1 57039 22
I need that IP... so I can set it to another environment.
Thank you (3 Replies)
Discussion started by: adelsin
3 Replies
8. Shell Programming and Scripting
Hi,
Is there any way I can grep an array against another array?
Basically here's what I need to do.
There will be an array containing some fixed texts and I have to check whether some files contain these lines. Reading the same files over and over again for each different pattern doesnt seem... (1 Reply)
Discussion started by: King Nothing
1 Replies
9. Shell Programming and Scripting
I am using a seed file shown below to separate cisco devices by ios/os type. I want to bunch all the devices based on ios/os version. Once I find a match, I only want to push the ip address into the appropriate array.
Example of seedfile
8 host1 (C3500XL-C3H2S-M) 11.0(5)WC17 10.1.44.21
9... (1 Reply)
Discussion started by: popeye
1 Replies
10. Shell Programming and Scripting
normally when i type:
condor_q | tail -1
command line returns:
0 jobs; 0 idle, 0 running, 0 held
I want use the number in front of 'running' in a series of equality tests to submit more jobs when my queue gets low. Someone showed me how to do it a few days ago by setting an array equal to... (4 Replies)
Discussion started by: pattywac
4 Replies
Test::Strict(3pm) User Contributed Perl Documentation Test::Strict(3pm)
NAME
Test::Strict - Check syntax, presence of use strict; and test coverage
SYNOPSIS
"Test::Strict" lets you check the syntax, presence of "use strict;" and presence "use warnings;" in your perl code. It report its results
in standard "Test::Simple" fashion:
use Test::Strict tests => 3;
syntax_ok( 'bin/myscript.pl' );
strict_ok( 'My::Module', "use strict; in My::Module" );
warnings_ok( 'lib/My/Module.pm' );
Module authors can include the following in a t/strict.t and have "Test::Strict" automatically find and check all perl files in a module
distribution:
use Test::Strict;
all_perl_files_ok(); # Syntax ok and use strict;
or
use Test::Strict;
all_perl_files_ok( @mydirs );
"Test::Strict" can also enforce a minimum test coverage the test suite should reach. Module authors can include the following in a
t/cover.t and have "Test::Strict" automatically check the test coverage:
use Test::Strict;
all_cover_ok( 80 ); # at least 80% coverage
or
use Test::Strict;
all_cover_ok( 80, 't/' );
DESCRIPTION
The most basic test one can write is "does it compile ?". This module tests if the code compiles and play nice with "Test::Simple"
modules.
Another good practice this module can test is to "use strict;" in all perl files.
By setting a minimum test coverage through "all_cover_ok()", a code author can ensure his code is tested above a preset level of kwality
throughout the development cycle.
Along with Test::Pod, this module can provide the first tests to setup for a module author.
This module should be able to run under the -T flag for perl >= 5.6. All paths are untainted with the following pattern:
"qr|^([-+@w./:\]+)$|" controlled by $Test::Strict::UNTAINT_PATTERN.
FUNCTIONS
syntax_ok( $file [, $text] )
Run a syntax check on $file by running "perl -c $file" with an external perl interpreter. The external perl interpreter path is stored in
$Test::Strict::PERL which can be modified. You may prefer "use_ok()" from Test::More to syntax test a module. For a module, the path
(lib/My/Module.pm) or the name (My::Module) can be both used.
strict_ok( $file [, $text] )
Check if $file contains a "use strict;" statement. "use Moose" and "use Mouse" are also considered valid.
This is a pretty naive test which may be fooled in some edge cases. For a module, the path (lib/My/Module.pm) or the name (My::Module) can
be both used.
warnings_ok( $file [, $text] )
Check if warnings have been turned on.
If $file is a module, check if it contains a "use warnings;" or "use warnings::..." or "use Moose" or "use Mouse" statement. If the perl
version is <= 5.6, this test is skipped ("use warnings" appeared in perl 5.6).
If $file is a script, check if it starts with "#!...perl -w". If the -w is not found and perl is >= 5.6, check for a "use warnings;" or
"use warnings::..." or "use Moose" or "use Mouse" statement.
This is a pretty naive test which may be fooled in some edge cases. For a module, the path (lib/My/Module.pm) or the name (My::Module) can
be both used.
all_perl_files_ok( [ @directories ] )
Applies "strict_ok()" and "syntax_ok()" to all perl files found in @directories (and sub directories). If no <@directories> is given, the
starting point is one level above the current running script, that should cover all the files of a typical CPAN distribution. A perl file
is *.pl or *.pm or *.t or a file starting with "#!...perl"
If the test plan is defined:
use Test::Strict tests => 18;
all_perl_files_ok();
the total number of files tested must be specified.
You can control which tests are run on each perl site through:
$Test::Strict::TEST_SYNTAX (default = 1)
$Test::Strict::TEST_STRICT (default = 1)
$Test::Strict::TEST_WARNINGS (default = 0)
$Test::Strict::TEST_SKIP (default = []) "Trusted" files to skip
all_cover_ok( [coverage_threshold [, @t_dirs]] )
This will run all the tests in @t_dirs (or current script's directory if @t_dirs is undef) under Devel::Cover and calculate the global test
coverage of the code loaded by the tests. If the test coverage is greater or equal than "coverage_threshold", it is a pass, otherwise it's
a fail. The default coverage threshold is 50 (meaning 50% of the code loaded has been covered by test).
The threshold can be modified through $Test::Strict::COVERAGE_THRESHOLD.
You may want to select which files are selected for code coverage through $Test::Strict::DEVEL_COVER_OPTIONS, see Devel::Cover for the list
of available options. The default is '+ignore,"/Test/Strict"'.
The path to "cover" utility can be modified through $Test::Strict::COVER.
The 50% threshold is a completely arbitrary value, which should not be considered as a good enough coverage.
The total coverage is the return value of "all_cover_ok()".
CAVEATS
For "all_cover_ok()" to work properly, it is strongly advised to install the most recent version of Devel::Cover and use perl 5.8.1 or
above. In the case of a "make test" scenario, "all_perl_files_ok()" re-run all the tests in a separate perl interpreter, this may lead to
some side effects.
SEE ALSO
Test::More, Test::Pod. Test::Distribution, <Test:NoWarnings>
AUTHOR
Pierre Denis, "<pdenis@gmail.com>".
COPYRIGHT
Copyright 2005, 2010 Pierre Denis, All Rights Reserved.
You may use, modify, and distribute this package under the same terms as Perl itself.
perl v5.10.1 2010-02-14 Test::Strict(3pm)