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 check

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

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

last statement in a package

2015-05-20 Thread Sunita Pradhan
Hi Why a perl programmer use 1 or any number as last statement in module or package (like : 1;)?I checked without that also package gets loaded . Can somebody please explain properly , it would be good with examples ? ThanksSunita

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
7; isn't always a don't :) > > > > 'do' might be a shorter, more readable idiom in the sense of "do > something > > until a condition occurs": > > > I can't agree with the either or here ... [snip] > > > perl -e 'do

Re: last

2013-06-27 Thread shawn wilson
>> >>>> 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

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 n

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.

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

Re: last

2013-06-27 Thread Dr.Ruud
{ … } while condition(); The while here is a statement modifier, and the do{} is a single statement with one or more internal statements grouped as one. Please don't use a do...while "loop". Technically, it's not a loop and `last`, `next`, and `redo` won't work as you would

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
{ … } while condition(); The while here is a statement modifier, and the do{} is a single statement with one or more internal statements grouped as one. Please don't use a do...while "loop". Technically, it's not a loop and `last`, `next`, and `redo` won't work as you would

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
condition(); > > The while here is a statement modifier, and the do{} is a single > statement with one or more internal statements grouped as one. Please don't use a do...while "loop". Technically, it's not a loop and `last`, `next`, and `redo` won't work as you would

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
f' statement, you'd also need statements like 'printif', 'nextif', 'redoif' and a lot of others to keep it regular. You'd have to disallow things like '$a = 5 unless($b < 4);' unless you'd create 'letif' and 'letunless&#

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&

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

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 n

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

Re: last

2013-06-24 Thread Uri Guttman
. No condition is actually attached to “stop”. last if $its_raining; By your logic, no condition is attached to "last". The problem with perl is that it doesn't allow you to open your umbrella. i have been following this thread and i haven't seen a good explanation to

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 functio

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

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

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 >

Re: last

2013-06-24 Thread lee
o condition is actually > attached to “stop”. last if $its_raining; By your logic, no condition is attached to "last". The problem with perl is that it doesn't allow you to open your umbrella. -- "Object-oriented programming languages aren't completely convinced that

Re: last

2013-06-24 Thread lee
. 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 &#x

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

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

Re: last

2013-06-24 Thread Shlomi Fish
gt; >> > 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 "

Re: last

2013-06-23 Thread lee
gt; > >> > 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 w

Re: last

2013-06-23 Thread timothy adigun
> > > > > 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

Re: last

2013-06-23 Thread Shlomi Fish
> > > > lee, > > > > > > > > > > You have a post statement if and then a code block. You can only use > > one > > > > of > > > > > two forms: > > > > > > > > > > print "test" if $co

Re: last

2013-06-23 Thread timothy adigun
t; > > > > > print "test" if $color eq "blue"; #no parenthesis required > > > > if($color eq "blue"){print "test";} > > > > > > ++ > > > > > And I can't have 'last if $color eq "blu

Re: last

2013-06-23 Thread Shlomi Fish
> > > 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&q

Re: last

2013-06-23 Thread timothy adigun
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-23 Thread timothy adigun
t; 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 something quite natural and a log

Re: last

2013-06-23 Thread Shlomi Fish
#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 something quite natural and a logical thing to do ... Do you want something like:

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

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 : $cou

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

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.

last

