[18483] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 651 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 8 03:06:26 2001

Date: Sun, 8 Apr 2001 00:05:16 -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: <986713515-v10-i651@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 8 Apr 2001     Volume: 10 Number: 651

Today's topics:
    Re: [OT] Re: password encryption <soszko@gmu.edu>
        Any way to ignore white space characters? <pric3596@cs.uidaho.edu>
    Re: Any way to ignore white space characters? (Tad McClellan)
    Re: Any way to ignore white space characters? (The Mosquito ScriptKiddiot)
    Re: Any way to ignore white space characters? (Martien Verbruggen)
    Re: Any way to ignore white space characters? <soszko@gmu.edu>
        Catch ctrl-C before it kills perl process?  <msw99@u.washington.edu>
        changing image in frames page <admin@photo.cncdsl.com>
    Re: changing image in frames page <juex@my-deja.com>
    Re: complaint about moderation of this group <mjcarman@home.com>
    Re: complaint about moderation of this group (Tad McClellan)
    Re: complaint about moderation of this group <admin@gatordev.net>
    Re: complaint about moderation of this group (Martien Verbruggen)
    Re: complaint about moderation of this group (Alan Barclay)
    Re: complaint about moderation of this group <uri@sysarch.com>
    Re: complaint about moderation of this group <juex@my-deja.com>
    Re: complaint about moderation of this group (David H. Adler)
        explain this please (The Mosquito ScriptKiddiot)
        makefile <cherry@netdepot.com>
    Re: problem with making dirs! <gtoomey@usa.net>
        Redirecting command output into an array (John R Ramsden)
    Re: Redirecting command output into an array (Gwyn Judd)
    Re: Redirecting command output into an array (Alan Barclay)
    Re: sendmail script - got to be something simple <moverho1@nycap.rr.com>
        So what do YOU use Perl for? <soszko@gmu.edu>
    Re: So what do YOU use Perl for? <gtoomey@usa.net>
    Re: So what do YOU use Perl for? (Gwyn Judd)
    Re: So what do YOU use Perl for? <juex@my-deja.com>
    Re: time difference 2 <c_clarkson@hotmail.com>
        Unicode named property in regexes (\p & \P) (Alan Barclay)
    Re: Want Lisp-like state machine impl. <ron@savage.net.au>
        White Space Characters <philip@p6m7g82k.student.umd.edu>
    Re: White Space Characters <uri@sysarch.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 07 Apr 2001 21:18:13 -0400
From: Szilvia Oszko <soszko@gmu.edu>
Subject: Re: [OT] Re: password encryption
Message-Id: <3ACFBC55.7A20D002@gmu.edu>



Steven Smolinski wrote:

> [
>     First of all, DO NOT STEALTH CC ME AGAIN!
>     Yes, I meant to shout that.
> ]

What is stealth cc and what's so awful about it?



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

Date: Sat, 7 Apr 2001 17:27:31 -0700
From: "Preston Price" <pric3596@cs.uidaho.edu>
Subject: Any way to ignore white space characters?
Message-Id: <9aob42$npd$1@kestrel.csrv.uidaho.edu>

This is my problem. I have a file that I want to read certain file names
from to load into a stack. Then after the stack is built and manipulated I
want to print names back to the file. What happens is that when I print them
back to the file I put a "\n" after it so that I can read the files back in
line by line in later executions. However after about 3 runs the program is
shot because when I read the files back in they have the "\n" at the end of
them so I end up with big spaces in my file when I write the file names back
to the file.
After about 3 runs it would look like this:
file3


file2

file1

If anyone knows how to ignore the "\n"s when reading in I would greatly
appreciate it!
Thanks in advance







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

Date: Sat, 7 Apr 2001 19:49:22 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Any way to ignore white space characters?
Message-Id: <slrn9cv9s2.p77.tadmc@tadmc26.august.net>

Preston Price <pric3596@cs.uidaho.edu> wrote:

>If anyone knows how to ignore the "\n"s when reading in I would greatly
>appreciate it!


You cannot ignore them while reading.

You can easily remove them after they have been read though.

   perldoc -f chomp


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 08 Apr 2001 01:54:51 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: Re: Any way to ignore white space characters?
Message-Id: <20010407215451.21885.00004243@ng-fi1.aol.com>

i haven't tried this so don't take my word for it...but i thinkg if u add the
"/s" at the end...

like so:

$sumstuff=~ /yourstuffhere/s;

???

peace


The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology


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

Date: Sun, 8 Apr 2001 12:24:05 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Any way to ignore white space characters?
Message-Id: <slrn9cviu5.3ud.mgjv@martien.heliotrope.home>

