Re: passing a list as a variable

2006-07-24 Thread D. Bolliger
Dr.Ruud am Dienstag, 25. Juli 2006 00:34: > D. Bolliger: > > Dr.Ruud: > >> D. Bolliger: > >>> # input sanitizing > >>> # > >>> my $re_range=qr/\d+\s*\.\.\s*\d+/; > >>> $user_input=~/^\s*$re_range(?:\s*,\s*$re_range)*\s*$/ > >>> or die 'invalid input!'; > >>> > >>> my @list4=eval $user_input; > >>

Re: passing a list as a variable

2006-07-24 Thread Dr.Ruud
"Chris Charley" schreef: > Ryan Moszynski: >> Can I pass a list as a variable as I am trying to do, or doesn't perl >> support that? > > Just another way to do it using Set::IntSpan :-) I was trying to find a recent thread on the same issue, and now I found it, because I remembered that IntSpan

Re: passing a list as a variable

2006-07-24 Thread Dr.Ruud
D. Bolliger: > Dr.Ruud: >> D. Bolliger: >>> # input sanitizing >>> # >>> my $re_range=qr/\d+\s*\.\.\s*\d+/; >>> $user_input=~/^\s*$re_range(?:\s*,\s*$re_range)*\s*$/ >>> or die 'invalid input!'; >>> >>> my @list4=eval $user_input; >> >> An embedded newline can fool that test. >> >> You can make

Re: passing a list as a variable

2006-07-24 Thread D. Bolliger
Dr.Ruud am Montag, 24. Juli 2006 20:54: > "D. Bolliger" schreef: > > # input sanitizing > > # > > my $re_range=qr/\d+\s*\.\.\s*\d+/; > > $user_input=~/^\s*$re_range(?:\s*,\s*$re_range)*\s*$/ > > or die 'invalid input!'; > > > > my @list4=eval $user_input; > > An embedded newline can fool that tes

Re: passing a list as a variable

2006-07-24 Thread Chris Charley
- Original Message - From: ""Ryan Moszynski"" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: Sent: Monday, July 24, 2006 12:40 PM Subject: passing a list as a variable Is there a way to make my commented 'foreach" line act the same as the line above it? Can I pass a list as a v

Re: passing a list as a variable

2006-07-24 Thread Dr.Ruud
"D. Bolliger" schreef: > # input sanitizing > # > my $re_range=qr/\d+\s*\.\.\s*\d+/; > $user_input=~/^\s*$re_range(?:\s*,\s*$re_range)*\s*$/ > or die 'invalid input!'; > > my @list4=eval $user_input; An embedded newline can fool that test. You can make it much stricter, by replacing the \s by

Re: passing a list as a variable

2006-07-24 Thread Mumia W.
On 07/24/2006 12:12 PM, Mumia W. wrote: On 07/24/2006 11:40 AM, Ryan Moszynski wrote: Is there a way to make my commented 'foreach" line act the same as the line above it? [...] foreach (0..10,33..43,100..111){ #foreach ($list4){ [...] Use the split function to split $list4 on the comma

Re: passing a list as a variable

2006-07-24 Thread Mumia W.
On 07/24/2006 11:40 AM, Ryan Moszynski wrote: Is there a way to make my commented 'foreach" line act the same as the line above it? [...] foreach (0..10,33..43,100..111){ #foreach ($list4){ [...] Use the split function to split $list4 on the commas. Read about split: "perldoc -f split"

Re: passing a list as a variable

2006-07-24 Thread D. Bolliger
Joshua Colson am Montag, 24. Juli 2006 19:32: > On Mon, 2006-07-24 at 13:13 -0400, Ryan Moszynski wrote: > > thanks, that works, but it won't solve my problem. > > > > I'm writing a program where the user enters a list through the keyboard, > > like: "0..10,33..43,100..111" > > > > I would like to

Re: passing a list as a variable

2006-07-24 Thread Ryan Moszynski
thanks guys. Dr. Ruud's solution does the trick. I was trying to get around having to do that, but i guess you can't have everything. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: passing a list as a variable

2006-07-24 Thread Joshua Colson
On Mon, 2006-07-24 at 13:13 -0400, Ryan Moszynski wrote: > thanks, that works, but it won't solve my problem. > > I'm writing a program where the user enters a list through the keyboard, like: > "0..10,33..43,100..111" > > I would like to pass this list directly into a foreach function. The > pr

Re: passing a list as a variable

2006-07-24 Thread Ryan Moszynski
thanks, that works, but it won't solve my problem. I'm writing a program where the user enters a list through the keyboard, like: "0..10,33..43,100..111" I would like to pass this list directly into a foreach function. The problem is, when i pass my scalar in, i get: ### Argument "0..15,33..43,

Re: passing a list as a variable

2006-07-24 Thread Dr.Ruud
"Ryan Moszynski" schreef: > Can I pass a list as a variable as I am trying to do, or doesn't perl > support that? > > ### > #!/usr/bin/perl -w > $|=1; > #use strict; > > system "clear"; > my @array = 1024; > my $list4 = "0..10,33..43,100..111"; > > foreach (0..10,33..43,100..111){ >

RE: passing a list as a variable

2006-07-24 Thread Moon, John
-Original Message- From: Ryan Moszynski [mailto:[EMAIL PROTECTED] Sent: Monday, July 24, 2006 12:41 PM To: beginners@perl.org Subject: passing a list as a variable Is there a way to make my commented 'foreach" line act the same as the line above it? Can I pass a list as a variable as I a

Re: passing a list as a variable

2006-07-24 Thread D. Bolliger
Ryan Moszynski am Montag, 24. Juli 2006 18:40: > Is there a way to make my commented 'foreach" line act the same as the > line above it? Yes! DISCLAIMER: Please excuse my bad english > Can I pass a list as a variable as I am trying to do, or doesn't perl > support that? You can, but... see belo

RE: passing a list as a variable

2006-07-24 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Ryan Moszynski wrote: > Is there a way to make my commented 'foreach" line act the same as the > line above it? > > Can I pass a list as a variable as I am trying to do, or doesn't perl > support that? > > ### > #!/usr/bin/perl -w > $|=1; > #use strict; > > system "clear"; > my @array =

Re: passing a list as a variable

2006-07-24 Thread Joshua Colson
On Mon, 2006-07-24 at 12:40 -0400, Ryan Moszynski wrote: > Is there a way to make my commented 'foreach" line act the same as the > line above it? > Sure. > Can I pass a list as a variable as I am trying to do, or doesn't perl > support that? > > ### > #!/usr/bin/perl -w > $|=1; > #use s