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: 3-argument open on STDIN

2011-08-17 Thread Shawn H Corey
On 11-08-17 06:53 PM, Bryan R Harris wrote: How can I do a 3-argument open on STDIN? This doesn't work because the 3-argument open won't open STDIN when you tell it to open "-". ** @files = ("-"); for (@files) { print reverse readfile($_); } sub read

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: 3-argument open on STDIN

2011-08-17 Thread Rob Dixon
On 18/08/2011 01:35, John Delacour wrote: At 17:53 -0500 17/08/2011, Bryan R Harris wrote: How can I do a 3-argument open on STDIN? This doesn't work because the 3-argument open won't open STDIN when you tell it to open "-". ** @files = ("-"); for (@files)

Re: 3-argument open on STDIN

2011-08-17 Thread John Delacour
At 17:53 -0500 17/08/2011, Bryan R Harris wrote: How can I do a 3-argument open on STDIN? This doesn't work because the 3-argument open won't open STDIN when you tell it to open "-". ** @files = ("-"); for (@files) { print reverse readfile($_); } [...]

Re: Sorting a String

2011-08-17 Thread John W. Krahn
Shlomi Fish wrote: "Wagner, David --- Sr Programmer Analyst --- CFS" wrote: Since a \n is at end, then could use split like: for my $dtl ( sort {$a<=> $b} split(/\n/, $a_string) ) { One can also do split(/^/m, $a_string) to split into lines while preserving the newlines. It wi

Re: File sorting question

2011-08-17 Thread Brandon McCaig
On Wed, Aug 17, 2011 at 5:59 PM, ERIC KRAUSE wrote: > The problem for me is the line endings I think. When I open the > file and read in one line, I get the whole file. I think the > line endings are ^p (MS paragraph markers), but I can't open > the file to view them. The files are huge, 150M or b

Re: 3-argument open on STDIN

2011-08-17 Thread Brandon McCaig
On Wed, Aug 17, 2011 at 6:53 PM, Bryan R Harris wrote: > How can I use the "safe" 3-argument open and still be able to read off a > pipe? What I have done in the past is manually compare the filename to '-' and skip the opening and just assign STDIN to my file handle. use strict; use warnings;

3-argument open on STDIN

2011-08-17 Thread Bryan R Harris
How can I do a 3-argument open on STDIN? This doesn't work because the 3-argument open won't open STDIN when you tell it to open "-". ** @files = ("-"); for (@files) { print reverse readfile($_); } sub readfile { open(my $fh,"<",$_[0]) or die "$me

Re: File sorting question

2011-08-17 Thread Jim Gibson
On 8/17/11 Wed Aug 17, 2011 2:59 PM, "ERIC KRAUSE" scribbled: > Hello all, > I am beating my head against the wall, any help would be appreciated. > > I have a file: > / // / m / cvfbcbf/ A123/ / / /// > / // / m / cvfbcbf/ A234/ / / /// > / /

File sorting question

2011-08-17 Thread ERIC KRAUSE
Hello all, I am beating my head against the wall, any help would be appreciated. I have a file: / // / m / cvfbcbf/ A123/ / / /// / // / m / cvfbcbf/ A234/ / / /// / // / m / cvfbcbf/ B123/ / / /// There is spaces in the b

Re: why si this code not working (variable substitution)

2011-08-17 Thread Uri Guttman
> "RP" == Rajeev Prasad writes: RP> foreach $line (@arr1){ RP>  foreach (@arr2) { RP>  chomp($_); RP>  @arr3 = split(/ /,$_); RP>  $mystringvar = eval "qq{$line}"; <--this suggestion came from web search. and it is a very bad idea. string eval is very dange

Re: why si this code not working (variable substitution)

2011-08-17 Thread Rajeev Prasad
Thanks all.   I tried below it works:   foreach $line (@arr1){  foreach (@arr2) {  chomp($_);  @arr3 = split(/ /,$_);  $mystringvar = eval "qq{$line}"; <--this suggestion came from web search.  print $mystringvar;  } } i got the key line in this code from web. thx to all c

Re: why si this code not working (variable substitution)

2011-08-17 Thread Shlomi Fish
Hi Rajeev, On Tue, 16 Aug 2011 17:38:16 -0700 (PDT) Rajeev Prasad wrote: >   >   > foreach $str1 (@arr1){ >  foreach (@arr2) { >  @arr3 = split(/ /,"$_"); >  print "array = @arr3  element0 = $arr3[0] element1 = $arr3[1]";   #this > is just to check, it showing values 0 and 1 as correctly assigne

Re: Sorting a String

2011-08-17 Thread Shlomi Fish
Hi, On Tue, 16 Aug 2011 11:09:35 -0500 "Wagner, David --- Sr Programmer Analyst --- CFS" wrote: > >-Original Message- > >From: Matt [mailto:lm7...@gmail.com] > >Sent: Tuesday, August 16, 2011 10:04 > >To: beginners@perl.org > >Subject: Sorting a String > > > >I believe you can sort an ar

RE: Sorting a String

2011-08-17 Thread Wagner, David --- Sr Programmer Analyst --- CFS
>-Original Message- >From: Matt [mailto:lm7...@gmail.com] >Sent: Tuesday, August 16, 2011 10:04 >To: beginners@perl.org >Subject: Sorting a String > >I believe you can sort an array like so: > >sort @my_array; > >I need to sort a string though. > >I have $a_string that contains: > >4565 lin