On 08 Apr 2001 01:54:51 GMT,
	The Mosquito ScriptKiddiot <anotherway83@aol.com> wrote:

[ You don't provide any context, so I'll do it for you]

"Preston Price" <pric3596@cs.uidaho.edu> wrote:

>> If anyone knows how to ignore the "\n"s when reading in I would
>> greatly appreciate it!

> i haven't tried this so don't take my word for it...but i thinkg if u
> add the "/s" at the end...

The /s at the end of what? The OP doesn't show any Perl code. All the OP
does is ask 'how to ignore the "\n"s when reading' lines from a file. As
far as I know, neither readline() or the <> construct accept /s at the
end. 

And saying things like "I haven't tried it" is not an excuse, it just
makes it much more worse that you post bad advice.

And you seem to ave misspelled "you" as "u".

> like so:
> 
> $sumstuff=~ /yourstuffhere/s;

Huh? Where was there any mention of regular expression matches?

he right answer is most likely that the OP needs to strip off the
end-of-lines just after reading, as is a standard idiom in Perl
programs:

while (my $line = <WHATEVER>)
{
	chomp $line;
	# do other stuff here
}

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd.   | Every time I looked at the
NSW, Australia                  | speedometer, I got lost.


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

Date: Sat, 07 Apr 2001 20:30:42 -0400
From: Szilvia Oszko <soszko@gmu.edu>
Subject: Re: Any way to ignore white space characters?
Message-Id: <3ACFB132.E323F62E@gmu.edu>



Preston Price wrote:

> This is my problem. I have a file that I want to read certain file names
> from to load into a stack. Then after the stack is built and manipulated I
> want to print names back to the file. What happens is that when I print them
> back to the file I put a "\n" after it so that I can read the files back in
> line by line in later executions. However after about 3 runs the program is
> shot because when I read the files back in they have the "\n" at the end of
> them so I end up with big spaces in my file when I write the file names back
> to the file.
> After about 3 runs it would look like this:
> file3
>
> file2
>
> file1
>
> If anyone knows how to ignore the "\n"s when reading in I would greatly
> appreciate it!
> Thanks in advance

Look up chomp.



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

Date: Sat, 07 Apr 2001 19:23:12 -0700
From: Matthew Weaver <msw99@u.washington.edu>
Subject: Catch ctrl-C before it kills perl process? 
Message-Id: <3ACFCB90.A47186DA@yahoo.com>

My script runs a bunch of executables, but some of the executables may
get stuck in an infinite loop.  Is there a way to catch ctrl-C (to
stop the loop) before it stops my whole script?  

I'm running this on Windows 98.  A couple things I've tried:

   $cmd = "run.exe < input.txt";
   eval('system "$cmd"');
   print $@;

It seems to catch errors generated in the run.exe program, but if that
goes into a loop I'm sunk and have to kill everything.  

   $cmd = "run.exe < input.txt";
   eval('alarm(30); system "$cmd"');

Nope, apparently alarm isn't implemented under Windows.  

Is this problem solvable?  Thanks.

-Matthew


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

Date: 08 Apr 2001 04:50:08 GMT
From: "ROKKSTAR" <admin@photo.cncdsl.com>
Subject: changing image in frames page
Message-Id: <9aoqm0$cef@dispatch.concentric.net>

I have a web page with 2 frames;  content & imagesbuttons.
when the page loads there is a "spacer.gif" image in 'content.htm'

(content.htm)
<table
<tr><td> <img border="0" src="spacer.gif" width="250"
height="400"></td></tr>
</table>


'imagesbuttons.htm' contains 22  50x50 pixel .jpg's and I would like to be
able to click on each on individually in any order and have the
corresponding
400x250 .jpg appear in the content page.

(imagebuttons.htm)
  <td width="4%" align="center"><img border="0" src="buttons/surf.jpg"
width="50" height="50"></A></td>


I'd like to be able to call an image by clicking on one of the image buttons
 and having the associated image displayed in the content page; in place of
"spacer.gif"
I'd like to try to do this with perl do to browser incompatibilities I've
experianced by doing this in Java.
any suggestions or ideas?
James




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

Date: Sat, 7 Apr 2001 22:36:01 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: changing image in frames page
Message-Id: <3acff8c2$1@news.microsoft.com>

"ROKKSTAR" <admin@photo.cncdsl.com> wrote in message
news:9aoqm0$cef@dispatch.concentric.net...
> I have a web page with 2 frames;  content & imagesbuttons.
> when the page loads there is a "spacer.gif" image in 'content.htm'
[...]
> I'd like to try to do this with perl do to browser incompatibilities I've
> experianced by doing this in Java.
> any suggestions or ideas?

