hi,
I want to print all the lines between the matching braces.
For example,the file contains like the below.
asdfsdf
fsdfsd
WO{
w1{
ada
... (3 Replies)
Hi there
does anybody know how i can get the line number from an entry or entries in a file ?? for example if i had a file
test1
test2
test3
test1
and i needed to get the line numbers for all instances of test1 in that file
with the answer being (1,4)
Would anybody be able... (7 Replies)
I am reading a cpp file thru shell script . There are many fuctions inside the cpp file
eg
pvvd_fncn_name1
{
..... something
}
pvvd_fncn_name2
{
..... something
}
what I require is a method to find the first opening brace and the coresponding last brace and search... (2 Replies)
Hi,
I have several block of text that I need to select, however this text may be spread over several lines and contains the '{' and '}' within it.
For e.g.,
ABC=100{
DEF = 200
{
GHI,
JKL
}
}
#2nd Block
123
{
456{78,910}}
}I am trying to figure out how to remove... (2 Replies)
Hi All,
My file looks some thing like this,
File 1: -
A 10
B 30
C 5
D 25
E 72
F 23
now my requirement is to find the line with highest number in it, i;e the result should be
E 72
Thanks in Advance (1 Reply)
Hi all,
I want to display line number for matching string in a file. can anyone please help me.
I used
grep -n "ABC" file
so it displays
6 ABC.
But i only want to have line number,i don't want that it should prefix matching context with line number.
Actually my original... (10 Replies)
Hello All,
What i am doing is , i tail a file from certain chatacter and then cat -n to get the line numbers.I search for a particular string and gets it line number. What i am interested in is the next line immediately after the pattern i search.
But grep gives me result for all line... (5 Replies)
Hi Frnds,
I need to find the line number of a particular line in a file and store that line number to a variable.
if a file named myfile contains following
look at the sun
look at the moon
look at the star
look at the ocean
i need to get the line number of the line 'look at the... (3 Replies)
Hello,
I am trying to find out the line numbers where regex match and put them into a file with below command:
awk '/'$pat'/ {print NR}' $fileName >> temp.txt
where $pat is the regex
but this command is taking a lot of time to execute with bigger files for size more than 5000000... (8 Replies)
Discussion started by: JoeColeEPL9
8 Replies
LEARN ABOUT MOJAVE
test::object5.18
Test::Object(3) User Contributed Perl Documentation Test::Object(3)NAME
Test::Object - Thoroughly testing objects via registered handlers
SYNOPSIS
###################################################################
# In your test module, register test handlers again class names #
###################################################################
package My::ModuleTester;
use Test::More;
use Test::Object;
# Foo::Bar is a subclass of Foo
Test::Object->register(
class => 'Foo',
tests => 5,
code => &foo_ok,
);
Test::Object->register(
class => 'Foo::Bar',
# No fixed number of tests
code => &foobar_ok,
);
sub foo_ok {
my $object = shift;
ok( $object->foo, '->foo returns true' );
}
sub foobar_ok {
my $object = shift;
is( $object->foo, 'bar', '->foo returns "bar"' );
}
1;
###################################################################
# In test script, test object against all registered classes #
###################################################################
#!/usr/bin/perl -w
use Test::More 'no_plan';
use Test::Object;
use My::ModuleTester;
my $object = Foo::Bar->new;
isa_ok( $object, 'Foo::Bar' );
object_ok( $object );
DESCRIPTION
In situations where you have deep trees of classes, there is a common situation in which you test a module 4 or 5 subclasses down, which
should follow the correct behaviour of not just the subclass, but of all the parent classes.
This should be done to ensure that the implementation of a subclass has not somehow "broken" the object's behaviour in a more general
sense.
"Test::Object" is a testing package designed to allow you to easily test what you believe is a valid object against the expected behaviour
of all of the classes in its inheritance tree in one single call.
To do this, you "register" tests (in the form of CODE or function references) with "Test::Object", with each test associated with a
particular class.
When you call "object_ok" in your test script, "Test::Object" will check the object against all registered tests. For each class that your
object responds to "$object->isa($class)" for, the appropriate testing function will be called.
Doing it this way allows adapter objects and other things that respond to "isa" differently that the default to still be tested against the
classes that it is advertising itself as correctly.
This also means that more than one test might be "counted" for each call to "object_ok". You should account for this correctly in your
expected test count.
SUPPORT
Bugs should be submitted via the CPAN bug tracker, located at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Object>
For other issues, contact the author.
AUTHOR
Adam Kennedy <cpan@ali.as>
SEE ALSO
<http://ali.as/>, Test::More, Test::Builder::Tester, Test::Class
COPYRIGHT
Copyright 2005, 2006 Adam Kennedy. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl v5.18.2 2006-09-06 Test::Object(3)