Re: last statement in a package

2015-05-21 Thread Brandon McCaig
On Thu, May 21, 2015 at 3:41 AM, Vincent Lequertier wrote: > From http://perldoc.perl.org/perlmod.html#Perl-Modules, "1;" is used to end > with a true value There is a bit better explanation here: http://www.perlmonks.org/?node_id=781340 In short, `use' is like syntactic sugar around `require'

Re: last statement in a package

2015-05-21 Thread Vincent Lequertier
From http://perldoc.perl.org/perlmod.html#Perl-Modules, "1;" is used to end with a true value --- Vincent Lequertier s...@riseup.net Le 2015-05-21 08:13, Sunita Pradhan a écrit : Hi Why a perl programmer use 1 or any number as last statement in module or package (like : 1;)?I checked without t

Re: last statement in a package

2015-05-21 Thread Uday Vernekar
When a module is loaded (via use) the compiler will complain unless the last statement executed when it is loaded is true. This line ensures that this is the case (as long as you don't place any code after this line). Perl's way of making sure that it successfully parsed all the way to the end of t

Re: last statement in a package

2015-05-21 Thread Uday Vernekar
As Per my Understanding... The last line file must contain the line with the 1; statement. As This in effect returns a true value to the program using the module. if you are Not using the 1; statement it will not let the module be loaded correctly. On Thu, May 21, 2015 at 11:43 AM, Sunita Pradhan

Re: last

2013-06-28 Thread Charles DeRykus
On Fri, Jun 28, 2013 at 1:21 AM, Dr.Ruud wrote: > On 28/06/2013 09:08, Charles DeRykus wrote: > > [...] I was making a case that "do" in limited cases could be a >> >> shorter and/or slightly clearer idiom. >> > > I think the context was if you would ever go as far as using double braces > to

Re: last

2013-06-28 Thread Shawn H Corey
On Fri, 28 Jun 2013 10:21:43 +0200 "Dr.Ruud" wrote: > In a serious environment, code should be readable much more than > writable. So spend the extra minutes to make it as clear and > non-ambiguous as you can. Then someone else can more easily fix any > bugs you introduced, without having to as

Re: last

2013-06-28 Thread Dr.Ruud
On 28/06/2013 09:08, Charles DeRykus wrote: [...] I was making a case that "do" in limited cases could be a shorter and/or slightly clearer idiom. I think the context was if you would ever go as far as using double braces to make a loop-construct out of 'do'. But even more how combining a

Re: last

2013-06-28 Thread Charles DeRykus
On Thu, Jun 27, 2013 at 10:20 PM, shawn wilson wrote: > >... > > True. But, "do" should probably draw a more explicit caution in the docs > > since there are less tricky ways in most cases. > > > > However, there may be a few places when 'do' isn't always a don't :) > > > > 'do' might be a short

Re: last

2013-06-27 Thread shawn wilson
On Fri, Jun 28, 2013 at 12:04 AM, Charles DeRykus wrote: > > > > On Thu, Jun 27, 2013 at 1:31 PM, Dr.Ruud wrote: >> >> On 27/06/2013 22:01, Shawn H Corey wrote: >>> >>> On Thu, 27 Jun 2013 21:53:46 +0200 >>> "Dr.Ruud" wrote: See also 'Statement Modifiers' in perlsyn. There it is s

Re: last

2013-06-27 Thread Charles DeRykus
On Thu, Jun 27, 2013 at 1:31 PM, Dr.Ruud wrote: > On 27/06/2013 22:01, Shawn H Corey wrote: > >> On Thu, 27 Jun 2013 21:53:46 +0200 >> "Dr.Ruud" wrote: >> > See also 'Statement Modifiers' in perlsyn. >>> There it is shown how to make next and last work with do{}. I read >>> that as a rather fun

Re: last

2013-06-27 Thread Dr.Ruud
On 27/06/2013 22:01, Shawn H Corey wrote: On Thu, 27 Jun 2013 21:53:46 +0200 "Dr.Ruud" wrote: See also 'Statement Modifiers' in perlsyn. There it is shown how to make next and last work with do{}. I read that as a rather funny way to discourage people from do-ing it. "Here be dragons." I w

Re: last

2013-06-27 Thread Shawn H Corey
On Thu, 27 Jun 2013 21:53:46 +0200 "Dr.Ruud" wrote: > See also 'Statement Modifiers' in perlsyn. > > There it is shown how to make next and last work with do{}. I read > that as a rather funny way to discourage people from do-ing it. "Here be dragons." I would say that was a warning to avoid it

Re: last

