Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Rodrick Brown
On Mon, Mar 30, 2009 at 12:42 AM, Chap Harrison c...@pobox.com wrote: This may be beyond the beginner level I don't know. I'd like to prompt the user to type in a City, State, and Zip in one line.  It's free-form, in that it's just for display, but I can make a pretty decent suggestion  

Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Chap Harrison
On Mar 30, 2009, at 6:31 AM, Rodrick Brown wrote: Sounds like something as basic as print Question to ask: ; $value=INPUT; is what your looking for? No, I'm looking for a limited version of the editing capabilities that modern command line interfaces have; namely, the ability to preload

Can't Retrieve Data From foreach block

2009-03-30 Thread Thomas H. George
How can I retrieve data loaded into an array within a foreach block? The array is defined outside the foreach block and is not the indexing array of the foreach loop. I have defined three arrays my @lines = (); my @line = (); my @lastnames = (); loaded into @lines a file in which each line is a

Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Chas. Owens
On Mon, Mar 30, 2009 at 00:42, Chap Harrison c...@pobox.com wrote: This may be beyond the beginner level I don't know. I'd like to prompt the user to type in a City, State, and Zip in one line.  It's free-form, in that it's just for display, but I can make a pretty decent suggestion  

Re: Can't Retrieve Data From foreach block

2009-03-30 Thread Alexander Koenig
Hi, You wrote on 03/30/2009 04:07 PM: How can I retrieve data loaded into an array within a foreach block? The array is defined outside the foreach block and is not the indexing array of the foreach loop. I ran your code and it works fine here. I did however have the same problem as you at

Re: Can't Retrieve Data From foreach block

2009-03-30 Thread Gunnar Hjalmarsson
Thomas H. George wrote: How can I retrieve data loaded into an array within a foreach block? The array is defined outside the foreach block and is not the indexing array of the foreach loop. I was about to ask the same question as Alex did. A few other remarks: my @lines = (); my @line =

Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Chap Harrison
On Mar 30, 2009, at 9:29 AM, Chas. Owens wrote: #!/usr/bin/perl use strict; use warnings; use Term::ReadLine; my $term = Term::ReadLine-new($0); Thanks - it does exactly what I wanted. I've looked at the perldoc for Term::ReadLine and it's a little thin - mainly because it describes

Input from bash shell to perl -e

2009-03-30 Thread D. Crouse
I have a perl -e function in my .bashrc file. This sources in the perl -e function so I can run it by just the command name. I'm having trouble with the substitution of my $1 bash variable into the perl -e function. Here is what I have so far. grepi () { perl -ne 'BEGIN {$/ = \n\n} print if

Re: Accepting terminal input with pre-loaded editable value

2009-03-30 Thread Chas. Owens
On Mon, Mar 30, 2009 at 11:30, Chap Harrison c...@pobox.com wrote: snip I've looked at the perldoc for Term::ReadLine and it's a little thin - mainly because it describes itself as being only a front-end to a variety of other packages. snip Yeah, you really need to look in Term::Readline::Gnu

Re: Input from bash shell to perl -e

2009-03-30 Thread D. Crouse
SOLUTION ! ah I got it !!! :) You have to use the $ENV grepi () { searchfor=$1 \ perl -ne 'BEGIN {$/ = \n\n} print if /$ENV{searchfor}/' $2 } Just an hour or two of working on it...and it finally pas out ! ! :) WOOT ! On Mon, Mar 30, 2009 at 11:30 AM, D. Crouse dc...@crouse.us

Re: Input from bash shell to perl -e

2009-03-30 Thread John W. Krahn
D. Crouse wrote: I have a perl -e function in my .bashrc file. This sources in the perl -e function so I can run it by just the command name. I'm having trouble with the substitution of my $1 bash variable into the perl -e function. Here is what I have so far. grepi () { perl -ne 'BEGIN {$/ =

Re: Input from bash shell to perl -e

2009-03-30 Thread D. Crouse
Thanks :) On Mon, Mar 30, 2009 at 12:02 PM, John W. Krahn jwkr...@shaw.ca wrote: D. Crouse wrote: I have a perl -e function in my .bashrc file. This sources in the perl -e function so I can run it by just the command name. I'm having trouble with the substitution of my $1 bash variable

Array question

2009-03-30 Thread ANJAN PURKAYASTHA
Hi, Here is my problem; I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1). I need to parse through this series of arrays and extract the index of the 0s in the array. Is there any quick way of doing this? TIA, Anjan -- = anjan purkayastha, phd

Re: Array question

2009-03-30 Thread Rodrick Brown
On Mon, Mar 30, 2009 at 2:20 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: Hi, Here is my problem; I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1). I need to parse through this series of arrays and extract the index of the 0s in the array. Is there any

Re: Array question

2009-03-30 Thread Chas. Owens
On Mon, Mar 30, 2009 at 14:20, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: Hi, Here is my problem; I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1). I need to parse through this series of arrays and extract the index of the 0s in the array. Is there any

Re: Array question

2009-03-30 Thread Chas. Owens
On Mon, Mar 30, 2009 at 14:28, Rodrick Brown rodrick.br...@gmail.com wrote: snip Millions of ways here is one: snip my $pos = 0; for my $index (@arr) {  if ( $index == 0 ) {     printf (%d , $pos );  }  $pos++; } snip If you are going to go with a full bore for loop, you might as well

Re: Array question

2009-03-30 Thread John W. Krahn
ANJAN PURKAYASTHA wrote: Hi, Hello, Here is my problem; I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1). I need to parse through this series of arrays and extract the index of the 0s in the array. Is there any quick way of doing this? $ perl -le' my @array = ( 1,

Re: Array question

2009-03-30 Thread Dave Tang
On Tue, 31 Mar 2009 04:49:17 +1000, John W. Krahn jwkr...@shaw.ca wrote: Or instead of using arrays you could store the 1s and 0s in strings: $ perl -le' my $string = 10110111001; print $-[0] while $string =~ /0/g; ' 1 4 8 9 Hi John, Could you explain how the above code works please? I

Re: Array question

2009-03-30 Thread John W. Krahn
Dave Tang wrote: On Tue, 31 Mar 2009 04:49:17 +1000, John W. Krahn jwkr...@shaw.ca wrote: Or instead of using arrays you could store the 1s and 0s in strings: $ perl -le' my $string = 10110111001; print $-[0] while $string =~ /0/g; ' 1 4 8 9 Could you explain how the above code works