Perl threads

2011-11-05 Thread Sharan Basappa
Hello,

We are in the process of writing a perl program that can send network
traffic on the native pc network port.
Essentially, the perl program emulates as if different traffic type sources
are sending the traffic data.
For this, our plan is to have a independent thread to emulate each traffic
type (e.g. slow/small traffic, small/fast traffic, large/infrequent traffic
etc.)
So, a mail program would spawn multiple threads and these threads would
send events back to main thread.
The main thread would then send traffic depending on the type of event it
receives.

Can someone let me know what perl constructs to use for implementing this
program. This is our first time with perl threads.

Thanks ...


dereferencing hash arrays

2010-08-19 Thread Sharan Basappa
Hello,

Assuming I have reference to an hash array $rHash, what would be the
way to dereference it.
Would it be: %hashEntry = %{$rHash}; ?

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: dereferencing hash arrays

2010-08-19 Thread Sharan Basappa
wow!

My impending question about usage of - also got answered ...

On Thu, Aug 19, 2010 at 5:59 PM, Chas. Owens chas.ow...@gmail.com wrote:
 On Thu, Aug 19, 2010 at 07:51, Sharan Basappa sharan.basa...@gmail.com 
 wrote:
 Hello,

 Assuming I have reference to an hash array $rHash, what would be the
 way to dereference it.
 Would it be: %hashEntry = %{$rHash}; ?
 snip

 The ways to dereference a hash are

 # treat $ref as a hash variable
 %$ref

 # treat $ref as a hash variable, useful for when the reference is not
 a simple scalar
 %{$ref}

 #index into $ref
 $ref-{key}

 # bulkier way of indexing into $ref, the - operator is preferred
 ${$ref}{key}

 # take a slice of $ref
 @{$ref}{qw/k1 k2 k3/}

 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




add newline

2010-08-03 Thread Sharan Basappa
In my program, I am building a text file f that also contains newlines
irst into an array.
I push every line to the array, but how do I add new lines to this text?

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: add newline

2010-08-03 Thread Sharan Basappa
Thanks a lot, Rob ...

On Tue, Aug 3, 2010 at 4:13 PM, Rob Coops rco...@gmail.com wrote:


 On Tue, Aug 3, 2010 at 12:26 PM, Sharan Basappa sharan.basa...@gmail.com
 wrote:

 In my program, I am building a text file f that also contains newlines
 irst into an array.
 I push every line to the array, but how do I add new lines to this text?

 Regards,
 Sharan

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



 Hi Sharan,
 There are several options (it is perl after all :-)
 First you could when you are adding a value to the array also add the
 newline character:
  push (@myarray, $value . \n);
 Second you could of course add the line feeds as seperate array values:
  push (@myarray, $value);
  push (@myarray, \n);
 Third you could of course when you are printing the values from the array
 add the linefeeds:
  print join(\n, @myarray);
 or
  foreach my $value ( @myarray ) {
   print $value . \n;
  or
   print $value;
   print \n;
  }
 There are a few more options but these are the most common once you will see
 around the perl world. It really depends on what you want to do with you
 array. If you only use the array to print the output I would advise using
 the join option as that is certainly the most efficient memory wise and at
 least feeling wise the fastest way of working (though I have not verified
 this) the second option is just silly and likely quite slow and memory
 inefficient.
 If you are using the array as a form of log file you might want to have a
 look at log4perl on cpan. Which is a much more industrial strength solution
 then reinventing the wheel is likely to be.
 Regards,
 Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




has and non unique keys

2010-08-02 Thread Sharan Basappa
Folks,

Is there any restriction that the keys in perl should be unique?
If not, are there any special considerations that need to be kept in mind while
accessing the elements?

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: has and non unique keys

2010-08-02 Thread Sharan Basappa
Hello Uri,

Thanks for the explanation. I figured this out once I ran the code
where I got this doubt.
The reason why I raised this question is that languages like C++ do
allow hashes arrays
that can have different values but same key. Thats the reason for the
second part of my
question.

Regards,
Sharan

On Mon, Aug 2, 2010 at 3:36 PM, Uri Guttman u...@stemsystems.com wrote:
 SB == Sharan Basappa sharan.basa...@gmail.com writes:

  SB Is there any restriction that the keys in perl should be unique?
  SB If not, are there any special considerations that need to be kept
  SB in mind while accessing the elements?

 well, think about it first. what would happen if a hash allowed
 duplicate keys? how would you know which associated value was attached
 to the duplicate key? the whole point of hashes is to index by a
 string. requiring unique keys is what makes it a hash. in a similar vein
 what would happen if you could index an array multiple times with the
 same integer? it makes no sense. same for hashes.

 uri

 --
 Uri Guttman  --  ...@stemsystems.com    http://www.sysarch.com --
 -  Perl Code Review , Architecture, Development, Training, Support --
 -  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: has and non unique keys

2010-08-02 Thread Sharan Basappa
Shlomi,

I am not trying to be critical of perl or anything (if that is what you felt).
I am only trying to see if a certain feature exists or not.
The current problem I am working on has duplicate key values and hence
the question.

The STL multipmap library explanation is below:
http://www.cplusplus.com/reference/stl/multimap/

Regards,
Sharan

On Mon, Aug 2, 2010 at 4:18 PM, Shlomi Fish shlo...@iglu.org.il wrote:
 Hi Sharan,

 On Monday 02 August 2010 13:13:19 Sharan Basappa wrote:
 Hello Uri,

 Thanks for the explanation. I figured this out once I ran the code
 where I got this doubt.
 The reason why I raised this question is that languages like C++ do
 allow hashes arrays

 Please don't call hashes hashes arrays. They are either hashes or
 associative arrays. (Technically, hashes are the name of the implementation
 rather than the Abstract Data Type of a Dictionary that matches keys to values
 , but we call that in Perl because it's a short and convenient word).

 that can have different values but same key. Thats the reason for the
 second part of my
 question.

 Are you talking about the C Standard Template Library (STL)? How does what you
 are referring to allow multiple values for the same key? I should note that if
 you wish to do something like that in Perl, you can have the key point to a
 value that is an array reference, a hash reference or a different data
 structure.

 Regards,

        Shlomi Fish

 --
 -
 Shlomi Fish       http://www.shlomifish.org/
 Stop Using MSIE - http://www.shlomifish.org/no-ie/

 God considered inflicting XSLT as the tenth plague of Egypt, but then
 decided against it because he thought it would be too evil.

 Please reply to list if it's a mailing list post - http://shlom.in/reply .


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




array to hash array

2010-07-26 Thread Sharan Basappa
Hi,

Can someone tell me how to convert an array to hash.

Each array entry has a row of values
e.g. a(0) = ab cd ef; a(1) = mn de fg

The hash array needs to be constructed with one of the element in the
array row as the key.
e.g. hash{ab} = cd ef  - ab is a string in the array row
   hash{mn} = de fg- mn is a string in the array row

Can someone comment?

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




hash arrays

2010-07-26 Thread Sharan Basappa
Folks,

I am reusing a code for some enhancements. According to my
understanding, it is a record with
some unique string as key and then hash array as the value.

I iterate through the array and print as follows:

foreach my $key (keys %{$abc})
{
  print $key ${$abc}{$key} \n;
}

I get values such like:
val_0001 HASH(0x186c0060)
val_0002 HASH(0x187ea490)
val_0003 HASH(0x18655bc0)
val_0004 HASH(0x1880fc60)

Can someone tell me how to get the actual value instead of HASH* as above?

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: hash arrays

2010-07-26 Thread Sharan Basappa
Thank you, Bob  others. I think I now understand better. I have the
source code. So now I should be able to figure this out.

Regards,
Sharan

On Mon, Jul 26, 2010 at 6:00 PM, Rob Coops rco...@gmail.com wrote:


 On Mon, Jul 26, 2010 at 2:09 PM, Sharan Basappa sharan.basa...@gmail.com
 wrote:

 Folks,

 I am reusing a code for some enhancements. According to my
 understanding, it is a record with
 some unique string as key and then hash array as the value.

 I iterate through the array and print as follows:

 foreach my $key (keys %{$abc})
 {
  print $key ${$abc}{$key} \n;
 }

 I get values such like:
 val_0001 HASH(0x186c0060)
 val_0002 HASH(0x187ea490)
 val_0003 HASH(0x18655bc0)
 val_0004 HASH(0x1880fc60)

 Can someone tell me how to get the actual value instead of HASH* as above?

 Regards,
 Sharan

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



 Hi Sharan,
 When you do: print $key ${$abc}{$key} you get this output: val_0001
 HASH(0x186c0060) so that basically means that the value associated with:
 val_0001 is a hash.
 So if we do something along the lines of:
 foreach my $key (keys %{$abc})
 {
  my %hash = %{$abc}{$key};
  foreach my $key2 ( keys %value ) {
   print $key\t$key2\t$value{$key2}\n;
  }
 }
 You should get something like this:
 val_0001   key_0001  value_0001
 val_0001   key_0002  value_0002
 val_0001   key_0003  value_0003
 val_0002   key_0001  value_0001
 etc
 Of course you should decide if this is really needed if you are only
 interested in finding out what is inside $abc for debugging purposes for
 instance you might just want to make your life easy and simply use
 Data::Dumper to push content to the screen.
 For all you know that HASH(0x186c0060) might contain a value that is it self
 an array which contains a list of hashes with arrays as values etc... for
 just seeing what is in there it is often better to simply use Data::Dumper
 as it has been written to deal with all those possibilities so you don't
 have to worry about them.
 Regards,
 Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




need explanation

2010-07-16 Thread Sharan Basappa
Folks,

I am putting a line of code which I am not able to clearly understand.
This is a reuse ...

my(@table) = @{$tableRef};

The tableRef is returned as a reference after reading a file that
contains record.
Two questions:
1) what does @{$tableRef} really do?
2) what does @table contain?

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: need explanation

2010-07-16 Thread Sharan Basappa
Thanks, Vishal.

I was confused with usage {}. So you are saying that it will
dereference the array.
Isn't @$tableRef not enough in that case?

Regards,
Sharan


On Fri, Jul 16, 2010 at 3:33 PM, Vishal Gupta
vishal.knit2...@hotmail.com wrote:
 Hi Sharan,

 Please find below the answers:

 1) what does @{$tableRef} really do?

 This will de-reference the $tableRef, which is suppose to be an array
 reference.

 2) what does @table contain?

 @table will contains the original array, which is referenced by $tableRef.

 Regards,
 Vishal
 
 Manage your finance and manage money through MSN Money Special Drag n' drop

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




parsing csv

2010-07-02 Thread Sharan Basappa
Folks,

I have to parse a csv file and convert it into some other format.
Can someone tell me what support perl has for csv parsing.
My requirements are very modest, so somethng simple would be preferable.

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: parsing csv

2010-07-02 Thread Sharan Basappa
On Fri, Jul 2, 2010 at 2:19 PM, Shlomi Fish shlo...@iglu.org.il wrote:
 On Friday 02 Jul 2010 11:40:05 Sharan Basappa wrote:
 Folks,

 I have to parse a csv file and convert it into some other format.
 Can someone tell me what support perl has for csv parsing.
 My requirements are very modest, so somethng simple would be preferable.

Thank you all. Can I get to see some examples. The documentation is
very short (for a novice like me) ...

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: parsing csv

2010-07-02 Thread Sharan Basappa
Thanks a lot. I am now installing the module to try out and start
implementing my own code.
I think I will need help in installing the module ...

This goes through fine:
perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Text::CSV_XS

Make fails:
make
cp CSV_XS.pm blib/lib/Text/CSV_XS.pm
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap
/usr/lib/perl5/5.8.8/ExtUtils/typemap  CSV_XS.xs  CSV_XS.xsc  mv
CSV_XS.xsc CSV_XS.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\0.73\
-DXS_VERSION=\0.73\ -fPIC
-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE   CSV_XS.c
cc1: invalid option `tune=generic'
cc1: unrecognized option `-fstack-protector'
cc1: invalid parameter `ssp-buffer-size'

Can someone help me ...

Regards,
Sharan


On Fri, Jul 2, 2010 at 2:35 PM, Shlomi Fish shlo...@iglu.org.il wrote:
 On Friday 02 Jul 2010 11:55:47 Sharan Basappa wrote:
 On Fri, Jul 2, 2010 at 2:19 PM, Shlomi Fish shlo...@iglu.org.il wrote:
  On Friday 02 Jul 2010 11:40:05 Sharan Basappa wrote:
  Folks,
 
  I have to parse a csv file and convert it into some other format.
  Can someone tell me what support perl has for csv parsing.
  My requirements are very modest, so somethng simple would be preferable.

 Thank you all. Can I get to see some examples. The documentation is
 very short (for a novice like me) ...

 There is an example here:

 http://search.cpan.org/perldoc?Text::CSV_XS

 There are other examples inside the Text-CSV_XS source distribution.

 Regards,

        Shlomi Fish

 --
 -
 Shlomi Fish       http://www.shlomifish.org/
 What Makes Software Apps High Quality -  http://shlom.in/sw-quality

 God considered inflicting XSLT as the tenth plague of Egypt, but then
 decided against it because he thought it would be too evil.

 Please reply to list if it's a mailing list post - http://shlom.in/reply .


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: parsing csv

2010-07-02 Thread Sharan Basappa
Hi Jason,

Does CSV module come prebuilt so that I can avoid installing.
I dont know SQL but my requirements are very modest.
Extract lines and get filed and reformat them to another type.

Regads,
Sharan

On Fri, Jul 2, 2010 at 3:53 PM, Jason Feng q15...@hotmail.com wrote:
 Hi there,

 If you know some SQL, I'd suggest you using DBI and DBD::CSV.

 Cheers,
 Jason

 Date: Fri, 2 Jul 2010 18:47:22 +1000
 Subject: Re: parsing csv
 From: rc...@pcug.org.au
 To: sharan.basa...@gmail.com
 CC: beginners@perl.org


  Folks,
 
  I have to parse a csv file and convert it into some other format.
  Can someone tell me what support perl has for csv parsing.
  My requirements are very modest, so somethng simple would be
  preferable.
 
  Regards,
  Sharan




 You might want to search http://search.cpan.org/search?query=csvmode=all

 http://search.cpan.org/~tmtm/Text-CSV-Simple-1.00/lib/Text/CSV/Simple.pm
 seems to be one that could suit you?
 --



 Owen


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



 
 Find it at CarPoint.com.au New, Used, Demo, Dealer or Private?

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: parsing csv

2010-07-02 Thread Sharan Basappa
Hi Alan,

I am not resisting installing but I am having trouble installing
Text::CSV module.

I would be glad if someone helps with these errors ...

perl Makefile.PL PREFIX=/home/sharan/tools/perl-install

Checking if your kit is complete...
Looks good
Writing Makefile for Text::CSV_XS

Make fails:
make
cp CSV_XS.pm blib/lib/Text/CSV_XS.pm
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap
/usr/lib/perl5/5.8.8/ExtUtils/typemap  CSV_XS.xs  CSV_XS.xsc  mv
CSV_XS.xsc CSV_XS.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\0.73\
-DXS_VERSION=\0.73\ -fPIC
-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE   CSV_XS.c
cc1: invalid option `tune=generic'
cc1: unrecognized option `-fstack-protector'
cc1: invalid parameter `ssp-buffer-size'