Yes, have the Perl script generate the same output as you would generate if
the CGI program was written in C, Cobol, or Haskell. This can be done using
the "print" command or the CGI module.
You already know what that output is, don't you? If you don't know then you
don't have a Perl question but a web authoring or CGI question. Ask in a web
authoring NG.

jue




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

Date: Sat, 07 Apr 2001 22:24:44 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: complaint about moderation of this group
Message-Id: <3ACF9399.16DBA6C9@home.com>

---Pete--- wrote:
>
> I suspect that people like Kyle perform an initial NG search
> on "Perl" and no CGI groups come up. Therefore this group
> with the   "perl.misc" seems most appropriate for posting
> Perl/CGI questions.

I think they just figure that since they're writing it in Perl, it must
be a Perl question. It usually takes something like the recipe analogy
to get folks to take a step back and think about why it might *not* be.

> [I]t's not likely that a new CGI newsgroup will be formed 
> because comp.infosystems.www.authoring.cgi is low traffic 
> as it is.

Heh. That's because they all seem to be over here. Oh well.

> I assume that CGI is off-topic here in comp.lang.perl.misc
> bacause of the high amount of traffic already, just dealing
> with plain old Perl topics.

Yes and no. If there were only a few messages here each day, then I
doubt that anyone would really mind seeing CGI questions. However, they
would still be off-topic.

-mjc


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

Date: Sat, 7 Apr 2001 19:42:12 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: complaint about moderation of this group
Message-Id: <slrn9cv9ek.p5n.tadmc@tadmc26.august.net>

---Pete--- <bogus@erol.com> wrote:

>Suggestion:
>If this "CGI off-topic" issue is an ongoing problem here, I
>suggest that a new NG be fomed called... comp.lang.perl.cgi


Let us know when you have the RFD ready.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 08 Apr 2001 03:00:31 GMT
From: Scott <admin@gatordev.net>
Subject: Re: complaint about moderation of this group
Message-Id: <3ACF7AC8.31D50E6C@gatordev.net>



Michael Carman wrote:

> Yes and no. If there were only a few messages here each day, then I
> doubt that anyone would really mind seeing CGI questions. However, they
> would still be off-topic.
>
> -mjc

CGI scripts that are written in perl are not off topic.  What is on topic?
What kind of script or application written in perl is on topic if CGI
scripts are off topic?  How about perl scripts for unix administration? Are
they off topic too?  A perl related question is on topic as long as it
isn't about a perl script that is processed by a web server. That's totally
ludicrous.  I would say that most people using perl are using it for web
related activities such as CGI scripts or mod_perl programs. Saying that
CGI is off topic in this newsgroup is like saying that servlets are off
topic to a java newsgroup.

Who cares if a post is more CGI related than perl related?  This is a high
traffic newsgroup and a lot of the people who come here know about CGI
too.  If I had a CGI related question I would post it here instead of to
some low volume group where I am unlikely to get a reply.  This is the only
perl group I subscribe to, so if someone had a CGI question that I could
answer then the only way I would see it was if they posted to this group.
Hence the name comp.lang.perl.misc. Miscellaneous; all the odds and ends of
anything slightly perl related under the sun.
Give me your weary, your weak, those with perl related questions, they will
likely be answered here.

Scott



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

Date: Sun, 8 Apr 2001 13:52:23 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: complaint about moderation of this group
Message-Id: <slrn9cvo3n.3ud.mgjv@martien.heliotrope.home>

On Sun, 08 Apr 2001 03:00:31 GMT,
	Scott <admin@gatordev.net> wrote:
> 
> 
> Michael Carman wrote:
> 
>> Yes and no. If there were only a few messages here each day, then I
>> doubt that anyone would really mind seeing CGI questions. However, they
>> would still be off-topic.
>>
>> -mjc
> 
> CGI scripts that are written in perl are not off topic.  What is on topic?

CGI programs are not offtopic as long as the issues discussed are Perl
issues. The CGI issues are offtopic. That is the point. It has nothing
to do with what the program is supposed to do, be it CGI, system admin
tasks, text parsing, or calculating the average number of raindrops in a
cumulus cloud. The Perl parts of all those prorgams are on-topic. The
non-Perl parts, i.e. the langiuage independent parts, are offtopic. 

What is so bloody hard to understand about that?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.   | Gates?
NSW, Australia                  | 


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

