words selection

T

Truty

Hi,

Please help me,
I would like to realise a filtre to select only word in file with
caracteres include into this variable $carac_available;
but not caracteres include into this variable $carac_notavailable;

my name file is "dico.txt"

sample with $carac_available = 'eo'; and $carac_notavailable =
'hydngp';
word selected : close, mouve, ... because 'o' and 'e' is include into
this words and 'h', 'y', 'd', 'n', 'g', 'p' is not include into this
words.

content dico.txt :
doing
close
sunny
drugs
mouve
....


my code with problem :
open (FILE_ANSWER,"dico.txt.txt");
while ($ligne = <FILE_ANSWER>) {
chomp($ligne);
if (($ligne =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\) ) { print $ligne." | "; }
}
close FILE_ANSWER;



Please, can you please me ?
 
D

David Squire

Truty said:
Hi,

Please help me,
I would like to realise a filtre to select only word in file with
caracteres include into this variable $carac_available;
but not caracteres include into this variable $carac_notavailable;

my name file is "dico.txt"

sample with $carac_available = 'eo'; and $carac_notavailable = 'hydngp';
word selected : close, mouve, ... because 'o' and 'e' is include into
this words and 'h', 'y', 'd', 'n', 'g', 'p' is not include into this words.

content dico.txt :
doing
close
sunny
drugs
mouve
...


my code with problem :

missing:

use strict;
use warnings;
open (FILE_ANSWER,"dico.txt.txt");

Is this your real code? That filename does not match the one above, and
you really, really must check that the open was successful. This would
be much better:

open my $FILE_ANSWER, '<', 'dico.txt' or die "Could not open dico.txt
for reading: $!";
while ($ligne = <FILE_ANSWER>) {
chomp($ligne);
if (($ligne =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\) ) { print $ligne." | "; }

$carac_available and $carac_available are not defined in this example.
Please post a *complete* script that we can run and test. Cut-and-paste
the code, don't retype it.

This will not even compile. You can't use backslashes as regex
delimiters. The compiler should have told you that.

You would probably be better off creating compiled regular expression
variables rather than strings. See my example below.
}
close FILE_ANSWER;

----

#!/usr/bin/perl

use strict;
use warnings;

my $carac_available = qr([eo]);
my $carac_notavailable = qr([hydngp]);

while (my $ligne = <DATA>) {
chomp $ligne;
if (($ligne =~ $carac_available) && ($ligne !~ $carac_notavailable)) {
print $ligne." | ";
}
}

__DATA__
doing
close
sunny
drugs
mouve
botts
 
T

Truty

Thanks David,


I try to select more code for help me but I can't to copy and paste all
code.

Wait ... ;)
 
D

David Squire

Truty said:
Thanks David,


I try to select more code for help me but I can't to copy and paste all
code.


Please quote context when you reply. See the posting guidelines for this
group, which are posted here regularly.


DS
 
T

Truty

Truty avait soumis l'idée :
Hi,

Please help me,
I would like to realise a filtre to select only word in file with caracteres
include into this variable $carac_available;
but not caracteres include into this variable $carac_notavailable;

my name file is "dico.txt"

sample with $carac_available = 'eo'; and $carac_notavailable = 'hydngp';
word selected : close, mouve, ... because 'o' and 'e' is include into this
words and 'h', 'y', 'd', 'n', 'g', 'p' is not include into this words.

content dico.txt :
doing
close
sunny
drugs
mouve
...


my code with problem :
open (FILE_ANSWER,"dico.txt.txt");
while ($ligne = <FILE_ANSWER>) {
chomp($ligne);
if (($ligne =~ \[$carac_available]\) && ($ligne !~ \[$carac_notavailable]\)
) { print $ligne." | "; }
}
close FILE_ANSWER;



Please, can you please me ?

CODE :

#!/usr/bin/perl
use strict;
use warnings;

