greatshots has asked for the wisdom of the Perl Monks concerning the following question:

monks,

open ( SMI, "schema_migration.csv") or die "$!"; # buffering the newschema { @schema_migration = <SMI>; map { $_ =~ s/\n//g } @schema_migration; } print "\n"; print "\nout :$schema_migration[3]:\n"; exit;
Output
:ut :nokia_card_traffic_classes_raw.day,nokia_card_traffic_classes_dl_ +raw.day
From print statment the first character is not getting printed in stdout. wondering, why it happened so ! what eats the 'o' from printing. Os or my program ?

Replies are listed 'Best First'.
Re: printing is not printing the full string
by Crackers2 (Parson) on Oct 30, 2006 at 03:42 UTC

    Just a hunch... maybe your data contains both carriage returns and line feeds, and you're only removing the line feeds?

    So the last character of $schema_migration[3] puts the cursor back to the left, causing the : to overwrite the 'o' of 'out'

      thanks a lot Crackers.
      # buffering the newschema { @schema_migration = <SMI>; map { $_ =~ s/[\n\r]//g } @schema_migration; } print "\n"; print "\nout :$schema_migration[3]:\n"; exit;
      the above correction worked for me as expected. thanks once again.
        IMO s/\r?\n// is more general as it removes \r only if present (Windows) yet \n everytime (both Windows and Un*x). (No one cares of old MacOS (-; )
Re: printing is not printing the full string
by GrandFather (Saint) on Oct 30, 2006 at 03:09 UTC

    Your output simply does not match the code you provide. How about providing a sample that demonstrates the problem and can be run without any external dependencies. See I know what I mean. Why don't you? for some tips.


    DWIM is Perl's answer to Gödel
      but, that is what the output I got. I am wondering really about the mismatch of my output.

        I think Crackers2++ probably has the right answer, but not by reproducing the problem given your sample.

        In general we are not mind readers and can't test the data you don't provide. If you include data in your sample we have a better chance of knowing where you are having trouble and are more likely to be able to help. The disadvantage of course is that you have to do a little more work yourself and may actually solve the problem.


        DWIM is Perl's answer to Gödel