Re: Snagging the last page of a report
On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus) wrote: snip How to seek last 2k? Here's a start for you, getting the last 2k of the file. Looping and checking for last page break is left up to you. :-) #!/usr/bin/perl -w use strict; my $filename = shift or die Usage: $0 file \n; # Open the file in read mode open FILE, $filename or die Couldn't open $filename: $!; # Rewind from the end of the file until -2k seek FILE,0, 2; #go to EOF seek FILE,-2048,2; #get last 2k bytes $/=undef; my $tail = FILE; print $tail\n; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Snagging the last page of a report
What is $/ Is this a made up variable or a Perl special variable? I don't recall coming across it in the learning Perl book. But I have just started the programming Perl book. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of zentara Sent: Friday, December 06, 2002 6:36 AM To: [EMAIL PROTECTED] Subject: Re: Snagging the last page of a report On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus) wrote: snip How to seek last 2k? Here's a start for you, getting the last 2k of the file. Looping and checking for last page break is left up to you. :-) #!/usr/bin/perl -w use strict; my $filename = shift or die Usage: $0 file \n; # Open the file in read mode open FILE, $filename or die Couldn't open $filename: $!; # Rewind from the end of the file until -2k seek FILE,0, 2; #go to EOF seek FILE,-2048,2; #get last 2k bytes $/=undef; my $tail = FILE; print $tail\n; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Snagging the last page of a report
Perl special variable it is the input separator. From the camel (the real one): Entirely undefining $/ makes the next line input operation slurp in the remainder of the file as one scalar value. Which is how it was used in the first post. See $\ for the output separator. It is a good idea to 'local' this beast before changing it. http://danconia.org On Fri, 6 Dec 2002 14:20:01 -0500, Paul Kraus [EMAIL PROTECTED] wrote: What is $/ Is this a made up variable or a Perl special variable? I don't recall coming across it in the learning Perl book. But I have just started the programming Perl book. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of zentara Sent: Friday, December 06, 2002 6:36 AM To: [EMAIL PROTECTED] Subject: Re: Snagging the last page of a report On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus) wrote: snip How to seek last 2k? Here's a start for you, getting the last 2k of the file. Looping and checking for last page break is left up to you. :-) #!/usr/bin/perl -w use strict; my $filename = shift or die Usage: $0 file \n; # Open the file in read mode open FILE, $filename or die Couldn't open $filename: $!; # Rewind from the end of the file until -2k seek FILE,0, 2; #go to EOF seek FILE,-2048,2; #get last 2k bytes $/=undef; my $tail = FILE; print $tail\n; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Snagging the last page of a report
p.s. see perldoc perlvar and search for INPUT_RECORD_SEPARATOR http://danconia.org On Fri, 6 Dec 2002 13:31:48 -0600, [EMAIL PROTECTED] wrote: Perl special variable it is the input separator. From the camel (the real one): Entirely undefining $/ makes the next line input operation slurp in the remainder of the file as one scalar value. Which is how it was used in the first post. See $\ for the output separator. It is a good idea to 'local' this beast before changing it. http://danconia.org On Fri, 6 Dec 2002 14:20:01 -0500, Paul Kraus [EMAIL PROTECTED] wrote: What is $/ Is this a made up variable or a Perl special variable? I don't recall coming across it in the learning Perl book. But I have just started the programming Perl book. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of zentara Sent: Friday, December 06, 2002 6:36 AM To: [EMAIL PROTECTED] Subject: Re: Snagging the last page of a report On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus) wrote: snip How to seek last 2k? Here's a start for you, getting the last 2k of the file. Looping and checking for last page break is left up to you. :-) #!/usr/bin/perl -w use strict; my $filename = shift or die Usage: $0 file \n; # Open the file in read mode open FILE, $filename or die Couldn't open $filename: $!; # Rewind from the end of the file until -2k seek FILE,0, 2; #go to EOF seek FILE,-2048,2; #get last 2k bytes $/=undef; my $tail = FILE; print $tail\n; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Snagging the last page of a report
My reports seem to perform a form feed with ^L this doesn't seem to all me to find it with regexpr. Do I have to search for the ASCII equivalent? What does this translate to and where did you look to find out? Paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, December 06, 2002 2:38 PM To: Paul Kraus Cc: [EMAIL PROTECTED] Subject: RE: Snagging the last page of a report p.s. see perldoc perlvar and search for INPUT_RECORD_SEPARATOR http://danconia.org On Fri, 6 Dec 2002 13:31:48 -0600, [EMAIL PROTECTED] wrote: Perl special variable it is the input separator. From the camel (the real one): Entirely undefining $/ makes the next line input operation slurp in the remainder of the file as one scalar value. Which is how it was used in the first post. See $\ for the output separator. It is a good idea to 'local' this beast before changing it. http://danconia.org On Fri, 6 Dec 2002 14:20:01 -0500, Paul Kraus [EMAIL PROTECTED] wrote: What is $/ Is this a made up variable or a Perl special variable? I don't recall coming across it in the learning Perl book. But I have just started the programming Perl book. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of zentara Sent: Friday, December 06, 2002 6:36 AM To: [EMAIL PROTECTED] Subject: Re: Snagging the last page of a report On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus) wrote: snip How to seek last 2k? Here's a start for you, getting the last 2k of the file. Looping and checking for last page break is left up to you. :-) #!/usr/bin/perl -w use strict; my $filename = shift or die Usage: $0 file \n; # Open the file in read mode open FILE, $filename or die Couldn't open $filename: $!; # Rewind from the end of the file until -2k seek FILE,0, 2; #go to EOF seek FILE,-2048,2; #get last 2k bytes $/=undef; my $tail = FILE; print $tail\n; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Snagging the last page of a report
Paul Kraus wrote: My reports seem to perform a form feed with ^L this doesn't seem to all me to find it with regexpr. Do I have to search for the ASCII equivalent? What does this translate to and where did you look to find out? The form feed character is reresented by \f (or \cL or \014 or \xC) in double quoted strings. These special characters are described in the Quote and Quote-like Operators section of the perlop manpage. perldoc perlop John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Snagging the last page of a report
Every month I have several reports I print to disk. They are hundreds of pages long. I only need the last page of each. As it is now I open it in a text editor scroll down and copy the last page to a new text document. This is irritating and I want to play with the Perl I have been learning. How can I snag the last page of something. I could do a search to find end of file (I think you can do that with reg expr). Then if somehow I could have it report the position of the file the EOF occurs I could then somehow count back to the first part of the page then ummm well you see my confusion. Any help and suggestions are appreciated. All though a solution would definitely solve my problem it wouldn't be fun at all :) However if I could get some hints or be pointed at some relevant info I would greatly appreciate it. Thanks in advance. Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Snagging the last page of a report
perldoc -f seek /Stefan Lidman Paul Kraus wrote: How do I look up info for a fuction like seek. I tried perldoc seek and perldoc Seek to no avail. Thanks. -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 05, 2002 2:14 PM To: 'Paul Kraus'; Perl Subject: RE: Snagging the last page of a report -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 05, 2002 2:00 PM To: Perl Subject: Snagging the last page of a report Every month I have several reports I print to disk. They are hundreds of pages long. I only need the last page of each. As it is now I open it in a text editor scroll down and copy the last page to a new text document. This is irritating and I want to play with the Perl I have been learning. How can I snag the last page of something. I could do a search to find end of file (I think you can do that with reg expr). No, regexes are for searching strings. The seek() function can be used to position the pointer at the end of the file. Then if somehow I could have it report the position of the file the EOF occurs I could then somehow count back to the first part of the page then ummm well you see my confusion. Any help and suggestions are appreciated. All though a solution would definitely solve my problem it wouldn't be fun at all :) The trick is to find whatever delimits the last page. It might be as simple as an ASCII formfeed (12) character. In general, you would seek to EOF, then back up a reasonable page size (say 2kb) and read a block of data. If you find the start of the last page, you're good. If not, back up another 2k and try again. However if I could get some hints or be pointed at some relevant info I would greatly appreciate it. Thanks in advance. There's a File::ReadBackwards module on CPAN that might be helpful. It handles all the file pointer manipulation for you. You could just read lines backwards into an array until you find the first line of the page. Then print reverse(@myarray) to print the last page. If the files were small, you could suck the whole file into a single string and extract the last page using a regex. But for big reports that's a bad idea... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Last page
Assuming you'll utilise the CGI module, this would work: my $q = new CGI; my $calling_page = $q-referer(); hth, Jos Boumans Stéphane JEAN BAPTISTE wrote: How can I get the URL which was calling my script (like document.referrer in Javascript) tks
Re: Last page - That's OK
It was all I need Thank you Stéphane JEAN BAPTISTE a écrit : How can I get the URL which was calling my script (like document.referrer in Javascript) tks
Re: Last page
The URL which was calling your script is stored in the variable $ENV{'HTTP_REFERER'} . note: referrer spelt as referer and not referrer.