# in @sayword is recording words already say
# sample sayword : 'abcde' , 'kjuhy', '12345, 'KJITR' ...
my $sayword[0]= 'abcde'; # for test
# caracteres false is in this string
my $carac_notavailable = 'zwxvbdsau'; # for test
# caracteres OK is in this string
my $carac_available = 'cea'; # for test
my $line;
my $fileanswer = length($sayword[0]); # to select the file '4
caracteres' or '5 caracteres' or ......
open (FILE,"$fileanswer.txt"); # file = 4.txt or 5.txt or ....
while ($line = <FILE>) {
chomp($line);
if (($line =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\)) {
print $line." | "; # display word available
}
}
close FILE;




I hope to help me ...
 
D

David Squire

Truty said:
CODE :

#!/usr/bin/perl
use strict;
use warnings;

# in @sayword is recording words already say
# sample sayword : 'abcde' , 'kjuhy', '12345, 'KJITR' ...
my $sayword[0]= 'abcde'; # for test
# caracteres false is in this string
my $carac_notavailable = 'zwxvbdsau'; # for test
# caracteres OK is in this string
my $carac_available = 'cea'; # for test
my $line;
my $fileanswer = length($sayword[0]); # to select the file '4
caracteres' or '5 caracteres' or ......
open (FILE,"$fileanswer.txt"); # file = 4.txt or 5.txt or ....
while ($line = <FILE>) {
chomp($line);
if (($line =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\)) {
print $line." | "; # display word available
}
}
close FILE;

---- Attempting to run this produces -----

Backslash found where operator expected at ./test2.pl line 17, near "]\"
(Missing operator before \?)
Backslash found where operator expected at ./test2.pl line 17, near "]\"
(Missing operator before \?)
syntax error at ./test2.pl line 7, near "$sayword["
syntax error at ./test2.pl line 17, near "]\"
Global symbol "$ligne" requires explicit package name at ./test2.pl line 17.
syntax error at ./test2.pl line 20, near "}"
Execution of ./test2.pl aborted due to compilation errors.

----

This code contains the same errors that I pointed out in your original
post, as well as some new ones. Please read my post and make the
necessary changes before posting again.

You really should not post code that won't compile. The error messages
from the compiler and Perl's own documentation should get you past
syntax errors. I suggest that you read an introductory book on Perl, and
also become familiar with the documentation that comes with Perl. For a
start, try reading

perldoc perldata
perldoc perlre


DS
 
D

David Squire

David said:
Truty wrote:
[snip]
if (($ligne =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\) ) { print $ligne." | "; }
[snip]

This will not even compile. You can't use backslashes as regex
delimiters. The compiler should have told you that.

Clarification: you can't use backslashes as the delimiters without an
operator such as "m" being used at the start, e.g.

if (($ligne =~ /[$carac_available]/) && ($ligne !~
/[$carac_notavailable]/) ) { print $ligne." | "; }

is OK, and so is

if (($ligne =~ m\[$carac_available]\]) && ($ligne !~
m\[$carac_notavailable]\) ) { print $ligne." | "; }


DS
 
D

David Squire

David said:
David said:
Truty wrote:
[snip]
if (($ligne =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\) ) { print $ligne." | "; }
[snip]

This will not even compile. You can't use backslashes as regex
delimiters. The compiler should have told you that.

Clarification: you can't use backslashes as the delimiters without an
operator such as "m" being used at the start, e.g.

if (($ligne =~ /[$carac_available]/) && ($ligne !~
/[$carac_notavailable]/) ) { print $ligne." | "; }

is OK, and so is

if (($ligne =~ m\[$carac_available]\]) && ($ligne !~
m\[$carac_notavailable]\) ) { print $ligne." | "; }

Arggh. That should be

if (($ligne =~ m\[$carac_available]]\) && ($ligne !~
m\[$carac_notavailable]\) ) { print $ligne." | "; }
 
T

Truty

David Squire avait énoncé :
Truty said:
CODE :

#!/usr/bin/perl
use strict;
use warnings;

# in @sayword is recording words already say
# sample sayword : 'abcde' , 'kjuhy', '12345, 'KJITR' ...
my $sayword[0]= 'abcde'; # for test
# caracteres false is in this string
my $carac_notavailable = 'zwxvbdsau'; # for test
# caracteres OK is in this string
my $carac_available = 'cea'; # for test
my $line;
my $fileanswer = length($sayword[0]); # to select the file '4 caracteres'
or '5 caracteres' or ......
open (FILE,"$fileanswer.txt"); # file = 4.txt or 5.txt or ....
while ($line = <FILE>) {
chomp($line);
if (($line =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\)) {
print $line." | "; # display word available
}
}
close FILE;