2013-06-17 Thread lee
Hi, trying to figure out what `last' actually does, I wrote this test script: use strict; use warnings; use autodie; my $counter = 0; while($counter < 8) { last if($counter > 2) { print "if: " . $counter . "\n"; } else {

Re: last regex question (for the evening)

2012-11-22 Thread shawn wilson
while( 1 ){ > > if( $line =~ m{ \G ( [^"\\]+ | \\ ["\\] ) }gcx ){ > $captured[-1] .= $1 if $inside; > }elsif( $line =~ m{ \G \" }gcx ){ > $inside ^= 1; > push @captured, '' if ! $inside; > }else{ > last CAPTURE_LOOP;

Re: last regex question (for the evening)

2012-11-22 Thread Shawn H Corey
}elsif( $line =~ m{ \G \" }gcx ){ $inside ^= 1; push @captured, '' if ! $inside; }else{ last CAPTURE_LOOP; } } if( $inside ){ warn "missing closing quotes\n"; }else{ pop @captured; # last item is a bogus empty string } print

Re: last regex question (for the evening)

2012-11-22 Thread Shawn H Corey
line =~ m{ \G ( [^"\\]+ | \\ ["\\] ) }gcx ){ $captured[-1] .= $1 if $inside; }elsif( $line =~ m{ \G \" }gcx ){ $inside ^= 1; push @captured, '' if ! $inside; }else{ last CAPTURE_LOOP; } } pop @captured; # last one is always any empty string if

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

last regex question (for the evening)

2012-11-21 Thread shawn wilson
how do i capture all quoted strings? this gives an error: print "$str1\n"; ($one, $two) = $str1 =~/"([^(?:[^"]")]*)" (\d+)/; print "$one $two\n"; what i want is: $str1 = "\"something\" 444"; $str1 = "\"\\\"escaped quote\\\" 321"; $str1 = "\"\\\"esc quote\\\" other stuff\" 567"; to match - and s

Re: how to only read the files last 13 lines

2012-06-12 Thread Shlomi Fish
Hi Lina, On Tue, 12 Jun 2012 14:08:45 +0800 lina wrote: > Hi, > > How to read the files last 13 lines, > > only process the data of the last 13 lines, ignore the head parts. > > Thanks with best regards, > in addition to what other people here said, please loo

Re: how to only read the files last 13 lines

2012-06-12 Thread timothy adigun
Hi lina, On Tue, Jun 12, 2012 at 7:08 AM, lina wrote: > Hi, > > How to read the files last 13 lines, > > only process the data of the last 13 lines, ignore the head parts. > > Thanks with best regards, > > > you can also use Tie::File like so: use Tie::File

Re: how to only read the files last 13 lines

2012-06-11 Thread Shekar
If you are on linux, try command ->tail -13 FILE_NAME -- Shekar On Tue, Jun 12, 2012 at 11:38 AM, lina wrote: > Hi, > > How to read the files last 13 lines, > > only process the data of the last 13 lines, ignore the head parts. > > Thanks with best regards, > &g

Re: how to only read the files last 13 lines

2012-06-11 Thread pangj
How to read the files last 13 lines, only process the data of the last 13 lines, ignore the head parts. Thanks with best regards, Try File::Tail, this is might what you are looking for: use File::Tail; my $file=File::Tail->new(name=>"file.txt", tail=>13); while (def

how to only read the files last 13 lines

2012-06-11 Thread lina
Hi, How to read the files last 13 lines, only process the data of the last 13 lines, ignore the head parts. Thanks with best regards, -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: translate following files based on the last line of the previous file

2012-04-23 Thread lina
, "<","text_2.xvg"; while(<$fh>){ print $_; } Of course, it is possible to read the last line of a file without resorting to creating a child process. See, for example, the module File::ReadBackwards. Thanks. Here I came up a working script (unavoidably clumsy). I don&#

Re: translate following files based on the last line of the previous file

2012-04-23 Thread lina
t;$fh>){ print $_; } Of course, it is possible to read the last line of a file without resorting to creating a child process. See, for example, the module File::ReadBackwards. Thanks. Here I came up a working script (unavoidably clumsy). I don't know how to refine it, or make i

Re: translate following files based on the last line of the previous file

2012-04-22 Thread Jim Gibson
stem function. It does not return the output of the child process to your program. For that, you need the qx() operator, or backticks: my $dict = qx("tail -n 1 text_1.xvg"); > print $dict; > print "\n\n"; > open my $fh, "<","text_2.xvg"; &g

translate following files based on the last line of the previous file

2012-04-22 Thread lina
Hi, I have a series of files. $ cat text_1.xvg 0 0 1 2 3 2 1 0 2 3 4 1 2 0 3 $ cat text_2.xvg 0 0 1 2 3 2 1 0 3 2 4 1 3 0 2 I wish to translate the text_2 numbers (except the first field) based on the last line of the text_1.xvg namely text_2.xvg will

Re: How to grab last element of array from split with no temporary variables?

2011-08-18 Thread Brandon McCaig
On Wed, Aug 17, 2011 at 9:58 PM, Randal L. Schwartz wrote: > Golfers do NOT understand the DAMAGE they are doing to Perl's > perception outside the Perl community, and I wish they'd damn well > stop. In my experience, people outside of the Perl community perceive /any/ Perl as obfuscated anyway

Re: How to grab last element of array from split with no temporary variables?

2011-08-17 Thread timothy adigun
> Golfers do NOT understand the DAMAGE they are doing to Perl's > perception outside the Perl community, What is golf? Hi Marc, Perl "golf" is a game where one reduce the number of characters {key "strokes"} used in a perl program, just like how golf players seek to hit balls into series

Re: How to grab last element of array from split with no temporary variables?

2011-08-17 Thread sono-io
On Aug 17, 2011, at 6:58 PM, Randal L. Schwartz wrote: > Golfers do NOT understand the DAMAGE they are doing to Perl's > perception outside the Perl community, What is golf? Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@

Re: How to grab last element of array from split with no temporary variables?

2011-08-17 Thread Randal L. Schwartz
> ""John" == "John W Krahn" writes: >> That's deprecated though, if not already gone. (Looks gone in Perl >> 5.14.) It was a readily-admitted misfeature. John> Unless you're playing golf. :-) I'd argue that Golf itself is a misfeature of Perl. More like a bug. Golfers do NOT understan

Re: How to grab last element of array from split with no temporary variables?

2011-08-14 Thread Peter Scott
On Thu, 11 Aug 2011 23:30:32 -0700, John W. Krahn wrote: > Peter Scott wrote: >> On Thu, 11 Aug 2011 16:17:51 -0700, siegfried wrote: >>> Is there a way to do it with less typing? How can I do it without >>> creating a temporary variable "@p"? Thanks, siegfried >>> >>> find /xyz -exec perl -e 'fore

Re: How to grab last element of array from split with no temporary variables?

2011-08-12 Thread John W. Krahn
Randal L. Schwartz wrote: "John" == "John W Krahn" writes: John> split() uses @_ by default so you could just say: That's deprecated though, if not already gone. (Looks gone in Perl 5.14.) It was a readily-admitted misfeature. Unless you're playing golf. :-) John -- Any intelligent f

Re: How to grab last element of array from split with no temporary variables?

2011-08-12 Thread Randal L. Schwartz
> "John" == "John W Krahn" writes: John> split() uses @_ by default so you could just say: That's deprecated though, if not already gone. (Looks gone in Perl 5.14.) It was a readily-admitted misfeature. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http:/

Re: How to grab last element of array from split with no temporary variables?

2011-08-12 Thread Rob Dixon
On 12/08/2011 18:52, Rob Dixon wrote: > On 12/08/2011 00:17, siegfr...@heintze.com wrote: >> This works! Is there a way to do it with less typing? How can I do it >> without creating a temporary variable "@p"? >> Thanks, >> siegfried >> >> find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; r

Re: How to grab last element of array from split with no temporary variables?

2011-08-12 Thread Rob Dixon
On 12/08/2011 00:17, siegfr...@heintze.com wrote: This works! Is there a way to do it with less typing? How can I do it without creating a temporary variable "@p"? Thanks, siegfried find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_, "./$p[$#p].txt" } ' find /xyz -exec perl -e

Re: How to grab last element of array from split with no temporary variables?

2011-08-12 Thread Brandon McCaig
On Thu, Aug 11, 2011 at 7:17 PM, wrote: > find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_, > "./$p[$#p].txt" } ' If I'm reading this right then it looks like you're trying to recursively move all files in /xyz into the current directory. Probably don't need Perl for that. fi

Re: How to grab last element of array from split with no temporary variables?

2011-08-11 Thread John W. Krahn
Peter Scott wrote: On Thu, 11 Aug 2011 16:17:51 -0700, siegfried wrote: This works! Really? I get "find: missing argument to `-exec'" I think your command also renames directories. You want that? Is there a way to do it with less typing? How can I do it without creating a temporary variab

