If statements

2001-08-13 Thread mrhate
Hey all, I just started learning Perl yesterday and I've already gotten pretty far in my first program. My question is... well... here's the situation. The first part of my program asks if the user has a current login on the program. If they don't, then the program goes on, if they do, it goe

IF statements

2001-05-01 Thread Mark Martin
What I have is this: if ($variable == 02){ print OUT1 "$variable"; $lines1 ++; } elsif($variable == 03){ print OUT1 "$variable\n"; $lines2 ++; } elsif($variable == "08"){ print OUT1 "$variable\n"; $lines2 ++; } elsif($variable == 79){ pr

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-01 Thread Kaustav Bhattacharya
rom: Mark Martin [mailto:[EMAIL PROTECTED]] > Sent: 01 May 2001 16:55 > To: [EMAIL PROTECTED] > Subject: IF statements > > > What I have is this: > > if ($variable == 02){ > print OUT1 "$variable"; > $lines1 ++; > } elsif($variable == 03){ >

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 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 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 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 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 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.

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

One liner If statements

2003-01-02 Thread Jensen Kenneth B SrA AFPC/DPDMPQ
In reading messages on this list I've picked up some snippets like 'do some code here' if (condition); Can the same be done if you have an if statement like this If (condition){ print "hi"; $somevar++; } Or can you only have 1 command preceding the if? I tried Print "hi" $somevar++ if (co

IF statements and timestamps

2002-03-08 Thread Aaron Shurts
I have some code that looks like this: if (($duration < 600) && (($ts > $ts_offp) && ($ts < $ts_end))) { $$data{$csid}{under_off} += 1; $$data{$csid}{duration_offd} += $duration; $$data{$csid}{total_off_callsd} += 1; } The problem being it doesn't look

Re: One liner If statements

2003-01-02 Thread Rob Dixon
do { print "hi"; $somevar++; } if condition; (You don't need to parenthesize the conditional expression in this format.) HTH, Rob "Jensen Kenneth B Sra Afpc/Dpdmpq" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > In reading messages on

Re: One liner If statements

2003-01-02 Thread Tanton Gibbs
also: print (hi), $somevar++ if( condition ); - Original Message - From: "Rob Dixon" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 02, 2003 1:04 PM Subject: Re: One liner If statements > do { > print "hi"; >

RE: One liner If statements

2003-01-02 Thread Jensen Kenneth B SrA AFPC/DPDMPQ
Can else statements be added? print (hi), $somevar++ if( condition ) else print (bye); -Original Message- From: Tanton Gibbs [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:07 PM To: [EMAIL PROTECTED] Subject: Re: One liner If statements also: print (hi), $somevar++ if

Re: One liner If statements

2003-01-02 Thread Paul Johnson
On Thu, Jan 02, 2003 at 12:56:46PM -0600, Jensen Kenneth B SrA AFPC/DPDMPQ wrote: > In reading messages on this list I've picked up some snippets like > > 'do some code here' if (condition); > > Can the same be done if you have an if statement like this > > If (condition){ > print "hi"; > $s

RE: One liner If statements

2003-01-02 Thread Dan Muey
print "hi"; $somevar++; } else { print "Joemama"; } -Original Message- From: Jensen Kenneth B SrA AFPC/DPDMPQ [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:17 PM To: 'Tanton Gibbs'; [EMAIL PROTECTED] Subj

RE: One liner If statements

2003-01-02 Thread Jensen Kenneth B SrA AFPC/DPDMPQ
: Dan Muey [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:25 PM To: [EMAIL PROTECTED] Subject: RE: One liner If statements Is there a specific reason you need to do it that way? If you need to run a bunch of code why not use sub routines if($hi eq $low) { &hi_is

RE: One liner If statements

2003-01-02 Thread Dan Muey
cool , makes sense, just wondering -Original Message- From: Jensen Kenneth B SrA AFPC/DPDMPQ [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:29 PM To: Dan Muey; [EMAIL PROTECTED] Subject: RE: One liner If statements No specific reason why, was just exploring other ways to

Re: One liner If statements

2003-01-02 Thread Rob Dixon
ROTECTED]> > Sent: Thursday, January 02, 2003 1:04 PM > Subject: Re: One liner If statements > > > > do { > > print "hi"; > > $somevar++; > > } if condition; > > > > (You don't need to parenthesize the conditio

RE: One liner If statements

2003-01-02 Thread david
Jensen Kenneth B Sra Afpc/Dpdmpq wrote: > Can else statements be added? > > print (hi), $somevar++ if( condition ) else print (bye); good idea but it doens't work that way. try: #!/usr/bin/perl -w use strict; my $var = 1; $var ? ( print("hello world\n"), $var++, print("

Re: One liner If statements

2003-01-02 Thread R. Joseph Newton
PQ [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 1:29 PM > To: Dan Muey; [EMAIL PROTECTED] > Subject: RE: One liner If statements > > No specific reason why, was just exploring other ways to do the same thing. Messing >around with the benchmark module and seeing whi

IF statements and modules - do they mix?

2005-07-26 Thread Dave Adams
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 simple and silly example

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

[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 %