Advice on proper command to use

M

mike

Hi,

I will be doing some file modification depending on certain conditions
like:

If the file contains xxxDefault() then check if it has comments
(preceeding it).
If not add getXXX();
if true then add getXXX() before comments.

I need some advice which command/s is/are most efficient to use.

br,

//mike
 
J

Jürgen Exner

mike said:
Hi,

I will be doing some file modification depending on certain conditions
like:

If the file contains xxxDefault() then check if it has comments
(preceeding it).
If not add getXXX();
if true then add getXXX() before comments.

I need some advice which command/s is/are most efficient to use.

???
How would efficient commands help you if they don't solve your problem?
First step write an algorithm that solves the problem. If it turns out
to be too slow, then investigate if there is a faster algorithm,
preferably in a better O(n) class.
And only after you've exhausted that avenue and the program is still too
slow it may(!) be worthwhile to micro-optimize and choose different
functions, but even then only after thourougly benchmarking your code.

jue
 
M

mike

???
How would efficient commands help you if they don't solve your problem?
First step write an algorithm that solves the problem. If it turns out
to be too slow, then investigate if there is a faster algorithm,
preferably in a better O(n) class.
And only after you've exhausted that avenue and the program is still too
slow it may(!) be worthwhile to micro-optimize and choose different
functions, but even then only after thourougly benchmarking your code.

jue

Well I don't know what command is most appropriate for the task.
Please advice me.

br,

//mike
 
J

Jürgen Exner

mike said:
Well I don't know what command is most appropriate for the task.
Please advice me.

To the best of my knowledge there is no single command that would
accomplish what you are trying to do. Therefore most likely you will
have to write an algorithm, combining many different commands into a
program.
Some commands you might find useful are probably open(), index() or
m//, print(), and close().
You may also want to re-read 'perldoc -q insert'.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top