On Fri, Jul 2, 2010 at 4:04 PM, Alan Haggai Alavi
alanhag...@alanhaggai.org wrote:
 On 2 July 2010 15:56, Sharan Basappa sharan.basa...@gmail.com wrote:
 Hi Jason,

 Does CSV module come prebuilt so that I can avoid installing.
 I dont know SQL but my requirements are very modest.
 Extract lines and get filed and reformat them to another type.

 Regads,
 Sharan


 Hi Sharan,

 DBD::CSV is not in core. You can check it yourself by using the
 `corelist` command-line frontend to Module::Corelist.

 For example:
 alanhag...@love:~$ corelist DBD::CSV

 DBD::CSV was not in CORE (or so I think)

 By the way, why do you resist installing modules from CPAN?

 Regards,
 Alan.
 --
 The difference makes the difference


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl on windows

2009-05-19 Thread Sharan Basappa
Actually there was no exe. I only got a zip folder and uncompressed. I
am clueless what to do after that...

Regards,

On Tue, May 19, 2009 at 1:26 AM, Dr.Ruud rvtol+use...@isolution.nl wrote:
 Sharan Basappa wrote:

 Ruud:

 Sharan:

 I would like to know install perl on my windows laptop. Any
 suggestions on which one to use.

 Strawberry Perl  http://vanillaperl.com/

 I downloaded strawberry and extracted it. I dont see any install
 notes.
 Any idea how to install (is extraction all we have to do)

 So you downloaded the exe and ran it?

 --
 Ruud

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl on windows

2009-05-18 Thread Sharan Basappa
I downloaded strawberry and extracted it. I dont see any install notes.
Any idea how to install (is extraction all we have to do)

Regards,
Sharan

On Sat, May 16, 2009 at 12:51 AM, Dr.Ruud rvtol+use...@isolution.nl wrote:
 Sharan Basappa wrote:

 I would like to know install perl on my windows laptop. Any
 suggestions on which one to use.

 Strawberry Perl  http://vanillaperl.com/

 --
 Ruud

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




perl on windows

2009-05-15 Thread Sharan Basappa
Hi,

I would like to know install perl on my windows laptop. Any
suggestions on which one to use.
Also, my work requires some special modules like algorithm. How do I
handle that?

Regards

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl on windows

2009-05-15 Thread Sharan Basappa
Thanks a lot. Another question, does it also have an IDE kind of
environment just to make my life easy?

Regards

On Fri, May 15, 2009 at 7:38 PM, JeffHua jeff...@aol.com wrote:
 Sharan Basappa:

 Hi,

 I would like to know install perl on my windows laptop. Any
 suggestions on which one to use.
 Also, my work requires some special modules like algorithm. How do I
 handle that?


 Hi,

 try ActivePerl:

 www.activestate.com/activeperl/

 or Cygwin a Linux-like environment for Windows:

 www.cygwin.com/


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl on windows

2009-05-15 Thread Sharan Basappa
I am not talking about text editors, but GUI IDEs that help compile,
run, debug (probably do more I dont know)

On Fri, May 15, 2009 at 7:52 PM, JeffHua jeff...@aol.com wrote:
 Sharan Basappa :

 Thanks a lot. Another question, does it also have an IDE kind of
 environment just to make my life easy?


 For activestate you may try Komodo Edit:
 http://www.activestate.com/komodo_edit/

 If under Cygwin you could use VI/VIM, which is powerful.



 On Fri, May 15, 2009 at 7:38 PM, JeffHua jeff...@aol.com wrote:

 Sharan Basappa:

 Hi,

 I would like to know install perl on my windows laptop. Any
 suggestions on which one to use.
 Also, my work requires some special modules like algorithm. How do I
 handle that?

 Hi,

 try ActivePerl:

 www.activestate.com/activeperl/

 or Cygwin a Linux-like environment for Windows:

 www.cygwin.com/





-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl on windows

2009-05-15 Thread Sharan Basappa
Thanks. That answers my question...

On Fri, May 15, 2009 at 8:04 PM, JeffHua jeff...@aol.com wrote:
 Sharan Basappa:

 I am not talking about text editors, but GUI IDEs that help compile,
 run, debug (probably do more I dont know)


 But Perl is just an old script language, many guys of here don't use an IDE.
 If you really want one, the wellknown perl IDE is still activestate's, see:

 http://www.activestate.com/activeperl_pro_studio/

 Or you may try google it for finding another.

 Jeff.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




xml parsing

2009-04-29 Thread Sharan Basappa
Hi,

I have a kind of user defined xml file where users enter their test information.
I need to parse the xml file, get the relevant data and then use the
test information to invoke
low level scripts that run the tests. Is there a xml parser that can
do this job?
Also, I have heard a bit about xml schemas. Does the fact that I am
using my own format
of xml file make any difference?

Regards,

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: xml parsing

2009-04-29 Thread Sharan Basappa
On Wed, Apr 29, 2009 at 7:54 PM, Bruce Ferrell bferr...@baywinds.org wrote:
 Have a look at XML::Simple

 I'm a lousy programmer and even I can use it :)

Thanks, Bruce. My requirements are really modest, so I think this
should be sufficient ...

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl what

2009-03-19 Thread Sharan Basappa
I have started going through TK documents. The initial sections seem
to concentrate more on adding different options to screen and do some
background action based on user input. My requirement is not so much
on user control but more on the visual display side (pardon if I am
using generic terms since I am not a SW guy). I just want to make sure
I am spending time in the right area. So sending this mail.

Regards,

On Tue, Mar 17, 2009 at 11:41 AM, Chas. Owens chas.ow...@gmail.com wrote:
 On Tue, Mar 17, 2009 at 01:58, Sharan Basappa sharan.basa...@gmail.com 
 wrote:
 Hi Chas,

 Clearly I did not communicate properly. So what I am looking is for
 some support to do some
 GUI stuff. The idea is take information from text and show it in the
 form a waveform. This
 will help a lot since it is rather difficult to go through the text file.
 snip

 There are many GUI Toolkits for Perl.  Which one is best for you
 depends in what platform you are on.  I like Gtk2[1], two others with
 wide following are Tk[2] and Wx[3].  I believe all of them has some
 form of canvas widget.  If you want to represent data like a waveform
 that would be where I would start looking.

 1. http://search.cpan.org/dist/Gtk2/Gtk2.pm
 2. http://search.cpan.org/dist/Tk/pod/overview.pod
 3. http://search.cpan.org/dist/Wx/Wx.pm

 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl what

2009-03-19 Thread Sharan Basappa
Thanks, I did go through the TK docs a little more. Here is what I
understood -- at a high level --
If someone can comment on this, it would really help me

TK provides options
-  to creates windows
- to create virtual areas within this window
- to create tool bar, menu etc in the window
- links the user action to perl action etc.

For my application, what I really need is that the tool should accept
one or more log files. It should then parse log files and properly arrange
the log data. It should then display the log info in the form of a waveform,
where the x axis indicates the time (which comes from the log file itself)
There can be multiple rows of log information (which I call as streams).
The stream info also comes from the log file.

Thanks in advance ...


On Thu, Mar 19, 2009 at 2:50 PM, Dermot paik...@googlemail.com wrote:
 2009/3/19 Sharan Basappa sharan.basa...@gmail.com:
 I have started going through TK documents. The initial sections seem
 to concentrate more on adding different options to screen and do some
 background action based on user input. My requirement is not so much
 on user control but more on the visual display side (pardon if I am
 using generic terms since I am not a SW guy). I just want to make sure
 I am spending time in the right area. So sending this mail.

 Regards,


 If your mean the window layout then I think you want to look at the
 -pack() method.

 http://search.cpan.org/~srezic/Tk-804.028/pod/pack.pod


 It's how you specify the placing of items within each element.
 HTH,
 Dp.

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl what

2009-03-17 Thread Sharan Basappa
Some user interaction is expected, at least in terms of clicking to
get additional details of a
log point ... But yes, since more might be required later, I would
probably go with (G)TK

Regards

On Tue, Mar 17, 2009 at 1:47 PM, Thomas Bätzler t.baetz...@bringe.com wrote:
 Sharan Basappa sharan.basa...@gmail.com wrote:
 Clearly I did not communicate properly. So what I am looking is for
 some support to do some GUI stuff. The idea is take information from
 text and show it in the form a waveform. This will help a lot since
 it is rather difficult to go through the text file.

 If you don't need user interaction beyond a next button and don't want to 
 bother with a GUI toolkit, you could use Perl to convert your input data to 
 gnuplot plot files.

 HTH,
 Thomas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




perl what

2009-03-16 Thread Sharan Basappa
Hi,

We have quite a bit of log information generated during our work. The
thought I have is to create a tool that actually
takes all the info in the log and then displays in a visual manner. I
have fair amount of experience in Perl but for an
application of this kind, I am wondering what I need to do this. Is
perl enough? does it require some other additional
tool? Please provide some guidance here.

Regards,

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl what

2009-03-16 Thread Sharan Basappa
Hi Chas,

Clearly I did not communicate properly. So what I am looking is for
some support to do some
GUI stuff. The idea is take information from text and show it in the
form a waveform. This
will help a lot since it is rather difficult to go through the text file.

Regards,
Sharan

On Mon, Mar 16, 2009 at 8:59 PM, Chas. Owens chas.ow...@gmail.com wrote:
 On Mon, Mar 16, 2009 at 10:31, Sharan Basappa sharan.basa...@gmail.com 
 wrote:
 Hi,

 We have quite a bit of log information generated during our work. The
 thought I have is to create a tool that actually
 takes all the info in the log and then displays in a visual manner. I
 have fair amount of experience in Perl but for an
 application of this kind, I am wondering what I need to do this. Is
 perl enough? does it require some other additional
 tool? Please provide some guidance here.
 snip

 Perl should be capable of doing whatever you want.  If you need to
 create graphical charts you might look into Chart[1] module.

 1. http://search.cpan.org/~chartgrp/Chart-2.4.1/Chart.pod

 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: removing an arbitrary element from array

2009-01-28 Thread Sharan Basappa
On Sun, Dec 7, 2008 at 2:01 AM, Rob Dixon rob.di...@gmx.com wrote:
 Sharan Basappa wrote:

 I was wondering if there is a quick way to remove an arbitrary element
 from an array.
 I have an array which stores _ delimited strings a_b_c_1). The last
 string stores the rank of the string.
 I have to remove a string from array that has the lowest number.

 e.g. a_b_c_1, a_b_c_2. In this case, a_b_c_2 should be removed. The
 strings are not arranged in any
 specific order in the array.

 I'm hoping you've made a mistake, because if I understand you correctly then 
 out
 of ('a_b_c_1', 'a_b_c_2') the first should be removed because 1 is less than 
 two.

 If I'm right then the program below should be useful.

 HTH,

 Rob



 use strict;
 use warnings;

 my @data = qw/
  a_b_c_99
  a_b_c_6
  a_b_c_1
  a_b_c_2
  a_b_c_22
 /;

 my ($idx, $min_seq);
 foreach (0 .. $#data) {
  my ($seq) = $data[$_] =~ /(\d+)$/;
  next if defined $idx and $seq  $min_seq;
  ($idx, $min_seq) = ($_, $seq);
 }

 splice @data, $idx, 1;


Hi Rob,

I have a question on this. I realized that I also need to save the
element that I am removing from
the array. Would this code work (should remove the element and save it
in the variable)
$removed_element = splice @data, $idx, 1

Regards

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: removing an arbitrary element from array

2009-01-28 Thread Sharan Basappa
Thank you ...

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




launch process

2009-01-16 Thread Sharan Basappa
Hi,

What is the method to launch unix process from perl. I believe this is
going to be system call.
The additional requirement I have is that the calls should be non
blocking mainly as these
process execution should happen in parallel.

Regards,
Sharan

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: implementing algo

2008-12-25 Thread Sharan Basappa
Hi Jenda, Rob, Shawn,

 I am attaching a sample flowchart figure.

 Step1 and Step2 are the process steps and D1 and D2 are the decisions.

 Will this code translate to the foll in perl?

 do
 {
  do
  {
 step1
  } while (D1)
  step2
 } while (D2)

 What if D2 traces back to Step2 instead? How would the code change?

 Regards