Date: 8 Apr 2001 04:03:28 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: complaint about moderation of this group
Message-Id: <986702604.961329@elaine.furryape.com>

In article <3ACF7AC8.31D50E6C@gatordev.net>, Scott  <admin@gatordev.net> wrote:
>What kind of script or application written in perl is on topic if CGI
>scripts are off topic?  How about perl scripts for unix administration? Are
>they off topic too?  A perl related question is on topic as long as it
>isn't about a perl script that is processed by a web server. That's totally
>ludicrous.  I would say that most people using perl are using it for web

A perl related question is on topic but CGI & other similar questions
are not really perl related questions - they are really questions about
something else.

How do I set a cookie using CGI.pm - On topic.
How do I set a cookie - Not on topic.
Why does a cookie work in IE but not in Netcape - VERY not on topic.

How do call the 'useradd' program from perl - On topic.
How do add a user using the 'useradd' program - Not on topic.
I added a user and now I can't login any more - VERY not on topic.


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

Date: Sun, 08 Apr 2001 04:54:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: complaint about moderation of this group
Message-Id: <x7g0fkq9cx.fsf@home.sysarch.com>

>>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:

  MV> CGI programs are not offtopic as long as the issues discussed are
  MV> Perl issues. The CGI issues are offtopic. That is the point. It
  MV> has nothing to do with what the program is supposed to do, be it
  MV> CGI, system admin tasks, text parsing, or calculating the average
  MV> number of raindrops in a cumulus cloud. The Perl parts of all
  MV> those prorgams are on-topic. The non-Perl parts, i.e. the
  MV> langiuage independent parts, are offtopic.

  MV> What is so bloody hard to understand about that?

what causes that are programmers who are not competent enough to tell
what is language related and what is application or problem space
related. and because of perl's popularity we get many of those
programmers here. they graduate from 'programming' html into basic perl
doing cgi. so many have said perl is only used for cgi or similar
falsehoods. the regulars here typically know multiple languages and
easily can tell which issues are language (and therefore group)
specific.

unfortunately this will always happen. kiddies will come in with a
program with a problem that is not perlrelated but think it is because
their program is written in perl. maybe this issue should be put into
tad's page.

idea for tad: if the faq or posting rules for the group is too long for
one post, split it up and auto post each section like the FAQ does. also
keep the whole thing on the web and link to that in each post. that way
you get small readable posts and the full thing is reachable.

then we can add a section on how to tell if a problem is in perl or
problem space.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sat, 7 Apr 2001 22:17:32 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: complaint about moderation of this group
Message-Id: <3acff46c@news.microsoft.com>

"Scott" <admin@gatordev.net> wrote in message
news:3ACF7AC8.31D50E6C@gatordev.net...
> Michael Carman wrote:
>
> > Yes and no. If there were only a few messages here each day, then I
> > doubt that anyone would really mind seeing CGI questions. However, they
> > would still be off-topic.
> >
> > -mjc
>
> CGI scripts that are written in perl are not off topic.  What is on topic?
> What kind of script or application written in perl is on topic if CGI
> scripts are off topic?  How about perl scripts for unix administration?
Are
> they off topic too?  A perl related question is on topic as long as it
> isn't about a perl script that is processed by a web server. That's
totally
> ludicrous.

If that would be the criteria then you would be right. However you missed
the point.
Any Perl script is on topic as long as the question is about Perl! Perl! You
know, Perl!
Off-topic examples:
- How do I display another HTML page in a new frame (disguised as "I have a
CGI script written in Perl script that ....")
- How do I sort XML using XSL (disguised as "I have a CGI script written in
Perl which created a XSL file which ....)"
- "How do I auto-mount a MSDOS filesystem on Linux at boot-time (disguised
as "I have Perl script which run at boot-time and ....")