2013-06-27 Thread Dr.Ruud
On 27/06/2013 17:03, Shawn H Corey wrote: On Thu, 27 Jun 2013 07:45:17 -0700 Jim Gibson wrote: Note that the statement modifier syntax allows you to write a do-while or do-until loop, where at least one pass is made through the loop before the loop termination test is performed: do { … }

Re: last

2013-06-27 Thread Andy Bach
On Thu, Jun 27, 2013 at 4:33 AM, lee wrote: > >> > This is sort of a p5p question but the above might cut this off at the > >> > knees (or better show a gap that needs to be filled). > >> > >> What is a p5p question? > In case this was the original quesiont p5p stands for Perl 5 Porters, the lis

Re: last

2013-06-27 Thread Rob Dixon
On 27/06/2013 16:03, Shawn H Corey wrote: On Thu, 27 Jun 2013 07:45:17 -0700 Jim Gibson wrote: Note that the statement modifier syntax allows you to write a do-while or do-until loop, where at least one pass is made through the loop before the loop termination test is performed: do { … } w

Re: last

2013-06-27 Thread Uri Guttman
On 06/27/2013 05:39 AM, lee wrote: John SJ Anderson writes: Lee, have you read the 'statement modifiers' and 'compound statement' portions of 'perldoc perlsyn'? You may find that this clarifies this issue for you. Well yes, I understand that there are two different kinds of 'if' one of which

Re: last

2013-06-27 Thread Shawn H Corey
On Thu, 27 Jun 2013 07:45:17 -0700 Jim Gibson wrote: > Note that the statement modifier syntax allows you to write a > do-while or do-until loop, where at least one pass is made through > the loop before the loop termination test is performed: > > do { > … > } while condition(); > > The while

Re: last

2013-06-27 Thread Jim Gibson
On Jun 27, 2013, at 2:39 AM, lee wrote: > John SJ Anderson writes: > >> Lee, have you read the 'statement modifiers' and 'compound statement' >> portions of 'perldoc perlsyn'? You may find that this clarifies this >> issue for you. > > Well yes, I understand that there are two different kinds

Re: last

2013-06-27 Thread lee
shawn wilson writes: > On Jun 25, 2013 3:11 AM, "lee" wrote: >> >> shawn wilson writes: >> >> > Lee, can you provide an example of another programming language that >> > implements this or a thesis that describes this problem in more depth? >> >> I'm not sure what you mean --- other programming

Re: last

