in reply to parse array to replace specific spaces with pipes

rovfs understandable confusion (wrt the setting of $_) apart, you appear to be slightly confused as to what is going on:

You say I'm trying to read the file..., whereas your code clearly generates the file (file.txt) using data read, a row at a time, from an Oracle query.

Given this, it strikes me that the simplest solution to your formatting problem (which would, at the same time, solve the problem identified by roboticus) - is, IMO, to modify the query to force Oracle to change the default column separator - to '|' as required - in the report.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: parse array to replace specific spaces with pipes
by neurotoxx (Novice) on Jul 10, 2009 at 16:21 UTC

    That was my original plan, but I wasn't able to figure out how to set that in the SQL query. I'll check the docs. Thanks for you help, I sincerely appreciate it.

    -Neurotoxx
      The simplest approach is to specify the list of columns concatenated with the '|' character - something like (I can't remember the exact syntax):
      SELECT id + '|' + FirstName + '|' + Surname FROM some_table WHERE ....

      Otherwise, IIRC, you need to issue a set command (to set the column separator) prior to running the query - RTFM for further details.

      A user level that continues to overstate my experience :-))

        I whish I had time to RTFMFM. ;) All the manuals and tutorials work with small array examples and don't seem to teach much about moving data across scalar, arrays, or hashes...or, perhaps I'm reading the wrong books.

        The original sql+ query had a select statement that didn't work through the DBI interface. I think the DBI only uses standard SQL?

        SQL statement SET HEADING OFF SPOOL file.txt SELECT 'NUMBER|FIRST|LAST|ID' FROM DUAL; SELECT EMPLID ||'|'|| FIRST_NAME || '|' || LAST_NAME || '|' || ID FRO +M db.VIEW WHERE (length(AS_UNIV_ID)>1) and (length(EMPLID)=9) and (le +ngth(FIRST_NAME)>1) and (length(LAST_NAME)>1); SPOOL OFF

        Best advise...kis. thx N