10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I have many folders under which there is always a file with the same name, which contains the data I need to process later. A perl oneliner was borrowed
perl -e 'print "gene_id\t", join("\t", map {/(.*)\//; $1} @ARGV),"\n";' *_test.trim/level.csvto make a header so that each column... (5 Replies)
Discussion started by: yifangt
5 Replies
2. Shell Programming and Scripting
I have a file like
file.
file.TODAY.THISYEAR
file.TODAY.LASTYEARI want to substitute the words in caps with their actual values so that output should look like
file.140805
file.140805.2014
file.140805.2013For this I am reading the file line bye line in an array and using multiple map... (1 Reply)
Discussion started by: sam05121988
1 Replies
3. Shell Programming and Scripting
Hello All,
I am writing the below script where it will connect to database and returns the results.
#!/sw/gcm/perl510/bin/perl
use SybaseC;
&openConnection;
&loadvalues;
sub openConnection {
$dbproc = new SybaseC(SYDB}, $ENV{DBDFLTUSR}, $ENV{DBDFLTPWD});
if... (2 Replies)
Discussion started by: filter
2 Replies
4. Shell Programming and Scripting
Hi,
Please help me to understand the following code:
perl -lne 'print if "$_ " =~ /(5 (?:\d+ ){5})\1/'
What the regular expression "?:" does?
Also, whether the expression "\1" is the same as in sed (i.e) printing the elements inside pair of parentheses? (3 Replies)
Discussion started by: royalibrahim
3 Replies
5. Shell Programming and Scripting
Hi,
In the following perl code:
#!/usr/bin/perl -w
if (open(FILE, "< in_file")) {
while (<FILE>) {
chomp($_);
if ($_ =~ /patt$/) {
my $f = (split(" ", $_));
print "$f\n";
}
}
close FILE;
}
Why changing the "FILE" as... (4 Replies)
Discussion started by: royalibrahim
4 Replies
6. Shell Programming and Scripting
Hi,
I have 2 arrays:
@names=qw(amith veena chaitra);
@files=qw(file.txt file1.txt file3.txt);
There is one to one relationship between names and files.
There needs to be mapping created between names and files.
The output should be like this:
amith --> file.txt
veena --->... (3 Replies)
Discussion started by: vanitham
3 Replies
7. Shell Programming and Scripting
Hi guys,
I'm trying to learn grep and map and having a little problem.
Let's say I have a file which contains:
Apple: abcdcabdadddbac
I want to replace any combinations of three of abcd, thus when I do this:
print grep {s/{3}/X/g} <F>; # will do the subtitution fine, output XXXX
... (1 Reply)
Discussion started by: new bie
1 Replies
8. Shell Programming and Scripting
Anyone please say what is the difference between $var and ${var} in perl
Sometimes $var used and sometimes ${var} used in same program.
Thanks in Advance,
Prabhu
---------- Post updated at 09:34 AM ---------- Previous update was at 05:59 AM ----------
Any one please clarify (1 Reply)
Discussion started by: prsampath
1 Replies
9. Shell Programming and Scripting
Dear friends,
I have two files. In first file first column ($1), i have numbers.
The second file containes, the same number in the fourth column($4).
I need a output file, matching the first file column 1 with second file column 4. The main thing is the output file lines will be sorted... (4 Replies)
Discussion started by: vasanth.vadalur
4 Replies
10. Shell Programming and Scripting
hi all
i wrote a shell script which uses perl script my code is :
>cat filename | while read i
>do
>perl -e 'require "/home/scripts/abc.pl" ; abc("$i")'
>done
perl script used will simply check syntax of Cobol programs but it didn't work for me so i asked my colleague he suggested... (1 Reply)
Discussion started by: zedex
1 Replies
Apache::TestTrace(3) User Contributed Perl Documentation Apache::TestTrace(3)
NAME
Apache::TestTrace - Helper output generation functions
SYNOPSIS
use Apache::TestTrace;
debug "foo bar";
info_sub "missed it";
error_mark "something is wrong";
# test sub that exercises all the tracing functions
sub test {
print $Apache::TestTrace::LogFH
"TraceLevel: $Apache::TestTrace::Level
";
$_->($_,[1..3],$_) for qw(emerg alert crit error
warning notice info debug todo);
print $Apache::TestTrace::LogFH "
"
};
# demo the trace subs using default setting
test();
{
# override the default trace level with 'crit'
local $Apache::TestTrace::Level = 'crit';
# now only 'crit' and higher levels will do tracing lower level
test();
}
{
# set the trace level to 'debug'
local $Apache::TestTrace::Level = 'debug';
# now only 'debug' and higher levels will do tracing lower level
test();
}
{
open OUT, ">/tmp/foo" or die $!;
# override the default Log filehandle
local $Apache::TestTrace::LogFH = *OUT;
# now the traces will go into a new filehandle
test();
close OUT;
}
# override tracing level via -trace opt
% t/TEST -trace=debug
# override tracing level via env var
% env APACHE_TEST_TRACE_LEVEL=debug t/TEST
DESCRIPTION
This module exports a number of functions that make it easier generating various diagnostics messages in your programs in a consistent way
and saves some keystrokes as it handles the new lines and sends the messages to STDERR for you.
This module provides the same trace methods as syslog(3)'s log levels. Listed from low level to high level: emerg(), alert(), crit(),
error(), warning(), notice(), info(), debug(). The only different function is warning(), since warn is already taken by Perl.
The module provides another trace function called todo() which is useful for todo items. It has the same level as debug (the highest).
There are two more variants of each of these functions. If the _mark suffix is appended (e.g., error_mark) the trace will start with the
filename and the line number the function was called from. If the _sub suffix is appended (e.g., error_info) the trace will start with the
name of the subroutine the function was called from.
If you have "Term::ANSIColor" installed the diagnostic messages will be colorized, otherwise a special for each function prefix will be
used.
If "Data::Dumper" is installed and you pass a reference to a variable to any of these functions, the variable will be dumped with
"Data::Dumper::Dumper()".
Functions whose level is above the level set in $Apache::TestTrace::Level become NOPs. For example if the level is set to alert, only
alert() and emerg() functions will generate the output. The default setting of this variable is warning. Other valid values are: emerg,
alert, crit, error, warning, notice, info, debug.
Another way to affect the trace level is to set $ENV{APACHE_TEST_TRACE_LEVEL}, which takes effect if $Apache::TestTrace::Level is not set.
So an explicit setting of $Apache::TestTrace::Level always takes precedence.
By default all the output generated by these functions goes to STDERR. You can override the default filehandler by overriding
$Apache::TestTrace::LogFH with a new filehandler.
When you override this package's global variables, think about localizing your local settings, so it won't affect other modules using this
module in the same run.
TODO
o provide an option to disable the coloring altogether via some flag
or import()
AUTHOR
Stas Bekman with contributions from Doug MacEachern
perl v5.16.2 2011-02-07 Apache::TestTrace(3)