2013-06-27 Thread lee
John SJ Anderson writes: > Lee, have you read the 'statement modifiers' and 'compound statement' > portions of 'perldoc perlsyn'? You may find that this clarifies this > issue for you. Well yes, I understand that there are two different kinds of 'if' one of which is kinda broken (but nonetheless

Re: last

2013-06-25 Thread John SJ Anderson
On Tue, Jun 25, 2013 at 9:23 AM, shawn wilson wrote: > > On Jun 25, 2013 3:11 AM, "lee" wrote: >> I'm not sure what you mean --- other programming languages I know don't >> have two different kinds of 'if's and the irregularities involved with >> that. > How does perl have "different kinds of i

Re: last

2013-06-25 Thread shawn wilson
On Jun 25, 2013 3:11 AM, "lee" wrote: > > shawn wilson writes: > > > Lee, can you provide an example of another programming language that > > implements this or a thesis that describes this problem in more depth? > > I'm not sure what you mean --- other programming languages I know don't > have t

Re: last

2013-06-25 Thread Brandon McCaig
On Mon, Jun 24, 2013 at 08:20:57PM -0700, John W. Krahn wrote: > The parentheses in this case do nothing, and they certainly don't > imply that last is a function. > > $ perl -le' > use warnings; > use strict; > for (1..2) { > (); > } In this case I'd guess that the parenthesis would be i

Re: last

2013-06-25 Thread lee
Uri Guttman writes: > On 06/24/2013 08:46 AM, lee wrote: >> John Delacour writes: >>> >>> “Stop if it’s raining, open your umbrella.” >>> >>> Nobody would know what you intend to say. No condition is actually >>> attached to “stop”. >> last if $its_raining; >> >> By your logic, no condition is

Re: last

2013-06-25 Thread lee
shawn wilson writes: > Lee, can you provide an example of another programming language that > implements this or a thesis that describes this problem in more depth? I'm not sure what you mean --- other programming languages I know don't have two different kinds of 'if's and the irregularities in

Re: last

2013-06-24 Thread John W. Krahn
Brandon McCaig wrote: On Sun, Jun 23, 2013 at 12:02:38PM +0300, Shlomi Fish wrote: "last" is not a function (a.k.a "subroutine") - it cannot be. It is a special statement which is handled in a special way by the Perl interpreter. "redo" and "next" are not functions either for a similar reason.

Re: last

2013-06-24 Thread Shawn H Corey
On Mon, 24 Jun 2013 17:14:02 -0400 Brandon McCaig wrote: > I think that you are just misunderstanding what is happening > here. `perldoc perlsyn' explains it. These are actually two > different things. The compound if-statement, which is typical of > other languages, and the if-style "statement m

Re: last

2013-06-24 Thread Brandon McCaig
On Mon, Jun 24, 2013 at 10:20:36AM +0200, lee wrote: > It's logical and expected because an 'if' statement goes like > 'if(condition) { is_true; } else { is_not_true;}'. > > Put a 'last' in front of the 'if' and the 'if' suddenly goes > like 'if(condition_is_true) last;' and no more. > > Flipping

Re: last

2013-06-24 Thread Uri Guttman
On 06/24/2013 08:46 AM, lee wrote: John Delacour writes: What you are saying is rather like expecting meaning from a sentence It tells you to stop when it's raining and to open your umbrella. like: “Stop if it’s raining, open your umbrella.” Nobody would know what you intend to say. No c

Re: last

2013-06-24 Thread Brandon McCaig
On Sun, Jun 23, 2013 at 12:02:38PM +0300, Shlomi Fish wrote: > "last" is not a function (a.k.a "subroutine") - it cannot be. > It is a special statement which is handled in a special way by > the Perl interpreter. "redo" and "next" are not functions > either for a similar reason. I think we can al

Re: last

2013-06-24 Thread shawn wilson
Lee, can you provide an example of another programming language that implements this or a thesis that describes this problem in more depth? This is sort of a p5p question but the above might cut this off at the knees (or better show a gap that needs to be filled).

Re: last

2013-06-24 Thread John W. Krahn
Dr.Ruud wrote: On 24/06/2013 07:36, lee wrote: It would be like: if ( $color eq "blue" ) { print "test\n"; last; } Alternative: print( "test\n" ), last if $color eq "blue"; I also see: print( "test\n" ) and last if $color eq "blue"; but always question that, because: what if print() fai

Re: last

2013-06-24 Thread lee
Shlomi Fish writes: >> An 'if' is an 'if', and when putting 'last' in front of it changes it to >> something else, why isn't there a keyword for it like 'lastif'? >> > > How so? > > last MYLABEL if $x == 5; > > does exactly the same as: > > if ($x == 5) { > last MYLABEL; > } > > Similarly:

Re: last

2013-06-24 Thread lee
"Dr.Ruud" writes: > On 24/06/2013 07:36, lee wrote: > >> It would be like: >> >> if ( $color eq "blue" ) { >>print "test\n"; >>last; >> } > > Alternative: > > print( "test\n" ), last > if $color eq "blue"; > > > I also see: > > print( "test\n" ) and last > if $color eq "blue";

Re: last

2013-06-24 Thread lee
John Delacour writes: > What you are saying is rather like expecting meaning from a sentence It tells you to stop when it's raining and to open your umbrella. > like: > > “Stop if it’s raining, open your umbrella.” > > Nobody would know what you intend to say. No condition is actually > attach

Re: last

2013-06-24 Thread lee
timothy adigun <2teezp...@gmail.com> writes: > Hi lee, > Please, check my comment below: > > On Sun, Jun 23, 2013 at 3:43 AM, lee wrote: > >> James Alton writes: >> >> > lee, >> > >> > You have a post statement if and then a code block. You can only use one >> of >> > two forms: >> > >> > print

Re: last

2013-06-24 Thread John Delacour
On 24/6/13 at 06:36, l...@yun.yagibdah.de (lee) wrote: while($test) { last if($foo) { print $bar; } else { print $test; } } doesn't work. Never mind “doesn’t work”; it doesn’t compile, because it is plain nonsense syntactically in whatever language. Compare your meaningless string with the

Re: last

2013-06-24 Thread Dr.Ruud
On 24/06/2013 07:36, lee wrote: It would be like: if ( $color eq "blue" ) { print "test\n"; last; } Alternative: print( "test\n" ), last if $color eq "blue"; I also see: print( "test\n" ) and last if $color eq "blue"; but always question that, because: what if print() f

Re: last

2013-06-24 Thread Shlomi Fish
Hello Lee, On Mon, 24 Jun 2013 07:36:26 +0200 lee wrote: > Shlomi Fish writes: > > > Hi Lee, > > > > On Sun, 23 Jun 2013 04:43:58 +0200 > > lee wrote: > > > >> James Alton writes: > >> > >> > lee, > >> > > >> > You have a post statement if and then a code block. You can only use one > >> >

Re: last

2013-06-23 Thread lee
Shlomi Fish writes: > Hi Lee, > > On Sun, 23 Jun 2013 04:43:58 +0200 > lee wrote: > >> James Alton writes: >> >> > lee, >> > >> > You have a post statement if and then a code block. You can only use one of >> > two forms: >> > >> > print "test" if $color eq "blue"; #no parenthesis required >>

Re: last

2013-06-23 Thread timothy adigun
On Sun, Jun 23, 2013 at 10:37 AM, Shlomi Fish wrote: > Hi Tim, > > On Sun, 23 Jun 2013 10:21:58 +0100 > timothy adigun <2teezp...@gmail.com> wrote: > > > Hi Shlomi, > > > > > > On Sun, Jun 23, 2013 at 10:02 AM, Shlomi Fish >wrote: > > > > > Hi Tim, > > > > > > just a note. > > > > > > On Sun, 23

Re: last

2013-06-23 Thread Shlomi Fish
Hi Tim, On Sun, 23 Jun 2013 10:21:58 +0100 timothy adigun <2teezp...@gmail.com> wrote: > Hi Shlomi, > > > On Sun, Jun 23, 2013 at 10:02 AM, Shlomi Fish wrote: > > > Hi Tim, > > > > just a note. > > > > On Sun, 23 Jun 2013 09:39:48 +0100 > > timothy adigun <2teezp...@gmail.com> wrote: > > > > >

Re: last

2013-06-23 Thread timothy adigun
Hi Shlomi, On Sun, Jun 23, 2013 at 10:02 AM, Shlomi Fish wrote: > Hi Tim, > > just a note. > > On Sun, 23 Jun 2013 09:39:48 +0100 > timothy adigun <2teezp...@gmail.com> wrote: > > > Hi lee, > > Please, check my comment below: > > > > On Sun, Jun 23, 2013 at 3:43 AM, lee wrote: > > > > > James A

Re: last

2013-06-23 Thread Shlomi Fish
Hi Tim, just a note. On Sun, 23 Jun 2013 09:39:48 +0100 timothy adigun <2teezp...@gmail.com> wrote: > Hi lee, > Please, check my comment below: > > On Sun, Jun 23, 2013 at 3:43 AM, lee wrote: > > > James Alton writes: > > > > > lee, > > > > > > You have a post statement if and then a code bl

Re: last

2013-06-23 Thread timothy adigun
Hi , On Sun, Jun 23, 2013 at 9:39 AM, timothy adigun <2teezp...@gmail.com> wrote: > Hi lee, > Please, check my comment below: > > On Sun, Jun 23, 2013 at 3:43 AM, lee wrote: > >> James Alton writes: >> >> > lee, >> > >> > You have a post statement if and then a code block. You can only use >> on

Re: last

2013-06-23 Thread timothy adigun
Hi lee, Please, check my comment below: On Sun, Jun 23, 2013 at 3:43 AM, lee wrote: > James Alton writes: > > > lee, > > > > You have a post statement if and then a code block. You can only use one > of > > two forms: > > > > print "test" if $color eq "blue"; #no parenthesis required > > if($co

Re: last

2013-06-23 Thread Shlomi Fish
Hi Lee, On Sun, 23 Jun 2013 04:43:58 +0200 lee wrote: > James Alton writes: > > > lee, > > > > You have a post statement if and then a code block. You can only use one of > > two forms: > > > > print "test" if $color eq "blue"; #no parenthesis required > > if($color eq "blue"){print "test";} >

Re: last

2013-06-22 Thread lee
James Alton writes: > lee, > > You have a post statement if and then a code block. You can only use one of > two forms: > > print "test" if $color eq "blue"; #no parenthesis required > if($color eq "blue"){print "test";} And I can't have 'last if $color eq "blue" print "test\n";'? That would be

Re: last

2013-06-17 Thread malisetti rammurthy
Bill, Below statement wont be helpful for lee, as he has requirement to loop at least one time. last if ($counter > 2); where as below one is working: if ( $counter > 2) { print 'if : ' . $counter . "\n"; #could do print "if : $counter\n" as well last; } On

Re: last

2013-06-17 Thread bill pemberton
I think the rest after the 'if' for the last is wrong. either do this: last if ($counter > 2); or if ( $counter > 2) { print 'if : ' . $counter . "\n"; #could do print "if : $counter\n" as well last; } On Mon, Jun 17, 2013 at 8:56 AM, lee wrote: > Hi, > > trying to figure out what

Re: last

2013-06-17 Thread James Alton
lee, You have a post statement if and then a code block. You can only use one of two forms: print "test" if $color eq "blue"; #no parenthesis required if($color eq "blue"){print "test";} As far as last, http://perldoc.perl.org/functions/last.html The example given: LINE: while () {

Re: last regex question (for the evening)

2012-11-22 Thread shawn wilson
i think i got it working correctly. thanks for your help: my ($ip, $ident, $userid, $time, $cgi, $url, $proto, $status, $size_tx, $ref, $ua, $size_rx, $re_time) = /^ ([-0-9\.]+)\# ip address (\S+)\ # i

Re: last regex question (for the evening)

2012-11-22 Thread Shawn H Corey
Oops, I found an error my parser. Here's version 1.0.2: DATA_LOOP: while( my $line = ){ print $line; my @captured = ( '' ); my $inside = 0; CAPTURE_LOOP: while( 1 ){ if( $line =~ m{ \G ( [^"\\]+ | \\ ["\\] ) }gcx ){ $captured[-1] .= $1 if $inside; }elsif( $line =~ m{ \G \

Re: last regex question (for the evening)

2012-11-22 Thread Shawn H Corey
On Wed, 21 Nov 2012 20:54:29 -0500 shawn wilson wrote: > how do i capture all quoted strings? OK, I rewrote it as a simple parser: DATA_LOOP: while( my $line = ){ print $line; my @captured = ( '' ); my $inside = 0; CAPTURE_LOOP: while( 1 ){ if( $line =~ m{ \G ( [^"\\]+ | \\ ["\\

Re: last regex question (for the evening)

2012-11-21 Thread Shawn H Corey
On Wed, 21 Nov 2012 20:54:29 -0500 shawn wilson wrote: > to match - and sometimes there are spaces before the match, a '\' with > no '"', etc. I think you want something like: while( ){ my @captured = m{ \" ( [^"\\]* (?: \\ ["\\] [^"\\]* )* ) \" }gx; print; print "\t$_\n" for @captured

Re: last regex question (for the evening)

2012-11-21 Thread shawn wilson
oh, and just to be clear (since i suppose it wasn't by me saying that i was looking at the regexes in other modules to accomplish this) this is, as someone else (on this list) once told me "masturbation with code". i can do what i set off to accomplish but i just wanted more and it annoyed me that

Re: last regex question (for the evening)

2012-11-21 Thread shawn wilson
that's a pretty cool module - i especially like their regex with lookup table trick. however, since i've got a decently lengthy regex written to do what i want, and because i'm itching to know how to actually do this at this point (i'd really like to know what's wrong with the regex i posted as wel

Re: last regex question (for the evening)

2012-11-21 Thread Shawn H Corey
On Wed, 21 Nov 2012 20:54:29 -0500 shawn wilson wrote: > how do i capture all quoted strings? Get Regexp::Common from CPAN and read Regexp::Common::delimited. http://search.cpan.org/~abigail/Regexp-Common-2011121001/ -- Just my 0.0002 million dollars worth, Shawn Programming is

Re: last element during foreach loop

2008-10-22 Thread Dr.Ruud
"Vijaya" schreef: > I think there are 3 possible ways to check the last element in your IF > condition inside Foreach loop. > > 1. $list[-1] eq $element > 2. $list[$#list] eq $element > 3. $list[scalar(@list)-1] eq $element Those all will not work (reliably), because you compare the value, and th

Re: last element during foreach loop

2008-10-22 Thread Vijaya
Hi Dave, I think there are 3 possible ways to check the last element in your IF condition inside Foreach loop. 1. $list[-1] eq $element 2. $list[$#list] eq $element 3. $list[scalar(@list)-1] eq $element See the example code and replace the if with other set of conditions given above

Re: last element during foreach loop

2008-10-21 Thread Rob Dixon
six24hourdays wrote: > On Oct 21, 11:06 am, [EMAIL PROTECTED] (Chas. Owens) wrote: >> On Tue, Oct 21, 2008 at 10:56, David Stiff <[EMAIL PROTECTED]> wrote: >>> >>> There probably is a better approach. >>> I am going through a list of Subversion branch names, e.g. >>> BRANCH_1 >>> BRANCH_1 >>> BRANC

Re: last element during foreach loop

2008-10-21 Thread six24hourdays
On Oct 21, 11:06 am, [EMAIL PROTECTED] (Chas. Owens) wrote: > On Tue, Oct 21, 2008 at 10:56, David Stiff <[EMAIL PROTECTED]> wrote: > > Hi Chas, > > > There probably is a better approach. > > > I am going through a list of Subversion branch names, e.g. > > > BRANCH_1 > > BRANCH_1 > > BRANCH_2 > > B

Re: last element during foreach loop

2008-10-21 Thread Dr.Ruud
"John W. Krahn" schreef: > six24hourdays: >> I would like to know how to test for the last element of a list >> during a foreach loop [...] > > You can't because a list does not have a name. [...] > You can however do it with an array by comparing references: > > $ perl -le' > my @x = "a" .. "z";

Re: last element during foreach loop

2008-10-21 Thread John W. Krahn
six24hourdays wrote: Hello, Hello, I would like to know how to test for the last element of a list during a foreach loop, e.g. foreach $element (@List) { if (this is the last element) { do something } } What would I use for the IF condition? You can't because a list does n

Re: last element during foreach loop

2008-10-21 Thread Chas. Owens
On Tue, Oct 21, 2008 at 11:06, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > #open my $fh, "-|", "svn somehing" > # or die "could not run 'svn something': $!"; snip Whoops, that is what I get for going too fast. The multiple argument version is faster because it doesn't need to spawn a sub

Re: last element during foreach loop

2008-10-21 Thread Chas. Owens
On Tue, Oct 21, 2008 at 10:56, David Stiff <[EMAIL PROTECTED]> wrote: > Hi Chas, > > There probably is a better approach. > > I am going through a list of Subversion branch names, e.g. > > BRANCH_1 > BRANCH_1 > BRANCH_2 > BRANCH_2 > BRANCH_3 > BRANCH_3 > BRANCH_4 > BRANCH_4 > > and checking to see

Re: last element during foreach loop

2008-10-21 Thread Mr. Shawn H. Corey
On Tue, 2008-10-21 at 10:55 -0400, Mr. Shawn H. Corey wrote: > if( @list ){ > my $last_item = pop @list; > for my $item ( @list ){ > # do stuff for all items but last > } > # do stuff for $last_item > } > If you want @list restored after you're done processing: if( @list ){ my $las

Re: last element during foreach loop

2008-10-21 Thread Mr. Shawn H. Corey
On Tue, 2008-10-21 at 22:47 +0800, Jeff Pang wrote: > 2008/10/21 Chas. Owens <[EMAIL PROTECTED]>: > > > > > This is an odd desire; are you sure you really need to do this? Can > > you tell us what you are trying to achieve? Jeff's answer does what > > you want, but most likely there is a better

Re: last element during foreach loop

2008-10-21 Thread Jeff Pang
2008/10/21 Chas. Owens <[EMAIL PROTECTED]>: > > This is an odd desire; are you sure you really need to do this? Can > you tell us what you are trying to achieve? Jeff's answer does what > you want, but most likely there is a better approach to be using for > your actual problem. > Agree. He pro

Re: last element during foreach loop

2008-10-21 Thread Chas. Owens
On Tue, Oct 21, 2008 at 09:39, six24hourdays <[EMAIL PROTECTED]> wrote: > Hello, > > I would like to know how to test for the last element of a list during > a foreach loop, e.g. > > foreach $element (@List) { >if (this is the last element) { >do something >} > } > > What would I us

Re: last element during foreach loop

2008-10-21 Thread Jeff Pang
2008/10/21 six24hourdays <[EMAIL PROTECTED]>: > Hello, > > I would like to know how to test for the last element of a list during > a foreach loop, e.g. > > foreach $element (@List) { >if (this is the last element) { >do something >} > } > my $i =0; for (@list) { if ($i == $#l

Re: Last line issue

2008-01-27 Thread Dr.Ruud
"John W. Krahn" schreef: > tr/\t/ /s; To also squash adjacent space characters: tr/\t / /s; -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Last line issue

2008-01-26 Thread John W. Krahn
Andrej Kastrin wrote: John W. Krahn wrote: This should do what you want: #!/usr/bin/perl use warnings; use strict; my $FNI = shift; my $FNO = "$FNI.dat"; open my $OUT, '>', $FNO or die "Cannot open '$FNO' $!"; open my $IN, '<', $FNI or die "Cannot open '$FNI' $!"; my ( $id, $line ); while

Re: Last line issue

2008-01-26 Thread Andrej Kastrin
Dear Jonh, many, many thanks for your quick answer. I modified your script a bit: $line .= $_ if /Id|To|From/; print $OUT "$id\t$line\n" if m!/Note!; to: $line .= $_ if m!! .. m!!; print $OUT "$id\t$line\n" if m!!; but some problem still persists with the output: 001 001Tho

Re: Last line issue

2008-01-26 Thread John W. Krahn
Andrej Kastrin wrote: Dear all, Hello, to pre-process my XML dataset in run simple Perl script on it, which extract Id identifier from XML data and paste the whole XML record to it. For example, the input data looks like: 001 Thomas Joana 002

Re: last entry in a file

2008-01-17 Thread Randal L. Schwartz
> "paul" == paul 0403 <[EMAIL PROTECTED]> writes: paul> Is there a quick and easy way in perl to get the last entry in a file paul> for a specific value paul> For example If I have the following data in a file paul> 1<\len> paul> int<\type> paul> 2<\len> paul> int<\type> paul> 3<\len> paul>

Re: last entry in a file

2008-01-17 Thread reader
[EMAIL PROTECTED] writes: > Please keep in mind that the data in the file is only a sample and it > will not alwasy be the second line from the bottome :-) > > I know I can read the file and keep track via a flag of where I am in > the file but this seems way to over-kill. I was hoping for some ni

Re: Last word

2005-08-23 Thread Todd Lewis
Thanks, for all the replys. Didn't know that you could simply reference the last element of an array by using [-1]. This seemed like it could be a one line task maybe two, just don't have command of the language. Peter Scott wrote: On Tue, 23 Aug 2005 06:17:11 -0700, I wrote: $last_wor

Re: Last word

2005-08-23 Thread Peter Scott
On Tue, 23 Aug 2005 06:17:11 -0700, I wrote: > $last_word = (split /\s/, $row->[1]//)[-1]; I seem beset by typos today. Don't know where that // came from. Should be: $last_word = (split /\s/, $row->[1])[-1]; -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To u

Re: Last word

2005-08-23 Thread Peter Scott
On Tue, 23 Aug 2005 07:25:05 -0700, Todd Lewis wrote: > I'm trying to retrieve the last word from an HTML table cell stored in > an array value. > All of the words are space delimited. > I've tried using split /\s/, $$row[1] but this doesn't always return the > last > word for me since there cou

Re: last installed perl modules

2005-06-04 Thread Xavier Noria
On Jun 4, 2005, at 10:39, Johan Meskens CS3 jmcs3 wrote: hello i remember there is a terminal command which lists the last installed perl modules but i don't remember it well enough to actually know it Perhaps you mean perldoc perllocal ? -- fxn -- To unsubscribe, e-mail: [EMAIL PRO

Re: last question on the switch statement ....

2005-04-18 Thread John W. Krahn
David Gilden wrote: Dear fellow PERL coders..., Hello, What is the "&& do" part of the code doing, i.e. I am looking to understand the syntax, the example was found in perl beginners archive, from some else's post... && is the logical 'and' operator. If the expression on its left is evaluated as

Re: last question on the switch statement ....

2005-04-18 Thread Vladimir D Belousov
Sorry for my English :) '&&' is a boolean operator. It returns TRUE when both statemets are ture, and false on other cases. But if the first statement is false, next statement will not be executed. For example: $hash{key} doesn't exists - if(exists($hash{key}) && $hash{key} =~ /\d+/); Is $^W is tru

Re: last modified file

2004-06-28 Thread Gunnar Hjalmarsson
F H wrote: Gunnar Hjalmarsson wrote: F H wrote: I have a directory where log files are saved in on a daily basis by a VB program. and what I need is a way to get the last file stored into that directory. The last modified file in that directory should do it. perldoc -f stat What I am looking

Fwd: Re: last modified file

2004-06-28 Thread F H
Note: forwarded message attached. Do you Yahoo!? Yahoo! Mail is new and improved - Check it out!--- Begin Message --- Thanks Gunnar for responding What I am looking for is how "code wise" find the last modified file in a directory within a script. here us my script     use MIME::Lite;use Net::SMT

Re: last modified file

2004-06-26 Thread Gunnar Hjalmarsson
F H wrote: I have a directory where log files are saved in on a daily basis by a VB program. and what I need is a way to get the last file stored into that directory. The last modified file in that directory should do it. perldoc -f stat -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin

RE: Last value in a array?

2003-08-14 Thread NYIMI Jose (BMB)
C:\>perldoc -f pop pop ARRAY pop Pops and returns the last value of the array, shortening the array by one element. Has an effect similar to $ARRAY[$#ARRAY--] If there are no elements in the array, returns the undefined value (althou

RE: Last value in a array?

2003-08-14 Thread EUROSPACE SZARINDAR
Hi, You can use my $LastValue = $ARRAY[ $#ARRAY-1 ]; The pop function suppress the last value of the ARRAY. Michel -Message d'origine- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Date: vendredi 8 août 2003 12:57 À: [EMAIL PROTECTED] Objet: Last value in a array? Hi, I have a c

RE: Last value in a array?

2003-08-11 Thread NYIMI Jose (BMB)
"; Output: 4 5 -Original Message- From: EUROSPACE SZARINDAR [mailto:[EMAIL PROTECTED] Sent: Friday, August 08, 2003 1:40 PM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: Last value in a array? Hi, You can use my $LastValue = $ARRAY[ $#ARRAY-1 ]; The pop fu

RE: Last value in a array?

2003-08-08 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Hi, > > I have a couple of arrays which have different number of > values - I need only the last value in each - are there a command to > do that? > > e.g > > $array[LAST] :-) Negative subscripts count from the end of the array, so the last element is: $array[-1

RE: Last Logon of ALL users in the domain (U)

2003-07-02 Thread Meidling, Keith, CTR, OSD-NII
[mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 2:00 PM To: 'Leon'; 'Tillman, James'; 'Robert-Jan Mora' Cc: 'perl'; 'win32'; 'Yahoo Beginner Perl' Subject: RE: Last Logon of ALL users in the domain If you want the Time of logon

RE: Last Post today I swear - use in package

2003-06-25 Thread Dan Muey
> On Tuesday, June 24, 2003 at 4:15 PM, Dan Muey stated: > : > : This is last post for me today I swear!!! > > But . . . > > On Tuesday, June 24, 2003 at 4:38 PM, Dan Muey posted: > > : Cool, Thanks again Jenda, it's coming slowly, > : bit by bit. > > > Just can't trust that guy!

RE: Last Post today I swear - use in package

2003-06-24 Thread Charles K. Clarkson
On Tuesday, June 24, 2003 at 4:15 PM, Dan Muey stated: : : This is last post for me today I swear!!! But . . . On Tuesday, June 24, 2003 at 4:38 PM, Dan Muey posted: : Cool, Thanks again Jenda, it's coming slowly, : bit by bit. Just can't trust that guy! :) Charles K. Clarkson --

RE: Last Post today I swear - use in package

2003-06-24 Thread Dan Muey
Cool, Thanks again Jenda, it's coming slowly, bit by bit. Have a good one! > From: "Dan Muey" <[EMAIL PROTECTED]> > > Suppose I have a module: > > > > package MyConfig; > > > > use strict; > > use warnings; > > > > use CGI qw(:standard); # or user_name or one then other if > fail? use > > DB

Re: Last Post today I swear - use in package

2003-06-24 Thread Jenda Krynicky
From: "Dan Muey" <[EMAIL PROTECTED]> > Suppose I have a module: > > package MyConfig; > > use strict; > use warnings; > > use CGI qw(:standard); # or user_name or one then other if fail? > use DBI; > > use base 'Exporter'; > use Carp; > > > Now in the script I have > > #!/usr/bin/perl >

RE: Last Logon of ALL users in the domain

2003-06-12 Thread Tim Dumas
] Behalf Of Leon Sent: Thursday, June 12, 2003 12:03 PM To: Tillman, James; Robert-Jan Mora Cc: perl; win32; Yahoo Beginner Perl Subject: RE: Last Logon of ALL users in the domain This totally 100 percent worked. Thank you so much "Tillman, James" <[EMAIL PROTECTED]> wrote:

RE: Last Logon of ALL users in the domain

2003-06-12 Thread Gould, Kevin
AIL PROTECTED] Sent: Thursday, June 12, 2003 1:22 PM To: '[EMAIL PROTECTED]'; 'Leon'; 'Tillman, James'; 'Robert-Jan Mora' Cc: 'perl'; 'win32'; 'Yahoo Beginner Perl' Subject: RE: Last Logon of ALL users in the domain Is

RE: Last Logon of ALL users in the domain

2003-06-12 Thread Leon
{Name} . "=" . $last_login . "\n" } } Just a thought... jpt -Original Message- From: Leon [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 12:35 PM To: Robert-Jan Mora Cc: perl; win32; Yahoo Beginner Perl Subject: Re: Last Logon of ALL users in the domain Hi Rober

Re: Last Logon of ALL users in the domain

2003-06-12 Thread Leon
Hi Robert, Unfortunately after examining this script it works via passing a username to it. I can do this with adminmisc. I need to check ALL users in the domain. Here is a snippet of the code and what it appears to do: $username = $ARGV[0]; Grab the username from ARGV I appreciate the

RE: Last Logon of ALL users in the domain

2003-06-12 Thread Tim Johnson
NTDISABLE) >= 0){ print OUTFILE "DISABLED."; $total = $total - UF_ACCOUNTDISABLE; } if (($total - UF_SCRIPT) >= 0){ $total = $total - UF_SCRIPT; } if($user{passwordExpired} == 1){ print OUTFILE

  1   2   >