Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
filehandlers in perl

Posted by swethafrienz (swethafrienz), 12 September 2007
Hi,
the input file I am having looks like this...

70822085500    tnsmrt0pr02    0      267    50    230      
70822085600        "                0       280     60      245      
70822085700        "                 0       290    70    254        
70822085800        "                 0       299     80   263
70822085900        "                 0        312    90  274
70822080000        "                0         323   100    288

and the output file should be like this after subtracting the values of first row from second row ....and second row from third row...........



70822085500    tnsmrt0pr02    0     0   0       0    
70822085600        "                0      13  10    15    
70822085700        "                 0      10  10     9    
70822085800        "                 0      9     10     9
70822085900        "                 0      13   10     11
70822080000        "                0       11   10     14


I want to write the ode in perl.
help me out in this.

Thanks in advance,
Swetha




Posted by admin (Graham Ellis), 12 September 2007
What code have you written so far?  How were you thinking of doing this?  Or is this a "please write the whole program for me" request  

Posted by KevinAD (KevinAD), 12 September 2007
Quote:
help me out in this.


http://www.perl.org/books/beginning-perl/



Posted by admin (Graham Ellis), 13 September 2007
Code:
#!/usr/bin/perl -pa
@h = @F;
for ($k=2; $k<@F;$k++) {
       if ($F[1] =~ /"/) { $F[$k] = $F[$k] - $p[$k]; } else { $F[$k] = 0; }
}
@p=@h;
$_="@F\n";


I'm not keen to leave questions "hanging" ... in the absence of follow up from the original poster I have written the slightly provocative answer above.  You may argue with some of my style, and indeed with whether or not I should have followed up again quite so fast.

Posted by KevinAD (KevinAD), 13 September 2007
Maybe he's off reading the book I linked him to. One can hope.  

Posted by KevinAD (KevinAD), 21 September 2007
on 09/13/07 at 06:10:19, Graham Ellis wrote:
I'm not keen to leave questions "hanging" ... in the absence of follow up from the original poster I have written the slightly provocative answer above.  You may argue with some of my style, and indeed with whether or not I should have followed up again quite so fast.


Well, looks like the poster has no qualms with hanging you up.  

Posted by admin (Graham Ellis), 23 September 2007
Quote:
Well, looks like the poster has no qualms with hanging you up.  


Maybe ... but basically an answer has been provided / a resource generated and a discussion had ... between you and me, mind! I have learned to take a very laid back view and see feedback as a priviledge and a joy when it comes, rather than a right.

I was insired to write further on my blog ... if anyone comes back to that in the future, long after I penned this, there's a Permalink to the archive here





This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho