in reply to Reading line and Spliting it

Let me first recommend Text::CSV_XS or Spreadsheet::Read to you. Especially Spreadsheet::Read handles reading various tabular files, not only a limited subset of CSV files.

You don't show us what data is in $ColumnNames so it's hard to say what might go wrong in your case. If your data is delimited with commas, using split would separate them into elements in @colarray.

Maybe you can show us the relevant input and the output you get, and also tell us the output you expect so we can help you better?

Replies are listed 'Best First'.
Re^2: Reading line and Spliting it
by lazy (Novice) on Jul 17, 2014 at 07:19 UTC

    without those modules how to read column names only from a comma separated file

    Id,Name,Sex,RegDate,LeaveDate,Time,Dummy

    i need to read it but print/write like this

    Id,Name,Sex,RegDate,LeaveDate,Time

      So, where is your problem exactly? What is the code you have? What does your code output when run? What should it output instead?

        His username probably says it all.

        my problem is to delete the dummy column but the number of columns may differ dynamically as i have to read different files

        i use Tie::Array module to write into file. before writing i need to delete that dummy column which i read from another file. i have placed the code above in question itself !

        i need those column values to be separate values in an array. so that i can print the columns without dummy column

      Just doing a split like this will lead to insanity at some point, unless you can completely insure your data NEVER has commas, or has COMPLETELY PREDICTABLE commas in it. The modules help cope with encapsulated data (When dumping to CSV, Excel will often encapsulate data with a comma in double quotes) and other potential stupidity so you don't $self->shoot('foot'). They aren't perfect, but they're a vast improvement over blindly splitting on an arbitrary delimiter for real world data.