The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl -write values in a file to @array in perl meghana Shell Programming and Scripting 27 06-07-2009 05:05 PM
Creating a file ravisg Shell Programming and Scripting 2 05-10-2008 06:15 AM
help with creating new log file john89011 Shell Programming and Scripting 0 02-29-2008 12:45 PM
Creating a txt file outthere_3 UNIX for Dummies Questions & Answers 1 01-31-2008 11:09 PM
Creating a csv file based on Existing file skywayterrace Shell Programming and Scripting 3 12-02-2007 09:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-03-2008
chriss_58 chriss_58 is offline
Registered User
  
 

Join Date: May 2008
Posts: 41
creating a file using Perl

Hi guys,

when i use the following code:

open(DEST, ">>DESTINATION_")|| die "$!"; #OPEN FILE FOR WRITING
@contents=@field;
print DEST "@contents\n";

I am creating a file that lookss like this:
Wed May 14 11:42:03 2008 10800 306973223399 19419-NEA 1 1259 1 3 80

What i want to do is to create a file that looks like the line below:
Wed May 14 11:42:03 2008| 10800| 306973223399| 19419-NEA| 1 | 1259| 1| 3| 80

This means that every field in the @contents must be seperated by its neighboor with a "|"

Any idea how am i going to implement this?

Thank you very much!
  #2 (permalink)  
Old 06-03-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
print DEST (join ("|", @contents), "\n");
You could also use @field directly; there is no benefit from copying the value to @contents separately.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0