Re: Regarding pattern matching

2007-05-17 Thread Matthew J. Avitable
Dharshana Eswaran wrote: Hi All, I am trying to extract few strings from a text file. The pattern of the text stored in the file is as follows: #define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */ I need to extract MNSS_FACILITY_IND_ID, TF_MNSS_ME

Re: missing something from regex ...

2007-05-16 Thread Matthew J. Avitable
Gregory Machin wrote: $row = "CLIENT_LIST,tsc-odi.vpn.ct-net.org,165.146.60.29:11134,10.1.0.46,1959761,218729,Wed May 16 11:24:37 2007,1179307477" $row = ~/(\w+)\,(\w+)\,(\d+\.\d+\.\d+\.\d+\:\d+)\,(\d+\.\d+\.\d+\.\d+)\,(\d+)\,(\d+)\,\,(\d+)/ print "info $1 \n"; print "hostname $2 \n"; prin

Re: creating hash from scalar variable

2007-04-30 Thread Matthew J. Avitable
Unf. Got the picture! I'll spend my night in the stockades :) -m Rob Dixon wrote: Matthew J. Avitable wrote: Given the original string ... my $test = 'NAS-IP-Address = 192.168.42.1 ... Acct-Unique-Session-Id = "87d380e1881d226c" Timestamp = 1177282824

Re: creating hash from scalar variable

2007-04-29 Thread Matthew J. Avitable
Given the original string ... my $test = 'NAS-IP-Address = 192.168.42.1 ... Acct-Unique-Session-Id = "87d380e1881d226c" Timestamp = 1177282824'; You could also invoke perl 5.8's ability to treat an in-memory string as a file: ## get a filehandle on $test open(my $fh, '<', \$test

Re: improving my code: array of references

2007-04-27 Thread Matthew J. Avitable
Pierre, Thank you, but I got it to work the way I wanted, thanks to Matthew and Rob's posts: map { modify_variable(${$_}) } = \($var1, $var2, $var3); To annotate to what Paul said - the above won't work. The block syntax of map is "map BLOCK LIST". Plus, it looks like you are going to

Re: improving my code: array of references

2007-04-26 Thread Matthew J. Avitable
Hi Pierre, my @tmp = ( $var1, $var2, $var3 ); @tmp = map modify_variable, @tmp; which is better Conway (in Perl Best Practices) prefers the block form of map, since in his opinion, it's more readable. So you could rewrite it as: my @tmp = ( $var1, $var2, $var3 ); @tmp = map { modify_variab