If your question is: "In order to perform task X I need to do Y. How do I do
that in Perl?"
Then your question is on topic and (unless covered in the FAQ or other
documentation) very welcome here. (X="make my website compatible with
Netscape"; Y="need to send header item "foo"  before header item "bar" to
the client").

> I would say that most people using perl are using it for web
> related activities such as CGI scripts or mod_perl programs. Saying that
> CGI is off topic in this newsgroup is like saying that servlets are off
> topic to a java newsgroup.

Not quite. The difference is that servlets are part of the Java Script
language. Just the same way Perl modules are on-topic here, too (except that
there is a more specialized NG CLP.modules).
Following your argument any question about HTML, XML, XSL, Basic, Java,
DHTML, VBS, actually any text format would be on-topic, too, as long as you
are using a Perl script to create/process the HTML-, XML-, .... file. That
cannot be right.

>[...]  If I had a CGI related question I would post it here instead of to
> some low volume group where I am unlikely to get a reply.
Do you also ask the clerk in the appliance department about how long to
broil the 15 pound turkey because you are using a kitchen range? Or do you
ask the clerk in the meat department?
To follow this analogy: If you already know that the turkey needs 4 hours,
then it is totally ok to ask the clerk in the appliance section: "In the
typical oven the turkey takes four hours. How long does it take in this new
high-powered microwave?"
Got the idea? If you have a question about the tool (i.e. Perl), then ask
here. If you have a question about the materials or the end product better
ask someplace else.

> This is the only
> perl group I subscribe to, so if someone had a CGI question that I could
> answer then the only way I would see it was if they posted to this group.

Perl != CGI. You are missing the chance of getting your question answered by
someone who uses AWK, C, bash, or whatever to write his CGI programs.

> Hence the name comp.lang.perl.misc. Miscellaneous; all the odds and ends
of
> anything slightly perl related under the sun.

Wrong! Dead wrong!
Read the charta: CLPM is for those questions about Perl (ABOUT PERL!) which
don't fit into one of the more specialized Perl NGs.

jue




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

Date: 8 Apr 2001 06:02:43 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: complaint about moderation of this group
Message-Id: <slrn9cvvo3.g98.dha@panix6.panix.com>

On Sun, 08 Apr 2001 03:00:31 GMT, Scott <admin@gatordev.net> wrote:

>This is a high traffic newsgroup and a lot of the people who come here
>know about CGI too.  If I had a CGI related question I would post it
>here instead of to some low volume group where I am unlikely to get a
>reply.

This doesn't make much sense.  Think about it...

You'd rather ask in a group where a) most people won't answer your
question because it's off topic, b) may have people who "know about CGI
too", but many of those are not expert in it and c) the traffic is much
higher, so your question won't even be *seen* by a lot of people because
1) due to this traffic, many score down messages that look like they are
off topic (even though some that seem so are not) and 2) the very fact
of the high volume increses the possibility of your message just getting
lost in the morass of information.

That, rather than in a group which a) is easier to read all of (and hence
has a better chance of your message getting noticed and b) is full of
people who know a lot about your *specific* problem area.

Sounds a bit odd to me...

Yours for a better Usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I'm not a non-conformist, I just follow directions poorly.
	- graffiti on the men's room wall at the Blind Tiger


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

Date: 08 Apr 2001 02:25:46 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: explain this please
Message-Id: <20010407222546.05296.00001818@ng-fc1.aol.com>

hey

this example is in Programming Perl but i can't understand it...i know it's got
sumthing to do with how the scope of the variable changes when it's declared
'local', but i don't see why 

$cool='lothlorien';
$cool=~ m/ (?{$i=0}) (.(?{$i=$i+1;}) )* lori (?{print $i;})/x;


gives the value of $i as 10 while


$cool='lothlorien';
$cool=~ m/ (?{$i=0}) (.(?{local $i=$i+1;}) )* lori (?{print $i;})/x;

gives the value of $i as 4

thanks

peace


The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology


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

Date: Sun, 08 Apr 2001 01:55:33 GMT
From: Ronald W Cherry <cherry@netdepot.com>
Subject: makefile
Message-Id: <3ACFC5F9.8B466DC@netdepot.com>

Hi,

Just downloaded Perl for the PC.

Attempting to run nmake on Makefile, get fatal error saying cant  make
config_H.vc?

nmake is part of Microsofts Visual C++

Makefile is in Perl\win32

config_H.vc exists in same dir as Makefile

What to do?



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

Date: Sun, 8 Apr 2001 10:04:25 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: problem with making dirs!
Message-Id: <6JNz6.11278$45.64807@newsfeeds.bigpond.com>

Many of the Perl CGI questions posted to this group are Web config problems.

And as a matter of interest, why are you using Perl under IIS and not
Linux/Apache.
I've used both and IIS is a dog - a cocker spaniel in fact.

gtoomey
-------------
"Bert" <webmaster@netdating.nl> wrote in message
news:3acf5e3e$0$13309@reader5...
> > Because it is not Mr. Perl's problem.
> >
> > It is Mr. Web Server's problem.





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

Date: Sun, 08 Apr 2001 01:25:19 GMT
From: jr@redmink.demon.co.uk (John R Ramsden)
Subject: Redirecting command output into an array
Message-Id: <3acfbdcf.37697914@news.demon.co.uk>

