All in a single perl code: extraction of rightmost 2 digits, omit any containing lines greater than 33, numerically sort left-over lines based on right-most 2 characters:
producing:
On system like:
Best wishes ... cheers, drl
Hi folks,
I need to find the following value:
First,I need to find the starting section by finding the line:
<process-type id="OC4J_RiGHTv_${SCHEMA_NAME}" module-id="OC4J">
Second,under this line I need to find the following line:
<port id="rmi" range="3765-3776"/>
And third,from this line... (4 Replies)
Hi All
I have a script which has produced a list, I have used 'sed' to number my list, but i want to list at end of line with the first line starting at zero (0) and brackets round it
ie
My List i want
Hello (0)
this (1)
day (2)
can (3)
be (4)
sed '/./=' filename | sed '/./N; s/\n/) /'... (5 Replies)
Hi
I want to find whether the argument passed to my script ends in a number or not. Like, I want to find out if the argument is of the form: xyzwpq123 or just of the form xyzwpq.
Can someone please help me!?
Thanks (2 Replies)
how to list all files in current directory whose second character is a digit.
i guess i hav to use grep command + ls for this. but dont know how to use? (6 Replies)
Hi Everyone,
a.txt
1272904667;1272904737;1
1272904747;1272904819;1
1272904810;1272904857;1
1272904889;1272904926;1
1272905399;1272905406;1
1272905411;1272905422;1
if i want to get the record, when the a.txt 1st field is between 1272904749 and 1272905399, any simple way by using awk,... (1 Reply)
I have to write a c program which takes a 3 digit number n and calculates the value of (2^n)+1 and then determines the number is prime or not.
I have tried to first calculate the value of 2^n and then adding one to it and then apply the logic of prime number.
but the ultimate problem is that... (7 Replies)
how can i list all files in my home directory that have a 4 digit id number, the line number where the id is located and the id itself not printing the entire line? (5 Replies)
list all file whose 3rd char is digit (or Nth position is digit)
what will be the required command? (5 Replies)
Discussion started by: rahul
5 Replies
LEARN ABOUT DEBIAN
moosex::attributehelpers::methodprovider::list
MooseX::AttributeHelpers::MethodProvider::List(3pm) User Contributed Perl Documentation MooseX::AttributeHelpers::MethodProvider::List(3pm)NAME
MooseX::AttributeHelpers::MethodProvider::List - method generator for MooseX::AttributeHelpers::Collection::List
SYNOPSIS
package Stuff;
use Moose;
use MooseX::AttributeHelpers;
has 'options' => (
metaclass => 'Collection::List',
is => 'rw',
isa => 'ArrayRef[Str]',
default => sub { [] },
auto_deref => 1,
provides => {
elements => 'all_options',
map => 'map_options',
grep => 'filter_options',
find => 'find_option',
first => 'first_option',
last => 'last_option',
get => 'get_option',
join => 'join_options',
count => 'count_options',
empty => 'do_i_have_options',
sort => 'sorted_options',
}
);
no Moose;
1;
DESCRIPTION
This is a role which provides the method generators for MooseX::AttributeHelpers::Collection::List.
METHODS
meta
PROVIDED METHODS
count
Returns the number of elements in the list.
$stuff = Stuff->new;
$stuff->options(["foo", "bar", "baz", "boo"]);
my $count = $stuff->count_options;
print "$count
"; # prints 4
empty
If the list is populated, returns true. Otherwise, returns false.
$stuff->do_i_have_options ? print "Good boy.
" : die "No options!
" ;
find
This method accepts a subroutine reference as its argument. That sub will receive each element of the list in turn. If it returns true
for an element, that element will be returned by the "find" method.
my $found = $stuff->find_option( sub { $_[0] =~ /^b/ } );
print "$found
"; # prints "bar"
grep
This method accepts a subroutine reference as its argument. This method returns every element for which that subroutine reference
returns a true value.
my @found = $stuff->filter_options( sub { $_[0] =~ /^b/ } );
print "@found
"; # prints "bar baz boo"
map This method accepts a subroutine reference as its argument. The subroutine will be executed for each element of the list. It is
expected to return a modified version of that element. The return value of the method is a list of the modified options.
my @mod_options = $stuff->map_options( sub { $_[0] . "-tag" } );
print "@mod_options
"; # prints "foo-tag bar-tag baz-tag boo-tag"
sort
Sorts and returns the elements of the list.
You can provide an optional subroutine reference to sort with (as you can with the core "sort" function). However, instead of using $a
and $b, you will need to use $_[0] and $_[1] instead.
# ascending ASCIIbetical
my @sorted = $stuff->sort_options();
# Descending alphabetical order
my @sorted_options = $stuff->sort_options( sub { lc $_[1] cmp lc $_[0] } );
print "@sorted_options
"; # prints "foo boo baz bar"
elements
Returns all of the elements of the list
my @option = $stuff->all_options;
print "@options
"; # prints "foo bar baz boo"
join
Joins every element of the list using the separator given as argument.
my $joined = $stuff->join_options( ':' );
print "$joined
"; # prints "foo:bar:baz:boo"
get Returns an element of the list by its index.
my $option = $stuff->get_option(1);
print "$option
"; # prints "bar"
first
Returns the first element of the list.
my $first = $stuff->first_option;
print "$first
"; # prints "foo"
last
Returns the last element of the list.
my $last = $stuff->last_option;
print "$last
"; # prints "boo"
BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to
cpan-RT.
AUTHOR
Stevan Little <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2007-2009 by Infinity Interactive, Inc.
<http://www.iinteractive.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2010-01-02 MooseX::AttributeHelpers::MethodProvider::List(3pm)