Re: How to grab last element of array from split with no temporary variables?

2011-08-11 Thread Peter Scott
On Thu, 11 Aug 2011 16:17:51 -0700, siegfried wrote: > This works! Really? I get "find: missing argument to `-exec'" I think your command also renames directories. You want that? > Is there a way to do it with less typing? How can I do it > without creating a temporary variable "@p"? Thanks,

Re: How to grab last element of array from split with no temporary variables?

2011-08-11 Thread John W. Krahn
Shawn H Corey wrote: On 11/08/11 07:17 PM, siegfr...@heintze.com wrote: This works! Is there a way to do it with less typing? How can I do it without creating a temporary variable "@p"? Thanks, siegfried find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_, "./$p[$#p].txt" } '

Re: How to grab last element of array from split with no temporary variables?

2011-08-11 Thread Jim Bauer
On Thu, 11 Aug 2011 16:17:51 -0700, wrote: > This works! Is there a way to do it with less typing? How can I do it > without creating a temporary variable "@p"? rename($_, sprintf("./%s.txt", (split '/')[-1])); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,

Re: How to grab last element of array from split with no temporary variables?

2011-08-11 Thread Jim Gibson
On 8/11/11 Thu Aug 11, 2011 4:17 PM, "siegfr...@heintze.com" scribbled: > This works! Is there a way to do it with less typing? How can I do it > without creating a temporary variable "@p"? > Thanks, > siegfried > > find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_, > "./$p[$

Re: How to grab last element of array from split with no temporary variables?

2011-08-11 Thread Shawn H Corey
On 11/08/11 07:17 PM, siegfr...@heintze.com wrote: This works! Is there a way to do it with less typing? How can I do it without creating a temporary variable "@p"? Thanks, siegfried find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_, "./$p[$#p].txt" } ' find /xyz -exec pe

How to grab last element of array from split with no temporary variables?

2011-08-11 Thread siegfried
This works! Is there a way to do it with less typing? How can I do it without creating a temporary variable "@p"? Thanks, siegfried find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_, "./$p[$#p].txt" } ' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: Truncate Last few lines

