Ask a Question related to PERL Beginners, Design and Development.
-
Wiggins D Anconia #1
Re: Simple Perl code/syntax question
> Hallo everyone and thank you for your previous help
Well there is the FAQ about case statements:>
> in basic the code would be
>
> for x=1 to 100
> Select Case
> Case=10,20,30,40,50,60,70,80,90
> then do this
> else
> else do this
> end select
> next x
>
> how is this done in perl?
>
> foreach (10,20,30,40,50,60,70,80,90);
> {
> do this;
> }
>
> ???? I think I need to unpack my books! (i'm moving)LOL
> Lou
>
perldoc -q 'switch or case'
In your case (pun intended) assuming the list is formed as you have it,
then you could do,
foreach my $index (1 .. 100) {
unless ($index % 10) {
# multiple of ten
}
else {
# not a multiple of ten
}
}
If your matches are not quite so nice,
my @list = (1, 15, 23, 67, 89);
foreach my $index (1 .. 100) {
if (grep $index == $_, @list) {
# case matched
}
else {
# non match
}
}
All code untested, HTH,
[url]http://danconia.org[/url]
Wiggins D Anconia Guest
-
Simple syntax question
Hi I don't remember how to get the diplayed result broken in multiple lines. The command: mysql> SHOW INDEX FROM recentchanges; gives one... -
simple syntax issue?
Hi, I just want a function to return true, but after a LoadVars.onLoad event. Am I right in assuuming that the return in the onLoad = function... -
Simple ANSI syntax Outer Join question
Hello. I have an application that uses many *= and =* outer joins in its queries. In order to convert an older query into the proper syntax, I am... -
Simple PHP Headers Syntax Question
What is the correct syntax to add a variable to a query string using the GET method of a form? I am trying to pass a dynamic variable ('$username').... -
Perl code question
Hi all, I'm trying to do something which I believe is quite complex, and I'm hoping someone here might not find it so complex. The problem...



Reply With Quote

