Re: new for regular expression in Perl

2006-01-04 Thread chen li
Thanks Chris and others for the information. Chris, I have another question: I have a file containing multiple lines and it looks like this: (line 1).chen. (line 2).. (line 3) chen. If I read the whole file at once and change it into a string I have no problem using

Re: calling subroutine via hash

2006-01-04 Thread Tom Phoenix
On 1/3/06, John W. Burns [EMAIL PROTECTED] wrote: my $radius_ref = @data; Could you have omitted a backslash on that line? Your code does what I think it should do, when I add the backslash before the @-sign. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail:

Re: Basic Math Problem

2006-01-04 Thread Tom Phoenix
On 1/3/06, David Newman [EMAIL PROTECTED] wrote: One quick fix here is to use printf instead: printf \n\%02f = %02f, $result, $result; I believe you were doing this to round off money numbers: numbers with exactly two digits after the decimal point. To do that, you need a slightly different

Re: calling subroutine via hash

2006-01-04 Thread Gautam Dey
John, The problem is not that it does not call the second subroutine, but that the second subroutine does not output anything. On Jan 3, 2006, at 12:39 PM, John W. Burns wrote: [cut] my %dispatch = ( foo = sub { my $x = 3; my $ans = ($x**2); print answer is: $ans \n;

conclusion: about eval and stdin

2006-01-04 Thread Adriano Allora
hi to all and thanks to all suggested me some solution, using debug lines (or something similar) I understood how obtaining the output I want. Now, I'm writing this e-mail to show a possible way to do a discrete corrector: I write a regexp to substitute (maybe with another regexp including

Re: new for regular expression in Perl

2006-01-04 Thread Shashidhara Bapat
Hi Chen, You can do one line at a time also. (Also, if you read whole file, convert it into a string and work on that string, the original file will not change.) - Regards, Shashi. On 1/4/06, chen li [EMAIL PROTECTED] wrote: Thanks Chris and others for the information. Chris, I have

Re: new for regular expression in Perl

2006-01-04 Thread chen li
Hi Shashi, Thanks for the reply. Sorry I didn't make myself clear enough in the previous email. If I read the whole file into an array (@file) and then change it into a scalar($string) the position of each word will change from the second line. If I want to know the position of each match the

Re: new for regular expression in Perl

2006-01-04 Thread Dave Gray
On 1/4/06, chen li [EMAIL PROTECTED] wrote: I think it might be natural for me to read the file line by line and get the return position looks like these(just an example), similar to do the word search in microsoft Word, which is what I really want: match in line 1 and the end of matching

Re: pack an array

2006-01-04 Thread Dave Gray
On 1/2/06, John W. Krahn [EMAIL PROTECTED] wrote: Gerard Robin wrote: Hello, Hello, I guess that one can write in more perlish fashion that I did: the part between the of this script to pack the array @array. Please, can someone give me some hint ? You don't need to use an

Re: new for regular expression in Perl

2006-01-04 Thread Chris Charley
- Original Message - From: chen li [EMAIL PROTECTED] [snip] I think it might be natural for me to read the file line by line and get the return position looks like these(just an example), similar to do the word search in microsoft Word, which is what I really want: match in line 1

Formatting Question

2006-01-04 Thread Sanbuah
Hello, Here's my question. Let's say I have the following numbers and I want to print them out so they are formatted in money terms: examples: 10834.00 1939432.00 to print out as: $10,834.00 $1,939,432.00 How can I do this? I was suspecting that the printf or sprintf functions

Re: Formatting Question

2006-01-04 Thread Jeremy Vinding
[EMAIL PROTECTED] wrote: Hello, Here's my question. Let's say I have the following numbers and I want to print them out so they are formatted in money terms: examples: 10834.00 1939432.00 to print out as: $10,834.00 $1,939,432.00 How can I do this? I was suspecting that the

Re: Formatting Question

2006-01-04 Thread Tom Phoenix
On 1/4/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say I have the following numbers and I want to print them out so they are formatted in money terms: Have you seen this sub? It's from p. 184 of the llama book (Learning Perl, 4th ed.). sub big_money { my $number = sprintf %.2f,