Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Multiply the numbers in a text file

by pvaldes (Chaplain)
on May 09, 2015 at 21:52 UTC ( #1126207=note: print w/replies, xml ) Need Help??


in reply to Multiply the numbers in a text file

Divide your problem in smaller chunks

1-You will need to acces to the input file values, so study how to create a filehandle with the function open. Open a terminal and write perldoc PerlIO for the man pages.

2-You'll need to select your desired numbers. How to do this depend on what is your strategy to pick a number and discard another but you will need probably a regexp. See perldoc perlrequick for a short intro and perldoc perlre for a more extensive and complete manual

3-Replace all non-zero values. See "search and replace" in perldoc perlrequick. Register your values to a variable and then multiply your var with something like '$mynevvalue = $myoldvalue * 5'

4-print out the text file: you'll need an output filehandle. Read 'perldoc PerlIO' and study the function open.

5-don't forget to close both filehandles with the function close

  • Comment on Re: Multiply the numbers in a text file

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1126207]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2019-10-21 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?