It's probably childishly simple to a Perl guru, and I may even
figure it out myself before anyone has a chance to reply, but
in a Perl program is there a simple method for redirecting the
output of a command into an array?

I have written a program (my first Perl program!) to treewalk a
directory and in the process write a text file comprising the MD5
hash and full pathname of each file in that tree, one per line.
(It will be run on Windows/DOS if that makes any difference.)

For this purpose I need to grab the output from a line such as
system("md5 image.jpg"). Obviously one can redirect the command
into a file and then read the file; but I was hoping for a simpler
approach. Any suggestions gratefully received.

(MD5 is an industry-standard algorithm for constructing a 64-bit
integer based on the contents of a file, whether text or binary.
It is believed that the chances of two distinct files having the
same MD5 hash value are of the order 2^-64. As it happens, there
is a Perl implementation of MD5; but due to the intricate nature
of the bit-bashing algorithm that produces the hash value, it is
more practical to run this as a separate program. "MD" stands for
Message Digest - see http://www.landfield.com/rfcs/rfc1321.html
or http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html.)


Cheers

---------------------------------------------------------------------------
John R Ramsden    (jr@redmink.demon.co.uk)
---------------------------------------------------------------------------
The new is in the old concealed, the old is in the new revealed.
   St Augustine.
---------------------------------------------------------------------------


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

Date: Sun, 08 Apr 2001 01:33:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Redirecting command output into an array
Message-Id: <slrn9cvjrm.f5p.tjla@thislove.dyndns.org>

I was shocked! How could John R Ramsden <jr@redmink.demon.co.uk>
say such a terrible thing:
>It's probably childishly simple to a Perl guru, and I may even
>figure it out myself before anyone has a chance to reply, but
>in a Perl program is there a simple method for redirecting the
>output of a command into an array?

You mean like this:

@array = `some_command`;

?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A community is like a ship; everyone ought to be prepared to take the helm.
		-- Henrik Ibsen, "An Enemy of the People", 1882


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

Date: 8 Apr 2001 04:05:25 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Redirecting command output into an array
Message-Id: <986702720.324256@elaine.furryape.com>

In article <3acfbdcf.37697914@news.demon.co.uk>,
John R Ramsden <jr@redmink.demon.co.uk> wrote:
>For this purpose I need to grab the output from a line such as
>system("md5 image.jpg"). Obviously one can redirect the command
>into a file and then read the file; but I was hoping for a simpler
>approach. Any suggestions gratefully received.

Go to http://search.cpan.org and enter MD5

Whenever you're trying to do something that someone might have done
before, this should be your first step.


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

Date: Sun, 08 Apr 2001 05:48:44 GMT
From: "Mark" <moverho1@nycap.rr.com>
Subject: Re: sendmail script - got to be something simple
Message-Id: <0ZSz6.9486$RV1.2225453@typhoon.nyroc.rr.com>

I'm pretty new to this so im'm probly way off base here.
but im gonna through in my thoughts anyway.
I get this sometimes and it turns out to be a missing semi colon
the debuger generates a weird err from the runnaway string .
I dont see an "; to end your print statment though it could be after the
html part
but the err does say "line 2, at EOF"

print " content-type exsrata........
print"
    html stuff
             " ;
>>EOF<<

 your html as well it could be somthing within your html code
not set up in print properly and the debuger reading the html statments as
code


This is the extent of my knowledge.

This is a file read statment

open (MAIL, "../usr/lib/sendmail -t") or die "cannot open file: $!";
@tempory=(MAIL);
close(MAIL);

This is a file write statment

open (MAIL, "../usr/lib/sendmail -t") or die "cannot open file: $!";
print (MAIL) @tempory;
close(MAIL);

