Removing all newline characters in a string

2009-02-05 Thread Mahurshi Akilla
Is there a simple search and replace command I can do to remove all the newline characters from a string? (besides splitting the string based on \n and then joining the elements) This seems pretty basic but the below commands don't seem to work: s/\\n//g s/\n//g -- To unsubscribe, e-mail:

getting nth column of a string

2007-10-28 Thread Mahurshi Akilla
is there a way to get the nth column of a string in perl, similar to awk '{print $col_no}' in awk ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

split based on n number of occurances of a character

2007-10-26 Thread Mahurshi Akilla
Is there an easy way (without writing our own proc) to split a string based on number of occurances of a character ? for example: $my_string = a;b;c;d;e;f;g;h @regsplitarray = split (/;/, $my_string) splits based on every 1 occurance of ; what if i want it to do 2 at a time ? e.g.

Re: split based on n number of occurances of a character

2007-10-26 Thread Mahurshi Akilla
On Oct 26, 3:51 am, [EMAIL PROTECTED] (Jeff Pang) wrote: using a regex is may suitable. $ perl -e '$x= a;b;c;d;e;f;g;h;@re=$x=~/(\w+;\w+);{0,1}/g;print @re' a;b c;d e;f g;h On 10/26/07, Mahurshi Akilla [EMAIL PROTECTED] wrote: Is there an easy way (without writing our own proc) to split

average and standard deviation

2007-10-03 Thread Mahurshi Akilla
is there an easy way to get the average and standard deviation in perl (given an array of numbers). i don't want to reinvent the wheel and write my own functions. i saw something for the average (see below). it works fine. is there a similar quickie for std deviation (or perhaps, the median)

get a column out of a 2d array

2007-10-03 Thread Mahurshi Akilla
is there an easy way (without iterating through the array) to get a specified column out of a 2d array? lets say i have @array2d 1 2 3 4 5 6 7 8 what i am looking for is something like @my2ndcolum = // magic // i know you can get it with rows using ( $my2ndrowref = @array[1] ) but i don't

peek next line in file

2007-09-27 Thread Mahurshi Akilla
, but it would be nice to know if this can be done. Mahurshi Akilla -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Debugg in PERL

2007-09-16 Thread Mahurshi Akilla
switch ? Read about perl debuggers here: http://debugger.perl.org/ Mahurshi Akilla -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: spliting

2007-09-04 Thread Mahurshi Akilla
If you're trying to split a long string into smaller strings of 60 characters each, you can take a look at the substr function and build a loop around it. http://www.perlmeme.org/howtos/perlfunc/substr.html Mahurshi Akilla On Sep 4, 5:29 am, [EMAIL PROTECTED] (Pedro Soto) wrote: Hi, I have

Appending 1 D array into a 2 D array

2007-08-10 Thread Mahurshi Akilla
I am trying to read a csv file into a 2D array matrix I am having a hard time trying to get the array returned by split function to attach to a 2D array. See the code below for further info on what I'm trying to do ## initialize $row = 0; $col = 0; ## go thru each line of file while

Perl script to build a forum

2007-07-24 Thread Mahurshi Akilla
Does anyone know if there's a perl script available that can run a simple forum? I tried searching on google but any combination of perl and forum in the search words are giving me results on perl forums :-) but not the forums being run by perl. Thanks -- To unsubscribe, e-mail: [EMAIL