SEARCH YOUR SOLUTION HERE  

FAQ 5.26 How do I print to more than one file at once?

This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...

Posted On: Tuesday 27th of November 2012 11:51:26 PM Total Views:  713
View Complete with Replies




Related Messages:

FAQ 5.26 How do I set a file's timestamp in perl?   (134 Views)
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.26: How do I set a file's timestamp in perl You use the utime() function documented in "utime" in perlfunc. By way of example, here's a little program that copies the read and write times from its first argument to all the rest of them. if (@ARGV < 2) { die "usage: cptimes timestamp_file other_files ...\n"; } $timestamp = shift; ($atime, $mtime) = (stat($timestamp))[8,9]; utime $atime, $mtime, @ARGV; Error checking is, as usual, left as an exercise for the reader. The perldoc for utime also has an example that has the same effect as touch(1) on files that *already exist*. Certain file systems have a limited ability to store the times on a file at the expected level of precision. For example, the FAT and HPFS filesystem are unable to create dates on files with a finer granularity than two seconds. This is a limitation of the filesystems, not of utime(). -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
FAQ 5.26 How do I set a file's timestamp in perl?   (133 Views)
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.26: How do I set a file's timestamp in perl You use the utime() function documented in "utime" in perlfunc. By way of example, here's a little program that copies the read and write times from its first argument to all the rest of them. if (@ARGV < 2) { die "usage: cptimes timestamp_file other_files ...\n"; } $timestamp = shift; ($atime, $mtime) = (stat($timestamp))[8,9]; utime $atime, $mtime, @ARGV; Error checking is, as usual, left as an exercise for the reader. The perldoc for utime also has an example that has the same effect as touch(1) on files that *already exist*. Certain file systems have a limited ability to store the times on a file at the expected level of precision. For example, the FAT and HPFS filesystem are unable to create dates on files with a finer granularity than two seconds. This is a limitation of the filesystems, not of utime(). -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
perl: print line for each 10 data   (237 Views)
i have 1200 line of data as below:user1 date time @Glebe2037 Ha! but of course.....user2 date time @aerynea It mostly missed Fort Collinsuser3 date time Lansons is 20 years old this year ....current output:"@Glebe2037 Ha! but of course.....","10001","@aerynea It mostly missed Fort Collins","10002","Lansons is 20 years old this year","10003",............."11200".i need your help to organize this output which is they will print \n everytime the id increase by 10. require output:"aaaaaaa","10001",..............."10010""bbbbbb","10011",..............."10020"CODE#! /usr/bin/perl -wuse strict;open( my $fh, '
FAQ 5.27 How do I print to more than one file at once?   (144 Views)
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
strings printing bug   (152 Views)
The following script is to read 4 consecutive lines at a time from a file, concatenate the first 3 lines (with a ", "), and print the result to STDOUT. If the 3 lines aren't concatenated they print correctly, however ...
header" do?" class="" href="http://www.solveerrors.com/forums/17/perl/what-does-print-cgi-header-do-239529" style="color:#333333; font-weight:bold;"> What does "print $cgi->header" do?   (50 Views)
There is a line in script we have that I find baffling, it is print $cgi->header; To me this seems to be printing the results of the header method of the CGI module to standard output. Is something else going ...
CGI.PM and print table   (144 Views)
trying to replace this print "\n"; print "\n"; print "
\n"; with this print table( TR([ td([submit(),reset()]) ]) ); seems to work but then a new name/value pair for "submit" shows up in the browser address bar original ...
FAQ 8.4 How do I print something out in color?   (113 Views)
This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
FAQ 4.73 How do I print out or copy a recursive data structure?   (127 Views)
This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
How to use HTML::Parser to remove HTML tags and print result   (133 Views)
I am trying to use HTML::Parser to parse an HTML file, remove all HTML tags (including comments, etc.), replace all ENTITIES (e.g. &amp), and put the result into a variable as a string. I figure HTML::Parser itself can somehow preform ...
How can I print a number larger than 128?   (137 Views)
Dear all, I'm new here. I've got a number larger than 128. I want to send it by socket. I find that if print the number directly, I'll print the number in ascii format. So I'll have 3 separate numbers ...
How can I print a number larger than 128?   (120 Views)
Dear all, I'm new here. I've got a number larger than 128. I want to send it by socket. I find that if print the number directly, I'll print the number in ascii format. So I'll have 3 separate numbers ...
WHY are args for sprintf in scalar context?   (134 Views)
Just ran into this nasty trap: > perl -we'@a=("%s %s\n", qw/foo bar/); printf @a' foo bar > perl -we'@a=("%s %s\n", qw/foo bar/); print sprintf @a' 3 And indeed, 'perldoc -f sprintf' says: "Unlike printf, sprintf does not do what you ...
Converting hex to decimal when printed?   (106 Views)
ok, trying this again, since my first post seems to be non- existent... I am reading in 2-digit hex values from a file and would like to output them as decimals. Through online surfing, it seems like the easiest ...
FAQ 5.38 Why do I get weird spaces when I print an array of lines?   (123 Views)
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
How to print just numbers includes in Subject using POP3Client Module.   (135 Views)
How to print just numbers includes in Subject using POP3Client Module. Please Help use Mail::POP3Client; $pop = new Mail::POP3Client( USER => "xxxxxxxxxxxxxxxxx", PASSWORD => "xxxxxxxxxx", HOST => "xxxxxxxxxx" ), TIMEOUT => 1; for ($i = 1; $i <= $pop->Count(); $i++) ...
print on WIndows systems   (120 Views)
Hi again, I have to print out things like invoices, customer personal data and so on. I'd like to use GDI printer driver in order to have control of my prints. I'd like also to send some data to the ...
replacing nonprintable characters in a file   (153 Views)
Tips from a previous thread helped me with this task. The previous thread: http://groups-beta.google.com/group/...a566545d90faa2 To give back to the community, my two bits on how to nonprintable characters in a file. Simple for you perl gurus, but for perl ...
Printing on a printer with tractor feed under win32 - question   (150 Views)
Has anyone done it successfully. I'm trying to use Win32::Printer module but creating new pages doesn't feed the paper in deed amount, missing next forms. (custom paper size defined both in Win printer properties and Win32::Printer object) I'd grateful for ...
PERL + Repeat header on every page while printing excel   (245 Views)
I am working on an application using PERL 5.8. I have a requirement where i am getting data from Oracle database & exporting it to an excel. Users will print this excel file. We are getting bulk data from ...