im working with data bases so i think you can use $ instead of an array
like print(mail($tempory; which would send all your data out as 1 string ?

what kind of open statment is that is it a socket or somthing im not familer
with using the
! or the | in an open file statment? i am familer with the $!_  but not
!open I should
probly reread the operaters again.

if ( !open(MAIL, "|/usr/lib/sendmail -t") ) {
            print "Open mail failed\n";
            exit;
}

Can't modify constant item in scalar assignment

personaly I dont see were your refering to a scalar anywere in what you have
hear
other then the ! = not in perl like in != the numaric equlivent to ne which
is a string operater
which if the inturpeter is thinking its part of the numaric operater which
is a constant.



"Wes" <theXYZtenor@attXYZ.XYZnet> wrote in message
news:uHJz6.53601$hf.23315624@news1.elmhst1.il.home.com...
I appologize for posting this here, but I'm not sure if I've got a perl,
sendmail or server problem. This has got to be something so obvious: I'm
trying to run a simple sendmail script on an AT&T small business hosting
server and I have yet to be able to send mail. So far the folks at AT&T
haven't been very helpful.

script follows:

if ( !open(MAIL, "|/usr/lib/sendmail -t") ) {
            print "Open mail failed\n";
            exit;
}
print MAIL "To: me\@noplace.com\n";
print MAIL "From: me\@somewhere.net\n";
print MAIL "Subject: Testing mail script\n\n";
print MAIL "This is a test\n\n";

close (MAIL);
 ...remaining script generates html

The subsequent html in my script gets generated indicating the script
finishes. If I run with -d option I get the following output.


main::(/usr/local/apache/htdocs/hosts/meetinga/cgi-local/TestMail.pl:36):
36: if ( !open(MAIL, "|/usr/lib/sendmail -t") ) {
  DB<1> Can't modify constant item in scalar assignment at (eval 3) line 2,
at EOF

  DB<2>






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

Date: Sat, 07 Apr 2001 20:43:01 -0400
From: Szilvia Oszko <soszko@gmu.edu>
Subject: So what do YOU use Perl for?
Message-Id: <3ACFB415.63D2CA91@gmu.edu>

One recurring theme in this newsgroup seems to be that Perl!=CGI and
that while Perl is often used to write CGI scripts, it can also be used
to do a lot of other things. I'd be curious to see what non-CGI stuff
you do with Perl.



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

Date: Sun, 8 Apr 2001 15:03:10 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: So what do YOU use Perl for?
Message-Id: <b5Sz6.11508$45.65420@newsfeeds.bigpond.com>

Well ...

I use Perl to retrieve stock market information, and to analyse IPOs.

And Perl is great for all sorts of statistical reporting (provided you know
how to sort!)
I use if for analysing the performance of stock underwriters.

gtoomey
------------------------
"Szilvia Oszko" <soszko@gmu.edu> wrote in message
news:3ACFB415.63D2CA91@gmu.edu...
> One recurring theme in this newsgroup seems to be that Perl!=CGI and
> that while Perl is often used to write CGI scripts, it can also be used
> to do a lot of other things. I'd be curious to see what non-CGI stuff
> you do with Perl.
>




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

Date: Sun, 08 Apr 2001 05:43:27 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: So what do YOU use Perl for?
Message-Id: <slrn9d02ft.ff7.tjla@thislove.dyndns.org>

I was shocked! How could Szilvia Oszko <soszko@gmu.edu>
say such a terrible thing:
>One recurring theme in this newsgroup seems to be that Perl!=CGI and
>that while Perl is often used to write CGI scripts, it can also be used
>to do a lot of other things. I'd be curious to see what non-CGI stuff
>you do with Perl.

I use it to impress women.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
BOFH excuse #193:

Did you pay the new Support Fee?


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

Date: Sat, 7 Apr 2001 22:45:30 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: So what do YOU use Perl for?
Message-Id: <3acffafb$1@news.microsoft.com>

> "Szilvia Oszko" <soszko@gmu.edu> wrote in message
> news:3ACFB415.63D2CA91@gmu.edu...
> > One recurring theme in this newsgroup seems to be that Perl!=CGI and
> > that while Perl is often used to write CGI scripts, it can also be used
> > to do a lot of other things. I'd be curious to see what non-CGI stuff
> > you do with Perl.

Using Perl for don't know how long, maybe 10 years or so, for all kinds of
text processing, log file analysis, and tons and tons of automation
(prototype by manually running the individual tasks, then combine them into
a script and call the script daily at 3:00 in the morning).

Nothing web related whatsoever.

jue




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

Date: Sat, 7 Apr 2001 18:35:24 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: time difference 2
Message-Id: <F1404BDE3348E0E7.508C53762C5872EA.527C0678012C48AA@lp.airnews.net>

Waarddebon <Waarddebon@chello.nl> wrote:
: On my site I want to display the difference in time between
: a file on my host and the current time on my host.
: I've got these lines, notice the last line, it should display
: the remaining time in hours. but somehow it doesn't
: work right... it gives me as result: 274046.027222222
: (hours ????)

:                       $tijd = ($mtime/3600);

    Actually it's an assigment. It doesn't display anything. It
correctly assigns the last modify time in hours since the
epoch to $tijd.

: While the file it should check (zandloper.txt) is created
: less then 10 hours ago. What am I doing wrong here...

    We want to find out how long ago the file was last
modified. Let's say it was last modified at 2:00 and now
it's 4:00. One way to get the answer would be to find the
difference between the 2 times: 4 - 2 = 2hrs, which can
be rephrased as: 4 hours since noon - 2 hours since
noon = 2 hours since last modified.
    Since 'stat' is returning epoch seconds, we could use
'time' to return the number of non-leap seconds since
the epoch. Then we could subtract $mtime from it. That
would gives us a difference: the nuber of seconds since
last modified:

 my $seconds_since_epoch = time;
 my $file = '/data1/hm/babe/cgi-bin/zandloper.txt';
 my $mtime = (stat ($file))[9];
 my $seconds_since_modified = $seconds_since_epoch - $mtime;
 print $seconds_since_modified;

    or:

 my $file = '/data1/hm/babe/cgi-bin/zandloper.txt';
 # (stat ($file))[9] returns last modify time in seconds since the epoch
 my $seconds_since_modified = time - (stat ($file))[9];
 print $seconds_since_modified;

HTH,
Charles K. Clarkson


Whose cruel idea was it for the word 'Lisp' to have an 'S' in it?






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

Date: 8 Apr 2001 02:30:22 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Unicode named property in regexes (\p & \P)
Message-Id: <986697005.564941@elaine.furryape.com>

I'm reading 5.6.0's perlre page, and it mentions the \p & \P named
property escapes. I've worked out that they're a Unicode classification,
which is true if a character matches a property, for example '5' would
be true for \p{IsDigit} but false for \p{IsSpace}.

The perlre manpage gives a conversion table between POSIX character
classes such as [:digit:] and refers you to the manpage for utf8
for the rest.

The utf8 manpage doesn't mention \p & \P at all, but does mention
the perlunicode manpage.

The perlunicode manpage gives a few more examples, such as IsMirrored
and InTibetan.

What I don't see is an entire list of all the valid properties. I'm
sure there must be more than are listed.

Have I missed a page somethere? Is this something I should be
looking on Unicode's website, or in the perl source to find?


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

Date: Sun, 8 Apr 2001 09:48:28 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Want Lisp-like state machine impl.
Message-Id: <LQMz6.938$pO2.37397@ozemail.com.au>

If you want Lisp, write in Lisp.

If you want Perl, write in Perl.

Writing Lisp using Perl syntax is childish (to be polite). [Extended comment elided.]

Alternately, use a Perl (pre-written) Discrete Finite Automata package, such as http://savage.net.au/Perl.html#DFA::Command

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: 8 Apr 2001 01:10:03 GMT
From: "Philip M. Gollucci" <philip@p6m7g82k.student.umd.edu>
Subject: White Space Characters
Message-Id: <9aodpb$8n8$1@hecate.umd.edu>

You need to run chop($filename)
#!/usr/bin/perl -w

use strict;

open(FILE, "$file") || die $!;
   my @lines = <FILE>;
close(FILE);

eval {unlink $file};
print "IUnable to delete $file" if $@;

open(FILE, ">$file") || die $!;
    foreach $line (@lines) {
        chop($line);
 	print FILE $line;
    }
close(FILE);


-- 
*****************************************************************************
Philip M. Gollucci (p6m7g8)
Web-site    : http://www.p6m7g8.com
E-mail      : gollucci@wam.umd.edu 
	      Philip@p6m7g8.com 
Phone       : 301.249.6261 (Home)
	      301.314.3118 (College)
Major       : Computer Science 
Minor	    : Classical & Jazz Performance
Current Job : Science, Discovery, & the Universe Webmaster
	      URL: http://www.sdu.umd.edu 
Resume	    : http://www.wam.umd.edu/~gollucci/resume.html
*****************************************************************************



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

Date: Sun, 08 Apr 2001 05:12:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: White Space Characters
Message-Id: <x7bsq8q8kc.fsf@home.sysarch.com>

>>>>> "PMG" == Philip M Gollucci <philip@p6m7g82k.student.umd.edu> writes:

  PMG> You need to run chop($filename)

no, chomp it the proper function.

  PMG> open(FILE, "$file") || die $!;
  PMG>    my @lines = <FILE>;

why slurp in the whole file when you are doing line by line processing?
  PMG> close(FILE);

  PMG> eval {unlink $file};

huh? unlink won't kill your program or die. why the eval? why even the
unlink if you are going to open it for writing?

  PMG> open(FILE, ">$file") || die $!;
  PMG>     foreach $line (@lines) {
  PMG>         chop($line);
  PMG>  	print FILE $line;
  PMG>     }
  PMG> close(FILE);

and it all can be done with this one liner:

	perl -pi -e 'chomp' file

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 651
**************************************


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