- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Dynamic file_name problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 03:18 AM
01-30-2006 03:18 AM
======================================
$count = 0;
$inp= "input.txt";
open(fileIN, "input.txt");
while (
open(fileOUT, '>>out1.txt') or die "Can't open output file.\n";
$count = $count + 1 ;
chomp ($_);
print fileOUT $_ . ".ryba.dat\n" ;
$newfile = "ini\_$count\.txt "; #XXX !!!!!!! here
copy($file1, $newfile) or die "File cannot be copied.";
}
===========
tx to all
Dai
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 03:30 AM
01-30-2006 03:30 AM
Solution$newfile = sprintf("ini_%d.txt",$count);
The formatting works just line the printf, fprintf, and sprintf C functions so a man sprintf will tell you everything you need to know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 03:40 AM
01-30-2006 03:40 AM
Re: Dynamic file_name problem
If this is perl under Unix, your copy command should look like:
system("cp $file1 $newfile") or die "Can't copy!";
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 03:43 AM
01-30-2006 03:43 AM
Re: Dynamic file_name problem
Well, if you have used the File::Copy module, then I apologize, your 'copy' syntax is correct.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 03:49 AM
01-30-2006 03:49 AM
Re: Dynamic file_name problem
sure I'm using:
use File::Copy
Dai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 04:02 AM
01-30-2006 04:02 AM
Re: Dynamic file_name problem
Thanks again to everybody.
Just another small question: can I somehow maintain $count like 01,02,etc e.g. 2 digits, as I need that format for my file name. ini_01.txt
Tx
Dai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 04:09 AM
01-30-2006 04:09 AM
Re: Dynamic file_name problem
$newfile = sprintf("ini_%02d.txt",$count);
Note the leading zero with a width of two. See the man pages for 'printf' for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 04:12 AM
01-30-2006 04:12 AM