attachment: sample_flow.TIF-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


implementing algo

2008-12-24 Thread Sharan Basappa
Hi,

I am implementing an algorithm that I have worked out in theory. The
algorithm is in the form of a flowchart.
The area where I am having problem is where the flow passes from a
lower decision block to higher one.
I can implement this using a do while block for such flow. The issue
is when multiple such decisions
block go back to same point in the flowchart. When I look at the
flowchart, it looks like it can be simply
translated into code using jump blocks if a language supports it.
The other question I have is if my approach of using a flowchart was
incorrect in the first place.
But I did flowchart to get my idea straight and uncovered lot of
potential issues during this exercise.

Regards

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: removing an arbitrary element from array

2008-12-10 Thread Sharan Basappa
On Sun, Dec 7, 2008 at 2:01 AM, Rob Dixon [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:

 I was wondering if there is a quick way to remove an arbitrary element
 from an array.
 I have an array which stores _ delimited strings a_b_c_1). The last
 string stores the rank of the string.
 I have to remove a string from array that has the lowest number.

 e.g. a_b_c_1, a_b_c_2. In this case, a_b_c_2 should be removed. The
 strings are not arranged in any
 specific order in the array.

 I'm hoping you've made a mistake, because if I understand you correctly then 
 out
 of ('a_b_c_1', 'a_b_c_2') the first should be removed because 1 is less than 
 two.

 If I'm right then the program below should be useful.

 HTH,

 Rob



 use strict;
 use warnings;

 my @data = qw/
  a_b_c_99
  a_b_c_6
  a_b_c_1
  a_b_c_2
  a_b_c_22
 /;

 my ($idx, $min_seq);
 foreach (0 .. $#data) {
  my ($seq) = $data[$_] =~ /(\d+)$/;
  next if defined $idx and $seq  $min_seq;
  ($idx, $min_seq) = ($_, $seq);
 }

 splice @data, $idx, 1;


You are right, the lowest ranked string should be knocked off.
I tried your code and it works perfectly. I have integrated that with
my real code.
Thanks a lot.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




removing an arbitrary element from array

2008-12-05 Thread Sharan Basappa
Hi,

I was wondering if there is a quick way to remove an arbitrary element
from an array.
I have an array which stores _ delimited strings a_b_c_1). The last
string stores the rank of the string.
I have to remove a string from array that has the lowest number.

e.g. a_b_c_1, a_b_c_2. In this case, a_b_c_2 should be removed. The
strings are not arranged in any
specific order in the array.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




wait for file creation and wait

2008-11-26 Thread Sharan Basappa
Hi,

I am writing a scheduler for some proprietary task.
There are two questions pertaining to this

1) I have to wait for creation of a file by some external process. How
do I do that in perl?
In other words, is it possible to list out the files in perl?

2) If file is not created then I have to wait for sometime. How do I
put real time delay in perl?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




system command

2008-11-26 Thread Sharan Basappa
Hi,

I am trying to launch a program using system command.
The program usually takes 20-30 minutes to complete.
I launch the programs in a loop.
Will the system command wait for first program to complete and then proceed
to the next one.
What if I want to launch these programs in parallel which is not
possible if system command waits for
the first program to complete before proceeding to next one.

Regards,

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: system command

2008-11-26 Thread Sharan Basappa
 Or you might want to use threads, though they are certainly not the same
 both have their advantages and you might want to read up on them before
 making a decission on which to use.

 In any case I would advise you to first, use which ever way of modeling you
 prefer, to draw out the way the system works and to identify exactly which
 processes depend on which other processes. Due to the way OS's handle
 multiple seperate processes paying special attention to how the seperate
 independent parts run and how that might affect the main program or other
 independent parts becomes quite important. You need to count on some
 processes failing, not finshing as fast as you would normally expect because
 there are now more processes running at the same time and things like file
 locking if the independent parts are operating on the same files... all in
 all making a quick drawing even of a very simple program can prevent a lot
 of trouble later on.

Thank you Rob. The good thing is that these process I am trying to launch
are not dependant on each other. In fact, they are actually same process with
different parameters. I just need to launch them based on some algo and user
constraints.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




random

2008-11-25 Thread Sharan Basappa
Hi,

Would like to know if perl has native (without using special modules)
for generating random numbers?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm permute

2008-11-18 Thread Sharan Basappa
Tom  Jay,

Thanks a lot. Actually the user is same. I have confirmed again. I
know it irritates a lot when a help seeker posts incorrect data and
requests support. But in this case, the user is same. I have not gone
deep into the issue. But the distinct difference is that in the
terminal where it works, I have not sourced scripts that I usually do
for my day to day work (paths to tools etc. Some tools use perl)
Needless to say, on the terminal where it works, the scripts are not
sourced. I did try to echo PERL5LIB and see if that is the source
of confusion, but it is undefined in all the terminals.
perldoc -l Algorithm::Permute yields No documentation found for
Algorithm::Permute.

Anyway, now I know how to make it work consistently. My initial hunch
was that something to do with a variable that was set on
the shell prompt and hence got lost for some reason later.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm permute

2008-11-17 Thread Sharan Basappa

 You haven't installed anything.  You've downloaded and untarred/
 gunzipped the source.  You still have to run
 perl Makefile.PL
 make
 make test
 make install

 That final command will copy the installed module to the real library
 directory.  THAT is the path that you need for use lib.

 perldoc perlmod
 for more information

 Paul Lalli

I would like to rewind a bit and see why this could be happening. I am
really curious about this.
As I mentioned in my original mail, a working file stopped all of a sudden.
Now I have 3 terminals open. All 3 are on same machine ..

I have done uname -a to confirm this.
In 2 terminals, the script errors out with:
perl StTrAuto.pl
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/perm_install/lib/perl5/site_perl
/hwnet/activestate/perl-5.6/lib/5.6.1/i686-linux-thread-multi
/hwnet/activestate/perl-5.6/lib/5.6.1
/hwnet/activestate/perl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi
/hwnet/activestate/perl-5.6/lib/site_perl/5.6.1
/hwnet/activestate/perl-5.6/lib/site_perl .) at StTrAuto.pl line 5.
BEGIN failed--compilation aborted at StTrAuto.pl line 5.

On the 3 rd terminal, it works fine.

The machine is same, the script is same.

I ran env and redirected output to a file from 2 terminals. There
are lot of differences.
By now, I am pretty sure this is the cause for the script failing. But
there are so many differences
I am not able to make out what variable is causing script to konk.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm permute

2008-11-13 Thread Sharan Basappa
Just an update. I have installed to a new location and can see the
following files

/u/basappas/local/perl/Algorithm-Permute-0.06/
Algorithm  Changes   Makefile.PL  Perm2.plPermute.o   pm_to_blib  typemap
bench  lib   MANIFEST Permute.bs  Permute.pm  share
blib   Makefile  META.yml Permute.c   Permute.xs  test.pl

I put this path in my code use lib
/u/basappas/local/perl/Algorithm-Permute-0.06
and still see the error:
Can't locate loadable object for module Algorithm::Permute in @INC
(@INC contains: /u/basappas/local/perl/Algorithm-Permute-0.06
/hwnet/activestate/perl-5.6/lib/5.6.1/i686-linux-thread-multi
/hwnet/activestate/perl-5.6/lib/5.6.1
/hwnet/activestate/perl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi
/hwnet/activestate/perl-5.6/lib/site_perl/5.6.1
/hwnet/activestate/perl-5.6/lib/site_perl .) at Perm2.pl line 4
Compilation failed in require at Perm2.pl line 4.
BEGIN failed--compilation aborted at Perm2.pl line 4

Am I missing something really? (like setting path to perl_lib)

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm permute

2008-11-11 Thread Sharan Basappa
Hi Paul,



Regards

On Mon, Nov 10, 2008 at 11:06 PM, Paul Lalli [EMAIL PROTECTED] wrote:
 On Nov 10, 9:15 am, [EMAIL PROTECTED] (Sharan Basappa) wrote:
 Hi,

 After working fine with Algorithm::Permute module for weeks now,
 suddenly I seem to be getting errors.

 The particular error is:
 $ perl StTrAuto.pl
 Can't locate Algorithm/Permute.pm in @INC (@INC contains:
 /u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at
 StTrAuto.pl line 4.
 BEGIN failed--compilation aborted at StTrAuto.pl line 4.

 First few lines of code which I thought are causing the issue:
   1 #!/usr/bin/perl
   2 use warnings;
   3 use lib /u/sharan/local/perl/perm_install/lib/perl5/site_perl;
   4 use Algorithm::Permute;

 The interesting thing is that I have an example code elsewhere and
 that works fine.
 Again, the first few lines of code from example:

 #!/usr/bin/perl
 use warnings;
 use lib
 /u/sharan/local/perl/perm_install/lib/perl5/site_perl;
 use Algorithm::Permute;

 my @array = (1..4);
 Algorithm::Permute::permute { print @array\n } @array;
 [EMAIL PROTECTED] = Algorithm::Permute::permute (@array);

 Any clues


 elsewhere is the problem.  Algorithm::Permute is not a built-in
 module.  You have to install it manually via the CPAN on every machine
 you want to use it.   Whatever machine you're currently using, you
 haven't installed it - or at the very least, you haven't installed it
 to /u/sharan/local/perl/perm_install/lib/perl5/site_perl.  Try
 running
 find / -name Permute.pm 2 /dev/null
 to see where, if at all, the module is located on this system.

Hi Paul,

Its the same machine. The only difference is that the directory from
where I run my actual code
is different from the example code. I tried it again to make sure this
is the case.
When I put a find after the path I have included in use lib, I get the
following result:
./5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5
/i386-linux-thread-multi/Algorithm/Permute.pm
./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5
/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5
/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-l
inux-thread-multi/Algorithm/Permute.pm

Ok, let me try installing fresh once again and see if that helps ...

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: insert keyword

2008-11-11 Thread Sharan Basappa
 Hi,

 I have a string that has value delimited by space
 e.g. 1 2 10 8 etc.

 I need to add a keyword wherever there is a space.
 I wrote a small code to try this out:

 $str = one two three;
 $str =~ s/\s/x /g;

 In this case, I am trying to insert x where there is a space. one two
 three should
 become one x two x three.
 But the above example results in:
 nex twox three (chops off leading o char)

 The interesting this is that this happens only in debug mode.
 The regular output is: onex twox three

 I don't know what you call debug mode, so I can't tell you why you
 lose your leading character, but, I can tell you that the substitution
 is doing exactly what you have told it to.  You are telling it to
 replace any white space (not just spaces) characters with x .  If
 you want to retain the original character you need to say something
 like

 $str =~ s/(\s)/${1}x /g;

 But you probably really want to say

 $str =~ s/ / x /g;

 because \s will match all white space characters (i.e. tab, line feed,
 form feed, carriage return, space, \x{85}, \x{2028}, and
 \x{2029}).

I am sorry, I was looking at incorrect output.
But yes, it works in both the cases (with perl and perl -d option)

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




algorithm permute

2008-11-10 Thread Sharan Basappa
Hi,

After working fine with Algorithm::Permute module for weeks now,
suddenly I seem to be getting errors.

The particular error is:
$ perl StTrAuto.pl
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at
StTrAuto.pl line 4.
BEGIN failed--compilation aborted at StTrAuto.pl line 4.

First few lines of code which I thought are causing the issue:
  1 #!/usr/bin/perl
  2 use warnings;
  3 use lib /u/sharan/local/perl/perm_install/lib/perl5/site_perl;
  4 use Algorithm::Permute;

The interesting thing is that I have an example code elsewhere and
that works fine.
Again, the first few lines of code from example:

#!/usr/bin/perl
use warnings;
use lib
/u/sharan/local/perl/perm_install/lib/perl5/site_perl;
use Algorithm::Permute;

my @array = (1..4);
Algorithm::Permute::permute { print @array\n } @array;
[EMAIL PROTECTED] = Algorithm::Permute::permute (@array);

Any clues

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




insert keyword

2008-11-10 Thread Sharan Basappa
Hi,

I have a string that has value delimited by space
e.g. 1 2 10 8 etc.

I need to add a keyword wherever there is a space.
I wrote a small code to try this out:

$str = one two three;
$str =~ s/\s/x /g;

In this case, I am trying to insert x where there is a space. one two
three should
become one x two x three.
But the above example results in:
nex twox three (chops off leading o char)

The interesting this is that this happens only in debug mode.
The regular output is: onex twox three

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




substitute multiple spaces with just one

2008-11-04 Thread Sharan Basappa
Hi,

I have string that has one or more spaces. I would like to replace
them with a single space.
The simple code below replaces the spaces fine, but does not
substitute with a space.

$temp = 0 1  2   34; - version 1
$temp =~ s/\s+/\s/g;

$temp = 0 1  2   34; - version 2
$temp =~ s/\s+/s/g;

They both end up actually substituting spaces with string s

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: substitute multiple spaces with just one

2008-11-04 Thread Sharan Basappa
 You are completely right. :-)

 What you want to be doing is this: $temp =~ s/\s+/ /g;
 The reason for that is simple, \s is used to match a space or multiple
 spaces, it is not used to print a space that is actually done by the ' '
 (space). It might seem a little strange at first but just try and think of
 how you would read something like s/ {10}/../g; that would make no
 sense at all and you would have to go count the number of spaces so when
 matchin you use \s to represend a space, but when printing or substituting
 you simple use the ' ' (space).

Thanks. BTW, a variable ($x =  ) instead of actual space would do, right?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: debugger exiting

2008-11-04 Thread Sharan Basappa
 My final comment is that $temp is an awful name for a variable under almost 
 any
 circumstances.

I do agree. More often than not, if I dont have a meaningful name for
a variable it is mainly because the
problem and solution are not worked out clearly in mind.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