2011-05-20 Thread C.DeRykus
On May 20, 4:37 am, cmksw...@gmail.com (Ambuli) wrote: > Here i paste a perl script to delete last Two Lines. If you want > delete more lines in a file you can specify it. > > use File::ReadBackwards; >  my $filename = 'test.txt'; >  my $Lines_to_truncate = 2; # Here

Re: Truncate Last few lines

2011-05-20 Thread Shlomi Fish
Hi Ambuli, a few comments on your code: On Friday 20 May 2011 14:37:52 Ambuli wrote: > Here i paste a perl script to delete last Two Lines. If you want > delete more lines in a file you can specify it. > > Always start with "use strict;" and "use warnings&q

Truncate Last few lines

2011-05-20 Thread Ambuli
Here i paste a perl script to delete last Two Lines. If you want delete more lines in a file you can specify it. use File::ReadBackwards; my $filename = 'test.txt'; my $Lines_to_truncate = 2; # Here the line to truncate is mean Remove only Last Two Lines my $bw = File::ReadBack

Re: How to find the status, i.e. "next run time" and "last run time", of a task which is run through windows task scheduler !

2010-06-09 Thread C.DeRykus
On Jun 8, 2:18 am, learn.tech...@gmail.com (Amit Saxena) wrote: > Hi all, > > I want to know how to find the status, i.e. "next run time" and "last run > time", of a task which is run through windows task scheduler. > > This is required so as to find o

Re: How to find the status, i.e. "next run time" and "last run time", of a task which is run through windows task scheduler !

2010-06-08 Thread Chas. Owens
On Tue, Jun 8, 2010 at 05:18, Amit Saxena wrote: > Hi all, > > I want to know how to find the status, i.e. "next run time" and "last run > time", of a task which is run through windows task scheduler. > > This is required so as to find out instances where a

How to find the status, i.e. "next run time" and "last run time", of a task which is run through windows task scheduler !

2010-06-08 Thread Amit Saxena
Hi all, I want to know how to find the status, i.e. "next run time" and "last run time", of a task which is run through windows task scheduler. This is required so as to find out instances where a task gets "hanged" after run through windows task scheduler. Thanks & Regards, Amit Saxena

Re: logic not being able to score last element in the array

2010-05-07 Thread iinfer
ile) or die "open $inFile: $!"; > >   �...@key=split(',',); > >   �...@score_key=shift(@key); > >    return @key; > > } > > Is it possible that the last value is "C\n" instead of just "C"? You might > try this code... > sub key{

Re: logic not being able to score last element in the array

2010-05-05 Thread John W. Krahn
ill be compared to key; if the values match then a 1 or a 0 is stored in the third array. I can't understand why the last element in the score array is always a zero. I can't either because when I run your code I get the correct value in the score array every time. I am prin

Re: logic not being able to score last element in the array

2010-05-05 Thread Robert Wohlfarth
On Tue, May 4, 2010 at 8:39 PM, iinfer wrote: > # OPEN THE KEY > > my @key=(); > my @score_key=(); > sub key{ >my $inFile = 'key.csv'; >open(IN, $inFile) or die "open $inFile: $!"; >@key=split(',',); >@score_key=shift(@ke

logic not being able to score last element in the array

2010-05-05 Thread iinfer
f the values match then a 1 or a 0 is stored in the third array. I can't understand why the last element in the score array is always a zero. I am printing all the elements an the correct key, response are printed but the score is always zero. However when I use arrays "mkey" and

Re: Reg Exp: Extract from last appearance of A to first appearance B

2010-04-27 Thread HolyNoob
Thanks everyone, The solution of John W. Krahn works perfectly :) Incredible On Tue, Apr 27, 2010 at 1:41 PM, John W. Krahn wrote: > HolyNoob wrote: > >> Hi, >> > > Hello, > > > I'm trying to make a regexp to match the last appearance of a word

Re: Reg Exp: Extract from last appearance of A to first appearance B

2010-04-27 Thread John W. Krahn
HolyNoob wrote: Hi, Hello, I'm trying to make a regexp to match the last appearance of a word (lets say 'abc') until the first appearance of another word (for ex: 'xyz'), and I still cannot do it. For example: with a string like this "abc abc abc toto toto xyz

Re: Reg Exp: Extract from last appearance of A to first appearance B

2010-04-27 Thread Erez Schatz
z xyz xyz"; > print $1 if $st =~ m/abc(((?!abc).(?!abc))*?)xyz/ > > PS C:\> perl .\test.pl >  toto toto > > > On 27 April 2010 10:52, HolyNoob wrote: >> Hi, >> >> I'm trying to make a regexp to match the last appearance of a word (lets say >>

  1   2   3   4   5   6   7   >