[11086] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4686 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 19 09:17:14 1999

Date: Tue, 19 Jan 99 06:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 19 Jan 1999     Volume: 8 Number: 4686

Today's topics:
    Re: "Back button" in CGI script <r2-d2@REMOVEbigfoot.com>
    Re: "Back button" in CGI script dturley@pobox.com
    Re: == and = , again (Fluffy)
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
        about the $| variable! <ed98mba@lc.vetlanda.se>
    Re: Array slices with a maximum length (Bart Lateur)
    Re: Calculate next [mon..sun]day (Mike Bristow)
        Calling a sub <gernot@cat.at>
    Re: Calling a sub (Fluffy)
        Changing elements in a text file <r2-d2@REMOVEbigfoot.com>
        File Handle Elements as numeric values <r2-d2@REMOVEbigfoot.com>
        Formatting text ? wandr@my-dejanews.com
    Re: geting arguments <ed98mba@lc.vetlanda.se>
        getpeername on WinNT does it work? guyrj@an.hp.com
        How to determine time? info@netstyle.nl
    Re: How to link image in Perl script ? wouterse@my-dejanews.com
    Re: Lame coding question <spam@dikkelul.com>
    Re: pattern matching between multiple lines in a file <sysop@scbbs.com>
        perl & c++ markus@wotan.econ.surrey.ac.uk
        Perl problem :(Offline mode... <andrewf@beausys.demon.co.uk>
    Re: Perl problem :(Offline mode... <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Routing picture from my other site (Bart Lateur)
        So sorry, i got i right!!!! <ed98mba@lc.vetlanda.se>
    Re: Statistics for comp.lang.perl.misc <tchrist@mox.perl.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 19 Jan 1999 10:43:55 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Re: "Back button" in CGI script
Message-Id: <781np8$eoc$1@plug.news.pipex.net>

Just use the following Javascript:

<input type="Button" name="Back" value="<-------- Back"
onClick="history.go(-1)">

Hope this helps
Artoo

>Pardon a newbie question...
>
>I just got my first script working (a simple mail-generating form)... it
>does error-checking, and if required info is missing, I'd like to provde
>a "back" link to the HTML page that had the original form, so that the
>partial info entered by the user will be retained.
>
>I can pass the script the form file's name, and provide a link back to
>it, but that reloads the form, losing the info. I want to duplicate the
>browser's "back button" functionality.
>
>If you can, please cc: your response to me via email, as I don't always
>get to check the newsgroups at work.
>
>Thanks!
>--
>Joel Borden
>Mr. Marketing
>mr.marketing@worldnet.att.net
>




------------------------------

Date: Tue, 19 Jan 1999 13:21:41 GMT
From: dturley@pobox.com
Subject: Re: "Back button" in CGI script
Message-Id: <7820st$rsc$1@nnrp1.dejanews.com>

In article <36A4134D.4BD2@worldnet.att.net>,
  mr.marketing@worldnet.att.net wrote:

> I can pass the script the form file's name, and provide a link back to
> it, but that reloads the form, losing the info. I want to duplicate the
> browser's "back button" functionality.

You could use JavaScript:

<A HREF="javascript:history.go(-1);">Please try again.</A>

> If you can, please cc: your response to me via email, as I don't always
> get to check the newsgroups at work.

Then you shouldn't post here if you can't check for an answer.

--
____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 19 Jan 1999 13:11:49 GMT
From: meowing@banet.net (Fluffy)
Subject: Re: == and = , again
Message-Id: <7820af$nnp@meow.invalid>

Christian M. Aranda <christian.arandaNOSPAM@NOSPAMiiginc.com> wrote:

{using the C preprocesor}

> I know that I could use benchmark, but just in general how much slower
> would it be defining them?

It depends.  Is it a long-running process or something rapid-fire like
a CGI-based app?  A compile-time macro can have less overhead than a
real sub if you use it heavily.
-- 
"Meow."  --me


------------------------------

Date: Tue, 19 Jan 1999 11:25:47 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage916745041.541@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 10 Sep 1998

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://cpan.perl.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://cpan.perl.org/
    http://www.perl.com/CPAN/
    http://cpan.perl.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:

    setdir usenet-by-group/news.announce.newusers
    send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


------------------------------

Date: Tue, 19 Jan 1999 14:02:19 +0100
From: ed98mba <ed98mba@lc.vetlanda.se>
Subject: about the $| variable!
Message-Id: <36A4825B.B75EBB87@lc.vetlanda.se>

Hi again!

due to a desperate attempt to send something to the conferance, me and
my friends decided to write a nph- program that allows u to play
card-games with others! however! when we try the simplest script with
nph- tech. on our small w95 local webserver, it does not work! Can it be
that the $| variable don4t work on non native systems? this is the code
so far!!:

#! c:\Program\sambar42\perl\perl.exe

$| = 1;
$grans = "_my_strange_line_";

$text="hi everyone";
print <<_HUVUD_;
HTTP/1.1 200 OK
Content-Type: multipart/x-mixed-replace;boundary=$grans

--$grans
_HUVUD_

for ($i=20; $i>=0; $i--)
{
 $text="HI again!  only $i times left!!!";
 print <<_DOKUMENT_;
Content-Type: text/plain

$text

--$grans

_DOKUMENT_
 # Vdnta en sekund innan ndsta utskrift
 sleep 1;
}
print "--";

if anyone can help me with this or if someone can make it work on a
native system, please inform me of it!

/thanx aLOOT
Martin Belohorka



------------------------------

Date: Tue, 19 Jan 1999 10:33:45 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Array slices with a maximum length
Message-Id: <36a45c90.6626481@news.skynet.be>

Bart Lateur wrote:

>	@result = ('A' .. 'Z');		# 26 entries
>	$slice = 10; 		# 10 at a time
>	$page = 2;		# start at 20
>	@slice = @result[$page*$slice .. ($page+1)*$slice-1];
>
>The problem is that once you get past the end of the original array, you
>get extra undefined values as fills at the end of the array. Try:
>
	$" = "#";
>	print "\[@slice\]\n";

Well, *all* replies so far (post and e-mail) use manual calculation of
the end index, and of the minimum of his and the last index. I think
that's a lot of useless work. Besides, this ignoreds my remark:

>(Note that @result needn't even be an array:
>it could be a function returning an array, too.)

So:

	sub search {
		return ('A' .. 'Z');
	}

The suggested solution (it all comes down to just one, really) requires
string that result in an array @result, or you just can't have the value
$#result. That's not nice, either. (I ignore for the moment that for
this particular application, I need the hit count too = scalar @result.)

And this doesn't work:

	@slice = (@result = &search())[ $page*$slice ..
			&min(($page+1)*$slice -1, $#result)];

because, apparently, @result isn't set yet when $#result gets used (it
contains -1).

If I am to use an array anyway, I might use an approach with less
computation:

	$page = 2; $slice = 10;
	my @result = &search();
	@slice = splice @result,$slice*$page,$slice;
	$" = "#";
	print "\[@slice\]\n";

Lo and behold, it WORKS. NO undefined fill values! The only thing I
don't like now, is that the original result array is messed up, which
*may* be a rather expensive operation.

Anybody who can beat that?

	Bart.


------------------------------

Date: Tue, 19 Jan 1999 10:02:41 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: Calculate next [mon..sun]day
Message-Id: <slrn7a8m21.169.mike@lindt.fat.dotat.at>

On Mon, 18 Jan 1999 18:23:23 -0500, Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
>marcel_anthonijsz@my-dejanews.com writes:
>
>> I want to calculate the date of next [mon..sun]day, what is the easiest and
>> most nice way to do this? It should work after the year 0 .. (Hey, my brain
>> has a Y2K bug!).
>
>Personally, I would use one of the Time::* modules.
>But, here's an easy way (any bugs?):
>
>$time = time;
>$today = (localtime($time))[6];
>$tomorrow = (localtime($time + 24*60*60))[6];

Some days have leap seconds.

-- 
"On the Internet, no one knows you're using Windows NT"
	-- Ramiro Estrugo 


------------------------------

Date: Tue, 19 Jan 1999 14:39:58 +0100
From: Gernot Homma <gernot@cat.at>
Subject: Calling a sub
Message-Id: <36A48B2E.CCBF6039@cat.at>

This is a multi-part message in MIME format.
--------------5812923C8069525C698160A2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

I'm looking for a solution for the following problem

$mysub = "function1";


sub function1
{
    print "Hello";
}

I want to call "function1" though the scalar $mysub.
Is there a gobal solution? I know I could solve this problem with "if" -
statements, but I do'nt want to work this way.

Many thanks in advance,
Gernot




--------------5812923C8069525C698160A2
Content-Type: text/x-vcard; charset=us-ascii;
 name="gernot.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Gernot Homma
Content-Disposition: attachment;
 filename="gernot.vcf"

begin:vcard 
n:Homma;Gernot
x-mozilla-html:FALSE
org:Cyber-Atelier
adr:;;;Vienna ;;1210;Austria
version:2.1
email;internet:gernot@cat.at
tel;fax:+43 1 272 92 51 9
tel;work:+43 1 272 92 51
x-mozilla-cpt:;0
fn:Homma, Gernot
end:vcard

--------------5812923C8069525C698160A2--



------------------------------

Date: 19 Jan 1999 13:58:32 GMT
From: meowing@banet.net (Fluffy)
Subject: Re: Calling a sub
Message-Id: <782324$o27@meow.invalid>

Gernot Homma <gernot@cat.at> wrote:
> I'm looking for a solution for the following problem
> 
> $mysub = "function1";
> 
> sub function1
> {
>     print "Hello";
> }
> 
> I want to call "function1" though the scalar $mysub.

See the perlref documentation for the full details, but here is a
simple example of what you seem to want:

#!/usr/bin/perl -w
use strict;

my $mysubname = "function1";
my $mysub = \&$mysubname;

&$mysub('stranger');

sub function1 {
    print 'Hello, ', shift(), "!\n";
}
    
-- 
"Meow."  --me


------------------------------

Date: Tue, 19 Jan 1999 10:53:20 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Changing elements in a text file
Message-Id: <781oap$f4d$1@plug.news.pipex.net>

Hi All

How can you change specific elements in a text file?

EG: Text file:
hello|test|1234|
goodbye|tset|4321|

How can you make perl just edit the file and replace 1234 with 5678.  Is it
possible or do you have to bring in the file as an array and s/// the value
and then right the info back to the file?  I'm dealing with large files that
will use unnecessary processor power to write the entire file each time it
is changed.

Thanks for any help
Artoo




------------------------------

Date: Tue, 19 Jan 1999 10:57:31 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: File Handle Elements as numeric values
Message-Id: <781oik$f93$1@plug.news.pipex.net>

Hi All

How can you read an element from a file handle as a numeric value rather
than a text value.

EG: Text file
1234|4321|5678|8765|
12|34|56|78|

How can the file handle read any of the values from the array created as
their numeric value so they can be manipulated numerically, rather than as
text values which can not be manipulated numerically.

Thanks for any help
Artoo




------------------------------

Date: Tue, 19 Jan 1999 11:02:39 GMT
From: wandr@my-dejanews.com
Subject: Formatting text ?
Message-Id: <781oob$lfa$1@nnrp1.dejanews.com>

I am currently using an email subroutine which I call using
&Send_email($emailsubject, $emailbody, @recipients);

So far, $emailbody has only been a text string which has not required
formatting.  I now need $emailbody to contain an order form with whch
formatting is essential.
Is by best/ only option to use the Perl Format function ?If so, could someone
please provide me some tips on how to use it.

The following is an example of my understanding of formatting.

format EMAILFORMAT =
-----------------------------------------------------------------------------
--- -------------------------- Order Details:

Name: @<<<<<<<<<<<<<<<<<<<<<<<<<Cost centre: @<<<<<<<<<<<<<<<<< $subs{name}
, $subs{costcentre} Phone: @<<<<<<<<<<<<<<<<<<<<<<<< job #: 
@<<<<<<<<<<<<<<<<< $subs{phone}, $subs{ jobnumber } Fax:
@<<<<<<<<<<<<<<<<<<<<<<<<  Estimate:  @<<<<<<<<<<<<<<<<<
-----------------------------------------------------------------------------
--- ----------------------------

Can I simply use $emailbody = "EMAILFORMAT";
Surely this would simply assign the string "EMAILFORMAT" to the variable ???



Thanks to anyone who trawled through this problem.
Any help is much appreciated.

Cheers,
Ric Funk

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 19 Jan 1999 14:55:21 +0100
From: Martin Belohorka <ed98mba@lc.vetlanda.se>
Subject: Re: geting arguments
Message-Id: <36A48EC9.F958ED51@lc.vetlanda.se>



Matevz Sernc skrev:

> Hello
>
> I want that some user click on following link:
> http://www.domain.xyz/cgi-bin/here.cgi?user=mk10
>
> --
> How can i get the part after the "?" in a variable in here.cgi ??
>
> I then want to do an user-dependent output to the browser.
>
> But how to get the "mk10" in a variable ??
>
> Can anyone help me ?  (maybe someone has an simple cgi, i can see at)

>

> Now this is a true newbie quiz!!

> u get the input by the $ENV{QUERY_STRING}

then just use "Split" to get it to the form!  $form{user}=mk10
Have a nice tim programming [Pp]erl!

/martrin belohorka!




------------------------------

Date: Tue, 19 Jan 1999 13:37:15 GMT
From: guyrj@an.hp.com
Subject: getpeername on WinNT does it work?
Message-Id: <7821qa$sgp$1@nnrp1.dejanews.com>

I'm using perl 5.00502 on Win NT 4.0 sp3
When I call &accept or &getpeername the sockaddr returned contains the
IP address but the port is always '0', in this case I'm connecting on
port 58912.
Also calling getpeername after the connection is broken at the client
side results in the same info being returned.
code looks like:

$fh = new FileHandle '/dev/null';
$client_addr = accept($fh, $socket);
($port, $ip_addr) = &sockaddr_in($client_addr);
$ip_addr = &inet_ntoa($ip_addr);

and like

($port, $ip_addr) = sockaddr_in(gerpeername($fh));
$ip_addr = &inet_ntoa($ip_addr);

this code is being ported to WinNT from a unix system (where it works)

TIA Guy


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 19 Jan 1999 13:15:27 GMT
From: info@netstyle.nl
Subject: How to determine time?
Message-Id: <7820h8$rfl$1@nnrp1.dejanews.com>

Hi newsgroup,

I would like to know how to put the time in a string variable.
I know this:

$tim= time;

but this gives me the epoch-relative time and I do not want that.
How to let $tim have the folowing content i.e.
19-01-1999/8.05PM

ofcourse I want the actual hosstime instead of static stringcontent.

thanks,

Michel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 19 Jan 1999 13:08:25 GMT
From: wouterse@my-dejanews.com
Subject: Re: How to link image in Perl script ?
Message-Id: <782043$r24$1@nnrp1.dejanews.com>

print "<A HREF='blah@blah.blah'><IMG SRC='image.jpg'></A>"

that will do the trick:

Why not use:


PRINT <<EOF

-----PUT YOUR HTML CODE HERE----

EOF
;

This takes care of all the quoting and you do not have to repeat the print"
everytime.
And you do not have to print header information either.....

Michel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 19 Jan 1999 13:33:40 +0100
From: "Willem" <spam@dikkelul.com>
Subject: Re: Lame coding question
Message-Id: <781u9c$hl0$1@dinkel.civ.utwente.nl>

>if ($network eq "q") {   ## how do I make it check for a uppercase Q as
well


if ($network =~ /^q$/i)

# ^ means beginning of string
# $ means end of string
# i means case insensitive

Sorry not to help you with the rest, short on time etc :-)
Good luck
Willem





------------------------------

Date: Tue, 19 Jan 1999 10:56:00 GMT
From: Ron Parker <sysop@scbbs.com>
Subject: Re: pattern matching between multiple lines in a file
Message-Id: <36A465FC.8FECF132@scbbs.com>

Thanks for the suggestion.  Please let me know if I am missing someting here.
This is the program I put together using your suggestion:

#!/usr/bin/perl
$input = "match.in";
$output = "match.out";
open (INPUT, "$input");
open (OUTPUT, ">$output");
while (<INPUT>) {
 $chomp;
 if (my $line = /^TITLE/ .. /:/) {
  print OUTPUT "$_ ";
  print OUTPUT "\n" if $line =~ /E0/;
 }else{
  print OUTPUT "$_\n";
 }
}
close INPUT;
close OUTPUT;

This is the input file:

TITLE

Blah blah blah
Blah blah:

Rest of Text

TITLE

Blah blah blah
Blah blah:

Rest of Text

And this is what I got for output:



TITLE

 Blah blah blah
 Blah blah:



Rest of Text



TITLE

 Blah blah blah
 Blah blah:



Rest of Text

Could you tell me what I missed there?  If it's this simple, it would really
help!

ts wrote:

> >>>>> "R" == Ron Parker <sysop@scbbs.com> writes:
>
> R> Now, I wish to put the TITLE and the title description on the same line,
> R> and leave the regular text alone.  So, I will end up with:
>
>  Try (it keep the empty line)
>
> moulon% cat a.pl
> #!/usr/bin/perl
> while (<DATA>) {
>     chomp;
>     if (my $line = /^TITLE/ .. /:/) {
>         print "$_ ";
>         print "\n" if $line =~ /E0/;
>     } else {
>         print "$_\n";
>     }
> }
> __END__
> TITLE
> Blah Blah Blah
> Blah Blah:
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
>
> TITLE
> Blah Blah Blah
> Blah Blah:
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
> moulon% a.pl
> TITLE Blah Blah Blah Blah Blah:
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
>
> TITLE Blah Blah Blah Blah Blah:
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
> Regular Text (this is the rest of the text I don't want to touch)
> moulon%
>
> --
>
> Guy Decoux

--
Ron Parker
Software Creations      http://www.scbbs.com
TradeWinds Publishing   http://www.intl-trade.com
TradePoint Los Angeles  http://www.tradepointla.org




------------------------------

Date: Tue, 19 Jan 1999 12:07:39 GMT
From: markus@wotan.econ.surrey.ac.uk
Subject: perl & c++
Message-Id: <781si7$o7c$1@nnrp1.dejanews.com>

Dear list-members,

is there currently someone developing a wrapper library for C++ that accesses
perl variables such as string, hash, array and functions? I would like to
share experience on this or have a look on an already developed one.

Answers or links to such projects are more than welcome,
Markus

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 19 Jan 1999 12:19:45 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: Perl problem :(Offline mode...
Message-Id: <NxesJHAhhHp2Ew6i@beausys.demon.co.uk>

I have a program that opens a file, does some
transformation of the contents and then either
1. displays contents to STDOUT
2. writes contents to another (output) file

However, it is reporting the following message...
(offline mode : please give name=value pairs via STDIN)
(... or something like that) and then waiting for some
reply.
Why is it doing this ? And what is offline mode ?

---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).


------------------------------

Date: 19 Jan 1999 13:26:00 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <83u2xnxxd3.fsf@vcpc.univie.ac.at>

Re: Perl problem :(Offline mode..., Andrew
<andrewf@beausys.demon.co.uk> said:

Andrew> I have a program that opens a file, does
Andrew> some transformation of the contents and then
Andrew> either 1. displays contents to STDOUT
Andrew> 2. writes contents to another (output) file

Andrew> However, it is reporting the following
Andrew> message...  (offline mode : please give
Andrew> name=value pairs via STDIN) (... or
Andrew> something like that) and then waiting for
Andrew> some reply.  Why is it doing this ? And what
Andrew> is offline mode ?

You're using the CGI.pm module.

    perldoc CGI

Actually this is immensely helpful as it allows you
to do a lot of CGI testing from the command line.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


------------------------------

Date: Tue, 19 Jan 1999 11:03:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Routing picture from my other site
Message-Id: <36a56587.8920918@news.skynet.be>

Jay Westerdal wrote:

>   print "Content-type: image/gif\n";
>   print "\n";
>   open(IMAGE, "<$file") || die "Can't open $file: $!";
>   while (<IMAGE>)
>   {
>   print $_;
>    }
>    close(IMAGE);

Allow me to ignore your actual question (see LWP), and focus on this
side thing:

	* You're using TEXT file manipulation on a BINARY file! *

Don't ever do that! You might get away with it on Unix, but it
definitely won't work on PC. Plus: if you ever have a large
multi-megabyte file without any chr(10) in it, your program will get
into memory problems. Even on Unix.

* Use binmode (not a module) on file and STDOUT
* Read and write chunks of at most a few k at a time.

	Bart.


------------------------------

Date: Tue, 19 Jan 1999 14:49:52 +0100
From: Martin Belohorka <ed98mba@lc.vetlanda.se>
Subject: So sorry, i got i right!!!!
Message-Id: <36A48D80.11086D64@lc.vetlanda.se>

However! If you have tihs problem some times, u should know that the problem
was4nt in the script, but inte server configuration!

/pardon!  Martin belohorka!



------------------------------

Date: 19 Jan 1999 05:48:34 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <36a47f22@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    bart.lateur@skynet.be (Bart Lateur) writes:
:Greg Bacon wrote:
:>    - A line in the body of a post is considered to be original if it
:>      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.

:I object! Abigail cheated!

`cheated'?

:I noticed that Abigail lately used a different "quoting" character
:string, every few posts. Most were NOT caught by this filter.
:

So use a better regex.  Of course, anything can be worked around.


--tom

    #!/usr/local/bin/perl -w
    #
    # cfoq: check fascistly overquoted by tchrist@mox.perl.com
    #   (wants perl 5.0 or better; developed under 5.002)
    #
    # INPUT:   a news article
    # OUTPUT:  if -v, then shows how much it found and where
    #
    # OPTIONS: -v for verbose flag
    #	    -t NN to change tolerance percentage from 50%
    #	    -m for minimum lines that get subject to percentage counting;
    #		otherwise, it just checks for ANY new lines.  This way 
    #		short little 6-line messages with 4 lines of quoting don't
    #		get hassled
    #
    # EXIT:	   2 (bad failure) if no new lines
    #	   1 (failure)     if tolerance exceeded
    #	   0 (success)     otherwise

    # 5.0 might work, but I developed it under 5.002
    require 5.002;  

    use strict;

    use vars qw{
	$MINLINES  $opt_m 
	$VERBOSE   $opt_v
	$TOLERANCE $opt_t
    }; 

    use Getopt::Std;
    getopts("vt:m:") || die "usage: $0 [-v] [-t tolerance] [-m minlines] [input_file]\n";

    my (
	$total, 		# total number of lines, minus sig and attribution
	$quoted_lines, 	# how many lines were quoted
	$percent, 		# what percentage this in
	$pcount, 		# how many in this paragraph were counted
	$match_part,	# holding space for current match
	$gotsig,		# is this the sig paragraph?
    );

    $total = $quoted_lines = $pcount = $percent = 0;

    $MINLINES  = $opt_m || 20;
    $VERBOSE   = $opt_v;
    $TOLERANCE = $opt_t || 50; 

    $/ = ''; 	# set record reading to paragraph mode
    <ARGV>;   	# consume and discard header of message

    while (<ARGV>) {

	# strip sig line, remember we found it
	$gotsig = s/^-- \n.*//ms;

	# strip attribution, possibly multiline
	if ($. == 2) { s/\A.*?(<.*?>|\@).*?:\n//s }  

	# toss trailing blank lines into one single line
	s/\n+\Z/\n/;

	# now reduce miswrapped lines from idiotic broken PC newsreaders
	# into what they should have been
	s/(>.*)\n\s*([a-zA-Z])/$1 $2/g;

	# count lines in this paragraph
	$total++ while  /^./mg;

	# is it a single line, quoted in the customary fashion?
	if ( /^(>+).*\n\Z/ ) {
	    $quoted_lines++;
	    print " 1 line  quoted with $1\n" if $VERBOSE;
	    next;
	} 

	# otherwise, it's a multiline block, which may be quoted
	# with any leading repeated string that's neither alphanumeric
	# nor string
	while (/^(([^\w\s]+).*\n)(\2.*\n)+/mg) {  # YANETUT
	    $quoted_lines += $pcount = ($match_part = $&) =~ tr/\n//;
	    printf "%2d lines quoted with $2\n", $pcount 	if $VERBOSE;
	} 

	last if $gotsig;
    } 

    $percent = int($quoted_lines / $total * 100);
    print "$quoted_lines lines quoted out of $total: $percent%\n"
							if $VERBOSE;

    if ($total == $quoted_lines) {
	print "All $total lines were quoted lines!\n"   if $VERBOSE;
	exit(2);
    }

    if ($percent > $TOLERANCE) { 
	if ($total < $MINLINES) {
	    print "but since $total is less than $MINLINES lines, that's ok\n"
							if $VERBOSE;
	    exit 0;
	} else { 
	    exit 1;
	}
    } else {
	exit 0;
    } 
    __END__
-- 
    That means I'll have to use $ans to suppress newlines now.  
    Life is ridiculous. 
        --Larry Wall in Configure from the perl distribution


------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4686
**************************************

home help back first fref pref prev next nref lref last post