debugger exiting

2008-11-03 Thread Sharan Basappa
Hi,

I am using debugging for a program of mine.

The debugger exits probably after a regex match fail. I am not sure
why it should exit.
Any ideas, clues?

Regards

main::(StTrAuto.pl:106):  my @new_auto_tr = ();
  DB2 s
main::(StTrAuto.pl:107):  foreach $temp (@auto_tr)
main::(StTrAuto.pl:108):  {
  DB2 s
main::(StTrAuto.pl:109):if($temp =~ m/^$start_state)/)
main::(StTrAuto.pl:110):{
  DB2 s
Unmatched ) in regex; marked by -- HERE in m/^0) -- HERE / at
StTrAuto.pl line 109.
 at StTrAuto.pl line 109
Debugged program terminated.  Use q to quit or R to restart,
  use O inhibit_exit to avoid stopping after program termination,

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




match and putting in a variable with a single statement

2008-10-24 Thread Sharan Basappa
Hi,

I was just trying to match a string and save it in a single statement
as follows:

$extracted = cp xyz;
$state_var = $extracted =~ m/cp\s+(.*)/;
print $state_var $1 \n;

The output is: 1 xyz

So the assignment to $state_var does not work. Is this an incorrect way.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: match and putting in a variable with a single statement

2008-10-24 Thread Sharan Basappa
On Fri, Oct 24, 2008 at 8:42 PM, Chas. Owens [EMAIL PROTECTED] wrote:


 On Oct 24, 2008, at 11:00, Sharan Basappa [EMAIL PROTECTED]
 wrote:

 Hi,

 I was just trying to match a string and save it in a single statement
 as follows:

 $extracted = cp xyz;
 $state_var = $extracted =~ m/cp\s+(.*)/;
 print $state_var $1 \n;

 The output is: 1 xyz

 So the assignment to $state_var does not work. Is this an incorrect way.

 Regards

 In scalar context a match returns true if it matches or false if it doesn't.
  You want to use list context to cause the match to return the captures:

 ($var) = $foo =~ /(blah)/;

Thanks. This is exactly what I was looking for. Was trying to avoid
having to write two statements to
do this.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: using algorithm-permute

2008-10-22 Thread Sharan Basappa
On Wed, Oct 22, 2008 at 4:32 AM, Rob Dixon [EMAIL PROTECTED] wrote:
 Sharanbr wrote:
 On Oct 19, 6:38 am, [EMAIL PROTECTED] (Sisyphus) wrote:
 On Oct 17, 3:04 am, [EMAIL PROTECTED] (Sharan Basappa) wrote:

 #!/usr/bin/perl
 use warnings;
 use Algorithm::Permute;
 my @array = (1..4);
 Algorithm::Permute::permute { print @array\n } @array;

 use warnings;
 use strict;
 use Algorithm::Permute;

 my @array = (1..9);
 my $p = new Algorithm::Permute([EMAIL PROTECTED]);

 # print out the first 20 permutations of @array,
 # assigning each permutation to @new, and
 # printing it out:
 for(1..20) {
   my @new = $p-next;
   print @new\n;

 }

 I have modified the code a little bit to suit my requirements. But
 still the code does not seem to work i.e.
 the final print of @x does not display any value. However, I change
 the code foreach (@array) to for (1..)
 the way you have coded, it works fine. My requirement is to put all
 the permutations into a new array,
 not just (1..20)

 I have another basic doubt. After permute is called with @array
 argument, does it now contain
 new permutations or still (1..4).

 #!/usr/bin/perl
 use warnings;
 use Algorithm::Permute;

 my @array = (1..4);
 my $p  = new Algorithm::Permute([EMAIL PROTECTED]);
 foreach (@array)
 {
   my @x = $p-next;
   print @x \n;
 }

 You shouldn't pass a real array to the 'new' method as it destroys the array.
 It's bad but there it is, and the documentation does show it being called with
 an anonymous array.

 I'm not sure what you mean by 'put all the permutations into a new array', as
 each permutation is held in an array and I'm guessing that you don't know 
 about
 arrays of arrays?

 The program I've written below stores each permutation as a single string with
 spaces between the elements. If you really do want a array of arrays instead 
 of
 an array of strings then it's very obvious how to modify it to do that.

 HTH,

 Rob


 use strict;
 use warnings;

 use Algorithm::Permute;

 my $p = Algorithm::Permute-new([1 .. 4]);

 my @permutations;

 while (my @array = $p-next) {
  push @permutations, @array;
 }

 print $_\n foreach @permutations;

Thanks, Rob. The method works and also fits in the overall code I am writing.
The main reason for confusion from my side is my lack of understanding
of how different methods
of algo permute work (e.g. I was not aware that an anonymous array was
created. I was thinking that
the original array is modified to create permutations. Lack of good
doc also contributed to this confusion.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




using algorithm-permute

2008-10-16 Thread Sharan Basappa
Hi,

I need to create permutations of a given set of values.
The set is itself present in an array. From this I am trying to create
another array that has permutations of this set.

I am able to create a small example and run but from the description of
the module I am not sure how to put the permutations into another array.
Can someone tell me how the code given below can be modified.

PS: I am not well versed with perl classes

Regards,

#!/usr/bin/perl
use warnings;
use Algorithm::Permute;
my @array = (1..4);
Algorithm::Permute::permute { print @array\n } @array;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: add module path

2008-10-14 Thread Sharan Basappa
On Sat, Oct 11, 2008 at 5:51 PM, Jeff Pang [EMAIL PROTECTED] wrote:

 Message du 10/10/08 17:59
 De : Sharan Basappa
 A : Jeff Pang
 Copie à : Perl Beginners
 Objet : Re: add module path


 These are system installation. Can you tell me upto what directory
 should I be including use lib path?



 Under this case you don't need to specify a special path for the modules you
 installed.
 Perl can find them automatically.
 Perl will install them under one of these paths (the command below
 outputed):

 perl -e 'print join\n,@INC'


 Regards,
 Jeff.

 Créez votre adresse électronique [EMAIL PROTECTED]
 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.


Thanks Rob  Jeff,

I have tried installing the package in a common path.
I tried this for algorithm-permute and that goes through without any issues
I tried this for text-balanced and that creates issues.

It shows the foll issue:

Warning: prerequisite version 0 not found.
Could not eval '
package ExtUtils::MakeMaker::_version;
no strict;

local $VERSION;
$VERSION=undef; do {
use version; $VERSION = qv('2.0.0');
}; $VERSION
' in lib/Text/Balanced.pm: Can't locate version.pm in @INC
(@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at (eval 4) line 7, FH line 13.
BEGIN failed--compilation aborted at (eval 4) line 7, FH line 13.
WARNING: Setting VERSION via file 'lib/Text/Balanced.pm' failed
 at /usr/lib/perl5/5.8.5/ExtUtils/MakeMaker.pm line 506

So I tried installing version module first. That goes without any issues.
But I still face the above issue when trying to install text-balanced.

Regards

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: extract text between keywords

2008-10-14 Thread Sharan Basappa
On Fri, Oct 10, 2008 at 9:49 PM, Rob Dixon [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:

 I am trying to process a code for some processing.
 The code looks like

 keywordx ...

   keywordy identifier_a
 some text
   endkeywordy

   keywordz identifier_a
 some text
   endkeywordz

 endkeywordx

From this, I would like to extract text starting from keywordy and 
endkeywordy.
 Is using text balanced module the right way to go?
 An example with or without text-balanced module would be really helpful ...

 If your problem really is that simple, and you don't expect 'keywordy' blocks 
 to
 be nested inside other 'keywordy' blocks, then the program below will do what
 you need.

 It may help if you showed us some actual data so that we could get a better
 insight into how it behaves.

 HTH,

 Rob


 use strict;
 use warnings;

 while (DATA) {
  print if /\bkeywordy\b/ .. /\bendkeywordy\b/;
 }

 __DATA__
 keywordx ...

  keywordy identifier_a
some text
  endkeywordy

  keywordz identifier_a
some text
  endkeywordz

 endkeywordx

Thanks, Rob. I will give a try with this code. But given that there
are new lines between keyword and endkeyword,
do you think it will work.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: extract text between keywords

2008-10-14 Thread Sharan Basappa
On Tue, Oct 14, 2008 at 8:50 PM, Rob Dixon [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:
 On Fri, Oct 10, 2008 at 9:49 PM, Rob Dixon [EMAIL PROTECTED] wrote:

 If your problem really is that simple, and you don't expect 'keywordy' 
 blocks to
 be nested inside other 'keywordy' blocks, then the program below will do 
 what
 you need.

 It may help if you showed us some actual data so that we could get a better
 insight into how it behaves.


 use strict;
 use warnings;

 while (DATA) {
  print if /\bkeywordy\b/ .. /\bendkeywordy\b/;
 }

 __DATA__
 keywordx ...

  keywordy identifier_a
some text
  endkeywordy

  keywordz identifier_a
some text
  endkeywordz

 endkeywordx


 Thanks, Rob. I will give a try with this code. But given that there
 are new lines between keyword and endkeyword,
 do you think it will work.

 I am certain that it will work if the data is similar to what you have
 described. I hope it is obvious that my program reads the input file line by
 line, and you would need to write

  open my $fh, '', 'filename' or die $!;

  while ($fh) {
:
  }

 instead of using the DATA file handle as I did in my example.

 Rob


Thanks, Rob. I am aware that a file descriptor needs to be opened etc.
BTW, do you think text-balanced can help in situations that are slightly
more complex than I described above. For example, if I have data like:

keywordx id
some text
some text
{
  more text
  more text
}

I would like to extract starting from keywordx till closing braces.
Add to this, there will be multiple instances of such code pieces in the
input I am trying to process.

I looked at text-balanced but could not find anything that would help in doing
the above task.

Thanks once again ...

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




add module path

2008-10-10 Thread Sharan Basappa
Hi,

I have 2 permute and Text-balanced modules installed. They are in the path:
/home/user/local/perl/

I tried an example for permute by including the module path as:
/home/user/local/perl/perm_install/lib/perl5/site_perl

Now this seems to go through.

For Text-balanced, I dont find similar path.

I have a feeling I am overly complicating by including such a long path.
Please help and comment as to what the right way is to include the modules!

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: add module path

2008-10-10 Thread Sharan Basappa
2008/10/10 Jeff Pang [EMAIL PROTECTED]:

 Message du 10/10/08 16:49
 De : Sharan Basappa
 A : Perl Beginners
 Copie à :
 Objet : add module path


 Hi,

 I have 2 permute and Text-balanced modules installed. They are in the
 path:
 /home//local/perl/



 consider 'use lib' at the script's begin:

 use lib '/home/sth/local/perl';
 use modules; # your own modules under that path


 Regards,
 Jeff.

 Créez votre adresse électronique [EMAIL PROTECTED]
 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.


Sorry Jeff, if I was not clear in my question.
I am doing exactly what you have suggested (use use lib)
But the question really is what portion of the directory path to add to use lib.
For example, the text-balanced path looks somewhat like -
/home/user/local/perl/balanced_install
with lib and share directories in this path. So do I include
1) /home/user/local/perl/balanced_install?
2) /home/user/local/perl/balanced_install/lib?
or something else?

Regards

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: add module path

2008-10-10 Thread Sharan Basappa
Ok, so if I understand you correctly this is what I have to do

1) install module C in a/b/c directory (for example)

2) install module D in a/b/d directory

3) copy the .pm files installed under a/b/c and a/b/d to a/b/my_lib

4) include a/b/my_lib in perl code

So you are also saying that the path I am including should have .pm file under
the directory. Please note that currently under the lib directory installed,
there is no .pm file

Regards

On Fri, Oct 10, 2008 at 8:49 PM, Jeff Pang [EMAIL PROTECTED] wrote:
 Message du 10/10/08 17:13
 De : Sharan Basappa

 For example, the text-balanced path looks somewhat like -
 /home/user/local/perl/balanced_install
 with lib and share directories in this path. So do I include
 1) /home/user/local/perl/balanced_install?
 2) /home/user/local/perl/balanced_install/lib?

 That's decided by you.
 If you begin a project, all of the scripts are located in a path called
 /project/path.
 You could create the dir of /project/path/lib and put all the .pm files
 into it.
 Then you could use lib '/project/path/lib'  in each script of that
 project.


 Regards,
 Jeff.

 Créez votre adresse électronique [EMAIL PROTECTED]
 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




extract text between keywords

2008-10-10 Thread Sharan Basappa
Hi,

I am trying to process a code for some processing.
The code looks like

keywordx ...

  keywordy identifier_a
some text
  endkeywordy

  keywordz identifier_a
some text
  endkeywordz

endkeywordx

From this, I would like to extract text starting from keywordy and endkeywordy.
Is using text balanced module the right way to go?
An example with or without text-balanced module would be really helpful ...

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: add module path

2008-10-10 Thread Sharan Basappa
These are system installation. Can you tell me upto what directory
should I be including use lib path?

Regards

On Fri, Oct 10, 2008 at 9:10 PM, Jeff Pang [EMAIL PROTECTED] wrote:
 Message du 10/10/08 17:32
 De : Sharan Basappa
 A : Jeff Pang
 Copie à : Perl Beginners
 Objet : Re: add module path


 Ok, so if I understand you correctly this is what I have to do

 1) install module C in a/b/c directory (for example)

 2) install module D in a/b/d directory

 3) copy the .pm files installed under a/b/c and a/b/d to a/b/my_lib

 4) include a/b/my_lib in perl code


 If C and D is a system installation (ie,the modules from CPAN), you just use
 them as normal.
 if you have your own modules, then put them into a/b/my_lib (or any paths
 you liked).
 After that you use lib 'a/b/my_lib' in the codes.


 Regards,
 Jeff.

 Créez votre adresse électronique [EMAIL PROTECTED]
 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: extracting multiple statements ...

