Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'd like to ask for help from this community. I want to have a perl s 1

Status
Not open for further replies.

satori

Programmer
Jul 24, 2000
1
US
I'd like to ask for help from this community.<br>I want to have a perl script that reads each file in current directory(those files are name like filename.V, and the second column of the first line is &1), I need to replace the &1 with filename(Please note: it filename, not filename.V) and write out the same filename to another directory.<br>&nbsp;Thank you.
 
Satori,<br><br>The short script below:<br><br>opens each file like *.V in the current directory<br><br>creates a file with the same name in a directory below the current directory called archive_dir (the dir must already exist)<br><br>copies data from the current file into the archive_dir file.<br><br>closes both files<br><br>I don't understand what you mean by &quot;second column of the first line is &1)&quot; -- could you explain that please?<br><FONT FACE=monospace><b><br>while(&lt;*.V&gt;){<br>&nbsp;&nbsp;&nbsp;&nbsp;print &quot;$_\n&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;open OF, &quot;&gt;archive_dir/$_&quot; ¦¦ die $!;<br>&nbsp;&nbsp;&nbsp;&nbsp;open F, $_ ¦¦ die $!;<br>&nbsp;&nbsp;&nbsp;&nbsp;while(&lt;F&gt;){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print OF $_;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;close F;<br>&nbsp;&nbsp;&nbsp;&nbsp;close OF;<br>}<br></font></b><br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top