From: David Squire on
Truty wrote:
> David Squire a pens? tr?s fort :
>>
>> This method is perhaps clearer:
>>
>> ----
>>
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> my $carac_available = 'eo';
>> my $carac_notavailable = 'hydngp';
>>
>> while (my $ligne = <DATA>) {
>> chomp $ligne;
>> my $contains_all_carac_available = 1;
>> $contains_all_carac_available &= ($ligne =~ /$_/) for split //,
>> $carac_available;
>> if ($contains_all_carac_available && ($ligne !~
>> /[$carac_notavailable]/)) {
>> print $ligne." | ";
>> }
>> }
>>
>> __DATA__
>> doing
>> close
>> sunny
>> drugs
>> mouve
>> botts
>
> THANKS ! ! !
>
> It is working very well but I have just an error if $carac_available is
> empty or $carac_notavailable.

Then just test for that at the start of the loop...

> THANKS :D
>
>

De rien. Je cherchais quelquechose a faire cet apres-midi gris :)


DS
From: Truty on
David Squire a formul? ce samedi :
> Truty wrote:
>> David Squire a pens? tr?s fort :
>>>
>>> This method is perhaps clearer:
>>>
>>> ----
>>>
>>> #!/usr/bin/perl
>>>
>>> use strict;
>>> use warnings;
>>>
>>> my $carac_available = 'eo';
>>> my $carac_notavailable = 'hydngp';
>>>
>>> while (my $ligne = <DATA>) {
>>> chomp $ligne;
>>> my $contains_all_carac_available = 1;
>>> $contains_all_carac_available &= ($ligne =~ /$_/) for split //,
>>> $carac_available;
>>> if ($contains_all_carac_available && ($ligne !~
>>> /[$carac_notavailable]/)) {
>>> print $ligne." | ";
>>> }
>>> }
>>>
>>> __DATA__
>>> doing
>>> close
>>> sunny
>>> drugs
>>> mouve
>>> botts
>>
>> THANKS ! ! !
>>
>> It is working very well but I have just an error if $carac_available is
>> empty or $carac_notavailable.
>
> Then just test for that at the start of the loop...
>
>> THANKS :D
>>
>>
>
> De rien. Je cherchais quelquechose a faire cet apres-midi gris :)
>
>
> DS

lol je suis pas une star en anglais et tu parle fran?ais Mdr

ba je te remercie ?a donne un coup de pouce au projet, qui depuis qlq
jours ?taient bloqu? ? cause de ?a.


Merci encore !


From: Truty on
Truty a expos? le 02/09/2006 :
> David Squire a formul? ce samedi :
>> Truty wrote:
>>> David Squire a pens? tr?s fort :
>>>>
>>>> This method is perhaps clearer:
>>>>
>>>> ----
>>>>
>>>> #!/usr/bin/perl
>>>>
>>>> use strict;
>>>> use warnings;
>>>>
>>>> my $carac_available = 'eo';
>>>> my $carac_notavailable = 'hydngp';
>>>>
>>>> while (my $ligne = <DATA>) {
>>>> chomp $ligne;
>>>> my $contains_all_carac_available = 1;
>>>> $contains_all_carac_available &= ($ligne =~ /$_/) for split //,
>>>> $carac_available;
>>>> if ($contains_all_carac_available && ($ligne !~
>>>> /[$carac_notavailable]/)) {
>>>> print $ligne." | ";
>>>> }
>>>> }
>>>>
>>>> __DATA__
>>>> doing
>>>> close
>>>> sunny
>>>> drugs
>>>> mouve
>>>> botts
>>>
>>> THANKS ! ! !
>>>
>>> It is working very well but I have just an error if $carac_available is
>>> empty or $carac_notavailable.
>>
>> Then just test for that at the start of the loop...
>>
>>> THANKS :D
>>>
>>>
>>
>> De rien. Je cherchais quelquechose a faire cet apres-midi gris :)
>>
>>
>> DS
>
> lol je suis pas une star en anglais et tu parle fran?ais Mdr
>
> ba je te remercie ?a donne un coup de pouce au projet, qui depuis qlq jours
> ?taient bloqu? ? cause de ?a.
>
>
> Merci encore !

if $carac_available is empty or $carac_notavailable too. :s

while (my $ligne = <DATA>) {
chomp $ligne;
if ($carac_available not eq '') {
my $contains_all_carac_available = 1;
$contains_all_carac_available &= ($ligne =~ /$_/) for split
//,
$carac_available;
}
if ($carac_notavailable not eq '') {
if ($contains_all_carac_available && ($ligne !~
/[$carac_notavailable]/)) { print $ligne." | "; }
}
}

I haven't got understand your code, can you terminate it ?


From: David Squire on
Truty wrote:
> Truty a expos? le 02/09/2006 :
>> David Squire a formul? ce samedi :
>>> Truty wrote:
>>>>
>>>> It is working very well but I have just an error if $carac_available
>>>> is empty or $carac_notavailable.
>>>
>>> Then just test for that at the start of the loop...
>>>

[snip]

>
> if $carac_available is empty or $carac_notavailable too. :s
>
> while (my $ligne = <DATA>) {
> chomp $ligne;
> if ($carac_available not eq '') {
> my $contains_all_carac_available = 1;
> $contains_all_carac_available &= ($ligne =~ /$_/) for split //,
> $carac_available;
> }
> if ($carac_notavailable not eq '') {
> if ($contains_all_carac_available && ($ligne !~
> /[$carac_notavailable]/)) { print $ligne." | "; }
> }
> }
>
> I haven't got understand your code, can you terminate it ?

If those variables get modified during the loop, I guess you just want
to move on to the next iteration of the loop if either of them is empty.
You can do this by using this line:

next if !($carac_available && $carac_notavailable);


DS

PS. Please quote only the relevant context when replying, not the whole
post.
From: Truty on
David Squire avait ?crit le 02/09/2006 :
> next if !($carac_available && $carac_notavailable);

but with this line I haven't all words result, because
$carac_available is empty and $carac_notavailable isn't empty
or
$carac_available isn't empty and $carac_notavailable is empty