---- Attempting to run this produces -----

Backslash found where operator expected at ./test2.pl line 17, near "]\"
(Missing operator before \?)
Backslash found where operator expected at ./test2.pl line 17, near "]\"
(Missing operator before \?)
syntax error at ./test2.pl line 7, near "$sayword["
syntax error at ./test2.pl line 17, near "]\"
Global symbol "$ligne" requires explicit package name at ./test2.pl line 17.
syntax error at ./test2.pl line 20, near "}"
Execution of ./test2.pl aborted due to compilation errors.

----

This code contains the same errors that I pointed out in your original post,
as well as some new ones. Please read my post and make the necessary changes
before posting again.

You really should not post code that won't compile. The error messages from
the compiler and Perl's own documentation should get you past syntax errors.
I suggest that you read an introductory book on Perl, and also become
familiar with the documentation that comes with Perl. For a start, try
reading

perldoc perldata
perldoc perlre


DS

sorry :( but now there aren't error when you compile.

A complable code :

#!/usr/bin/perl
use strict;
use warnings;

# in @sayword is recording words already say
# sample sayword : 'abcde' , 'kjuhy', '12345, 'KJITR' ...
my @sayword;
$sayword[0]= "abcde"; # for test
# caracteres false is in this string
my $carac_notavailable = "zwxvbdsau"; # for test
# caracteres OK is in this string
my $carac_available = "cea"; # for test
my $line;
my $fileanswer = length($sayword[0]); # to select the file '4
caracteres' or '5 caracteres' or ......
open (FILE,"$fileanswer.txt"); # file = 4.txt or 5.txt or ....
while ($line = <FILE>) {
chomp($line);
if (($line =~ $carac_available) && ($line !~ $carac_notavailable)) {
print $line." | "; # display word available
}
}
close FILE;
 
M

Matt Garrish

David said:
Truty said:
while ($ligne = <FILE_ANSWER>) {
chomp($ligne);
if (($ligne =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\) ) { print $ligne." | "; }

This will not even compile. You can't use backslashes as regex
delimiters. The compiler should have told you that.

You can't use backslashes as a delimiter without specifying m\\, but
that's true for all non-standard delimiters.

Matt
 
D

David Squire

Truty said:
David Squire avait énoncé :
Truty said:
CODE :

#!/usr/bin/perl
use strict;
use warnings;

# in @sayword is recording words already say
# sample sayword : 'abcde' , 'kjuhy', '12345, 'KJITR' ...
my $sayword[0]= 'abcde'; # for test
# caracteres false is in this string
my $carac_notavailable = 'zwxvbdsau'; # for test
# caracteres OK is in this string
my $carac_available = 'cea'; # for test
my $line;
my $fileanswer = length($sayword[0]); # to select the file '4
caracteres' or '5 caracteres' or ......
open (FILE,"$fileanswer.txt"); # file = 4.txt or 5.txt or ....
while ($line = <FILE>) {
chomp($line);
if (($line =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\)) {
print $line." | "; # display word available
}
}
close FILE;

---- Attempting to run this produces -----

Backslash found where operator expected at ./test2.pl line 17, near "]\"
(Missing operator before \?)
Backslash found where operator expected at ./test2.pl line 17, near "]\"
(Missing operator before \?)
syntax error at ./test2.pl line 7, near "$sayword["
syntax error at ./test2.pl line 17, near "]\"
Global symbol "$ligne" requires explicit package name at ./test2.pl
line 17.
syntax error at ./test2.pl line 20, near "}"
Execution of ./test2.pl aborted due to compilation errors.

----

This code contains the same errors that I pointed out in your original
post, as well as some new ones. Please read my post and make the
necessary changes before posting again.

You really should not post code that won't compile. The error messages
from the compiler and Perl's own documentation should get you past
syntax errors. I suggest that you read an introductory book on Perl,
and also become familiar with the documentation that comes with Perl.
For a start, try reading

perldoc perldata
perldoc perlre


DS

sorry :( but now there aren't error when you compile.

A complable code :

#!/usr/bin/perl
use strict;
use warnings;

# in @sayword is recording words already say
# sample sayword : 'abcde' , 'kjuhy', '12345, 'KJITR' ...
my @sayword;
$sayword[0]= "abcde"; # for test
# caracteres false is in this string
my $carac_notavailable = "zwxvbdsau"; # for test
# caracteres OK is in this string
my $carac_available = "cea"; # for test

The variables $carac_notavailable and $carac_available are here just
strings, not compiled regular expressions as in the example I gave you...
my $line;
my $fileanswer = length($sayword[0]); # to select the file '4
caracteres' or '5 caracteres' or ......
open (FILE,"$fileanswer.txt"); # file = 4.txt or 5.txt or ....

You're still not checking that this is successful - you must. Nor are
you using a lexical file handle, or the three-argument form of open as
suggested.

Also, it is much better to use the __DATA__ technique (as in my example
code) for posts here, as then we can all test the scripts. We can't test
this, because we don't have your filesystem.
while ($line = <FILE>) {
chomp($line);
if (($line =~ $carac_available) && ($line !~ $carac_notavailable)) {

Here you are using $carac_notavailable and $carac_available as if they
were compiled regular expressions, but they are not in this code.
print $line." | "; # display word available
}
}
close FILE;

Go back and look again at my first reply.


DS
 
T

Truty

David Squire a exposé le 02/09/2006 :
Truty said:
Hi,

Please help me,
I would like to realise a filtre to select only word in file with
caracteres include into this variable $carac_available;
but not caracteres include into this variable $carac_notavailable;

my name file is "dico.txt"

sample with $carac_available = 'eo'; and $carac_notavailable = 'hydngp';
word selected : close, mouve, ... because 'o' and 'e' is include into this
words and 'h', 'y', 'd', 'n', 'g', 'p' is not include into this words.

content dico.txt :
doing
close
sunny
drugs
mouve
...


my code with problem :

missing:

use strict;
use warnings;
open (FILE_ANSWER,"dico.txt.txt");

Is this your real code? That filename does not match the one above, and you
really, really must check that the open was successful. This would be much
better:

open my $FILE_ANSWER, '<', 'dico.txt' or die "Could not open dico.txt for
reading: $!";
while ($ligne = <FILE_ANSWER>) {
chomp($ligne);
if (($ligne =~ \[$carac_available]\) && ($ligne !~
\[$carac_notavailable]\) ) { print $ligne." | "; }

$carac_available and $carac_available are not defined in this example. Please
post a *complete* script that we can run and test. Cut-and-paste the code,
don't retype it.

This will not even compile. You can't use backslashes as regex delimiters.
The compiler should have told you that.

You would probably be better off creating compiled regular expression
variables rather than strings. See my example below.
}
close FILE_ANSWER;

----

#!/usr/bin/perl

use strict;
use warnings;

my $carac_available = qr([eo]);
my $carac_notavailable = qr([hydngp]);

while (my $ligne = <DATA>) {
chomp $ligne;
if (($ligne =~ $carac_available) && ($ligne !~ $carac_notavailable)) {
print $ligne." | ";
}
}

__DATA__
doing
close
sunny
drugs
mouve
botts

----

Output:

close | mouve | botts |

Ok, this reply interest me but if __DATA __ content this :
doing
close
sunny
drugs
mouve
botts

my output will be this :
close | mouve |

and not :
close | mouve | botts |

because botts haven't 'e' caracteres.

if i define two string : (this string don't stay egal at 'eo' or
'hydngp', it is a variable)

my $carac_available;
my $carac_notavailable;
....
$carac_available = 'eo';
$carac_notavailable = 'hydngp';
....

could you tell me the correct code line to obtain the correct output ?

if (($ligne =~ $carac_available) && ($ligne !~ $carac_notavailable))
{ print $ligne." | "; }

please.
 
D

David Squire

Truty said:
David Squire a exposé le 02/09/2006 :
----

#!/usr/bin/perl

use strict;
use warnings;

my $carac_available = qr([eo]);
my $carac_notavailable = qr([hydngp]);

while (my $ligne = <DATA>) {
chomp $ligne;
if (($ligne =~ $carac_available) && ($ligne !~
$carac_notavailable)) {
print $ligne." | ";
}
}

__DATA__
doing
close
sunny
drugs
mouve
botts

----

Output:

close | mouve | botts |

Ok, this reply interest me but if __DATA __ content this :
doing
close
sunny
drugs
mouve
botts

Of course that's what it contains. Try running the script. The __DATA__
section is part of it.
my output will be this :
close | mouve |

and not :
close | mouve | botts |

because botts haven't 'e' caracteres.

You want the string to contain *all* the characters in
$carac_available? That is not what your example suggested at all. You
were trying to do something equivalent to

if (($ligne =~ /[eo]/) && ($ligne !~ /[hydngp]/)) {

This uses character classes. [eo] matches any character in 'eo'. It
doesn't require them all to be present. In words, that line means "If
$ligne contains any character in 'eo' and doesn't contain any character
in 'hydngp'..."

What you want is more difficult. Off the top of my head, I can't think
of a single regex that would do it (but I guess someone else will :) ).
How about this:

----

#!/usr/bin/perl

use strict;
use warnings;

my $carac_available = 'eo';
my $carac_notavailable = 'hydngp';

while (my $ligne = <DATA>) {
chomp $ligne;
my $carac_available_copy = $carac_available;
while ($carac_available_copy && $ligne =~
/([$carac_available_copy])/) {
$carac_available_copy =~ s/$1//g;
}
if (!$carac_available_copy && ($ligne !~ /[$carac_notavailable]/)) {
print $ligne." | ";
}
}

__DATA__
doing
close
sunny
drugs
mouve
botts

----

Output:

close | mouve |

----
if i define two string : (this string don't stay egal at 'eo' or
'hydngp', it is a variable)

my $carac_available;
my $carac_notavailable;
...
$carac_available = 'eo';
$carac_notavailable = 'hydngp';
...

could you tell me the correct code line to obtain the correct output ?

if you want to use string variables, you can do so. I've already
addressed that in this thread. You just need to use valid regex
delimiters. Also see the examples above.


DS
 
D

David Squire

David said:
What you want is more difficult. Off the top of my head, I can't think
of a single regex that would do it (but I guess someone else will :) ).
How about this:

----

#!/usr/bin/perl

use strict;
use warnings;

my $carac_available = 'eo';
my $carac_notavailable = 'hydngp';

while (my $ligne = <DATA>) {
chomp $ligne;
my $carac_available_copy = $carac_available;
while ($carac_available_copy && $ligne =~
/([$carac_available_copy])/) {
$carac_available_copy =~ s/$1//g;
}
if (!$carac_available_copy && ($ligne !~ /[$carac_notavailable]/)) {
print $ligne." | ";
}
}

__DATA__
doing
close
sunny
drugs
mouve
botts

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
 
T

Truty

David Squire a pensé très fort :
David said:
What you want is more difficult. Off the top of my head, I can't think of a
single regex that would do it (but I guess someone else will :) ). How
about this:

----

#!/usr/bin/perl

use strict;
use warnings;

my $carac_available = 'eo';
my $carac_notavailable = 'hydngp';

while (my $ligne = <DATA>) {
chomp $ligne;
my $carac_available_copy = $carac_available;
while ($carac_available_copy && $ligne =~ /([$carac_available_copy])/)
{
$carac_available_copy =~ s/$1//g;
}
if (!$carac_available_copy && ($ligne !~ /[$carac_notavailable]/)) {
print $ligne." | ";
}
}

__DATA__
doing
close
sunny
drugs
mouve
botts

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.

THANKS :D
 
D

David Squire

Truty said:
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...

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


DS
 
T

Truty

David Squire a formulé ce samedi :
Truty said:
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...

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 !
 
T

Truty

Truty a exposé le 02/09/2006 :
David Squire a formulé ce samedi :
Truty said:
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...

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 ?
 
D

David Squire

Truty said:
Truty a exposé le 02/09/2006 :
David Squire a formulé ce samedi :
[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.
 
T

Truty

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top