The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

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 06:05 PM
Calling a perl script from a perl script new2ss Shell Programming and Scripting 6 05-24-2009 06:03 PM
[Perl] Accessing array elements within a sed command in Perl script userix Shell Programming and Scripting 2 10-03-2008 01:05 PM
[PERL] Running unix commands within Perl Scripts userix Shell Programming and Scripting 1 05-28-2008 07:06 PM
Perl: Run perl script in the current process vino Shell Programming and Scripting 10 12-09-2005 10:45 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-02-2009
EDALBNUG EDALBNUG is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 14
How to Turn perl one-liners into full perl script?

I have the following command prompt perl one liner:


Code:
perl -e 's/[a-z]\(\)\\,\"]//g; s/^\s//g; s/;/\n/g' -pi result1

I tried to move this one liner into a perl script I am practicing with (just started learning perl right now).

I tried the following (I only know how to open a file and output to a new file right now):


Code:
open (var2, "result1") or die "Error Opening Target\n";
open (var3, ">mod2") or die "Error Generating Target\n";


while (<var2>) {
  $_=~s/[a-z\(\)\\,\"]//g; 
  $_=~s/^\s+//g; 
  $_=~s/;/\n/g;
  print var3;
}

Which does nothing (I get an empty var3 file)

Can anyone point out what mistakes I made in the script?
 

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 05:38 AM.


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