[17297] in Perl-Users-Digest
Perl-Users Digest, Issue: 4719 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 25 09:05:31 2000
Date: Wed, 25 Oct 2000 06:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972479111-v9-i4719@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 25 Oct 2000 Volume: 9 Number: 4719
Today's topics:
Re: [Newbie]: "if" statements <sferrandez@wineandco.com>
Re: [Newbie]: "if" statements <nickco3@yahoo.co.uk>
Re: A Simpler perlish way (Martien Verbruggen)
Re: Apache/Perl "Method Not Allowed" error nobull@mail.com
Re: Bi-directional pipes with NT <hmacdonald@europarl.eu.int>
Re: Bi-directional pipes with NT <hmacdonald@europarl.eu.int>
Re: Bi-directional pipes with NT <elephant@squirrelgroup.com>
Bitreverse an integer <bart.lateur@skynet.be>
Re: Bitreverse an integer <sb@muccpu1.muc.sdm.de>
Re: Bitreverse an integer <bart.lateur@skynet.be>
Re: Bitreverse an integer <sb@muccpu1.muc.sdm.de>
Re: File locking <bart.lateur@skynet.be>
Re: force dowload <ubl@schaffhausen.de>
Re: grep with perl ! I am very new at this. (Tad McClellan)
Re: grep with perl ! I am very new at this. <jras@best.ms.philips.com>
Re: Help with array concatenation <dlorre@caramail.com>
Re: here and filehandle (Anno Siegel)
Re: here and filehandle (Gwyn Judd)
How do I print to a file with wrap text on? <poohba@fnord.io.com>
Re: How do I print to a file with wrap text on? <elephant@squirrelgroup.com>
Re: How do I print to a file with wrap text on? nobull@mail.com
Re: How do I print to a file with wrap text on? (Gwyn Judd)
Re: How to pass a String to the STDIN of an other prg? nobull@mail.com
htacces <laroche@imra-europe.com>
Re: htacces <anders@wall.alweb.dk>
Re: Integer overflow (Ilya Zakharevich)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 25 Oct 2000 10:33:48 +0200
From: =?iso-8859-1?Q?S=E9bastien?= Ferrandez <sferrandez@wineandco.com>
Subject: Re: [Newbie]: "if" statements
Message-Id: <39F69AEC.C2A989A0@wineandco.com>
Yes thanks, I like this solution a lot (associative array ?). It is very simple
and easy to read and makes me avoid using these disgraceful "ifs". Thanks again
to you all for your solutions...
Craig Berry wrote:
> =?iso-8859-1?Q?S=E9bastien?= Ferrandez (sferrandez@wineandco.com) wrote:
> : I have to make a perl script, a language I've never tried out before but
> : as i assume this is quite close to PHP, I tried that one which doesn't
> : work :
> :
> : print "avant : $jour\n\n";
> :
> : if ($jour=="lun") {
> : $jour_complet = "Lundi";
>
> '==' is for numeric comparison. For string equality, you want 'eq'.
>
> : } elsif ($jour=="mar") {
> : $jour_complet = "Mardi";
> [others snipped]
>
> A more perlish way to do this would be:
>
> my %dayMap = qw( lun Lundi mar Mercredi ); # and so forth for other pairs
> my $jour_complet = $dayMap{$jour};
>
> --
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "Quidquid latine dictum sit, altum viditur."
> |
------------------------------
Date: Wed, 25 Oct 2000 09:40:19 +0100
From: Nick Condon <nickco3@yahoo.co.uk>
Subject: Re: [Newbie]: "if" statements
Message-Id: <39F69C73.A8EF00D4@yahoo.co.uk>
Sébastien Ferrandez wrote:
> I have to make a perl script, a language I've never tried out before but
> as i assume this is quite close to PHP, I tried that one which doesn't
> work :
>
> print "avant : $jour\n\n";
>
> if ($jour=="lun") {
> $jour_complet = "Lundi";
> } elsif ($jour=="mar") {
> $jour_complet = "Mardi";
> } elsif ($jour=="mer") {
> $jour_complet = "Mercredi";
> } elsif ($jour=="jeu") {
> $jour_complet = "Jeudi";
> } elsif ($jour=="ven") {
> $jour_complet = "Vendredi";
> } elsif ($jour=="sam") {
> $jour_complet = "Samedi";
> } elsif ($jour=="dim") {
> $jour_complet = "Dimanche";
> } else { $jour_complet= "erreur"; }
>
> print "le jour : $jour_complet\n\n";
>
> $jour is a string containing "mar", thus it should output "Mardi" but in
> fact it outputs "Lundi".
> It seems quite trivial yet I miss the point here. Maybe too used to PHP
> ;)
> I've been looking at various perl tutorial sites but I found that to be
> syntaxically (almost?) correct.
> Any hint ? Thanks !
($jour == "lun") is a *numerical* operator. You want the string operatoer
'eq':
($jour eq "lun")
A more Perlish way of doing this would be to use a hash. Initialise it like
this:
%jour_complet = (
lun => "Lundi",
mar => "Mardi",
mer => "Mercredi",
jeu => "Jeudi",
ven => "Vendredi",
sam => "Samedi",
dim => "Dimanche",
);
and use it this way:
print "avant : $jour\n\n";
print "le jour: $jour_complet{$jour}\n";
------------------------------
Date: Wed, 25 Oct 2000 20:44:40 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: A Simpler perlish way
Message-Id: <slrn8vdas8.6bi.mgjv@martien.heliotrope.home>
On Tue, 24 Oct 2000 14:43:14 -0400,
Jody Fedor <Jodyman@usa.net> wrote:
>
> Bart Lateur wrote in message <49fhusk7mbm0ejsu395g8f99mgr6am2u8n@4ax.com>...
> >Jody Fedor wrote:
> >
> >>if ($yr%4 == 0) {$days[1] = 29} else {$days[1] = 28};
> >
> >This rule is too simple. The proper rule is:
> >
> > if the year is divisible by 4
> > it's a leap year, unless
> > the year is divisible by 100,
> > then it's not a leap year, unless
> > the year is divisible by 400,
> > then it *is* a leap year
> >
> >So 2000 is a leap year, but 1900 was not.
>
> I assume 2096 is a leap year, then why not 2100? It is four
> years later?
>
> 2096/4 = 524
> 2096/100 = 20.96
> 2096/400 = 5.24
>
> 2100/4 = 525
> 2100/100 = 21 (Shouldn't be a leap year)
> 2100/400 = 5.25
>
> Doesn't leap year come every 4 years no matter what? Help here.
Did you read the above?
A leap year does not come every four years, no matter what. It comes on
all years that are divisible by 4, except when they are also divisible
by 100, but again when it is also divisible by 400.
2100 is divisible by 4, 100 and not by 400, so it is not a leap year.
# cal 2 2100
February 2100
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28
2000 is divisible by 4, by 100 and also by 400. It is a leap year. 2096
is divisible by 4, not by 100 or 400. It is a leap year.
Why were you asking this when the question had already been answered? If
you don't trust this group to give you the right answer, and/or correct
wrong ones, then why are you reading it?
If it convinces you more, you could do a web search, maybe?
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing
Interactive Media Division | down all the noises the baby makes
Commercial Dynamics Pty. Ltd. | so later I can ask him what he meant
NSW, Australia | - Steven Wright
------------------------------
Date: 25 Oct 2000 13:36:32 +0100
From: nobull@mail.com
Subject: Re: Apache/Perl "Method Not Allowed" error
Message-Id: <u98zrdkshb.fsf@wcl-l.bham.ac.uk>
al_woods@my-deja.com writes:
> Can anyone give me a lead on what I'm missing?
An intuative sense of what are likely to be Perl questions and what
are likely to be Apache questions.
Hint: look for <LIMIT></LIMIT> sections in your Apache config files.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 25 Oct 2000 09:37:18 +0200
From: macdo <hmacdonald@europarl.eu.int>
To: jason <elephant@squirrelgroup.com>
Subject: Re: Bi-directional pipes with NT
Message-Id: <39F68DAE.7E377A7D@europarl.eu.int>
Could you possibly send me the code,
or relevant snippets.
> >macdo wrote ..
> >In NT is it possible to impliment bi-directional communication via pipes
> >between a parent and a child.
>
> jason wrote:
> they work for me in 5.6.0 on NT4
> jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 25 Oct 2000 09:38:43 +0200
From: macdo <hmacdonald@europarl.eu.int>
Subject: Re: Bi-directional pipes with NT
Message-Id: <39F68E03.2DC86681@europarl.eu.int>
Could you possibly send me the code,
or relevant snippets.
> >macdo wrote ..
> >In NT is it possible to impliment bi-directional communication via pipes
> >between a parent and a child.
>
> jason wrote:
> they work for me in 5.6.0 on NT4
> jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 25 Oct 2000 20:57:30 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Bi-directional pipes with NT
Message-Id: <MPG.146167a79cbc148c98984d@localhost>
[ in future please post your reply beneath what you're replying to ]
[ it enables easier communication when everyone does the same thing ]
[ in future please indicate when you have CCed an email to someone ]
[ that you're replying to so that they don't have to reply twice ]
macdo wrote ..
>> >macdo wrote ..
>> >In NT is it possible to impliment bi-directional communication via pipes
>> >between a parent and a child.
>>
>> jason wrote:
>> they work for me in 5.6.0 on NT4
-
>Could you possibly send me the code,
>or relevant snippets.
as I said in email - I used exactly the code that you'd entered here -
just plugged it in and it ran on Perl 5.6.0 on NT4
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 25 Oct 2000 10:28:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Bitreverse an integer
Message-Id: <7jcdvsc7qatsvnn545r47is3ml281188il@4ax.com>
Is there a better way to bitreverse a number? For example, with a
"register length" of 10 bits, 768 (0b1100000000, two highest bits of 10
set) should be turned into 3 (0b0000000011, two lowest bits set), and
vice versa. The highest bit of the source number becomes the lowest bit
in the destination.
These two methods seem to work, but they're pretty clumsy (IMO), let
alone unmaintainable:
for (my $i=3; $i<1024; $i <<= 1) {
printf "%4d\t%4d\t%4d\n", $i, # source
oct('0b' . unpack 'b10', pack 'v', $i), # method 1
unpack 'v', pack 'b10', sprintf '%010b', $i; # method 2
}
Isn't there a less obscure way?
--
Bart.
------------------------------
Date: 25 Oct 2000 11:07:05 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Bitreverse an integer
Message-Id: <8t6esp$l5i$1@solti3.sdm.de>
In article <7jcdvsc7qatsvnn545r47is3ml281188il@4ax.com>, Bart Lateur <bart.lateur@skynet.be> wrote:
> Is there a better way to bitreverse a number? For example, with a
> "register length" of 10 bits, 768 (0b1100000000, two highest bits of 10
> set) should be turned into 3 (0b0000000011, two lowest bits set), and
> vice versa. The highest bit of the source number becomes the lowest bit
> in the destination.
> These two methods seem to work, but they're pretty clumsy (IMO), let
> alone unmaintainable:
> for (my $i=3; $i<1024; $i <<= 1) {
> printf "%4d\t%4d\t%4d\n", $i, # source
> oct('0b' . unpack 'b10', pack 'v', $i), # method 1
> unpack 'v', pack 'b10', sprintf '%010b', $i; # method 2
> }
> Isn't there a less obscure way?
The module Bit::Vector has a method which does bit reversing.
See CPAN and download URL below (in my sig).
Hope this helps!
Regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Wed, 25 Oct 2000 11:44:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bitreverse an integer
Message-Id: <2thdvsohls278td0rsnf37l7mdtttvsi8n@4ax.com>
Steffen Beyer wrote:
>The module Bit::Vector has a method which does bit reversing.
Good. Now can you tell me why this thing insists on making a signed
number out of my data? I want unsigned integers.
use Bit::Vector;
$vector = Bit::Vector->new_Dec(10,1);
$vector->Reverse($vector);
print $vector->to_Dec;
-->
-512
Entering
$vector = Bit::Vector->new_Dec(10,768);
gives an overflow, most probably for the same reason.
Bit::Vector::new_Dec(): numeric overflow error at test.pl line 3.
Yet, all the docs suggest that a bitvector is basically internally an
unsigned number.
Is this a module compilation bug? (ActiveState Perl 5.6.0 for Win32,
precompiled module)
--
Bart.
------------------------------
Date: 25 Oct 2000 12:27:35 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Bitreverse an integer
Message-Id: <8t6jjn$mi5$1@solti3.sdm.de>
In article <2thdvsohls278td0rsnf37l7mdtttvsi8n@4ax.com>, Bart Lateur <bart.lateur@skynet.be> wrote:
>>The module Bit::Vector has a method which does bit reversing.
> Good. Now can you tell me why this thing insists on making a signed
> number out of my data? I want unsigned integers.
> use Bit::Vector;
> $vector = Bit::Vector->new_Dec(10,1);
> $vector->Reverse($vector);
> print $vector->to_Dec;
> -->
> -512
> Entering
> $vector = Bit::Vector->new_Dec(10,768);
> gives an overflow, most probably for the same reason.
> Bit::Vector::new_Dec(): numeric overflow error at test.pl line 3.
Which version of Bit::Vector are you using?
This is fixed in version 6.0.
> Yet, all the docs suggest that a bitvector is basically internally an
> unsigned number.
True.
Only some methods interpret the contents of a bit vector as signed,
such as to_Dec().
> Is this a module compilation bug? (ActiveState Perl 5.6.0 for Win32,
> precompiled module)
No, no bug. Just the way certain methods interpret things.
If you want to enforce positive decimal representation, you can use
one of the following two work-arounds:
#!perl
use Bit::Vector;
$vector = Bit::Vector->new_Dec(10,1);
$vector->Reverse($vector);
$dec = $vector->to_Dec();
$dec += int(2 ** $vector->Size() + 0.5) if ($dec < 0);
print "$dec\n";
(only works for bit vectors with sizes <= number of bits in a machine word)
#!perl
use Bit::Vector;
$vector = Bit::Vector->new_Dec(10,1);
$vector->Reverse($vector);
$vector->Resize($vector->Size()+1);
print $vector->to_Dec, "\n";
If what you want is just the number, use one of the "Chunk_...()" or
"Word_...()" methods to export it to Perl, not the (very expensive)
conversion to decimal!
Hope this helps!
Best regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Wed, 25 Oct 2000 07:44:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File locking
Message-Id: <9p3dvs8kcjg969pirlmbmnn8jltrpe9fko@4ax.com>
Michael Cook wrote:
> But my question is not *how* to flush per filehandle, but *should* I?
I'll stress just once again, that setting autoflush happens per
filehandle. For example, by default, autoflush is on for STDERR, but not
for STDOUT if the data is being sent to a file.
So, you have to set autoflush individually for each filehandle for which
you want it to be in effect.
--
Bart.
------------------------------
Date: Wed, 25 Oct 2000 09:03:39 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: force dowload
Message-Id: <39F685CA.B78A2769@schaffhausen.de>
Brian Canning schrieb:
>
> I have written a small script that generates various pages with links on
> them
> one of the link is to a PDF file. How can I get it to force a download
> instead
> of using the Acrobat reader i.e. a download windows pops up and it
> doesn't use the plug-in reader inside the window?
>
> Brian
You can't do that with Perl, in fact you cannot do it at all. The
decision
whether to download, open, neglect, open in notepad or print a file
is a user preference. Of course there are some client sided solutions
to change that preference but those are not practial for web applications.
malte
--
$me = Person->new("Malte Ubl");
$me->comp ("Schaffhausen | Interactive");
$me->job ("Developer for web-based Applications");
$me->phone("+49 4121 472964");
$me->fax ("+49 4121 472938");
exit; # reference count = 0 -> $me->DESTROY
------------------------------
Date: Tue, 24 Oct 2000 22:02:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: grep with perl ! I am very new at this.
Message-Id: <slrn8vcfqc.a4p.tadmc@magna.metronet.com>
On Wed, 25 Oct 2000 01:44:08 GMT, msalerno@my-deja.com
<msalerno@my-deja.com> wrote:
>I am writing a script and part of it required me to do a grep. I know
>that there is a built in grep function but I don't know if I can use it
>to grep files.
No. Perl's grep works on lists, not files...
but you can read a file into a list or array and then use
Perl's grep() on it.
But if all you need is the count, then "one-line at a time"
will work, and should be preferred whenever possible.
>I need to do the equivelent of a grep -ic to a file and
>I would like to use a built in function if possible.
Good attitude. Never "shell out" when you can avoid it.
>Also I have
>written a small script to do the grep calling the grep binary. It does
>everything, but I need to take the value (a number) and use it within
>the script,
Bad attitude.
You tried the system() function without reading the docs
for the system() function?
perldoc -f system
>but I can't figure out how.
^^^
system() runs a command and gives you its exit code.
There is a different construct that runs a command and
returns the commands output.
You want to capture the output of the grep command.
If you tried the above perldoc command, you already know
what how to capture output from an external command :-)
But that _is_ shelling out. Do it in native Perl.
>system "grep -ic 47 snmnefle.cfg"
Errr, the i switch isn't going to help if you are searching
for digit characters. Maybe that pattern isn't typical?
>Is there a way to do either ?
while (<>) {
$count++ if /$pattern/i;
}
print "do something with $count here\n";
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 25 Oct 2000 14:27:17 +0200
From: "Ras, J. v." <jras@best.ms.philips.com>
Subject: Re: grep with perl ! I am very new at this.
Message-Id: <39F6D1A5.62645F0C@best.ms.philips.com>
Hi Tad,
Try to set a variable in your srcipt that use a command
of the system (Linux or Unix)
#!/usr/bin/perl
$system = `grep -ic 47 snmnefle.cfg`;
print "Content-type: text/html\n\n";
print "<HTML><HR><PRE><FONT size=\"+0\"><BR>\n";
print " $system ";
print "</PRE></B></FONT><HR>\n";
This is what you mean.
Good luck
Jos van Ras
http://www.jgmvanras.f2s.com/
msalerno@my-deja.com wrote:
>
> I am writing a script and part of it required me to do a grep. I know
> that there is a built in grep function but I don't know if I can use it
> to grep files. I need to do the equivelent of a grep -ic to a file and
> I would like to use a built in function if possible. Also I have
> written a small script to do the grep calling the grep binary. It does
> everything, but I need to take the value (a number) and use it within
> the script, but I can't figure out how.
>
> system "grep -ic 47 snmnefle.cfg"
>
> Is there a way to do either ?
> Please help
>
> Thanks,
> Matt
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 09:57:40 GMT
From: Dominique Lorre <dlorre@caramail.com>
Subject: Re: Help with array concatenation
Message-Id: <8t6aqj$u82$1@nnrp1.deja.com>
In article <8sri9d$r4f$1@plonk.apk.net>,
"Jody Fedor" <Jodyman@usa.net> wrote:
> I have the following program, the object is to get the
> julian dates in an array for the form selected month
> and year from a webpage.
> My problem is that @dates end up with only the last 3 days of the
> month instead of the whole month.
No. Your problem is that you are mixing two different approaches :
1) using the 'cal' Linux command
2) computing dates 'by hand'
> $calendar = `/usr/bin/cal` ;
If you plan to use cal, you should look at the -j argument which does
the julian conversion for you (man cal for details).
> $yr = "2000"; # Hard code for testing
> @days = (31,28,31,30,31,30,31,31,30,31,30,31);
If you plan to do it that way, you don't need to use cal since you
already have enough information for building the array.
This program is obiously an 'ascending' program, i.e. you are building
tools to get your problem solved. Since classes can be considered as
being tools, you should think object when you are doing ascending
programming, so you can get rid of the problem before having it solved.
In your case you would have a class that would receive the month and
the year at initialization time and return the julian dates of the month
in a string. The interest of this approach is that you can use a stupid
function like:
sub jmdates {
@jmdates =
(244,244,244,244,245,246,
247,248,249,250,251,252,
253,254,255,256,257,258,
259,260,261,262,263,264) ;
}
This allows you to finish the program before having this problem
solved, then you can think about it and do it when you are ready. In
this case you probably don't really need a class, more a set of
functions, but it wouldn't hurt much to make it a class ;). Another
advantage is that your program wont change if you do a first version
using 'cal' and then decide to do it differently later: only the class
will have to be redesigned.
HTH
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 25 Oct 2000 09:29:08 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: here and filehandle
Message-Id: <8t6954$492$1@lublin.zrz.tu-berlin.de>
Bart Lateur <bart.lateur@skynet.be> wrote in comp.lang.perl.misc:
>Randy Harris wrote:
>
>>One simple approach to finding the problem, might be to simply examine
>>your output file to see which of the variables didn't interpolate.
>
>I proposed on the Perl 6 mailing list to add a possibility to
>interpolate undef() in a special, recognizable manner, not just the
>empty string, for example "%#(UNDEF)#%" (In fact, any string you like.
>That would certainly ease searching for bugs like this. But nobody who
>responded even remotely liked the idea. Fat chance that it will ever be
>implemented.
Identifying undefined scalars, while never a real problem, is a
frequent and tedious chore and anything to help with the task would
be welcome. Having undefined values interpolate as something
recognizable would certainly help.
Until then, occasionally a line like
my @undefs = grep { not defined eval} qw( $var, $key, $hash{$key});
is useful. Unfortunately, the little phrase cannot usefully be
compiled in a sub. Lexical variables (that's practically all
variables, right?) must be in view when the code is compiled, or
they may be mis-diagnosed as undefined, so it's best to insert
the line in full where it's needed.
Anno
------------------------------
Date: Wed, 25 Oct 2000 12:48:06 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: here and filehandle
Message-Id: <slrn8vdlk1.pan.tjla@thislove.dyndns.org>
I was shocked! How could Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
say such a terrible thing:
>Identifying undefined scalars, while never a real problem, is a
>frequent and tedious chore and anything to help with the task would
>be welcome. Having undefined values interpolate as something
Okay, stupid question time. What is preventing the compiler (okay
interpreter) from telling us which variable was undefined?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
No matter how long you shop for an item, after you've bought it, it will
be on sale cheaper.
------------------------------
Date: Wed, 25 Oct 2000 07:27:39 GMT
From: Robert Campbell <poohba@fnord.io.com>
Subject: How do I print to a file with wrap text on?
Message-Id: <Pine.LNX.4.21.0010250221140.10235-100000@fnord.io.com>
I have this script that is a random quote generator that is ran by cron
and what it does is sends the new quote to my .signature file. The only
problem is that it sends it but the text isn't wrapped. Also, is there an
easier way to do this?
#!/usr/bin/perl -w
$file = "/home/p/poohba/rap.quote";
$signature = "/home/p/poohba/.signature";
open (FILE, $file) || die "Can't open $file: $!\n";
@quotes=<FILE>;
close(FILE);
$num = int(rand(@quotes));
$saying = $quotes[$num];
($quote,$author) = split(/:/, $saying);
print "$quote\n\t\t\t\t\t\t$author\n";
open (SIGNATURE, ">$signature") || die "Can't open $signature: $!\n";
print SIGNATURE "$quote\n\t\t\t\t\t\t$author\n";
close(SIGNATURE);
As you can see what I mean by this signature.
--
We spit phlegm that's outrageous like sneaker prices mics get wet like dildo devices...
Mr. Eon
------------------------------
Date: Wed, 25 Oct 2000 21:03:40 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: How do I print to a file with wrap text on?
Message-Id: <MPG.14616919bf1c625098984e@localhost>
Robert Campbell wrote ..
>I have this script that is a random quote generator that is ran by cron
>and what it does is sends the new quote to my .signature file. The only
>problem is that it sends it but the text isn't wrapped.
have a look at the Text::Wrap module
perldoc Text::Wrap
>Also, is there an easier way to do this?
>
>#!/usr/bin/perl -w
>
>$file = "/home/p/poohba/rap.quote";
>$signature = "/home/p/poohba/.signature";
>
>open (FILE, $file) || die "Can't open $file: $!\n";
>@quotes=<FILE>;
>close(FILE);
>
>
>$num = int(rand(@quotes));
>$saying = $quotes[$num];
>($quote,$author) = split(/:/, $saying);
>print "$quote\n\t\t\t\t\t\t$author\n";
>open (SIGNATURE, ">$signature") || die "Can't open $signature: $!\n";
>print SIGNATURE "$quote\n\t\t\t\t\t\t$author\n";
>close(SIGNATURE);
'easier' implies that you think that there's something difficult in your
code .. I'm at a loss to see what
there's only one change I'd recommend to your script - and that's to
check the success of that final 'close' .. because it's a write
filehandle that close could fail indicating a problem with the write -
then again that might not be too important to you with such a thing
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 25 Oct 2000 13:26:07 +0100
From: nobull@mail.com
Subject: Re: How do I print to a file with wrap text on?
Message-Id: <u9bsw9ksyo.fsf@wcl-l.bham.ac.uk>
Robert Campbell <poohba@fnord.io.com> writes:
> I have this script that is a random quote generator that is ran by cron
> and what it does is sends the new quote to my .signature file. The only
> problem is that it sends it but the text isn't wrapped.
You want to wrap text? Take a look at the modules on CPAN, maybe
you'll find one with 'Text' and 'Wrap' in its name.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 25 Oct 2000 12:53:20 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How do I print to a file with wrap text on?
Message-Id: <slrn8vdlts.pan.tjla@thislove.dyndns.org>
I was shocked! How could Robert Campbell <poohba@fnord.io.com>
say such a terrible thing:
>I have this script that is a random quote generator that is ran by cron
>and what it does is sends the new quote to my .signature file. The only
>problem is that it sends it but the text isn't wrapped. Also, is there an
>easier way to do this?
>
>#!/usr/bin/perl -w
>
>$file = "/home/p/poohba/rap.quote";
>$signature = "/home/p/poohba/.signature";
>
>open (FILE, $file) || die "Can't open $file: $!\n";
>@quotes=<FILE>;
>close(FILE);
Hmm...See the FAQ:
perldoc -q 'random line'
You can do this without having to read in the whole quotes database into
memory at one time. Someone else already suggested one solution for your
problem but I think maybe you could get around the problem of needing to
format the quote when you read it in by having the file pre-formatted.
The Unix fortune file comes this way with a special character sequence
(a single '%' on a line by itself) denoting the end of a record. Note
that this will work just fine with the method detailed above in the FAQ
so long as you set $/ appropriately so you can still read in in line
mode.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Yet more fun with UNIX #108: $ man: why did you get a divorce? man:: Too many arguments.
------------------------------
Date: 25 Oct 2000 13:30:55 +0100
From: nobull@mail.com
Subject: Re: How to pass a String to the STDIN of an other prg?
Message-Id: <u9aebtksqo.fsf@wcl-l.bham.ac.uk>
dragnovich@my-deja.com writes:
> Hello folks! I have this problem an don't know how to solve it =)
Here's how to solve it. Take a look at the titles of the Perl
manuals. Guess which one is likely to cover inter-process
communication. Skim-read it until you find the section that covers
providing STDIN to sub-processes. Read that bit in detail.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 25 Oct 2000 09:23:21 GMT
From: "Alain LAROCHE" <laroche@imra-europe.com>
Subject: htacces
Message-Id: <dExJ5.2589$h33.8765518@nnrp2.proxad.net>
I'm using an .htacces to control user as follow
PerlSetVar AuthFile private/passlist.txt
AuthName "Secure access"
AuthType Basic
<limit GET POST>
require valid-user
</limit>
After a member's login, how can I have the user and password variable ?
Thank you for your help
Alain
------------------------------
Date: Wed, 25 Oct 2000 13:58:29 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: htacces
Message-Id: <hWzJ5.300$Uq1.39521@news000.worldonline.dk>
Alain LAROCHE wrote:
> I'm using an .htacces to control user as follow
>
> PerlSetVar AuthFile private/passlist.txt
> AuthName "Secure access"
> AuthType Basic
> <limit GET POST>
> require valid-user
> </limit>
>
> After a member's login, how can I have the user and password variable ?
> Thank you for your help
>
> Alain
>
>
Your'e in the wrong group, you may be looking for
comp.infosystems.www.authoring.cgi...
Hint: take a look in %ENV
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 25 Oct 2000 02:13:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Integer overflow
Message-Id: <8t5fl0$9lm$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn8v9q0j.a0g.mgjv@verbruggen.comdyn.com.au>:
> > "perlnumber": No items found.
> >
> > I'm using 5.004 (due to lack of recent port) here.
> Ah, yes, perlnumber is more recent than that. 5.6.0 IIRC. Even if you
> aren't willing or able to upgrade to 5.6.0 yet, you can still download
> the sources and look at the documentation in there :) There may be
> _some_ minor differences between 5.6.0 and 5.004 in the way numbers
> are handled, but I doubt it's much (Ilya will correct me if I'm wrong,
> I hope).
Before 5.6.0 (and even later on 64-bit platforms) numeric data was
"most of the time it works as you expect". If you wanted any more
guarantee than this, you needed to be "very careful". It was not
possible to define what is "very careful" unless you are fluent with
how Perl stores its polymorphic (possibly multiheaded) scalars.
My principal contribution is the understanding that it is *possible*
to describe *some* semantic of what a polymorphic numeric data is
supposed to represent, without jeopardizing the optimizations
performed by Perl. The fact that this semantic is actually easy to
describe (and looks natural) is just a nice ramification of the
theory.
And no, until recently Perl scalars were not following this semantic.
A read-only access to a variable could change a result of a consequent
read-only access.
Ilya
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4719
**************************************