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
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
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
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 ---
!~ 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
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
"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
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 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/
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
10 matches
Mail list logo