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:  688
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




FAQ 5.26 How do I set a file's timestamp in perl?

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.
VIEWS ON THIS POST

129

Posted on:

Wednesday 17th October 2012
View Replies!

FAQ 5.26 How do I set a file's timestamp in perl?

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.
VIEWS ON THIS POST

130

Posted on:

Wednesday 7th November 2012
View Replies!

perl: print line for each 10 data

i have 1200 line of data as below:user1 date time @Glebe2037 Ha! but of course.....user2 date time\t\t@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, '
VIEWS ON THIS POST

229

Posted on:

Saturday 24th November 2012
View Replies!

FAQ 5.27 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 ...
VIEWS ON THIS POST

140

Posted on:

Sunday 25th November 2012
View Replies!

strings printing bug

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 ...
VIEWS ON THIS POST

148

Posted on:

Sunday 25th November 2012
View Replies!

header" do?" style="color:#1385b4;text-transform:uppercase;" name="Post_239529"> What does "print $cgi->header" do?

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 ...
VIEWS ON THIS POST

49

Posted on:

Sunday 25th November 2012
View Replies!

CGI.PM and print table

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 ...

VIEWS ON THIS POST

141

Posted on:

Sunday 25th November 2012
View Replies!

FAQ 8.4 How do I print something out in color?

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 ...
VIEWS ON THIS POST

110

Posted on:

Sunday 25th November 2012
View Replies!

FAQ 4.73 How do I print out or copy a recursive data structure?

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 ...
VIEWS ON THIS POST

124

Posted on:

Sunday 25th November 2012
View Replies!

How to use HTML::Parser to remove HTML tags and print result

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 ...
VIEWS ON THIS POST

130

Posted on:

Monday 26th November 2012
View Replies!

How can I print a number larger than 128?

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 ...
VIEWS ON THIS POST

135

Posted on:

Monday 26th November 2012
View Replies!

How can I print a number larger than 128?

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 ...
VIEWS ON THIS POST

118

Posted on:

Monday 26th November 2012
View Replies!

WHY are args for sprintf in scalar context?

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 ...
VIEWS ON THIS POST

130

Posted on:

Monday 26th November 2012
View Replies!

Converting hex to decimal when printed?

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 ...
VIEWS ON THIS POST

103

Posted on:

Monday 26th November 2012
View Replies!

FAQ 5.38 Why do I get weird spaces when I print an array of lines?

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 ...
VIEWS ON THIS POST

118

Posted on:

Monday 26th November 2012
View Replies!

How to print just numbers includes in Subject using POP3Client Module.

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++) ...
VIEWS ON THIS POST

131

Posted on:

Monday 26th November 2012
View Replies!

print on WIndows systems

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 ...
VIEWS ON THIS POST

117

Posted on:

Monday 26th November 2012
View Replies!

replacing nonprintable characters in a file

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 ...
VIEWS ON THIS POST

150

Posted on:

Monday 26th November 2012
View Replies!

Printing on a printer with tractor feed under win32 - question

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 ...
VIEWS ON THIS POST

147

Posted on:

Monday 26th November 2012
View Replies!

PERL + Repeat header on every page while printing excel

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 ...
VIEWS ON THIS POST

241

Posted on:

Tuesday 27th November 2012
View Replies!