Hi Rajeev,
some comments on your code:
On Fri, 2 Sep 2011 13:28:49 -0700 (PDT)
Rajeev Prasad wrote:
>
> unfortunately it was not working as i intended.
>
> so i have new code with some help now:
> using $column variable, i can control which column (from 1 to 4) i want to be
> printed with c
rahn
To: Perl Beginners
Sent: Friday, September 2, 2011 2:12 PM
Subject: Re: how to do this in perl (from unix)
Rajeev Prasad wrote:
> Thank you John,
>
> that is almost perfect. only two issues:
>
> 1. getting error on sort for each line of input, column 5 onwards is text...:
&
Rajeev Prasad wrote:
Thank you John,
that is almost perfect. only two issues:
1. getting error on sort for each line of input, column 5 onwards is text...:
Argument "154 Overload Status\n" isn't numeric in sort at ./test.pl line
30, line 208.
2. by chaniging the column number in join (..
)
/^0/ = expression to check wether line starts with 0
? = if line starts with zero then ??? not sure
() = not sure...
: = not sure...
5. sort = sorts the final array on first column (which is by the way
numerical)
6. OUT_FH = writes the outcome to the file_handle.
From: Jo
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
>
>
> >> 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
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
> 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
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: $!";
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.
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
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
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")
mpAR = ;
close(tmpFH);
foreach $line (@tmpAR) {
@tmpAR2 = split(/ /,"$line");
$line2 = "$tmpAR[0] $tmpAR[5..-1]";
push(@tmpAR3,$line2);
};
@tmpAR3 = sort(@tmpAR3);
print @tmpAR3;
From: Rajeev Prasad
To: Rajeev Prasad ; Perl Beginners
Sent: Thursday, September 1
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
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.
$agree = param('agree');
if($agree) {...}
else { print "Sorry you must agree"; }
Seems like you need a way for regstr.html to check for the input. You mayu need to
change it to cgi instead of html so it can do that.
DMuey
> I am very new to perl.
> i need to write a simple user log system
> if
Xiongfei Wang wrote:
> I am very new to perl.
> i need to write a simple user log system
> if you go to
> http://apidb.org/regstragreement.html
> after you click agree, you will be direct to regiser page.
> http://apidb.org/regstr.html
> now if you click directly
> http://apidb.org/regstr.html
18 matches
Mail list logo