On 20 Jun 2001 17:23:53 -0300, Sebadamus wrote:
> Hello,
>
> I am starting with Perl; and I have to make programs previously made in
> Visual Basic in Perl... (at least Windows wont hang up, now I am using linux
> :-))))
>
> Well, I made a little menu that reads from a config file and update it, may
> be some one woult find it useful (or may be not :-( Am an sending it
> later...
>
> Well my problem is (first problem) how do I to make a "while" or an if using
> more than one condition, for ex. in Visual Basic it would be:
>
> do while a=5 or b=2
> loop
>
> In Perl I could only use this (I am learing using some helps I found in the
> page... anyway can you people tell me any other good help???)
>
> while ( $op ne "E\n" )
> {
> bla bla bla
> }
>
Perl has two "or" based operators ("||" and "or"). It also has two
"and" based operators ("&&" and "and"). Type "perldoc perlop" to read
about them and the other Perl operators.
The Perl syntax to match the VB loop above is:
while ($a = 5 or $b = 2) {
blah blah blah;
}
>
> Well THANKS YOU ALL FOR OUR HELP, I hope to be able to help you some time...
>
> Sebastian from Argentina, Buenos Aires.
>
> Here is my code...
>
> #!/usr/bin/perl
> #use warnings;
> use strict;
>
>
> open FH, "cleanvec.ini" or die "Error: $!";
> my @fields;
>
> while (<FH>) {
> push @fields, (split /=/, $_);
> }
> close FH;
>
> my $mininimatch=$fields[1];
> my $minfinmatch=$fields[3];
> my $maxe=$fields[5];
> my $mingapmatch=$fields[7];
> my $sufijooutput=$fields[9];
>
> my $op = "";
> while ( $op ne "E\n" )
> {
> print `clear`;
> print " Clean Vec (v1.2) BioInfo, GEMA\n";
> print " ----- --- ------\n";
> print "\n Config. actual\n";
> print " ------- ------\n";
> print " 1 - MinIniMatch = $mininimatch\n";
> print " 2 - MinFinMatch = $minfinmatch\n";
> print " 3 - MaxE = $maxe\n";
> print " 4 - MinGapMatch = $mingapmatch\n";
> print " 5 - SufijoOutput = $sufijooutput\n\n";
> print " G - Grabar como default estas opciones.\n";
> print " E - Ejecutar.\n";
> print "\n\n";
> print "(Control + c) - Salir\n";
> print "Opcion : ";
> $op = <STDIN>;
It may make the code cleaner here if you use "chomp" here to get rid of
the '\n'.
chomp $op; #op no longer has \n on the end
the ifs would then change to
if ($op eq '1')
> if ($op eq "1\n")
> {
> print "Nuevo valor para MinIniMatch : ";
> $mininimatch = <STDIN>;
> }
> elsif ($op eq "2\n")
> {
> print "Nuevo valor para MinFinMatch : ";
> $minfinmatch = <STDIN>;
> }
> elsif ($op eq "3\n")
> {
> print "Nuevo valor para Maxe : ";
> $maxe = <STDIN>;
> }
> elsif ($op eq "4\n")
> {
> print "Nuevo valor para MinGapMatch : ";
> $mingapmatch = <STDIN>;
> }
> elsif ($op eq "5\n")
> {
> print "Nuevo valor para SufijoOutput : ";
> $sufijooutput = <STDIN>;
> }
> elsif ($op eq "G\n")
> {
> open FH, "> cleanvec.ini" or die "Error: $!";
> print FH "mininimatch=$mininimatch";
> print FH "minfinmatch=$minfinmatch";
> print FH "maxe=$maxe";
> print FH "mingapmatch=$mingapmatch";
> print FH "sugijooutput=$sufijooutput";
> close FH
> }
> }
> if ($op eq "E\n")
> {
> print "Es igual a E...";
> }
>
>
--
Today is Sweetmorn, the 25th day of Confusion in the YOLD 3167
This statement is false.