Re: IF statements and modules - do they mix?

2005-07-29 Thread Scott R. Godin
John W. Krahn wrote: Scott R. Godin wrote: Dave Adams wrote: Does perl allow you to conditionally include a module? [snip] If you're using Perl 5.7.3 or later you can use if $DEBUG, diagnostics -verbose; details in 'perldoc if' :) And all you people who answered with something other

Re: IF statements and modules - do they mix?

2005-07-27 Thread John W. Krahn
Scott R. Godin wrote: > Dave Adams wrote: >> Does perl allow you to conditionally include a module? >> >> For example: >> >> #!/usr/bin/perl -w >> use strict; >> my $DEBUG = 0; >> if (DEBUG) { >> use diagnostics; >> } >> my $filename = "test$$.txt"; >> open (FH , ">$filename") || die "error: $!

Re: IF statements and modules - do they mix?

2005-07-27 Thread Scott R. Godin
Dave Adams wrote: Does perl allow you to conditionally include a module? For example: #!/usr/bin/perl -w use strict; my $DEBUG = 0; if (DEBUG) { use diagnostics; } my $filename = "test$$.txt"; open (FH , ">$filename") || die "error: $!"; print (FH "hi"); close (FH); Although this is a simp

RE: IF statements and modules - do they mix?

2005-07-27 Thread Bob Showalter
Charles K. Clarkson wrote: > Dave Adams wrote: > > > Does perl allow you to conditionally include a module? > > In general, you can load a module at runtime by using > 'require' and manually running its import() sub routine. > > require Module; > Module::import( 'I

RE: IF statements and modules - do they mix?

2005-07-27 Thread Charles K. Clarkson
Dave Adams wrote: : Does perl allow you to conditionally include a module? In general, you can load a module at runtime by using 'require' and manually running its import() sub routine. require Module; Module::import( 'Import list' ); : For example: : : #!/usr/bi

Re: IF statements and modules - do they mix?

2005-07-26 Thread John W. Krahn
Dave Adams wrote: > Does perl allow you to conditionally include a module? > > For example: > > #!/usr/bin/perl -w > use strict; > my $DEBUG = 0; > if (DEBUG) { > use diagnostics; > } > my $filename = "test$$.txt"; > open (FH , ">$filename") || die "error: $!"; > print (FH "hi"); > close (FH)

Re: If statements

2001-08-13 Thread Jos I. Boumans
cute nick btw. take a look at http://japh.nu there's a tutorial on loops and blocks in the tutorial section.. it should answer your question. hth, Jos Boumans > Hey all, > > I just started learning Perl yesterday and I've already gotten pretty far in my first program. > > My question is... wel

Re: IF statements

2001-05-02 Thread Paul Cotter
> There is no CASE statement in PERL. Instead you use something called SWITCH. There is no switch either - and if there was it would be lower case. There are many ways to emulate it; here is but one: :HOMOSTART# this is just a label - it can be ignored $_ = $caseVar; /^man$/and

Re: IF statements

2001-05-01 Thread Casey West
On Tue, May 01, 2001 at 01:22:59PM -0700, Paul wrote: : : --- Kaustav Bhattacharya <[EMAIL PROTECTED]> wrote: : > Mark, : > I only recently started coding in PERL so don't take the following as : > official. : > : > There is no CASE statement in PERL. Instead you use something called : > SWITCH.

[OT]RE: IF statements (the ugliest SWITCH! =o)

2001-05-01 Thread Paul
--- Kaustav Bhattacharya <[EMAIL PROTECTED]> wrote: > Mark, > I only recently started coding in PERL so don't take the following as > official. > > There is no CASE statement in PERL. Instead you use something called > SWITCH. Another trick, possibly not for beginners but sometimes handy: my %

RE: IF statements

2001-05-01 Thread Paul
--- Kaustav Bhattacharya <[EMAIL PROTECTED]> wrote: > Mark, > I only recently started coding in PERL so don't take the following as > official. > > There is no CASE statement in PERL. Instead you use something called > SWITCH. > The O'Reilly book has an example of how to use the SWITCH statemen

Re: IF statements

2001-05-01 Thread Stephen P. Potter
There isn't a switch statement either. There's a way to make something that looks similar to a switch, but it isn't a builtin control structure. -spp Lightning flashed, thunder crashed and "Kaustav Bhattacharya" whispered: | Mark, | I only recently started coding in PERL so don't take the foll

Re: IF statements

2001-05-01 Thread Stephen P. Potter
Lightning flashed, thunder crashed and Mark Martin <[EMAIL PROTECTED]> whisper ed: | What I have is this: | | if ($variable == 02){ | print OUT1 "$variable"; | $lines1 ++; | } elsif($variable == 03){ | print OUT1 "$variable\n"; | $lines2 ++; | } elsif($variable == "08"){

Re: IF statements

2001-05-01 Thread Timothy Kimball
: I think what I need is something called a case. but I can't find the syntax : anywhere. Perl doesn't have an official case (that is, switch) statement, but there is a Switch.pm module available on CPAN. Here's the synopsis from its manpage: use Switch; switch ($val) {

Re: IF statements

2001-05-01 Thread Gary Stainburn
Hi Mark, Try this: switch:for ($variable) { #put $variable into $_ (/02/ || /03/ || /08/) && do { print OUT1 "$variable\n"; $lines1++; last; } ; (/79/ || /93/ || /99/) && do { print OUT3 "$variable\n"; $lines3++; last; } ; } Using this code, if the bit be

RE: IF statements

2001-05-01 Thread Kaustav Bhattacharya
Mark, I only recently started coding in PERL so don't take the following as official. There is no CASE statement in PERL. Instead you use something called SWITCH. The O'Reilly book has an example of how to use the SWITCH statement. Kaustav > -Original Message- > From: Mark Martin [mail