I need a non-perl (bash) way to strip the path from a list of "find" results. Below is the perl version which I could use, if I could figure out how to call the script with a variable (like in sh, $1 is the variable passed in ./script variable)
$file = "/path/to/file.txt";
# How do I... (2 Replies)
Hi All,
I am calling a perl program in my shell script as follows.
MY_IN_FILE=ABC.dat
MY_OUT_FILE=XYZ.dat
MY_VARIABLE="SomeValue"
perl mycode.pl $MY_IN_FILE > $MY_OUT_FILE
Question:-
Now I want to pass value of $MY_VARIABLE from script to perl... How do I do that? Can someone... (5 Replies)
Hi All,
I am learning PERL for one of the projects, and in one of these scripts, I read a flat text file and print in the terminal.
The problem is, the text file has a date field. The format is yyyymmdd. I need to display this as dd-mon-yyyy.
Any ideas to do this? Thanks a lot for the... (9 Replies)
Hi all,
i had a code where in user will enter a date in yyyymmdd format.. i didnt use any validation for the date and now the problem is if a user enters date instead of month after year it is proceeding with the code..
like if the date is 20120426 and if the user enters 20122604 it... (4 Replies)
I have an Excel 2007 excel sheet on windows machine and using
Spreadsheet::XLSX I had written a script to read the excel sheet and was successful.
My requirement is I need to generate another excel sheet from the old excel 2007 sheet on unix machine.
Now is it possible to read the excel... (2 Replies)
my $sysdate = strftime('%Y-%m-%d', localtime );
biDeriveByDate('Table_Str',$sysdate,\@lIndx,\@lResVals)
In a perl script, when I'm trying to pass $sysdate to some external function it's not working since $sysdate is passed as a string mentioned above but my function is expecting a date value... (1 Reply)
hello,
i have a lot of C old code I'm updating to C11 with tgmath.h for generic math. the old code has very specific types, real and complex, like cabsl, csinhl, etc
usually for simple bulk replacements i would do something simple like this
perl -pi -e 's/cosl/cos/g' *.c
the reference... (0 Replies)
Hi All,
I have line
,A,FDRM0002,12/21/2017,,0.961751583,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
it contains date in mm/dd/yyyy format i want to change this to yyyymmdd format using perl.
Use code tags, thanks. (8 Replies)
The below perl script parses a variety of formats. If I use the numeric text file as input the script works correctly. However using the alpha text file as input there is a black output file. The portion in bold splits the field to parse f or NC_000023.10:g.153297761C>A into a variable $common but... (3 Replies)
Discussion started by: cmccabe
3 Replies
LEARN ABOUT MOJAVE
tap::parser::sourcehandler
TAP::Parser::SourceHandler(3pm) Perl Programmers Reference Guide TAP::Parser::SourceHandler(3pm)NAME
TAP::Parser::SourceHandler - Base class for different TAP source handlers
VERSION
Version 3.26
SYNOPSIS
# abstract class - don't use directly!
# see TAP::Parser::IteratorFactory for general usage
# must be sub-classed for use
package MySourceHandler;
use base qw( TAP::Parser::SourceHandler );
sub can_handle { return $confidence_level }
sub make_iterator { return $iterator }
# see example below for more details
DESCRIPTION
This is an abstract base class for TAP::Parser::Source handlers / handlers.
A "TAP::Parser::SourceHandler" does whatever is necessary to produce & capture a stream of TAP from the raw source, and package it up in a
TAP::Parser::Iterator for the parser to consume.
"SourceHandlers" must implement the source detection & handling interface used by TAP::Parser::IteratorFactory. At 2 methods, the
interface is pretty simple: "can_handle" and "make_source".
Unless you're writing a new TAP::Parser::SourceHandler, a plugin, or subclassing TAP::Parser, you probably won't need to use this module
directly.
METHODS
Class Methods
"can_handle"
Abstract method.
my $vote = $class->can_handle( $source );
$source is a TAP::Parser::Source.
Returns a number between 0 & 1 reflecting how confidently the raw source can be handled. For example, 0 means the source cannot handle it,
0.5 means it may be able to, and 1 means it definitely can. See "detect_source" in TAP::Parser::IteratorFactory for details on how this is
used.
"make_iterator"
Abstract method.
my $iterator = $class->make_iterator( $source );
$source is a TAP::Parser::Source.
Returns a new TAP::Parser::Iterator object for use by the TAP::Parser. "croak"s on error.
SUBCLASSING
Please see "SUBCLASSING" in TAP::Parser for a subclassing overview, and any of the subclasses that ship with this module as an example.
What follows is a quick overview.
Start by familiarizing yourself with TAP::Parser::Source and TAP::Parser::IteratorFactory. TAP::Parser::SourceHandler::RawTAP is the
easiest sub-class to use an an example.
It's important to point out that if you want your subclass to be automatically used by TAP::Parser you'll have to and make sure it gets
loaded somehow. If you're using prove you can write an App::Prove plugin. If you're using TAP::Parser or TAP::Harness directly (e.g.
through a custom script, ExtUtils::MakeMaker, or Module::Build) you can use the "config" option which will cause "load_sources" in
TAP::Parser::IteratorFactory to load your subclass).
Don't forget to register your class with "register_handler" in TAP::Parser::IteratorFactory.
Example
package MySourceHandler;
use strict;
use vars '@ISA'; # compat with older perls
use MySourceHandler; # see TAP::Parser::SourceHandler
use TAP::Parser::IteratorFactory;
@ISA = qw( TAP::Parser::SourceHandler );
TAP::Parser::IteratorFactory->register_handler( __PACKAGE__ );
sub can_handle {
my ( $class, $src ) = @_;
my $meta = $src->meta;
my $config = $src->config_for( $class );
if ($config->{accept_all}) {
return 1.0;
} elsif (my $file = $meta->{file}) {
return 0.0 unless $file->{exists};
return 1.0 if $file->{lc_ext} eq '.tap';
return 0.9 if $file->{shebang} && $file->{shebang} =~ /^#!.+tap/;
return 0.5 if $file->{text};
return 0.1 if $file->{binary};
} elsif ($meta->{scalar}) {
return 0.8 if $$raw_source_ref =~ /d..d/;
return 0.6 if $meta->{has_newlines};
} elsif ($meta->{array}) {
return 0.8 if $meta->{size} < 5;
return 0.6 if $raw_source_ref->[0] =~ /foo/;
return 0.5;
} elsif ($meta->{hash}) {
return 0.6 if $raw_source_ref->{foo};
return 0.2;
}
return 0;
}
sub make_iterator {
my ($class, $source) = @_;
# this is where you manipulate the source and
# capture the stream of TAP in an iterator
# either pick a TAP::Parser::Iterator::* or write your own...
my $iterator = TAP::Parser::Iterator::Array->new([ 'foo', 'bar' ]);
return $iterator;
}
1;
AUTHORS
TAPx Developers.
Source detection stuff added by Steve Purkis
SEE ALSO
TAP::Object, TAP::Parser, TAP::Parser::Source, TAP::Parser::Iterator, TAP::Parser::IteratorFactory, TAP::Parser::SourceHandler::Executable,
TAP::Parser::SourceHandler::Perl, TAP::Parser::SourceHandler::File, TAP::Parser::SourceHandler::Handle, TAP::Parser::SourceHandler::RawTAP
perl v5.18.2 2014-01-06 TAP::Parser::SourceHandler(3pm)