Re: how to do this in perl (from unix)

2011-09-01 Thread John W. Krahn
Jim Gibson wrote: At 6:14 PM -0700 9/1/11, John W. Krahn wrote: Jim Gibson wrote: On 9/1/11 Thu Sep 1, 2011 5:15 PM, "Rajeev Prasad" scribbled: @tmpAR2 = split(/ /,"$line"); There is no need to surround $line with double-quotes: @tmpAR2 = split(/ /,$line); Note that the split will delete

Re: how to do this in perl (from unix)

2011-09-01 Thread John Riselvato
> > > >> Beginning Perl programmers should note the difference between ' ' and / > / for split. In most cases, it doesn't matter. However, the split pattern ' > ' is a special case that splits on any whitespace, which includes the space > character, the tab character, and the newline character. It

Re: how to do this in perl (from unix)

2011-09-01 Thread Jim Gibson
At 6:14 PM -0700 9/1/11, John W. Krahn wrote: Jim Gibson wrote: On 9/1/11 Thu Sep 1, 2011 5:15 PM, "Rajeev Prasad" scribbled: @tmpAR2 = split(/ /,"$line"); There is no need to surround $line with double-quotes: @tmpAR2 = split(/ /,$line); Note that the split will delete the newline

Re: how to do this in perl (from unix)

2011-09-01 Thread Owen
> from linux: >   > cut -f1,5- -d" " file |grep -v "^0" | sort -n > to_file;   <==this > line: how to achieve this in perl? Perhaps try something like system (cut -f1,5- -d" " file |grep -v "^0" | sort -n > to_file); You may need to replace cut etc with /usr/bin/cut etc -- Owen -- T

Re: how to do this in perl (from unix)

2011-09-01 Thread John W. Krahn
John W. Krahn wrote: Rajeev Prasad wrote: from linux: cut -f1,5- -d" " file |grep -v "^0" | sort -n> to_file;<==this line: how to achieve this in perl? open IN_FH, '<', 'file' or die "Cannot open 'file' because: $!"; open OUT_FH, '>', 'to_file' or die "Cannot open 'to_file' because: $!";

Re: how to do this in perl (from unix)

2011-09-01 Thread John W. Krahn
Jim Gibson wrote: On 9/1/11 Thu Sep 1, 2011 5:15 PM, "Rajeev Prasad" scribbled: @tmpAR2 = split(/ /,"$line"); There is no need to surround $line with double-quotes: @tmpAR2 = split(/ /,$line); Note that the split will delete the newline character from the last element of @tmpAR2.

Re: how to do this in perl (from unix)

2011-09-01 Thread John W. Krahn
Rajeev Prasad wrote: from linux: cut -f1,5- -d" " file |grep -v "^0" | sort -n> to_file;<==this line: how to achieve this in perl? open IN_FH, '<', 'file'or die "Cannot open 'file' because: $!"; open OUT_FH, '>', 'to_file' or die "Cannot open 'to_file' because: $!"; print OUT_FH s

Re: how to do this in perl (from unix)

2011-09-01 Thread Jim Gibson
On 9/1/11 Thu Sep 1, 2011 5:15 PM, "Rajeev Prasad" scribbled: > tried further, still no resolution: Please use complete sentences in your posts. You are asking people to help you for free, so please give them the courtesy of using proper language. >   > file1 = (space seperated values) > outp

Re: how to do this in perl (from unix)

2011-09-01 Thread Jim Gibson
On 9/1/11 Thu Sep 1, 2011 4:38 PM, "Rajeev Prasad" scribbled: > from linux: >   > cut -f1,5- -d" " file |grep -v "^0" | sort -n > to_file;   <==this line: > how to achieve this in perl? >   >   > will below work,  in perl? >   > if ( ! -s $sourcedir/somefile ){ > >  open(tmpFH,"<","file2")

Re: how to do this in perl (from unix)

2011-09-01 Thread Rajeev Prasad
tried further, still no resolution:   file1 = (space seperated values) outputfile = (colum1, and 5 onwards)  field seperator would be space.   from linux:  cut -f1,5- -d" " file |grep -v "^0" | sort -n > to_file;        open(tmpFH,"<","file1");  @tmpAR = ;  close(tmpFH);  foreach $line (@tmpAR) {  

Re: how to do this in perl (from unix)

2011-09-01 Thread Parag Kalra
Please give a better problem statement like what is the form of data initially present in the file and what you wish to extract. You should also post sample file data for both the files (before and after) Not all people who know Perl might know Unix commands (rare but possible) and so they may no

Re: how to do this in perl (from unix)

2011-09-01 Thread Rajeev Prasad
I tried this    open(tmpFH,"<","somefile");  @tmpAR = ;  close(tmpFH);  push(my @tmpAR2,$tmpAR[0]);  push (@tmpAR2,$tmpAR[5..-1]);  my @tmpAR3 = grep {!/^0 /} @tmpAR2;  @tmpAR3 = sort(@tmpAR3);  print @tmpAR3;   but getting error: Argument "" isn't numeric in array element at ./test.pl line 31.

how to do this in perl (from unix)

2011-09-01 Thread Rajeev Prasad
from linux:   cut -f1,5- -d" " file |grep -v "^0" | sort -n > to_file;   <==this line: how to achieve this in perl?     will below work,  in perl?   if ( ! -s $sourcedir/somefile ){  open(tmpFH,"<","file2");  @tmpAR = ;  close(tmpFH);  push(@tmpAR2,$tmpAR[0],$tmpAR[5..]);#select on c

Re: Sandboxing while I am learning

2011-09-01 Thread flebber
On Sep 1, 4:54 am, byu...@langly.dyndns.org ("Brian F. Yulga") wrote: > Marc wrote: > > Shawn, > > >> if you use perlbrew and local::lib you > >> can test different perl versions and then different environments. > > >    I haven't looked into local::lib yet.  What advantage does that give you > >