Re: Negate a regular expression

2006-12-30 Thread Chad Perrin
On Fri, Dec 29, 2006 at 11:36:25PM -0500, Mathew Snyder wrote: > I'm trying to set up an if clause to exit if an answer given is anything but > either any case combination of 'y' or 'yes'. This is what I have: > > exit if $ans =~ m/[^y|^yes]/i; > > Will that do what I want? If you want anything

Re: Negate a regular expression

2006-12-30 Thread Mathew Snyder
Chad Perrin wrote: > On Fri, Dec 29, 2006 at 11:36:25PM -0500, Mathew Snyder wrote: >> I'm trying to set up an if clause to exit if an answer given is anything but >> either any case combination of 'y' or 'yes'. This is what I have: >> >> exit if $ans =~ m/[^y|^yes]/i; >> >> Will that do what I wa

Re: Strings vs Arrays

2006-12-30 Thread John W. Krahn
M. Lewis wrote: > > I now we can push (concatenate) data onto an array. > > I would assume that we could concatenate data on to a string as well > with something like: > > $newstring = $oldstring . $newdata Yes. > Maybe this isn't correct though. I've not yet tried it. > > My question is one

[bug or restriction about msgget] I have a confusion about msgget(System V message queue)

2006-12-30 Thread flw
hi all, [EMAIL PROTECTED]:~$ ipcs -q -- Message Queues keymsqid owner perms used-bytes messages [EMAIL PROTECTED]:~$ perl -e 'use IPC::SysV qw(IPC_CREAT);$m=msgget(0x12345678,IPC_CREAT|0666) || die $!' [EMAIL PROTECTED]:~$ ipcs -q -- Message Queues ---

Re: Negate a regular expression

2006-12-30 Thread Leonid Grinberg
!~ will return true if the thing on the right does not match. In your case, however, using unless seems more logical. Something like exit unless (lc($answer) =~ /^[y|yes]$/) should work. The ^ and $ are there to make sure that the string contains nothing but ``y'' or ``yes''. Make sure that you

Re: Strings vs Arrays

2006-12-30 Thread Leonid Grinberg
To push something to an array: push(@array, $data); To push something onto a scalar: $scalar = $scalar . $data; -or- $scalar .= $data; The better method depends entirely on what you intend to do with the data and how you have it. It is also very easy to both split a string into an array, @arr

Re: Negate a regular expression

2006-12-30 Thread Dr.Ruud
"Leonid Grinberg" schreef: > Something like > > exit unless (lc($answer) =~ /^[y|yes]$/) > > should work. The ^ and $ are there to make sure that the string > contains nothing but ``y'' or ``yes''. No. Your "[y|yes]" is equivalent to "[|esy]" and matches a single character. I guess you meant

Re: Strings vs Arrays

2006-12-30 Thread M. Lewis
John W. Krahn wrote: M. Lewis wrote: I now we can push (concatenate) data onto an array. I would assume that we could concatenate data on to a string as well with something like: $newstring = $oldstring . $newdata Yes. Maybe this isn't correct though. I've not yet tried it. My question is

Is item in array

2006-12-30 Thread Mathew Snyder
Is there an easy way to determine if an item is in an array without iterating through the array and comparing each element to the item in question? Mathew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Is item in array

2006-12-30 Thread Ken Foskey
On Sun, 2006-12-31 at 00:54 -0500, Mathew Snyder wrote: > Is there an easy way to determine if an item is in an array without iterating > through the array and comparing each element to the item in question? Look up grep. You might be wanting a hash table not an array. Ta Ken -- To unsubscrib