2008-09-23 Thread Sharan Basappa
On Mon, Sep 22, 2008 at 9:02 PM, Thomas Bätzler [EMAIL PROTECTED] wrote:
 Hi,

 Sharan Basappa [EMAIL PROTECTED] asked:
 I have a code snippet as follows:

 keyword id1 = a x b x c;
 keyword id2 = c x d x e;

 I would like to extract strings a x b x c and c x d x e.
 I know I can loop through the code and extract the strings,
 but is there a RE that can do this with a single statement.

 You could do something like

 #!/usr/bin/perl -w

 use strict;

 my $code;
 {
  local $/ = undef;

  $code = DATA;
 }

 my( @matches ) = ( $code =~ m/^\s*keyword\s+id\d+\s*=\s*(.*?)\s*;\s*$/gm );

 foreach my $match (@matches ){
  print $match\n;
 }

 __DATA__
 blah
 blah
 keyword id1 = a x b x c;
 blah
 keyword id2 = c x d x e;
 blah

 As a side point - is there way to debug RE. Example, many a
 times when we write an RE, it fails and requires fine tuning.
 But it would be good to see how far was the RE was able to go
 and at what point it bailed out.

 See http://www.weitz.de/regex-coach/

 HTH,
 Thomas


Thanks Tom and Shawn. The method given by Shawn works (with minor changes).

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




extracting multiple statements ...

2008-09-22 Thread Sharan Basappa
Hi,

I have a code snippet as follows:

keyword id1 = a x b x c;
keyword id2 = c x d x e;

I would like to extract strings a x b x c and c x d x e. I know I
can loop through the
code and extract the strings, but is there a RE that can do this with
a single statement.
My first guess was to use /s modifier but I am not sure.

As a side point - is there way to debug RE. Example, many a times when we write
an RE, it fails and requires fine tuning. But it would be good to see
how far was the
RE was able to go and at what point it bailed out.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: grabbing text between two tokens

2008-04-24 Thread Sharan Basappa
  OTOH, I don't see the point in struggling with Text::Balanced, when all you
 need is:

 my @extracted = $source =~ /covergroup.+?endgroup/gs;

The example I gave is simple but will become more complex as I keep adding
functionality to it. More complex input is yet to come. Also, I
believe people would
frown if they see applications of complex hand written regexes when
built in modules
can do that work.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: grabbing text between two tokens

2008-04-23 Thread Sharan Basappa
On Wed, Apr 23, 2008 at 8:33 PM, Gunnar Hjalmarsson [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:

  I have gone through the text-balanced doc and tried few examples
  myself. Looks like I need
  some help on this module usage and capabilities.
  Basically the text I am trying to extract is embedded inside two
  tokens (say {}),
  but it can occur anywhere in the input text stream. I tried using
 extract_tagged
  function, but that seems to succeed only if the text starts with the tag I
 am
  specifying.
  For example, the following example returns expected value (i.e. {abc}):
 

  snip



  $text = q{{abc}12345};
  ($extracted, $remainder) = extract_tagged($text, '{', '}');
  print $extracted \n;
 
  The following example does not (difference is that $text does not
  start with {):
 

  snip



  $text = q{12{abc}12345};
  ($extracted, $remainder) = extract_tagged($text, '{', '}');
  print $extracted \n;
 

  You need a prefix pattern as the fourth argument, e.g. '[\w\s]+'



  The other question I have is that I would like to use text-balanced
  module to extract multiple
  occurences of these strings that are tagged by these tokens. Is that
 possible?
 

  Use the extract_multiple() function.


Thanks, Gunnar. So I am assuming that extract_tagged is fine, but it
should go into
extract_multiple. Is that correct?

BTW, I seem to be having extracting code block below.
There is no output. Here is the code block:
#/usr/bin/perl


# read the input file for parsing - defered
# extract whatever is between covergroups
#!/usr/bin/perl
#use warnings;
use lib
/u/basappas/local/perl/perm_install/lib/perl5/site_perl;
use Text::Balanced qw (
extract_delimited
extract_bracketed
extract_quotelike
extract_codeblock
extract_variable
extract_tagged
extract_multiple

gen_delimited_pat
gen_extract_tagged
   );

$source =  covergroup cg @(posedge clk);
  coverpoint v_a
  {
bins sa = 0 = 1 = 2 = 0;
bins sa = 0 = 1 = 0;
  }
endgroup;

($extracted, $remainder) = extract_tagged($source, covergroup, endgroup,
'[\w\s]*');
print $extracted \n;

I remove the 4th arg and I see proper output. That is, the code is changed to:

#/usr/bin/perl


# read the input file for parsing - defered
# extract whatever is between covergroups
#!/usr/bin/perl
#use warnings;
use lib
/u/basappas/local/perl/perm_install/lib/perl5/site_perl;
use Text::Balanced qw (
extract_delimited
extract_bracketed
extract_quotelike
extract_codeblock
extract_variable
extract_tagged
extract_multiple

gen_delimited_pat
gen_extract_tagged
   );

$source =  covergroup cg @(posedge clk);
  coverpoint v_a
  {
bins sa = 0 = 1 = 2 = 0;
bins sa = 0 = 1 = 0;
  }
endgroup;

($extracted, $remainder) = extract_tagged($source, covergroup, endgroup);
print $extracted \n;

Is something wrong with the code?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: grabbing text between two tokens

2008-04-22 Thread Sharan Basappa
On Wed, Apr 16, 2008 at 12:20 AM, Gunnar Hjalmarsson [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:

  Gary Stainburn wrote:
 
  
   On Monday 14 April 2008 16:35, Sharan Basappa wrote:
  
  
I am trying to capture the text between two tokens. These tokens
always exist in pairs but can occur N times.
I somehow dont get what I want.
   
$str =~ m/tokena(.*)tokenb/ms;
print $1;
   
  
   Try
  
   $str =~ m/tokena(.*?)tokenb/ms;
  
 
 
  actually I tried this before posting this question. The issue is that
  regex stops after first match.
 

  Show us a short but _complete_ program, and we can help you correct it.


  --
  Gunnar Hjalmarsson
  Email: http://www.gunnar.cc/cgi-bin/contact.pl

  --

  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/

I have gone through the text-balanced doc and tried few examples
myself. Looks like I need
some help on this module usage and capabilities.
Basically the text I am trying to extract is embedded inside two
tokens (say {}),
but it can occur anywhere in the input text stream. I tried using extract_tagged
function, but that seems to succeed only if the text starts with the tag I am
specifying.
For example, the following example returns expected value (i.e. {abc}):
#!/usr/bin/perl
#use warnings;
use lib
/u/basappas/local/perl/perm_install/lib/perl5/site_perl;
use Text::Balanced qw (
extract_delimited
extract_bracketed
extract_quotelike
extract_codeblock
extract_variable
extract_tagged
extract_multiple

gen_delimited_pat
gen_extract_tagged
   );

$text = q{{abc}12345};
($extracted, $remainder) = extract_tagged($text, '{', '}');
print $extracted \n;

The following example does not (difference is that $text does not
start with {):#!/usr/bin/perl
#use warnings;
use lib
/u/basappas/local/perl/perm_install/lib/perl5/site_perl;
use Text::Balanced qw (
extract_delimited
extract_bracketed
extract_quotelike
extract_codeblock
extract_variable
extract_tagged
extract_multiple

gen_delimited_pat
gen_extract_tagged
   );

$text = q{12{abc}12345};
($extracted, $remainder) = extract_tagged($text, '{', '}');
print $extracted \n;

The other question I have is that I would like to use text-balanced
module to extract multiple
occurences of these strings that are tagged by these tokens. Is that possible?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: installing Text-Balanced module

2008-04-21 Thread Sharan Basappa
On Sat, Apr 19, 2008 at 12:35 AM, Gunnar Hjalmarsson [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:

  I downloaded version and installed it. That went smoothly. When I go back
 to text-balanced installation, it still does not seem to locate version.pm
 

  I think it's advisable to follow the recommendation in

 perldoc -q own module

  and use both the PREFIX and LIB options.

  Usually I install Perl modules as root, but as a learning exercise I
 installed version and Text::Balanced as a usual user. The log from the
 installation follows below.

  [EMAIL PROTECTED] .tmp]$ ls -lF
  total 368
  drwxr-xr-x4 gunnarh  gunnarh  4096 Dec 19  2006
 Text-Balanced-v2.0.0/
  -rw-r--r--1 gunnarh  gunnarh133120 Apr 18 13:39
 Text-Balanced-v2.0.0.tar
  drwxr-xr-x6 gunnarh  gunnarh  4096 Oct 24 20:47 version-0.74/
  -rw-r--r--1 gunnarh  gunnarh225280 Apr 18 13:39 version-0.74.tar
  [EMAIL PROTECTED] .tmp]$ cd version-0.74
  [EMAIL PROTECTED] version-0.74]$ perl Makefile.PL PREFIX=/home/gunnarh/perl
 LIB=/home/gunnarh/perl/lib
  Testing if you have a C compiler
  Checking if your kit is complete...
  Looks good
  Writing Makefile for version::vxs
  Writing Makefile for version
  [EMAIL PROTECTED] version-0.74]$ make
  cp lib/version.pm blib/lib/version.pm
  cp lib/version.pod blib/lib/version.pod
  make[1]: Entering directory `/home/gunnarh/.tmp/version-0.74/vutil'
  cp lib/version/vxs.pm ../blib/lib/version/vxs.pm
  gcc -c   -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING
 -fno-strict-aliasing -I/usr/loca
  l/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
 -O2 -g -pipe -march=i386 -m
  cpu=i686   -DVERSION=\0.74\ -DXS_VERSION=\0.74\ -fPIC
 -I/usr/lib/perl5/5.8.1/i386-linux-thread-
  multi/CORE   vutil.c
  /usr/bin/perl /usr/lib/perl5/5.8.1/ExtUtils/xsubpp  -typemap
 /usr/lib/perl5/5.8.1/ExtUtils/typemap -
  typemap ../lib/version/typemap  vxs.xs  vxs.xsc  mv vxs.xsc vxs.c
  gcc -c   -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING
 -fno-strict-aliasing -I/usr/loca
  l/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
 -O2 -g -pipe -march=i386 -m
  cpu=i686   -DVERSION=\0.74\ -DXS_VERSION=\0.74\ -fPIC
 -I/usr/lib/perl5/5.8.1/i386-linux-thread-
  multi/CORE   vxs.c
  Running Mkbootstrap for version::vxs ()
  chmod 644 vxs.bs
  rm -f ../blib/arch/auto/version/vxs/vxs.so
  LD_RUN_PATH= gcc  -shared -L/usr/local/lib vutil.o vxs.o  -o
 ../blib/arch/auto/version/vxs/vxs.so

  chmod 755 ../blib/arch/auto/version/vxs/vxs.so
  cp vxs.bs ../blib/arch/auto/version/vxs/vxs.bs
  chmod 644 ../blib/arch/auto/version/vxs/vxs.bs
  make[1]: Leaving directory `/home/gunnarh/.tmp/version-0.74/vutil'
  Manifying blib/man3/version.3pm
  [EMAIL PROTECTED] version-0.74]$ make test
  make[1]: Entering directory `/home/gunnarh/.tmp/version-0.74/vutil'
  make[1]: Leaving directory `/home/gunnarh/.tmp/version-0.74/vutil'
  PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e
 test_harness(0, 'blib/lib', 'blib/ar
  ch') t/*.t
  t/01base...ok
  t/02derivedok
  t/03requireok
 4/127 skipped: version require'd instead of use'd, cannot test qv
  All tests successful, 4 subtests skipped.
  Files=3, Tests=390,  1 wallclock secs ( 0.55 cusr +  0.03 csys =  0.58 CPU)
  make[1]: Entering directory `/home/gunnarh/.tmp/version-0.74/vutil'
  No tests defined for version::vxs extension.
  make[1]: Leaving directory `/home/gunnarh/.tmp/version-0.74/vutil'
  [EMAIL PROTECTED] version-0.74]$ make install
  make[1]: Entering directory `/home/gunnarh/.tmp/version-0.74/vutil'
  make[1]: Leaving directory `/home/gunnarh/.tmp/version-0.74/vutil'
  Installing
 /home/gunnarh/perl/lib/i386-linux-thread-multi/auto/version/vxs/vxs.so
  Installing
 /home/gunnarh/perl/lib/i386-linux-thread-multi/auto/version/vxs/vxs.bs
  Files found in blib/arch: installing files in blib/lib into architecture
 dependent library tree
  Installing /home/gunnarh/perl/lib/i386-linux-thread-multi/version.pod
  Installing /home/gunnarh/perl/lib/i386-linux-thread-multi/version.pm
  Installing /home/gunnarh/perl/lib/i386-linux-thread-multi/version/vxs.pm
  Installing /home/gunnarh/perl/share/man/man3/version.3pm
  Writing
 /home/gunnarh/perl/lib/i386-linux-thread-multi/auto/version/.packlist
  Appending installation info to
 /home/gunnarh/perl/lib/i386-linux-thread-multi/perllocal.pod
  [EMAIL PROTECTED] version-0.74]$ cd ..
  [EMAIL PROTECTED] .tmp]$ cd Text-Balanced-v2.0.0
  [EMAIL PROTECTED] Text-Balanced-v2.0.0]$ export
 PERL5LIB=/home/gunnarh/perl/lib
  [EMAIL PROTECTED] Text-Balanced-v2.0.0]$ perl Makefile.PL
 PREFIX=/home/gunnarh/perl LIB=/home/gunnarh/
  perl/lib
  Checking if your kit is complete...
  Looks good

  Writing Makefile for Text::Balanced
  [EMAIL PROTECTED] Text-Balanced-v2.0.0]$ make
  cp lib/Text/Balanced.pm blib/lib/Text/Balanced.pm
  Manifying blib/man3/Text::Balanced.3pm
  [EMAIL PROTECTED] Text-Balanced-v2.0.0]$ make test
  PERL_DL_NONLAZY=1

