[15665] in Perl-Users-Digest
Perl-Users Digest, Issue: 3078 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 17 18:07:06 2000
Date: Wed, 17 May 2000 15:05:30 -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: <958601130-v9-i3078@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 17 May 2000 Volume: 9 Number: 3078
Today's topics:
Re: Camel T-Shirt <jbc@west.net>
Re: Camel T-Shirt (Randal L. Schwartz)
Check to see if an array value is null <bbostowNObbSPAM@hotmail.com.invalid>
Re: Check to see if an array value is null <makarand_kulkarni@My-Deja.com>
Re: counting leading spaces (Abigail)
Re: counting leading spaces <jeff@vpservices.com>
Re: deleting from a hash by reference... <aqumsieh@hyperchip.com>
Re: Free programming offerred by student <epost1@my-deja.com>
generating gif image from cgi <edbubbleluk@hotmail.com>
help - undef $/; ? <spam-abuse@uk2.net>
Re: help - undef $/; ? <makarand_kulkarni@My-Deja.com>
Re: How to COPY a website <null@zaz.com.br>
Re: How to COPY a website greg@apple2.com
Re: How to execute "cat *.c" ??? (Pete M. Wilson)
Re: how to parse HTMLish name="value" pairs <StefanRieken@SoftHome.net>
Re: how to parse HTMLish name="value" pairs <godzilla@stomp.stomp.tokyo>
How to set to csh? <fpower@newbridge.com>
Re: How to set to csh? <makarand_kulkarni@My-Deja.com>
Re: How to set to csh? <rootbeer@redcat.com>
Re: manipulating a text file with perl <rootbeer@redcat.com>
MIME::Tools question <slu_2@altavista.net>
Re: Minivend evil? <jbc@west.net>
Re: More Newbie Questions - Manipulating Data.... <dave@dave.org.uk>
Re: More Newbie Questions - Manipulating Data.... <billy@arnis-bsl.com>
Re: More Newbie Questions - Manipulating Data.... <aahz@gol.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 May 2000 11:05:43 -0700
From: John Callender <jbc@west.net>
Subject: Re: Camel T-Shirt
Message-Id: <3922DF77.9EDE6ECA@west.net>
Jonathan Stowe wrote:
>
> On Tue, 16 May 2000 13:10:24 -0500, spurcell Wrote:
> > Hello,
> > I just signed up for some of Tom's classes and would like to get a Camel
> > T-Shirt to take up to Boulder.
> > I can't seem to find them anywhere, I went to O'Reilly and to Perl.com Does
> > anyone out there know where to get one?
>
> ORA sent me one a couple of weeks ago - I have no Idea why though - its kind
> of sandy colour with 'Perl - The open source advantage' and camels.
I got one of those, too. I believe it was in response to filling
out a "how do you use Perl?" survey on the www.ora.com Web site.
It joins my 1st (0th?) Perl Conference shirt, which is getting
kind of moldy, actually, and an "Oracle Books from O'Reilly"
shirt, with lots of bugs crawling around, that I got for being
chosen in some sort of "What kind of animal are you?" promotional
contest I entered. (I got 10 free books for that, too, only 6 of
which I already owned. :-)
John
------------------------------
Date: 17 May 2000 12:26:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Camel T-Shirt
Message-Id: <m1snvhdllo.fsf@halfdome.holdit.com>
>>>>> "John" == John Callender <jbc@west.net> writes:
John> It joins my 1st (0th?) Perl Conference shirt, which is getting
John> kind of moldy, actually, and an "Oracle Books from O'Reilly"
John> shirt, with lots of bugs crawling around, that I got for being
John> chosen in some sort of "What kind of animal are you?" promotional
John> contest I entered. (I got 10 free books for that, too, only 6 of
John> which I already owned. :-)
I'm afraid to look for my really ancient Camel-release-party T-shirt
from 1991. I'm sure it's probably seen better days. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 17 May 2000 14:38:37 -0700
From: Ben Bostow <bbostowNObbSPAM@hotmail.com.invalid>
Subject: Check to see if an array value is null
Message-Id: <23857c7c.5fcd31fa@usw-ex0110-076.remarq.com>
I am trying to write a while loop that runs through an
array and stops as soon as an array possition has no value.
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Wed, 17 May 2000 14:24:00 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Check to see if an array value is null
Message-Id: <39230DF0.EE927E97@My-Deja.com>
> I am trying to write a while loop that runs through an
> array and stops as soon as an array possition has no value.
>
assuming "no value " is a situation where the array item has the value undef;
foreach ( @array )
{
last if ( not defined );
# process $_ here.
}
~
------------------------------
Date: 17 May 2000 21:14:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: counting leading spaces
Message-Id: <slrn8i62th.lb4.abigail@ucan.foad.org>
On Tue, 16 May 2000 23:52:18 -0700, Jeff Zucker <jeff@vpservices.com> wrote:
++ Brian McDonald wrote:
++ >
++ > I know how to strip leading spaces...
++ >
++ > s/^\s+//;
++ >
++ > But I can't figure out a way to count them before I strip them. I need to
++ > count them in order to encode the formatting information for a series of
++ > lines of text.
++ >
++ > For example,
++ >
++ > I am a line of text.
++ > I am another line of text.
++ > I am an indented line of text.
++ >
++ > A variable called $indent should take the value of 2 (spaces) for the last
++ > line.
++
++ Well it looks like four spaces rather than 2 to me :-), but:
++
++ while(<DATA>){
++ if( /^(\s*)(\S.*)/ ) {
++ $indent = length($1);
++ $line = $2;
++ print "$indent : $line\n";
++ }
++ }
Some strings on which this is going to fail:
"\t\t\t\t\t" # Doesn't have any \S in it.
"foo\nbar"; # . doesn't match \n.
But this ought to work:
$indent = length sub {$_ [0] =~ s/^(\s+)//; $1 || ""} -> ($string);
Abigail
--
perl -le 'print "Just another Perl Hacker" if can -> can (can)'
------------------------------
Date: Wed, 17 May 2000 14:31:57 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: counting leading spaces
Message-Id: <39230FCD.FC446FDD@vpservices.com>
Abigail wrote:
>
> On Tue, 16 May 2000 23:52:18 -0700, Jeff Zucker <jeff@vpservices.com> wrote:
> ++ Brian McDonald wrote:
> ++ >
> ++ > I know how to strip leading spaces...
> ++ >
> ++ > s/^\s+//;
> ++ >
> ++ > But I can't figure out a way to count them before I strip them. I need to
> ++ > count them in order to encode the formatting information for a series of
> ++ > lines of text.
> ++ >
> ++ > For example,
> ++ >
> ++ > I am a line of text.
> ++ > I am another line of text.
> ++ > I am an indented line of text.
> ++ >
> ++ > A variable called $indent should take the value of 2 (spaces) for the last
> ++ > line.
> ++
> ++ Well it looks like four spaces rather than 2 to me :-), but:
> ++
> ++ while(<DATA>){
> ++ if( /^(\s*)(\S.*)/ ) {
> ++ $indent = length($1);
> ++ $line = $2;
> ++ print "$indent : $line\n";
> ++ }
> ++ }
>
> Some strings on which this is going to fail:
>
> "\t\t\t\t\t" # Doesn't have any \S in it.
> "foo\nbar"; # . doesn't match \n.
>
> But this ought to work:
>
> $indent = length sub {$_ [0] =~ s/^(\s+)//; $1 || ""} -> ($string);
Yep, true, yours works in more situations. The OP did say he wanted to
find the length of indentations in front of "a series of lines of text"
rather than indentations in front of "strings" and while both the
exceptions you mention are strings, neither is by itself "a line of
text" if text is defined as something other than whitespace and a line
is defined as something that has a newline at the end of it rather than
in the middle of it. But maybe the OP wasn't asking the right question
or maybe my definitions are off base.
--
Jeff
------------------------------
Date: Wed, 17 May 2000 20:40:54 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: deleting from a hash by reference...
Message-Id: <7aaehonc4n.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
stdenton@my-deja.com writes:
> In article <7a7lcudzz3.fsf@Merlin.i-did-not-set--mail-host-address--so-
> shoot-me>,
> Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
> > > But you can do:
> > >
> > > undef $$ref;
> > >
> > > This is not the same but it is quite likely that it is sufficient
> for
> > > your needs.
> >
> > This doesn't do what the OP wanted. Maybe he/she has some valid undef
> > values. You can't make any assumptions based on the original question.
>
> Due to the OP sitting in the cube next to me, I can provide a bit more
> info on the problem. The app is processing hundreds of messages per
> second. The goal is to identify and suppress dups. The hash key is
> the text of the message, potentially large; the hash value is a time
> stamp. As each message comes in, he looks for it in the hash and
> tosses it if there is another copy. Also, every so often, he walks the
> hash and deletes things that are getting too old. Right now, he has
> lots of copies of the hash key floating around, which he would like to
> minimize.
But you are missing a very important point: hash keys are unique. This
means that if you try to assign a key-value pair to a hash, and this key
already exists in the hash, then the old value will be over written by
the new one:
$x{a} = 1;
$x{a} = 2;
print $x{a}; # will print 2.
So, one way of doing what the OP wants (based on the explanation above)
would be:
while (<DATA>) { # loop through the data
next if exists $hash{$_};
$hash{$_} = localtime;
}
or something similar.
> IMHO, he is prematurely optimizing for space, but OTOH he knows the
> data better than I. Anyway, one of my suggestions is to take the 32-
> bit CRC of the message text and use that as the hash key, tossing the
> message.
Why not, as long as he doesn't need the message later on.
But this brings us to the question: Can two different strings have the
same CRC?
> The number of potential messages is well less that 4G, so
> collisions shouldn't be much of a problem. MD-5 would reduce the
> chances of a collision by a lot, but I suspect that a cryptographically
> secure hash would take so lot to compute that he couldn't keep up with
> the incoming data.
>
> I assume that using random 32-bit ints doesn't slow down a hash (say,
> due to it converting them to strings and hashing them), otherwise,
> we'll have to write our own hash tables using arrays.
No it won't. You shouldn't be worrying this much about speed and memory
efficiency. If you are, then you shouldn't be using Perl anyway.
--Ala
------------------------------
Date: Wed, 17 May 2000 19:21:06 GMT
From: Ethan Post <epost1@my-deja.com>
Subject: Re: Free programming offerred by student
Message-Id: <8furee$r3s$1@nnrp1.deja.com>
Join the GNUmetrics for Oracle project by answering this question...
http://x36.deja.com/[ST_rn=fs]/threadmsg_if.xp?
thitnum=29&mhitnum=0&CONTEXT=958591171.1281687561&new=0
In article <3922DF46.4740E73A@zipmail.com>,
Carl Gibbs <cgi2@zipmail.com> wrote:
> I'm a grad student and know C++, Java, Javascript, Perl, CGI, HTML,
the
> Win32API , MFC, Winsock and some 80x86 assembly. I'd like to get some
> practice and build my resume by working on some real-world projects.
> I've been programming for 15 years as a hobbyist but much of it has
been
> in older now-obsolete languages on non-x86 systems. I have an
> engineering degree and went to grad school.
>
> Allow me to work for free for you in any of the above areas. I do
> request that credit be given for the work ( a comment line in the code
> will suffice). Projects taking about 10 days of work or therabouts
would
> be nice. I'm currently familiar with the windows development platform,
> but could learn others if needed.
> Thanks
> -M
>
>
--
http://www.freetechnicaltraining.com/home/ethan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 17:45:38 -0400
From: "Ed" <edbubbleluk@hotmail.com>
Subject: generating gif image from cgi
Message-Id: <8fv3n5$fpg$1@slb7.atl.mindspring.net>
How can I read (using perl I guess) a text file that contains a number. ie.
a hit counter, stores it into a string and then go thru this string and
takes each number and generates a gif representation of that number assuming
there are all gif images existing as in 1.gif, 2.gif.
for example
1234344 would return a gif or a few gifts back to a static HTML page, and I
could call my cgi script as if it were an image like
<img src = 'image.cgi'> or something like that
Thanks
Ed
------------------------------
Date: Wed, 17 May 2000 22:08:39 +0100
From: Nadja Herkova <spam-abuse@uk2.net>
Subject: help - undef $/; ?
Message-Id: <39230A57.D893773A@uk2.net>
could someone explain the function of the command
undef $/;
in the second of the two examples ?
open (LIST, "$basedir$list");
@recips = <LIST>;
close (LIST);
undef $/; # slurp mode (undef)
open (LAYOUT, "$basedir$layout");
$layouthtml = <LAYOUT>;
close (LAYOUT);
the code functions correctly (and yes i will be adding else clauses),
but I can't find an explanation of the undef command that I understand
wholly
many thanks, Nadja
------------------------------
Date: Wed, 17 May 2000 14:16:37 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: help - undef $/; ?
Message-Id: <39230C35.9F7FB7D1@My-Deja.com>
> could someone explain the function of the command
> undef $/;
> in the second of the two examples ?
>
check
perldoc perlvar
> open (LIST, "$basedir$list");
> @recips = <LIST>;
> close (LIST);
>
here $/ will be (by default ) set to newline char and hence
each item in @recips will contain one line from the file.
> undef $/; # slurp mode (undef)
> open (LAYOUT, "$basedir$layout");
> $layouthtml = <LAYOUT>;
> close (LAYOUT);
>
as $/ is set to undef here the while file will be read
into the $layouthtnl scalar ( all at once ).
--
------------------------------
Date: Wed, 17 May 2000 13:58:28 -0600
From: Mark Holt <null@zaz.com.br>
Subject: Re: How to COPY a website
Message-Id: <3922F9E4.5E971812@zaz.com.br>
What if you worked for a webhosting company which offers free hosting and want
newbie users to be able to transfer their site with a minimum of knowledge.
No permission issues. How likely is this, you ask? 100%. It is my exact
position. Will you please stop lecturing about legal issues and if you have
any technical data to contribute then post. Legal issues I am capable of
working out on my own.
Alan Silver wrote:
> In article <160520001042313969%root@127.0.0.1>, J. C. <root@127.0.0.1>
> writes
> >In article <GiBzydAHTVI5Ewu9@prestwich-smile-gemach.freeserve.co.uk>,
> >Alan Silver
> ><alan-silver@prestwich-smile-gemach.freeserve.furryferret.co.uk> wrote:
> >
> >: Have you thought about the legal implications of this ? Unless the site
> >: author gives explicit permission for you to copy the site (or any part
> >: of it), then it's illegal to copy it.
> >
> >I think the guy just wants to download it for perusal "offline." Geez,
> >net lawyers are everywhere.
>
> I'm not a lawyer, I'm a mathematician actually. I'm just warning him of
> the dangers that's all. As a web designer, I get very upset at the
> thought of people downloading my entire site without asking. I wouldn't
> necessarily say no (depending on what they want it for), but i don't
> like people downloading it without asking.
>
> --
> Alan Silver
> Please remove the "furryferret" if replying by e-mail
------------------------------
Date: Wed, 17 May 2000 16:16:19 -0500
From: greg@apple2.com
Subject: Re: How to COPY a website
Message-Id: <greg-2DD8F6.16161917052000@news.binary.net>
In article <3922F9E4.5E971812@zaz.com.br>,
Mark Holt <null@zaz.com.br> wrote:
> What if you worked for a webhosting company which offers free hosting
> and want newbie users to be able to transfer their site with a
> minimum of knowledge.
Then I'd assume that, at a minimum, if the user was able to put the site
up in one place, they should be able to put it up themselves in a new
place. I'd expect them to have memory retention of this simple skill.
You could also give them an application that would lead them through
zipping up their own files and transfer them to you to put online for
them.
Because, you see, in that situation, they have access to their own files
besides via HTTP. (And HTTP-based site-grabbers won't necessarily get
the right files anyway.)
--
__ _____________ __
\ \_\ \__ __/ /_/ / <greg@apple2.com> ___
\ __ \ | | / __ /----------------------------------------------------\-\|/-/
\_\ \_\|_|/_/ /_/ <http://www.war-of-the-worlds.org/>
------------------------------
Date: Wed, 17 May 2000 17:33:18 GMT
From: wilsonpm@drop.gamewood.net (Pete M. Wilson)
Subject: Re: How to execute "cat *.c" ???
Message-Id: <3922d6a1.321178900@news.gamewood.net>
I'll assume you're talking Unix... :-)
The shell handles the wildcard expansion for Unix, so invoke the shell
instead of the command:
*UNTESTED CODE*
system($ENV{"SHELL"},"cat","*.c");
or expand the glob yourself (the shell expands it by replacing it with
a separate argument per matching filename - try echo *.c to see it
happen).
ovarene@webmails.com wrote:
>Hello,
>
>I'd like to make a system call with an asterix wild card (*), like for
>exemple: cat *.c.
>
>I tried things based on system();
>>@sys_args=("cat","*.c");
>>system(@sys_args);
>
>and other based on
>>use Shell;
>>cat("*.c");
>
>but always get the following error message:
>>cat: Cannot open *.c: No such file or directory
>
>the trouble seems to come from the argument "*.c"
>so i tried '*.c', "*\.c", ....
>but nothing worked !
>
>How can I use the "*" wildcard (wildcard to be interpreted in the shell
>environement ?
>
>Thanks
>
>Olivier
>oliveir.varene@sita.int
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
Pete M. Wilson
Gamewood Data Systems Internet Service
wilsonpm@gamewood.net
------------------------------
Date: Wed, 17 May 2000 22:58:38 +0200
From: Stefan Rieken <StefanRieken@SoftHome.net>
Subject: Re: how to parse HTMLish name="value" pairs
Message-Id: <392307FE.F7C2AF1E@SoftHome.net>
Jeff Zucker wrote:
> Ambitious bloke, aren't you :-). I'm sorry to be
> disparaging it seems to me that what you are trying to do
> has a) been done before by some very experienced people and
> b) is a lot more complex a task than it looks at first
> sight.
Damn! Has then everything been done before? I want to do something new!
You know what? I'm going to write a free UNIX-like operating system. It
won't be as good as Minix, to begin with it will only run on PCI-based
i386 machines.
This *gotta* be a simple and new thing.
;-),
Stefan
P.S.: I just tried to let the program be self-supportive, so that it
runs on any server without troubles. But I forgot about the use of $1
and pals, which make this code a lot more beautiful.
The limitations may still be there, off course. Indeed, some people will
most probably die because they use my program. But what the heck, I
don't live in a UCITA-ruled country, and, BTW, I said "NO WARRANTY",
right?
No really, the people who have to type these lines are marked as
"average intelligent or up". The real morons do not touch these lines.
So I think that together with good documentation about the limitations
of my script, we will work it out.
Oh and BTW, this was (hopefully) the most ugly part of my script, it
does some really funny things right now and I have more planned. So then
call me ambitious. I'm just glad that I can finally make something
people will *use* after that I have learned to say "Hello, World!" in at
least 9 different languages, including three assembly languages (386 in
both AT&T and Intel style };-), not to mention real-world languages.
Thanks for your advise, and thanks Godzilla! for the advise about the $1
thingy, and for taking the time to set up the examples!
------------------------------
Date: Wed, 17 May 2000 14:49:20 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to parse HTMLish name="value" pairs
Message-Id: <392313E0.B304017E@stomp.stomp.tokyo>
Stefan Rieken wrote:
> Jeff Zucker wrote:
> > Ambitious bloke, aren't you :-). I
> Damn! Has then everything been done before? I want to do something new!
> You know what? I'm going to write a free UNIX-like operating system. It
> won't be as good as Minix, to begin with it will only run on PCI-based
> i386 machines.
> This *gotta* be a simple and new thing.
> call me ambitious. I'm just glad that I can finally make something
> people will *use* after that I have learned to say "Hello, World!" in at
> least 9 different languages, including three assembly languages (386 in
> both AT&T and Intel style };-), not to mention real-world languages.
For an ambitious bloke like you, I have an
IBM Paperweight computer I would consider
donating. Nice system. 80286 at 8 MHz with
a large 760 kilobyte RAM, along with a fast
20 megabyte 300 rpm hard drive. Even has a
720 kilobyte 3.5 inch floppy drive, right
next to a.. uhh.. 5.25 inch really floppy
drive, however much data those hold, can't
remember now. I'll toss in a quick 1200 baud
modem if you will pay all shipping costs.
Entire system is in mint condition and comes
with DOS 3.x and GW-Basic pre-loaded along
with PC_Link, Radio Shack's precursor to
America Online. Not sure if you can still
logon to PC_Link though. Don't think you
want to anyhow. Last time I logged on, umm..
late eighties or early ninties, going rate
was $6.95 an hour. A little expensive for
surfing porno sites these days.
Perfect for your project don't you think?
Running Unix on this older IBM system of
mine would certainly be something new.
Godzilla!
------------------------------
Date: Wed, 17 May 2000 15:01:43 -0400
From: Fonce Power <fpower@newbridge.com>
Subject: How to set to csh?
Message-Id: <3922EC97.1BF11D1C@newbridge.com>
Hi,
I am a newbie to the group. I am trying to find a way to source a (csh) script within my perl script and use the environment variables
that are set in the command. I believe when spawning a shell command it usually defaults to sh and not csh. How can I change this? I dont'
want to have to hard-code settings of the environment variables. Here is an example of what I would like to do:
`source <script that sets $ENV vars>`;
# $VARNAME should be whatever it is set to in the command above
chdir $SCCSDIR;
# continue ....
Any help would be greatly appreciated.
Thanks,
Fonce
------------------------------
Date: Wed, 17 May 2000 14:45:22 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: How to set to csh?
Message-Id: <392312F2.693F2727@My-Deja.com>
> I am trying to find a way to source a (csh) script within my perl script and use the environment variables
> that are set in the command. I believe when spawning a shell command it usually defaults to sh and not csh. How can I change this? I dont'
> want to have to hard-code settings of the environment variables. Here is an example of what I would like to do:
>
> `source <script that sets $ENV vars>`;
just before you run your script run
echo source <file> | csh -t
when your script starts now it will have all the environemtn vars it needs.
--
------------------------------
Date: Wed, 17 May 2000 14:46:01 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to set to csh?
Message-Id: <Pine.GSO.4.10.10005171443520.25459-100000@user2.teleport.com>
On Wed, 17 May 2000, Fonce Power wrote:
> I am a newbie to the group. I am trying to find a way to source a
> (csh) script within my perl script and use the environment variables
> that are set in the command.
I think you can use the methods that have been discussed in this newsgroup
in recent weeks for doing this. If you search on a Usenet archive, like
Deja, do you find what you need?
http://www.deja.com/
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 17 May 2000 12:27:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: manipulating a text file with perl
Message-Id: <Pine.GSO.4.10.10005171226490.25459-100000@user2.teleport.com>
On Wed, 17 May 2000, Brian E. Seppanen wrote:
> system "rexec xxx.xxx.xxx.xxx lpstat > /tmp/status";
> #open the file /tmp/status
> open (F,/tmp/status);
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Of course, you meant to quote the file name there, right? :-)
You should be aware that another user could write their own /tmp/status
file. This shouldn't be a security problem here, I think, but perhaps you
should consider a piped open instead.
> #if /tmp/status is a zero length file everything is cool
> while (<F>) || die;
That's not how to test for a zero-length file. Nice try, though. :-)
Check out the -z filetest in the perlfunc manpage.
> #analyze the file
> #for each $queue with spooled files
> #for each job in $queue assign $count
> #get $ptime from Date string
> #compare $ptime to current time if time exceeds 30minutes send a page
> system "mail -s \"`hostname` Printer error on $queue, $count spooled job(s)\" seppanen+page@hawking";
It could be better to use a module to send mail.
> end
I hope that's not part of your program! If you're just trying to tell us
that that's all, that's fine - but writing '__END__' (without the quote
marks) is actually Perl.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 17 May 2000 14:52:08 -0400
From: Sydney Lu <slu_2@altavista.net>
Subject: MIME::Tools question
Message-Id: <4vp5iski54ehbk8fohjb693blqsskalopb@4ax.com>
I'm working on interfacing with an IMAP-wannabe mail sytem that has
the ability to show me the full header, with MIME tags, for a message
that I ask it for.
It also can let me download only part of a message, specificied by an
offset from the beginning, and a length.
Given MIME::Header, is there a clean way to find out where the message
text begins and its length,, as well as the filename(s), offset and
length of any attachments?
With that information, one could then download (and if need be,
decode), and then display the message text, and the names and sizes of
all attachments, and allow the user to select an attachment for
download from the server...
I've RTFM'ed, and don't see any clean ways to get the size, and offset
of the messages out, as well as the bounds?
TIA,
Sydney
------------------------------
Date: Wed, 17 May 2000 14:15:28 -0700
From: John Callender <jbc@west.net>
Subject: Re: Minivend evil?
Message-Id: <39230BF0.FC081B9C@west.net>
"Randal L. Schwartz" wrote:
>
> >>>>> "John" == John Callender <jbc@west.net> writes:
>
> John> <user #3> the minivend author included (or used to include) his
> John> own special versions of things
>
> It was in fact true at one point. I'm not sure it is or isn't now.
>
I've since received the following reply from Mike Heins, the
Minivend author:
> I am surprised this old thing is still floating around. It no
> longer does this.
>
> Basically, the scenario that caused it to happen is:
>
> 1. The user ran install as root.
> 2. Ignoring the fact that it was an application and not a
> module, and ignoring the suggested default, they selected
> /usr/lib/perl5/site_perl as the installation directory.
> 3. They had UNINST=1 set.
>
> So it overwrote modules in that case.
>
> I still distribute some copies of modules, as they are needed for
> operation and my user base doesn't always have root access or the
> capability of running CPAN to get them. But long ago I hid them from
> MakeMaker and they will not overwrite anything even with UNINST=1 set.
>
> Minivend has been installed thousands of times and this is the
> only case I have heard of.
(Apologies for the mangled wrapping). Anyway, his response put my
mind at ease.
John
------------------------------
Date: Wed, 17 May 2000 19:12:40 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: More Newbie Questions - Manipulating Data....
Message-Id: <v6o5iscn82b0i29dsihlc780mggdovspv3@4ax.com>
On Wed, 17 May 2000 10:54:51 -0700, Mur
<jboesNOjbSPAM@qtm.net.invalid> wrote:
>Heck, this is just too easy:
>
>perl -e '$n=q(012345); print join(q(,),$n,$n=~/\d/g)'
>
>The trick is this:
>
>@digits = $n =~ /\d/g;
>
>This will set @digits to each match of the pattern in the string
>$n. \d is a digit (0-9).
You don't think that something like
@digits = split('', $n);
is easier?
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: Wed, 17 May 2000 18:26:05 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: More Newbie Questions - Manipulating Data....
Message-Id: <8fuo78$ndm$1@nnrp1.deja.com>
In article <8fulm1$9sl$2@apple.news.easynet.net>,
"Roy Wood" <roy.wood@ukonline.co.uk> wrote:
> Hi (Again),
>
> As i have zero experience with Perl i wonder if anyone can help me.
>
> I have a variable which is an integer number. I want to be able to
break
> this number down into it's individual components. So 12000 would be
1 - 2 -
> 0 - 0 - 0 etc....
>
> What is the command that i should investigating to acheive this ?
>
my $number = 1234567;
my @components = split //, $number;
Suggested reading:
perldoc -f split
perldoc perldata
perldoc perlre
perldoc perlfaq4
Good luck.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 20:22:40 GMT
From: "Chris Williams" <aahz@gol.com>
Subject: Re: More Newbie Questions - Manipulating Data....
Message-Id: <kcDU4.1712$uL2.116068@nnrp.gol.com>
Welcome to TMTOWTDI.
"Dave Cross" <dave@dave.org.uk> wrote in message
news:v6o5iscn82b0i29dsihlc780mggdovspv3@4ax.com...
> On Wed, 17 May 2000 10:54:51 -0700, Mur
> <jboesNOjbSPAM@qtm.net.invalid> wrote:
>
> >Heck, this is just too easy:
> >
> >perl -e '$n=q(012345); print join(q(,),$n,$n=~/\d/g)'
> >
> >The trick is this:
> >
> >@digits = $n =~ /\d/g;
> >
> >This will set @digits to each match of the pattern in the string
> >$n. \d is a digit (0-9).
>
> You don't think that something like
>
> @digits = split('', $n);
>
> is easier?
>
>
> Dave...
>
> --
> <http://www.dave.org.uk> SMS: sms@dave.org.uk
> yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
>
> "There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
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 3078
**************************************