in reply to Re^2: problem in splitting the line
in thread problem in splitting the line

Thank you for your comments!

It looks like the most strict and short-spoken solution will be my $id = join(":",(split(/\s+|:/,$in))[5,6]);.

Sorry if my advice was wrong.

Replies are listed 'Best First'.
Re^4: problem in splitting the line
by Marshall (Canon) on Jul 21, 2012 at 17:59 UTC
    short-spoken yes. As for "best", I'm not sure about that.

    These variables at index 5 and 6 have some sort of application meaning. I would use that application meaning to explicitly name these two variables. And use those names in the print statement rather than using a simple join of an array based upon indicies.

    Creating a scalar value is "cheap" (in terms of processing power) - it usually won't make any significant difference in execution time.

    Choosing good variable names plays a key role in documentation.

    One year from now, you may forget what field 5 vs 6 meant. I have no idea what is appropriate here: $starting_balance or $ending_balance or whatever. But give them names so that it will make sense one or two years from now. Oh, another point: If others cannot understand it, you will not "be able to get rid of it". Meaning have the support person cannot take over this thing instead of you!

    Good code is understandable and maintainable.