Re: installing Text-Balanced module

2008-04-18 Thread Sharan Basappa
On Thu, Apr 17, 2008 at 9:17 PM, Chas. Owens [EMAIL PROTECTED] wrote:


 On Apr 17, 2008, at 11:41, Sharan Basappa wrote:


 PREREQ_PM = {
 'Test::More' = 0,
 'version'= 0,
 },snip


 So, that means I have to install this module?

 Regards
 snip

 That means that both Test::More and version must be installed.  You check to
 see if a module is installed by saying

 perl -MModule::Name -e 1

 if you get an error then the module is not present in your system (or at
 least not visible).  Note that you may need to set PERL5_LIB in order to
 find the modules you  are installing:

 export PERL5_PATH=/u/basappas/local/perl/perm_install/lib/perl5/site_perl

I downloaded version and installed it. That went smoothly.
When I go back to text-balanced installation, it still does not seem
to locate version.pm

Any ideas?

Here are the steps:

setenv PERL5_PATH
/u/basappas/local/perl/version_install/lib/perl5/site_perl
(version_install is where version has been installed)
perl Makefile.PL PREFIX=/u/basappas/local/perl/balanced_install

The error is:
perl Makefile.PL PREFIX=/u/basappas/local/perl/balanced_install
Warning: prerequisite version 0 not found.
Could not eval '
package ExtUtils::MakeMaker::_version;
no strict;

local $VERSION;
$VERSION=undef; do {
use version; $VERSION = qv('2.0.0');
}; $VERSION
' in lib/Text/Balanced.pm: Can't locate version.pm in @INC
(@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at (eval 4) line 7, FH line 13.
BEGIN failed--compilation aborted at (eval 4) line 7, FH line 13.
WARNING: Setting VERSION via file 'lib/Text/Balanced.pm' failed
 at /usr/lib/perl5/5.8.5/ExtUtils/MakeMaker.pm line 506
Writing Makefile for Text::Balanced

One thing that puzzles me is that the search path does not include
/u/basappas/local/perl/version_install/lib/perl5/site_perl.
This despite setting PERL5_LIB to the above path.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-04-17 Thread Sharan Basappa
On Thu, Apr 17, 2008 at 1:26 AM, Rob Dixon [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:
   Rob,
  
   I replied to Chas' mail with steps I have followed to install the module.
   I have also tried omitting Algorithm to PREFIX, but that does not help.
  
   perl Makefile.PL PREFIX=/u/basappas/local/perl/iter2/Algorithm-Permute-0.11
   make install
   setenv PERL5LIB /u/basappas/local/perl/iter2/Algorithm-Permute-0.11
   perl Perm2.pl
   Can't locate Algorithm/Permute.pm in @INC (@INC contains:
   /u/basappas/local/perl/onemore/Algorithm-Permute-0.11
  
   There are few parameters and I sure I am not using one of them properly.
   1) argument to PREFIX (with or without Algorithm)
   2) PERL5LIB path
   3) use lib directive in my script

  You don't need both to set PERL5LIB and 'use lib'. One or the other is fine.

  My reply said,


   the log from 'make install' will show you where the module has been
   installed to

  You still haven't published your installation log, so I can't help you
  much further, but it's wrong to include the Algorithm folder in the path
  you supply as the value of the PREFIX parameter

  Why are you using


   PREFIX=/u/basappas/local/perl/iter2/Algorithm-Permute-0.11

  when it could be just


   PREFIX=/u/basappas/local/perl

  ?

  Look in the installation log for where it has put Algorithm/Permute.pm -
  i.e. what is the path to the Algorithm folder. Use that path in your
  'use lib' statement.

  Rob

Rob,

To avoid confusion, I have almost reset the steps and trying to follow some of
the recommendations given in this forum. The following are the steps.

$perl Makefile.PL PREFIX=/u/basappas/local/perl/perm_install
/local/perl/perm_install
Writing Makefile for Algorithm::Permute
Writing Makefile for Algorithm::Permute

$make install
::site_perl::5.8.5::i386-linux-thread-multi::perl5::site_perl::5.8.5::i386-linux-thread-multi::Algorithm::Permute.3pm
Installing 
/u/basappas/local/perl/perm_install/share/man/man3/perl5::site_perl::5.8.5::i386-linux-thread-multi::perl5::site_perl::5.8.5::i386-linux-thread-multi::perl5::site_perl::5.8.5::i386-linux-thread-multi::perl5::5.8.5::i386-linux-thread-multi::perllocal.3pm
Installing 
/u/basappas/local/perl/perm_install/share/man/man3/perl5::site_perl::5.8.5::i386-linux-thread-multi::perl5::site_perl::5.8.5::i386-linux-thread-multi::perl5::site_perl::5.8.5::i386-linux-thread-multi::perl5::site_perl::5.8.5::i386-linux-thread-multi::Algorithm::Permute.3pm
Writing 
/u/basappas/local/perl/perm_install/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
Appending installation info to
/u/basappas/local/perl/perm_install/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod

