Advice on proper command to use

Discussion in 'Perl Misc' started by mike, Oct 12, 2009.

  1. mike

    mike Guest

    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
     
    mike, Oct 12, 2009
    #1
    1. Advertising

  2. mike <> wrote:
    >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
     
    Jürgen Exner, Oct 12, 2009
    #2
    1. Advertising

  3. mike

    mike Guest

    On 12 Okt, 15:33, Jürgen Exner <> wrote:
    > mike <> wrote:
    > >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


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

    br,

    //mike
     
    mike, Oct 12, 2009
    #3
  4. mike

    sreservoir Guest

    mike wrote:
    > On 12 Okt, 15:33, Jürgen Exner <> wrote:
    >> mike <> wrote:
    >>> 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

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


    it's tell()

    --

    "Six by nine. Forty two."
    "That's it. That's all there is."
    "I always thought something was fundamentally wrong with the universe"
     
    sreservoir, Oct 12, 2009
    #4
  5. mike <> wrote:
    >On 12 Okt, 15:33, Jürgen Exner <> wrote:
    >> mike <> wrote:
    >> >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?

    >
    >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
     
    Jürgen Exner, Oct 12, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Asun Friere
    Replies:
    1
    Views:
    507
    Paul Boddie
    Aug 27, 2003
  2. Peter Hansen
    Replies:
    23
    Views:
    878
    Anton Vredegoor
    Sep 5, 2003
  3. Gerrit Holl
    Replies:
    16
    Views:
    625
    Tom Plunket
    Aug 29, 2003
  4. RajW
    Replies:
    9
    Views:
    320
  5. H. Wade Minter
    Replies:
    8
    Views:
    295
    Robin
    Apr 25, 2004
Loading...

Share This Page