$make test
ok 24
ok 25
skipping 26: memory leak test
skipping 27: memory leak test
make[1]: Leaving directory
`/u/basappas/local/perl/perm_installable/Algorithm-Permute-0.06/Algorithm'

Now I move back to /u/basappas/local/perl where I have Perm2.pl
Its contents are:
#!/usr/bin/perl
use warnings;
use lib /u/basappas/local/perl/perm_install;
use Algorithm::Permute;

my @array = (1..4);
Algorithm::Permute::permute { print @array\n } @array;

The error is:
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/perm_install
/usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
BEGIN failed--compilation aborted at Perm2.pl line 4.

I am not sure if perm_install should be present in the lib pragma.
So I modified the perl code to be:
#!/usr/bin/perl
use warnings;
use lib /u/basappas/local/perl;
use Algorithm::Permute;

my @array = (1..4);
Algorithm::Permute::permute { print @array\n } @array;

The error is different. It is:
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl /usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5

Re: algorithm/permute.pm

2008-04-17 Thread Sharan Basappa
On Thu, Apr 17, 2008 at 7:37 PM, Chas. Owens [EMAIL PROTECTED] wrote:

  On Apr 17, 2008, at 10:03, Sharan Basappa wrote:
  snip


  $perl Makefile.PL PREFIX=/u/basappas/local/perl/perm_install
 
  snip

  Try

  use lib /u/basappas/local/perl/perm_install/lib/perl5/site_perl;



  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.


Thanks, Chas. It works now.
Thanks also to Sisyphus and Rob ..

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




installing Text-Balanced module

2008-04-17 Thread Sharan Basappa
I am installing Text-Balanced module locally.
perl Makefile.PL .. step does not complete.

It bails out with the foll. error:
Warning: prerequisite version 0 not found.
Could not eval '
package ExtUtils::MakeMaker::_version;
no strict;

local $VERSION;
$VERSION=undef; do {
use version; $VERSION = qv('2.0.0');
}; $VERSION
' in lib/Text/Balanced.pm: Can't locate version.pm in @INC
(@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at (eval 4) line 7, FH line 13.
BEGIN failed--compilation aborted at (eval 4) line 7, FH line 13.
WARNING: Setting VERSION via file 'lib/Text/Balanced.pm' failed
 at /usr/lib/perl5/5.8.5/ExtUtils/MakeMaker.pm line 506
Writing Makefile for Text::Balanced

This looks like a dependency issue. Can someone tell me what module
should I be installing before I can
install Text-Balanced?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: installing Text-Balanced module

2008-04-17 Thread Sharan Basappa
On Thu, Apr 17, 2008 at 8:41 PM, Gunnar Hjalmarsson [EMAIL PROTECTED] wrote:
 Sharan Basappa wrote:

  I am installing Text-Balanced module locally.
  perl Makefile.PL .. step does not complete.
 
  It bails out with the foll. error:
  Warning: prerequisite version 0 not found.
 

  snip



  This looks like a dependency issue. Can someone tell me what module
  should I be installing before I can
  install Text-Balanced?
 

  The Makefile.PL file can...
 http://search.cpan.org/src/DCONWAY/Text-Balanced-v2.0.0/Makefile.PL

I did not get you clearly. Are you saying that the Makefile can take
care of dependancy modules?
If so, what do the errors mean.
BTW, I continued despite the errors I mentioned above.
But when I run make test, the summary report shows:
2 tests skipped.
Failed 9/11 test scripts, 18.18% okay. 560/560 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 255

This tells me that all did not go well with installation.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: installing Text-Balanced module

2008-04-17 Thread Sharan Basappa
unfortunately the server I am trying to install the module is not
connected to net.

Regards

On Thu, Apr 17, 2008 at 9:05 PM, Chas. Owens [EMAIL PROTECTED] wrote:
 On Thu, Apr 17, 2008 at 10:57 AM, Sharan Basappa
  [EMAIL PROTECTED] wrote:
   I am installing Text-Balanced module locally.
perl Makefile.PL .. step does not complete.
  snip

   This looks like a dependency issue. Can someone tell me what module
should I be installing before I can
install Text-Balanced?
  snip

  If the machine you are using can connect to the Internet, you should
  really use CPAN to do the install (it takes care of the Perl
  dependencies).  Try running

  perl -MCPAN -e install Text::Balanced

  Answer with the default for most questions.  When you get to the part
  where it asks you

  Paramaters for the 'perl Makefile.PL' command?
  Typical frequently used settings:

 PREFIX=~/perl  non-root users (please see manual for more hints)

  Your choice:   [INSTALLDIRS=site]

  type in PREFIX=/u/basappas/local/perl/perm_install

  You should be able to use the defaults for the rest
  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: installing Text-Balanced module

2008-04-17 Thread Sharan Basappa
On Thu, Apr 17, 2008 at 9:07 PM, Chas. Owens [EMAIL PROTECTED] wrote:
 On Thu, Apr 17, 2008 at 11:34 AM, Sharan Basappa

 [EMAIL PROTECTED] wrote:


  On Thu, Apr 17, 2008 at 8:41 PM, Gunnar Hjalmarsson [EMAIL PROTECTED] 
  wrote:
 Sharan Basappa wrote:

  I am installing Text-Balanced module locally.
  perl Makefile.PL .. step does not complete.
 
  It bails out with the foll. error:
  Warning: prerequisite version 0 not found.
 

  snip



  This looks like a dependency issue. Can someone tell me what module
  should I be installing before I can
  install Text-Balanced?
 

  The Makefile.PL file can...
 http://search.cpan.org/src/DCONWAY/Text-Balanced-v2.0.0/Makefile.PL

I did not get you clearly. Are you saying that the Makefile can take
care of dependancy modules?
If so, what do the errors mean.
BTW, I continued despite the errors I mentioned above.
But when I run make test, the summary report shows:
2 tests skipped.
Failed 9/11 test scripts, 18.18% okay. 560/560 subtests failed, 0.00% 
 okay.
make: *** [test_dynamic] Error 255
  
This tells me that all did not go well with installation.
  
Regards
  
  
  
--

   To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
  
  
  

  He is trying to let you know that Makefile.PL contains the names of
  the modules this one is dependent on.  Specifically the hash ref
  stored in PREREQ_PM.

  use strict;
  use warnings;
  use ExtUtils::MakeMaker;

  WriteMakefile(
 NAME= 'Text::Balanced',
 AUTHOR  = 'Damian Conway [EMAIL PROTECTED]',
 VERSION_FROM= 'lib/Text/Balanced.pm',
 ABSTRACT_FROM   = 'lib/Text/Balanced.pm',
 INSTALLDIRS = ($] = 5.007003 ? 'perl' : 'site'),
 PL_FILES= {},
 PREREQ_PM = {
 'Test::More' = 0,
 'version'= 0,
 },
 dist= { COMPRESS = 'gzip -9f', SUFFIX = 'gz', },
 clean   = { FILES = 'Text-Balanced-*' },
  );




  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.


So, that means I have to install this module?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-04-16 Thread Sharan Basappa
On Tue, Apr 15, 2008 at 9:58 PM, Chas. Owens [EMAIL PROTECTED] wrote:
 Where/how did you install the module.  If it was not installed in the normal
 directory (ie the one it will be installed in if you installed as root) you
 will need to either set the PERL5_LIB environmental variable or use the lib
 pragma.


yes, the module is installed as a local library.
It is in path /u/basappas/local/perl/onemore/Algorithm-Permute-0.11

The following are the steps I followed:
perl Makefile.PL
PREFIX=/u/basappas/local/perl/onemore/Algorithm-Permute-0.11/Algorithm
-- this step completes normal
make install - this step completes normal

PERL5LIB is set to:
/u/basappas/local/perl/onemore/Algorithm-Permute-0.11/ (should it
point to Algorithm?)

My code snippet is:
#!/usr/bin/perl
use warnings;
use lib /u/basappas/local/perl/onemore/Algorithm-Permute-0.11;
use Algorithm::Permute;

my @array = (1..4);
Algorithm::Permute::permute { print @array\n } @array;

The error I get is:
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/onemore/Algorithm-Permute-0.11

Question:
- Am I right in adding Algorithm to the prefix arg
(PREFIX=/u/basappas/local/perl/onemore/Algorithm-Permute-0.11/Algorithm)?
- I was originally not adding Algorithm to the arg, but tried this
option since perl seem to be looking for Permute.pm inside Algorithm
dir (or  is it?)

Regards

  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.



  On Apr 15, 2008, at 12:00, Sharan Basappa wrote:


 
 
 
  On Fri, Apr 4, 2008 at 8:48 PM, Sharan Basappa [EMAIL PROTECTED]
 wrote:
 
   Dont seem to have luck. I did make test followed by make install.
   Here is what I got:
   make install
   Installing
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.so
   Installing
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.bs
   Files found in blib/arch: installing files in blib/lib into
   architecture dependent library tree
   Installing
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
   Installing
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/autosplit.ix
   Installing
 /u/basappas/local/perl/Algorithm-Permute-0.06/share/man/man3/Algorithm::Permute.3pm
   Writing
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
   Appending installation info to
  
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod
  
   The issue still remains. That is:
  
perl Perm2.pl
   
  
   Can't locate Algorithm/Permute.pm in @INC (@INC contains:
  
   /u/basappas/local/perl/Algorithm-Permute-0.06
  
   /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
   /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
   /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
   /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
   /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
   /usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
   BEGIN failed--compilation aborted at Perm2.pl line 4.
  
   Maybe I should rewind and start looking at this issue afresh now ...
  
   Regards
  
  
  
   On Tue, Apr 1, 2008 at 4:32 PM, sisyphus [EMAIL PROTECTED] wrote:
  
   
 I did the following:
 perl Makefile.PL
 PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06

   
That's probably where you've got the Algorithm-Permute source - I'm
not so sure it's a good idea to install the module into the source
folder, but if you want to do that then next run 'make test', followed
by 'make install'.
   
Then, try this script:
   
#!/usr/bin/perl
use warnings;
use lib /u/basappas/local/perl/Algorithm-Permute-0.06;
use Algorithm::Permute;
   
my @array = (1

Re: algorithm/permute.pm

2008-04-16 Thread Sharan Basappa
Rob,

I replied to Chas' mail with steps I have followed to install the module.
I have also tried omitting Algorithm to PREFIX, but that does not help.

perl Makefile.PL PREFIX=/u/basappas/local/perl/iter2/Algorithm-Permute-0.11
make install
setenv PERL5LIB /u/basappas/local/perl/iter2/Algorithm-Permute-0.11
perl Perm2.pl
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/onemore/Algorithm-Permute-0.11

There are few parameters and I sure I am not using one of them properly.
1) argument to PREFIX (with or without Algorithm)
2) PERL5LIB path
3) use lib directive in my script

TIA, Regards

On Tue, Apr 15, 2008 at 11:05 PM, Rob Dixon [EMAIL PROTECTED] wrote:

 Sharan Basappa wrote:
   On Fri, Apr 4, 2008 at 8:48 PM, Sharan Basappa [EMAIL PROTECTED] wrote:
   Dont seem to have luck. I did make test followed by make install.
Here is what I got:
make install
Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.so
Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.bs
Files found in blib/arch: installing files in blib/lib into
architecture dependent library tree
Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/autosplit.ix
Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/share/man/man3/Algorithm::Permute.3pm
Writing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
Appending installation info to

 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod
  
The issue still remains. That is:
perl Perm2.pl
  
   Can't locate Algorithm/Permute.pm in @INC (@INC contains:
  
   /u/basappas/local/perl/Algorithm-Permute-0.06
  
   /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
BEGIN failed--compilation aborted at Perm2.pl line 4.
  
Maybe I should rewind and start looking at this issue afresh now ...
  
Regards
  
  
  
On Tue, Apr 1, 2008 at 4:32 PM, sisyphus [EMAIL PROTECTED] wrote:
  I did the following:
   perl Makefile.PL 
 PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06

  That's probably where you've got the Algorithm-Permute source - I'm
  not so sure it's a good idea to install the module into the source
  folder, but if you want to do that then next run 'make test', followed
  by 'make install'.

  Then, try this script:

  #!/usr/bin/perl
  use warnings;
  use lib /u/basappas/local/perl/Algorithm-Permute-0.06;
  use Algorithm::Permute;

  my @array = (1..4);

 Algorithm::Permute::permute { print @array\n } @array;

  Why are you installing version 0.06 when the latest version is 0.11 ?



  Cheers,
  Rob


  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/



  
  
   Looking at the error once again, I did notice that I was probably not
   installing the module correctly.
   When I looked at the error, it said: Can't locate Algorithm/Permute.pm ..
   When I installed the module initially, the arg to prefix (perl
   Makefile.pl PREFIX=...) included
   the base directory and not Algorithm. The Algorithm directory expected
   above did not exist.
   Now I have installed as follows

Re: grabbing text between two tokens

2008-04-15 Thread Sharan Basappa
actually I tried this before posting this question. The issue is that
regex stops after first match.
The output is:
 name: name1

I did put /g at the end, but results are the same.

Regards

On Mon, Apr 14, 2008 at 9:11 PM, Gary Stainburn
[EMAIL PROTECTED] wrote:
 On Monday 14 April 2008 16:35, Sharan Basappa wrote:
   Hi,
  
   I am trying to capture the text between two tokens. These tokens
   always exist in pairs but can occur N times.
   I somehow dont get what I want.
  

  $str =~ m/tokena(.*)tokenb/ms;
   print $1;
  
  Try


  $str =~ m/tokena(.*?)tokenb/ms;

  The ? after the * stops it being greedy - i.e. it stops at the 1st tokenb and
  not the last

  Gary
  --
  Gary Stainburn

  This email does not contain private or confidential material as it
  may be snooped on by interested government parties for unknown
  and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: grabbing text between two tokens

2008-04-15 Thread Sharan Basappa
The issue is I have not been able to successfully install a local
module so far. I have tried this in the
context of Permute module and gave up after spending couple of days.

My mail with subject algorithm/permute.pm is the one I am talking about

Regards,

On Mon, Apr 14, 2008 at 9:44 PM, Chas. Owens [EMAIL PROTECTED] wrote:
 On Apr 14, 2008, at 11:35, Sharan Basappa wrote:


  Hi,
 
  I am trying to capture the text between two tokens. These tokens
  always exist in pairs but can occur N times.
  I somehow dont get what I want.
 
  snip

  You might consider looking at Text::Balanced*.

  * http://search.cpan.org/dist/Text-Balanced/lib/Text/Balanced.pm

  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-04-15 Thread Sharan Basappa
On Fri, Apr 4, 2008 at 8:48 PM, Sharan Basappa [EMAIL PROTECTED] wrote:
 Dont seem to have luck. I did make test followed by make install.
  Here is what I got:
  make install
  Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.so
  Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.bs
  Files found in blib/arch: installing files in blib/lib into
  architecture dependent library tree
  Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
  Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/autosplit.ix
  Installing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/share/man/man3/Algorithm::Permute.3pm
  Writing 
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
  Appending installation info to
  
 /u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod

  The issue still remains. That is:
  perl Perm2.pl

 Can't locate Algorithm/Permute.pm in @INC (@INC contains:

 /u/basappas/local/perl/Algorithm-Permute-0.06

 /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
  /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
  /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
  /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
  /usr/lib/perl5/site_perl
  /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
  /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
  /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
  /usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
  BEGIN failed--compilation aborted at Perm2.pl line 4.

  Maybe I should rewind and start looking at this issue afresh now ...

  Regards



  On Tue, Apr 1, 2008 at 4:32 PM, sisyphus [EMAIL PROTECTED] wrote:
I did the following:
 perl Makefile.PL PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06
  
That's probably where you've got the Algorithm-Permute source - I'm
not so sure it's a good idea to install the module into the source
folder, but if you want to do that then next run 'make test', followed
by 'make install'.
  
Then, try this script:
  
#!/usr/bin/perl
use warnings;
use lib /u/basappas/local/perl/Algorithm-Permute-0.06;
use Algorithm::Permute;
  
my @array = (1..4);
  
   Algorithm::Permute::permute { print @array\n } @array;
  
Why are you installing version 0.06 when the latest version is 0.11 ?
  
  
  
Cheers,
Rob
  
  
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
  
  
  


Looking at the error once again, I did notice that I was probably not
installing the module correctly.
When I looked at the error, it said: Can't locate Algorithm/Permute.pm ..
When I installed the module initially, the arg to prefix (perl
Makefile.pl PREFIX=...) included
the base directory and not Algorithm. The Algorithm directory expected
above did not exist.
Now I have installed as follows:
perl Makefile.pl PREFIX=base_directory/Algorithm
make install
make test

All these steps go through fine. In addition, I also find Algorithm
directory under the base dir.
the following are the files I find:
Algorithm  Changescoollex.oMANIFEST  Permute.bs  Permute.pm  README
bench  coollex.c  Makefile META.yml  Permute.c   Permute.xs  test.pl
blib   coollex.h  Makefile.PL  Perm2.pl  Permute.o   pm_to_blib  typemap

I thought this should solve my problem. The old error has disappeared
(Can't locate Algorithm/Permute.pm in)
But now I see a new error. That is:
Can't locate loadable object for module Algorithm::Permute in @INC

I was hoping that someone can provide some input so that I can get
around this issue.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




grabbing text between two tokens

2008-04-14 Thread Sharan Basappa
Hi,

I am trying to capture the text between two tokens. These tokens
always exist in pairs but can occur N times.
I somehow dont get what I want.

e.g.
In the example below, I would like to capture text between tokena and tokenb.
So it should capture name1 and name2.
$str = tokena
  name: name1
tokenb

tokena
  name: name2
tokenb;

$str =~ m/tokena(.*)tokenb/ms;
print $1;

When I run this program, I get
  name: name1
tokenb

tokena
  name: name2

Any suggestions?

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-04-04 Thread Sharan Basappa
Dont seem to have luck. I did make test followed by make install.
Here is what I got:
make install
Installing 
/u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.so
Installing 
/u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/Permute.bs
Files found in blib/arch: installing files in blib/lib into
architecture dependent library tree
Installing 
/u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm
Installing 
/u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/autosplit.ix
Installing 
/u/basappas/local/perl/Algorithm-Permute-0.06/share/man/man3/Algorithm::Permute.3pm
Writing 
/u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Algorithm/Permute/.packlist
Appending installation info to
/u/basappas/local/perl/Algorithm-Permute-0.06/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod

The issue still remains. That is:
perl Perm2.pl
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/Algorithm-Permute-0.06
/usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at Perm2.pl line 4.
BEGIN failed--compilation aborted at Perm2.pl line 4.

Maybe I should rewind and start looking at this issue afresh now ...

Regards

On Tue, Apr 1, 2008 at 4:32 PM, sisyphus [EMAIL PROTECTED] wrote:
  I did the following:
   perl Makefile.PL PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06

  That's probably where you've got the Algorithm-Permute source - I'm
  not so sure it's a good idea to install the module into the source
  folder, but if you want to do that then next run 'make test', followed
  by 'make install'.

  Then, try this script:

  #!/usr/bin/perl
  use warnings;
  use lib /u/basappas/local/perl/Algorithm-Permute-0.06;
  use Algorithm::Permute;

  my @array = (1..4);

 Algorithm::Permute::permute { print @array\n } @array;

  Why are you installing version 0.06 when the latest version is 0.11 ?



  Cheers,
  Rob


  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




cant find locally installed module

2008-04-01 Thread Sharan Basappa
I have installed permute module locally and added the path to my script.
However, perl fails to find the module.

The script:
#!/usr/bin/perl
use lib /u/basappas/local/perl/Algorithm-Permute-0.06;
use Algorithm::Permute;
my @array = (1..9);
Algorithm::Permute::permute { print @array\n } @array;

The files under /u/basappas/local/perl/Algorithm-Permute-0.06:
bench  Changes   Makefile.PL  META.ymlPermute.c  Permute.pm
pm_to_blib  typemap
blib   Makefile  MANIFEST Permute.bs  Permute.o  Permute.xs  test.pl

The error:
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/basappas/local/perl/Algorithm-Permute-0.06
/usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at Perm.pl line 3.
BEGIN failed--compilation aborted at Perm.pl line 3.

Please let me know if I am missing something...

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-03-31 Thread Sharan Basappa
I did the following:
perl Makefile.PL PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06

I got the following message:
perl/Algorithm-Permute-0.06
Writing Makefile for Algorithm::Permute

Now what? Should I execute the make file?

After that can I point to this library and start using new library?

Regards

On Wed, Mar 26, 2008 at 3:45 PM, sisyphus [EMAIL PROTECTED] wrote:

 On Mar 25, 2:52 am, [EMAIL PROTECTED] (Sharan Basappa) wrote:
   Hi,
  
   I am trying to use permute call from the above module and I get the
   following error.
   I believe this is due to either missing lib or incorrect path setting.
   Can you tell
   me how to install this package quickly in my home path and try out this 
 call?
  
   Regards
  
   Can't locate Algorithm/Permute.pm in @INC (@INC contains:
   /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
   /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
   /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
   /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
   /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
   /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
   /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
   /usr/lib/perl5/vendor_perl .) at Perm.pl line 2.
   BEGIN failed--compilation aborted at Perm.pl line 2.

  In addition to Paul's advice, I notice that @INC does not appear to
  contain (anything that resembles my expectation of what would be) your
  home path.
  Assuming that Permute.pm was successfully installed into the /home/me/
  lib/Algorithm/ directory, then Perm.pl would need to begin with:

  use lib '/home/me/lib';

  If, instead, the problem is how to install Algorithm::Permute into /
  home/me/lib, then (with a manual install) it's just a matter of
  starting with:

  perl Makefile.PL PREFIX=/home/me/lib
  or
  perl Makefile.PL PREFIX=~/lib

  (This is documented in 'perldoc Extutils::MakeMaker', which is
  referenced in the FAQ entry that Paul presented.)

  Cheers,
  Rob




  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm/permute.pm

2008-03-31 Thread Sharan Basappa
Here is what I have been able to do after installing the permute module:

My updated code looks like:
#!/usr/bin/perl
use lib /u/basappas/local/perl/Algorithm-Permute-0.06/Algorithm::Permute;
Algorithm::Permute::permute { print @array\n } @array;

When I execute this script, I get the following error:
Can't call method Algorithm::Permute::permute without a package or
object reference at Perm.pl line 3.

Actually, I took this example from permute user manual, which says:

use Algorithm::Permute;

  my $p = new Algorithm::Permute(['a'..'d']);
  while (@res = $p-next) {
print join(, , @res), \n;
  }

  my @array = (1..9);
  Algorithm::Permute::permute { print @array\n } @array;

Where Am I going wrong?

Regards

On Mon, Mar 31, 2008 at 6:40 PM, Sharan Basappa
[EMAIL PROTECTED] wrote:
 I did the following:
  perl Makefile.PL PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06

  I got the following message:
  perl/Algorithm-Permute-0.06
  Writing Makefile for Algorithm::Permute

  Now what? Should I execute the make file?

  After that can I point to this library and start using new library?

  Regards



  On Wed, Mar 26, 2008 at 3:45 PM, sisyphus [EMAIL PROTECTED] wrote:
  
   On Mar 25, 2:52 am, [EMAIL PROTECTED] (Sharan Basappa) wrote:
 Hi,

 I am trying to use permute call from the above module and I get the
 following error.
 I believe this is due to either missing lib or incorrect path setting.
 Can you tell
 me how to install this package quickly in my home path and try out this 
 call?

 Regards

 Can't locate Algorithm/Permute.pm in @INC (@INC contains:
 /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
 /usr/lib/perl5/site_perl
 /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
 /usr/lib/perl5/vendor_perl .) at Perm.pl line 2.
 BEGIN failed--compilation aborted at Perm.pl line 2.
  
In addition to Paul's advice, I notice that @INC does not appear to
contain (anything that resembles my expectation of what would be) your
home path.
Assuming that Permute.pm was successfully installed into the /home/me/
lib/Algorithm/ directory, then Perm.pl would need to begin with:
  
use lib '/home/me/lib';
  
If, instead, the problem is how to install Algorithm::Permute into /
home/me/lib, then (with a manual install) it's just a matter of
starting with:
  
perl Makefile.PL PREFIX=/home/me/lib
or
perl Makefile.PL PREFIX=~/lib
  
(This is documented in 'perldoc Extutils::MakeMaker', which is
referenced in the FAQ entry that Paul presented.)
  
Cheers,
Rob
  
  
  
  
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
  
  
  


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




parser using perl

2008-03-31 Thread Sharan Basappa
Hi,

I am trying to extract information from a file that follows the syntax
of a high level language (something like C++)
The script just needs to understand a very minuscule portion of this
language to do this. It does not have to
know the complete high level language. I just wanted to know any
modules are available within perl that makes
this job easier. I feel it is possible to do the complete work in
perl, but I might be wrong. Especially around the
recursion that languages support. The other option I have is to use a
public domain parser like Bison and parse
the input, build some data structure that perl can lookup and do the processing.

I would like to know experience of people on this forum ...

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: parser using perl

2008-03-31 Thread Sharan Basappa
I am not a compler expert, but if I all I am interested in few
productions out of
many productions, I can setup by scanner to generate tokens pertaining to
interesting productions and ignore the rest. As I said, I am not a
compiler expert.
So, I could be understating the problem ..

I will have a look at the parser library. Thanks ...

Regards

On Mon, Mar 31, 2008 at 8:16 PM, Chas. Owens [EMAIL PROTECTED] wrote:

 On Mon, Mar 31, 2008 at 10:36 AM, Sharan Basappa
  [EMAIL PROTECTED] wrote:
   Hi,
  
I am trying to extract information from a file that follows the syntax
of a high level language (something like C++)
The script just needs to understand a very minuscule portion of this
language to do this. It does not have to
know the complete high level language. I just wanted to know any
modules are available within perl that makes
this job easier. I feel it is possible to do the complete work in
perl, but I might be wrong. Especially around the
recursion that languages support. The other option I have is to use a
public domain parser like Bison and parse
the input, build some data structure that perl can lookup and do the 
 processing.
  
I would like to know experience of people on this forum ...
  
Regards


  Take a look at Parse::RecDescent*.  In general, it doesn't matter if
  you want to work with a small piece of a language or the whole
  language, you still need to implement a parser for the whole language.
   You can get an eighty or ninety percent solution without a full
  parser, but there will always be problems.

  * http://search.cpan.org/dist/Parse-RecDescent/lib/Parse/RecDescent.pm

  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: parser using perl

2008-03-31 Thread Sharan Basappa
true, I have the grammar in the form of BNF. But I am not interested
in converting
the BNF to parser rules, when I know that these productions are not
useful to me.
I am planning to write 8-10 rules and rules for pertaining tokens
only. Of course,
I might have to write additional rules to catch comments etc.

Regards,

On Mon, Mar 31, 2008 at 8:30 PM, Chas. Owens [EMAIL PROTECTED] wrote:
 On Mon, Mar 31, 2008 at 10:51 AM, Sharan Basappa

 [EMAIL PROTECTED] wrote:

  I am not a compler expert, but if I all I am interested in few
productions out of
many productions, I can setup by scanner to generate tokens pertaining to
interesting productions and ignore the rest. As I said, I am not a
compiler expert.
So, I could be understating the problem ..
  
I will have a look at the parser library. Thanks ...
  
Regards
  snip

  That assumes you have a grammar already, in which case generating a
  full parser is easy.  The problem comes from incomplete grammars.

  --


 Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




copy array

2008-03-25 Thread Sharan Basappa
Hi,

Is there a way I can copy only part of an array into another array.
For example, I want to copy only first 8 elements of source array
into destination array.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: copy array

2008-03-25 Thread Sharan Basappa
thanks. I can also assume that variables work instead of 0..7 ($1..$2)
so that I can
write this as an general algo

On Tue, Mar 25, 2008 at 9:31 PM, Rob Dixon [EMAIL PROTECTED] wrote:

 Sharan Basappa wrote:
   Hi,
  
   Is there a way I can copy only part of an array into another array.
   For example, I want to copy only first 8 elements of source array
   into destination array.

  my @dest = @source[0..7];

  Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




algorithm/permute.pm

2008-03-24 Thread Sharan Basappa
Hi,

I am trying to use permute call from the above module and I get the
following error.
I believe this is due to either missing lib or incorrect path setting.
Can you tell
me how to install this package quickly in my home path and try out this call?

Regards

Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at Perm.pl line 2.
BEGIN failed--compilation aborted at Perm.pl line 2.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: contributing to perl

2008-03-21 Thread Sharan Basappa
Thanks a lot. Actually, what I was looking for is how do I contribute
a subroutine like stuff to
perl. Most of the scripts listed in the link are standalone utilities
that achieve something.
What I want to conrtibute is something more basic. Lets say someone
(just for theory)
wanted to contribute a subroutine similar to split function. How would he do it?

On Fri, Mar 21, 2008 at 2:38 PM, J. Peng [EMAIL PROTECTED] wrote:
 You can contribute it to CPAN as a single perl script.
  See this guide:
  http://www.cpan.org/misc/cpan-faq.html#How_contribute_scripts



  On Fri, Mar 21, 2008 at 2:23 PM, Sharan Basappa
  [EMAIL PROTECTED] wrote:
   Hi,
  
I was thinking of contributing a utility function to perl. Want to
know what is the procedure.
Also, note that I dont have exposure to oops concept of perl (though I
have exposure to general
oops concept)
  
Regards
  
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
  
  
  


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: contributing to perl

2008-03-21 Thread Sharan Basappa
Thanks, I will take a look. But going by the webpage, it seems to me
that the changes will
to the language itself and chnages to compiler. But what I want to
contribute is a subroutine?
Is this the right way to go?

On Fri, Mar 21, 2008 at 3:03 PM, J. Peng [EMAIL PROTECTED] wrote:
 to perl5 or perl6? for perl5 you can subscribe to this list:
  http://lists.cpan.org/showlist.cgi?name=perl5-porters

  otherwise for perl6 you can subscribe to:
  http://lists.cpan.org/showlist.cgi?name=perl6-internals

  good luck on the processing.

  On Fri, Mar 21, 2008 at 5:25 PM, Sharan Basappa


 [EMAIL PROTECTED] wrote:
   Thanks a lot. Actually, what I was looking for is how do I contribute
a subroutine like stuff to
perl. Most of the scripts listed in the link are standalone utilities
that achieve something.
What I want to conrtibute is something more basic. Lets say someone
(just for theory)
wanted to contribute a subroutine similar to split function. How would he 
 do it?
  
  
  
On Fri, Mar 21, 2008 at 2:38 PM, J. Peng [EMAIL PROTECTED] wrote:
 You can contribute it to CPAN as a single perl script.
  See this guide:
  http://www.cpan.org/misc/cpan-faq.html#How_contribute_scripts



  On Fri, Mar 21, 2008 at 2:23 PM, Sharan Basappa
  [EMAIL PROTECTED] wrote:
   Hi,
  
I was thinking of contributing a utility function to perl. Want to
know what is the procedure.
Also, note that I dont have exposure to oops concept of perl 
 (though I
have exposure to general
oops concept)
  
Regards
  
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
  
  
  

  


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: contributing to perl

2008-03-21 Thread Sharan Basappa
ok. That clarifies ...

On Fri, Mar 21, 2008 at 3:29 PM, J. Peng [EMAIL PROTECTED] wrote:
 On Fri, Mar 21, 2008 at 5:55 PM, Sharan Basappa

 [EMAIL PROTECTED] wrote:

  Thanks, I will take a look. But going by the webpage, it seems to me
that the changes will
to the language itself and chnages to compiler. But what I want to
contribute is a subroutine?
Is this the right way to go?

  Write a module which includes that subroutine and contribute it to
  cpan, this is the best way I think.

  --


 To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




measuring performance

2008-03-20 Thread Sharan Basappa
* Haven't done this before, so need help *

Hi,

I am implementing two algos to solve same problem. I would like to
measure the performance of these 2 algos
(in terms of CPU cycles or wall clock etc.)
I have seen some explanation in some library document in perl the
comparison between different algos.

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: measuring performance

2008-03-20 Thread Sharan Basappa
Thanks, this is really helpful. In addition, is there a way to print
the cpu cycles taken from *ux command prompt?
I have worked with tools that, at the end of their job, print out the
cpu cycles it took for them.
I would assume that they use some command from *ux to do this.

Regards

On Thu, Mar 20, 2008 at 6:21 PM, Chas. Owens [EMAIL PROTECTED] wrote:
 On Thu, Mar 20, 2008 at 7:21 AM, Sharan Basappa
  [EMAIL PROTECTED] wrote:
  snip

  I am implementing two algos to solve same problem. I would like to
   measure the performance of these 2 algos
   (in terms of CPU cycles or wall clock etc.)
   I have seen some explanation in some library document in perl the
   comparison between different algos.
  snip

  You can use the Benchmark* module to compare two or more functions.
  What follows is a script that compares various methods of rotating an
  array.  You should also look into big O and little o notation.  The
  first few chapters of any good algorithms book should tell you what
  you need to know.

  #!/usr/bin/perl

  use strict;
  use warnings;

  use Benchmark;

  my @a;
  my %subs = (
 left_push_shift   = sub { push @a, shift @a; return 0 },
 left_slice= sub { @a = (@a[1..$#a], $a[0]); return 0 },
 right_unshift_pop = sub { unshift @a, pop @a; return 0 },
 right_slice   = sub { @a = (pop @a, @a); return 0 },
  );

  print test with ten elements\n;
  for my $sub (sort keys %subs) {
 @a = 1 .. 9;
 $subs{$sub}-();
 printf %-20s %s\n, $sub, join  , map {[$_]} @a;
  }

  for my $n (10, 100, 1_000, 10_000) {
 @a = 1 .. $n;
 print results for n of $n\n;
 Benchmark::cmpthese(-1, \%subs);
  }

  * http://perldoc.perl.org/Benchmark.html

  --
  Chas. Owens
  wonkden.net
  The most important skill a programmer can have is the ability to read.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: measuring performance

2008-03-20 Thread Sharan Basappa
ok, here is the issue I am having measuring the performance of a unix
process I am trying to execute
within perl. Within per because I want to use benchmark module to see
how long it takes to execute
this process.

Here is the code snippet:

#!/usr/bin/perl

use Benchmark;
# declare array
my @data;
# start timer
$start = new Benchmark;
system (vcs -sverilog Bins.sv -ntb_opts dtm -R);
$end = new Benchmark;
# calculate difference
$diff = timediff($end, $start);
# report
print Time taken was , timestr($diff, 'all'),  seconds;

The issue is that perl reports: Time taken was  1 wallclock secs

I think this is because perl is launching the process (vcs) and exits
(or is it?) and
hence there is really no time consumed between start and end. Can someone
comment?

Regards

On Thu, Mar 20, 2008 at 6:58 PM, John W. Krahn [EMAIL PROTECTED] wrote:
 Chas. Owens wrote:
   On Thu, Mar 20, 2008 at 9:15 AM, Sharan Basappa
   [EMAIL PROTECTED] wrote:
   Thanks, this is really helpful. In addition, is there a way to print
the cpu cycles taken from *ux command prompt?
I have worked with tools that, at the end of their job, print out the
cpu cycles it took for them.
I would assume that they use some command from *ux to do this.
   snip
  
   The time command in UNIX will give you the amount of time the program
   took to run, the amount of cpu time the program took to run, and the
   amount of time spent on system overhead:
  
   time ./q.pl
  
   real0m0.013s
   user0m0.007s
   sys 0m0.006s

  Or you could use the times() function built in to Perl.

  perldoc -f times


  John
  --
  Perl isn't a toolbox, but a small machine shop where you
  can special-order certain sorts of tools at low cost and
  in short order.-- Larry Wall



  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




  1   2   >