[18426] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 594 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 30 09:05:45 2001

Date: Fri, 30 Mar 2001 06:05:22 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985961121-v10-i594@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 30 Mar 2001     Volume: 10 Number: 594

Today's topics:
        @ references in $ values <stuart@fred.com>
    Re: @ references in $ values <bmb@ginger.libs.uga.edu>
    Re: add lines from logfile <bol@adv.magwien.gv.at>
    Re: add lines from logfile <bmb@ginger.libs.uga.edu>
    Re: Adding Values from an Array (Anno Siegel)
        Any Perl code for a simple proxy server? (Nim Chu)
    Re: Any Perl code for a simple proxy server? <blnukem@hotmail.com>
    Re: Any Perl code for a simple proxy server? (Randal L. Schwartz)
        automatic email of data file <roy@greenparrot.fsnet.co.uk>
    Re: bash history from perl? <gtoomey@usa.net>
        emailing of data file automatically (Roy)
    Re: fetch back STDERR outputs (Mark Jason Dominus)
        Finding the amount of hours since a recorded date. <taboo@comcen.com.au>
    Re: Finding the amount of hours since a recorded date. <josef.moellers@fujitsu-siemens.com>
    Re: Funny behavior? (Philip Lees)
    Re: Funny behavior? <bart.lateur@skynet.be>
    Re: Funny behavior? (Tad McClellan)
    Re: Funny behavior? (Tad McClellan)
    Re: Funny behavior? (Philip Lees)
    Re: Funny behavior? (Philip Lees)
        hide the source for my Perl program (I read the faq but <stingpd@tiscalinet.it>
    Re: LWP Timeout using get to get a webpage <gtoomey@usa.net>
    Re: my little project completed <bones3d@charter.net>
        Newbie question  <leongyc@tp.edu.sg>
    Re: Newbie question (Philip Lees)
    Re: Newbie (Damian James)
    Re: NT file permissions <Petri_member@newsguy.com>
    Re: Passing arguments to subroutines... nobull@mail.com
    Re: Perl is much simpler than it looks! <bones3d@charter.net>
    Re: Perl Mail Headers nobull@mail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 30 Mar 2001 14:06:43 +0100
From: "SAM" <stuart@fred.com>
Subject: @ references in $ values
Message-Id: <tc913mmkficnd2@corp.supernews.com>

Hi

Thanks to all that reply
I've been looking high and low for an answer to this problem but as its a
syntax problem and not a code related problem I have been unable to find any
answers.

Problem:

I have an initial function that returns a scalar an array and a hash into a
variable @m say. I can access all of the values I require however I cannot
find the length of the array as it is contained in the scalar $m[1].

I thought it would be something like $#$m[1] but I get a error.

Any suggestions

I know I could have put   ($a, @b, %c) = init();     but I would still be
interested to know how to get the length of an array when its reference is
contained in a scalar

thanks

Stu








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

Date: Fri, 30 Mar 2001 08:53:56 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: @ references in $ values
Message-Id: <Pine.A41.4.21.0103300845590.11484-100000@ginger.libs.uga.edu>

On Fri, 30 Mar 2001, SAM wrote:
> Problem:
> 
> I have an initial function that returns a scalar an array and a hash into a
> variable @m say. I can access all of the values I require however I cannot
> find the length of the array as it is contained in the scalar $m[1].
> 
> I thought it would be something like $#$m[1] but I get a error.

If I understand correctly:

#!/usr/local/bin/perl -wl
use strict;
my @m = ( 1, [2,3], {4=>5} );
print $#{$m[1]};       # last element subscript
print scalar @{$m[1]}; # array length

You said that you're looking for the length of the array, but
$#array doesn't give you that.

Brad



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

Date: Fri, 30 Mar 2001 11:24:11 +0200
From: Ferry Bolhar <bol@adv.magwien.gv.at>
Subject: Re: add lines from logfile
Message-Id: <985944241.217293@mozart.adv.magwien.gv.at>

Tobias Dresbach wrote:
> 
> Hi all,
> i have a log file like the following:
> IP-Address Port kbytes
> 192.168.0.1 53  10
> 192.168.1.2 21  150
> how is it possible to add all kbytes from the same port and ip-address?

open IN,"logfile";	# or whatever your file is
while (<IN>){
 ($addr,$port,$kbytes) = split /,/;
 $sum{"$addr:$port"} += $kbytes;
}
foreach (keys %sum){
 print "$_: $sum{$_}\n";
}

Greetings, Ferry
 
-- 
Ing. Ferry Bolhar-Nordenkampf
Municipality of Vienna
Municipality Department 14
A-1010 Vienna
E-mail: bol@adv.magwien.gv.at

"Wenn hier einer schuld ist, dann immer nur der Computer."


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

Date: Fri, 30 Mar 2001 08:35:59 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: add lines from logfile
Message-Id: <Pine.A41.4.21.0103300823530.11484-100000@ginger.libs.uga.edu>

On Fri, 30 Mar 2001, Uri Guttman wrote:
>>>> "BB" == Brad Baxter <bmb@ginger.libs.uga.edu> writes:
>BB> Golf?
 
>BB> perl -ane '$h{"@F[0,1]"}+=$F[2]}print"$_:$h{$_}\n"for keys%h;{' logfile
 
URI> perl -lane '$h{"@F[0,1]"}+=$F[2]}print"$_:$h{$_}"for keys%h;{' logfile
 
URI> one less (if you count the options)

Dang! :-)

Tie?

perl -ane '$_{"@F[0,1]"}+=$F[2]}warn"$_:$_{$_}\n"for keys%_;{' logfile

Brad



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

Date: 30 Mar 2001 09:53:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Adding Values from an Array
Message-Id: <9a1l2p$fsf$1@mamenchi.zrz.TU-Berlin.DE>


[dysfunctional comp.lang.perl trimmed from the newsgroups]

According to Chris Stith  <mischief@velma.motion.net>:
> FORM Rookie <m0rejunkmail@home.com> wrote:
> > OK here we go again. I need your help.
> 
> > Here's what I have:
> 
> > %some_things = ($thing1 => "2",
> >                           $thing2 => "4");
> 
> [snip]
> 
> > I need to add the values of $thing1 (2) and $thing2 (4) for a Grand
> > Total.
> 
> [snip]
> 
>     my $total = eval join '+', values %foo;

Oh, come on.  This may look pretty, but it is about as elegant as
shaving with a lawn mower.  Don't string-eval unless you must.
 
> or maybe:
> 
>     my $total;
>     for (values %foo) { $total += $_ }

The standard solution.  It is 26 times more efficient than the eval-
thing on my machine.

> or for the really perverse:
> 
>     my $total;
>     $total = (map { $total += $_ } values %foo)[-1]; 

Well... ahem... never mind :)

Anno


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

Date: Fri, 30 Mar 2001 09:58:53 GMT
From: nimchu@yahoo.com (Nim Chu)
Subject: Any Perl code for a simple proxy server?
Message-Id: <3ac48119.76954246@news-server.houston.rr.com>

I am looking for some simple example-type Perl code for a proxy server
that runs on Windows 98. Wants to surf internet from a netscape
browser session thru the proxy server. Anyone pointing to such source
code or info of how to write one is appreciated.


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

Date: Fri, 30 Mar 2001 11:40:13 GMT
From: "blnukem" <blnukem@hotmail.com>
Subject: Re: Any Perl code for a simple proxy server?
Message-Id: <xg_w6.70555$K54.8820549@news02.optonline.net>

Try here:

http://www.hotscripts.com/search/?query=proxy+server&category=Perl&bool=AND

Blnukem


"Nim Chu" <nimchu@yahoo.com> wrote in message
news:3ac48119.76954246@news-server.houston.rr.com...
> I am looking for some simple example-type Perl code for a proxy server
> that runs on Windows 98. Wants to surf internet from a netscape
> browser session thru the proxy server. Anyone pointing to such source
> code or info of how to write one is appreciated.




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

Date: 30 Mar 2001 05:21:41 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Any Perl code for a simple proxy server?
Message-Id: <m1bsqjo0ii.fsf@halfdome.holdit.com>

>>>>> "Nim" == Nim Chu <nimchu@yahoo.com> writes:

Nim> I am looking for some simple example-type Perl code for a proxy server
Nim> that runs on Windows 98. Wants to surf internet from a netscape
Nim> browser session thru the proxy server. Anyone pointing to such source
Nim> code or info of how to write one is appreciated.

1) Go to www.stonehenge.com/perl/googlecolumnsearch
2) type "proxy HTTP::Daemon" in the search box
3) follow the links

-- 
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: Fri, 30 Mar 2001 12:09:49 +0100
From: "Roy  Chappell" <roy@greenparrot.fsnet.co.uk>
Subject: automatic email of data file
Message-Id: <9a1pp4$f30$1@news6.svr.pol.co.uk>

HiYa All

Not sure if this is the correct place to post a query here goes.
I have a Profile Manager script up and running at
http://www.everyday-recruitment.co.uk, that saves profiles to a flat file
database. What i would like is for the data file to be automatically emailed
to the site owner. I would like this to occur at least daily and preferably
every time the data file is changed or from a button on a password protected
page.

The script also saves a <br> character in the data file from the large text
areas when the form filler hits the return key for new lien. How can i stop
this, as i have to use x-replace to remove them each time.

Thanks for any help you can give me, my knowledge of cgi is limited (but iam
very keen on improving it) so please be gently.

SeeYa

Roy Chappell




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

Date: Fri, 30 Mar 2001 21:03:32 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: bash history from perl?
Message-Id: <txZw6.5996$45.34447@newsfeeds.bigpond.com>

The history command is a shell builtin, like echo.
history does not work in batch mode (see man bash).

~/.bash_history is inititlised at startup, but still should be readable.

gtoomey
-------------
"Peter Bismuti" <bismuti@cs.fsu.edu> wrote in message
news:9a0lo3$qto$1@news.fsu.edu...
>
> I tried writing a script that executed the 'history' command and
> parsed the output.  What I discovered is that the history command is
> a bash command, there is no binary file, no /bin/history or
> /usr/bin/history.  I can't figure out any way of executing it from within
> perl, `` don't work.  Reading in the .bash_history command directly
> doesn't work either since the history is cached and what is in the file
> does not represent the current history, but what the history was the
> last time a shell exited ( I believe ).
>
>
> How can this be done?
>
> Thanks!
>




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

Date: Fri, 30 Mar 2001 11:38:01 GMT
From: roy@greenparrot.fsnet.co.uk (Roy)
Subject: emailing of data file automatically
Message-Id: <3ac47009.9422398@news.freeserve.net>

HiYa All

Not sure if this is the correct place to post a query here goes.
I have a Profile Manager script up and running at
http://www.everyday-recruitment.co.uk, that saves profiles to a flat
file
database. What i would like is for the data file to be automatically
emailed
to the site owner. I would like this to occur at least daily and
preferably
every time the data file is changed or from a button on a password
protected
page.

The script also saves a <br> character in the data file from the large
text
areas when the form filler hits the return key for new lien. How can i
stop
this, as i have to use x-replace to remove them each time.

Thanks for any help you can give me, my knowledge of cgi is limited
(but iam
very keen on improving it) so please be gently.

SeeYa

Roy Chappell




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

Date: Fri, 30 Mar 2001 13:53:52 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: fetch back STDERR outputs
Message-Id: <3ac48ffc.3f35$1f7@news.op.net>

In article <3AC3D282.71A123EE@home.com>,
Rick Delaney  <rick.delaney@home.com> wrote:
>> 'use warnings' does not work properly in 5.6.0 with regard to 'only
>> once' warnings.
>
>That's a pretty sweeping generalization.

No, just the opposite.  "Does not work properly" only means  that there is
a case for which it fails.  It does not mean that it fails in every case.
Anyway, I withdraw the remark, since it seems that the error I had in
mind doesn't actually apply in this case.


>since "only once" warnings apply only to the symbol name.  But I think
>the intention of the first is clearer.

I'll say.

>But if
>
>  {
>     no warnings "once";
>     open TOUCH,"+>zero-length.file" or die $!;
>  }
>
>is a little wordy, one can still do ...

Seems to me that

        use vars '*TOUCH';
        open TOUCH,"+>zero-length.file" or die $!;

is the best of these three choices.



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

Date: 30 Mar 2001 22:56:04 +1000
From: "Kiel Stirling " <taboo@comcen.com.au>
Subject: Finding the amount of hours since a recorded date.
Message-Id: <3ac48264$1@nexus.comcen.com.au>


Hi all,

Anyone know of a easy way of finding the amount of hours that 
have passed since a recorded date?

I'm try'n to write something like unix uptime.

Regards,

Kiel Stirling.



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

Date: Fri, 30 Mar 2001 16:02:43 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Finding the amount of hours since a recorded date.
Message-Id: <3AC49203.D812DE16@fujitsu-siemens.com>

Kiel Stirling wrote:
> =

> Hi all,
> =

> Anyone know of a easy way of finding the amount of hours that
> have passed since a recorded date?
> =

> I'm try'n to write something like unix uptime.

You might want to look at the POSIX module and the mktime function
therein.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Fri, 30 Mar 2001 07:58:22 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Funny behavior?
Message-Id: <3ac43c38.68612639@news.grnet.gr>

On Fri, 30 Mar 2001 07:28:14 GMT, pjlees@ics.forthcomingevents.gr
(Philip Lees) wrote:

>On Fri, 30 Mar 2001 01:51:16 -0000, Chris Stith
><mischief@velma.motion.net> wrote:
>
>>perldoc -q HERE
>>
>>You are supposed to check the FAQ before posting.
>
>Have you actually tried this? Sure, the here doc faq is in there, but
>way, way down towards the end after a number of totally irrelevant
>things such as:
>
>  Where can I get a list of Larry Wall witticisms?
>
>If I tried that first off I would assume that perldoc was broken.

Furthermore, looking back I see that the OP didn't even _know_ what
here docs are called, so how's he supposed to search the FAQ?

Or am I just humour impaired today?

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: Fri, 30 Mar 2001 10:44:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Funny behavior?
Message-Id: <luo8ct4hilif1ouqgp61b75k92l1udqu56@4ax.com>

Adam Moore wrote:

>   my $test = q{
>       some garbage
>   };
>
>Won't mess with your indentation, and you can zoom around your blocks with ]}
>in vim. :)

Oh yes it will. All whitespace on the left of the text, including that
right before the closing brace, is included. Is that what you want?

The requirement of the end marker for the here doc to touch the left
side of the page, is a reminder of this behaviour: the whitespace on the
left in the text isn't ignored either.

Besides, POD doesn't work either if the "=" is preceded by whitespace.

-- 
	Bart.


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

Date: Fri, 30 Mar 2001 06:52:53 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Funny behavior?
Message-Id: <slrn9c8ssl.nkl.tadmc@tadmc26.august.net>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>On Fri, 30 Mar 2001 07:28:14 GMT, pjlees@ics.forthcomingevents.gr
>(Philip Lees) wrote:
>>On Fri, 30 Mar 2001 01:51:16 -0000, Chris Stith
>><mischief@velma.motion.net> wrote:
>>
>>>perldoc -q HERE
>>>
>>>You are supposed to check the FAQ before posting.
>>
>>Have you actually tried this? Sure, the here doc faq is in there, but

>Furthermore, looking back I see that the OP didn't even _know_ what
>here docs are called, so how's he supposed to search the FAQ?


He knew that you use doubled angle brackets for them though:

   perldoc -q '<<'


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


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

Date: Fri, 30 Mar 2001 06:50:16 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Funny behavior?
Message-Id: <slrn9c8sno.nkl.tadmc@tadmc26.august.net>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>On Fri, 30 Mar 2001 01:51:16 -0000, Chris Stith
><mischief@velma.motion.net> wrote:
>
>>perldoc -q HERE
>>
>>You are supposed to check the FAQ before posting.
>
>Have you actually tried this? Sure, the here doc faq is in there, but
>way, way down towards the end after a number of totally irrelevant
>things such as:
>
>  Where can I get a list of Larry Wall witticisms?
>
>If I tried that first off I would assume that perldoc was broken.


Operator error is not the same as a broken tool.

   perldoc -q '\bhere'

If a search term gets too many hits, restrict the search term
some more.


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


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

Date: Fri, 30 Mar 2001 13:11:02 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Funny behavior?
Message-Id: <3ac484eb.87223140@news.grnet.gr>

On Fri, 30 Mar 2001 06:52:53 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:

>   perldoc -q '<<'

That produces:

<< was unexpected at this time.

with or without the quotes.

Or, using double instead of single quotes:

No documentation for perl FAQ keyword `<<' found

Maybe it's just the MS-DOS (NT) version that's broken.

I went through this myself a while ago. I knew the here docs stuff was
in the FAQ somewhere, but darned if I could find it.

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: Fri, 30 Mar 2001 13:37:48 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Funny behavior?
Message-Id: <3ac4860c.87512906@news.grnet.gr>

On Fri, 30 Mar 2001 06:50:16 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:

>Operator error is not the same as a broken tool.
>
>   perldoc -q '\bhere'

No documentation for perl FAQ keyword `'\bhere'' found

However, I find that

perldoc -q "\bhere"

produces the desired result.

But how is someone new to Perl supposed to figure that out? Is there a
FAQ for how to use the FAQ?

As I said elswhere in the thread I suppose this may be an OS-specific
problem. 

I refer to the docs all the time and find them generally excellent. I
use the HTML version, simply because I find that format easier to
read, and I put up with the absence of a search tool, now that I know
how to find my way around.

When I was starting out with Perl about a year ago, though, I found it
incredibly difficult to find what I wanted, mostly because I often
didn't really know what I was looking for, like the OP in this case.

I thought that Chris' advice was unlikely to be of any help to the OP,
and I still think that. I'm not getting at Chris personally - he's one
of the most helpful contributors to this group. It's just that in this
case the knee jerk FAQ reaction has led to a shot in the foot.

Phil

(If you want to respond to this, please copy to my e-mail as it's the
end of my working day and I won't be reading the group again until
Monday. I know you don't like munged e-mail addresses, so use
pjlees@med.uoc.gr, which I check from home.)
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: Fri, 30 Mar 2001 15:11:00 +0200
From: "Ðyl@ñ" <stingpd@tiscalinet.it>
Subject: hide the source for my Perl program (I read the faq but...)
Message-Id: <9a1vvc$no0$1@fe1.cs.interbusiness.it>

I want to make a cgi for a web site, and I need to hide the source code, so
I decided to use ''source filter'' (faq number 3) but the problem is that
the file that crypts the source code needs to stay in the same dir where the
code that I want to hide is. So this filter is not good for me....
what else can i do, where can I hide the module that makes the encrypt?






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

Date: Fri, 30 Mar 2001 21:10:18 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: LWP Timeout using get to get a webpage
Message-Id: <QDZw6.6003$45.33752@newsfeeds.bigpond.com>

Sorry, I just copied the code from somewhere else.

Cookies are not necessary, but Krispy Kremes are mandatory.

gtoomey
----------------
"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
news:3AC344ED.8B0B3E95@mortgagestats.com...
>
>
> Gregory Toomey wrote:
>
> > use LWP::UserAgent;
> > use HTTP::Cookies;
> >
> >       $ua = new LWP::UserAgent;
> >       $ua->agent("$0/0.1 " . $ua->agent);
> >       $ua->timeout(30); # change your timout value as necessary
> >        $req = new HTTP::Request 'GET' => 'http://www.somesite.com';
#change
> > as apprporiate
> >       $req->header('Accept' => 'text/html');
> >       $res = $ua->request($req);
> >
> >       if ($res->is_success) {
> >                 #web page is now in the variable$res
> > }
>
> Why do we need the HTTP::Cookies module here?
>




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

Date: Fri, 30 Mar 2001 05:26:01 -0600
From: James Meade <bones3d@charter.net>
Subject: Re: my little project completed
Message-Id: <bones3d-36327A.05260130032001@corp.supernews.com>

Interesting. :-)

I'm kind of new to the perl scripting scene myself. I recently ported a 
project of mine from shockwave to perl to get around some technical 
issues with the shockwave version. It works amazingly well as a perl 
script. :-)

Anyway, here's mine:

http://www.themarketspace.com/personal/base/

Currently, I'm working on a member profile database for another website 
I run. With any luck I'll have it working sometime next week. :-)

8==8 Bones 8==8


In article <99t5tl$hmm$1@bob.news.rcn.net>,
 "null" <nospamplease@thankyou.com> wrote:

> Thanks to everyone in this group for their advice/guidance.
> I finished my little app and it's online at
> http://www.lophty.com/rebootage/rebootageX.htm.
> 
> The front-end is shockwave (just a heads up for those who despise/fear
> plugin content).
> Basically you can drag around all of the sprites on the stage of the
> shockwave movie and pressing "enter" sends the browser to the perl script
> with all of the graphic sprite file name information and locations in a
> query string appended to the url.  The script parses the query string and
> produces a "screen capture" of the shockwave movie stage.
> 
> The number of sprite instances, their locations on the background, etc. are
> not hard-coded, so you can "hack" the query string a bit.
> 
> Not amazing or glorious, but my first foray into perl.
> Thanks again for your help.
> 
> =D
> 
> -brian
> 
>


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

Date: Fri, 30 Mar 2001 17:01:35 +0800
From: "yc" <leongyc@tp.edu.sg>
Subject: Newbie question 
Message-Id: <3ac446a0.0@news-svr.tp.ac.sg>

Hi,

I want to compare two files (FileA and FileB - both are text file). If the
first field of the two files is the same, then write the first field to a
new file.

I want to jump out from the inner loop when the 'if' comparison statement is
true (ie the result has written to the new file) and continue the outer
loop, how to go about it ?

If the logic is wrong, any enlightenment is appreciated.

open (First_File, "FileA") or die "Can't open File: $!\n";
while (<First_File>)
{
   @array_1=split /:/;
   @var1_1=$array_1[0];
   open (Second_File, "FileB") or die "Can't open File: $!\n";
   while (<Second_File>)
   {
      @array_2=split /:/;
      @var2_1=$array_2[0];
      if (@var1_1==@var2_1)
      {
         open (My_File, ">>myfile");
         print My_File "@var1_1\n";
         ****** jump out from the loop, cont'd the outer loop ******
      }
   }
}




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

Date: Fri, 30 Mar 2001 10:34:18 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Newbie question
Message-Id: <3ac45bb2.76670536@news.grnet.gr>

On Fri, 30 Mar 2001 17:01:35 +0800, "yc" <leongyc@tp.edu.sg> wrote:

>I want to compare two files (FileA and FileB - both are text file). If the
>first field of the two files is the same, then write the first field to a
>new file.
>
>I want to jump out from the inner loop when the 'if' comparison statement is
>true (ie the result has written to the new file) and continue the outer
>loop, how to go about it ?
>
>If the logic is wrong, any enlightenment is appreciated.

Your most important problem is that you are not letting Perl help you
find your mistakes. You should put the -w flag on the shebang line and
put 

use strict;

near the start of your script.

>open (First_File, "FileA") or die "Can't open File: $!\n";

Checking for success of open - good! Most people use all caps for file
handles: FIRST_FILE.

>while (<First_File>)
>{
>   @array_1=split /:/;

When using strictures, you must declare all variables the first time
you use them:

	my @array_1 = split/:/;

This helps you find typos, as Perl will tell you about undeclared
variables.

>   @var1_1=$array_1[0];

You don't want an array assignment here - you only have one value. Use
a scalar:

	my $var1_1	= $array_1[0];

>   open (Second_File, "FileB") or die "Can't open File: $!\n";
>   while (<Second_File>)
>   {
>      @array_2=split /:/;
>      @var2_1=$array_2[0];

See above concerning use of my and scalar variable.

>      if (@var1_1==@var2_1)

This doesn't do what you think it does. The condition will be true
whenever the two arrays @var1_1 and @var2_1 have the same number of
elements. since you are assigning one element to each of them, it will
always be true.

	if ($var1_1 == $var2_1)

This is a numeric comparison. Are you sure the first field will always
be a number? If not, use the string comparison operator.

	if ($var1_1 eq $var2_1)

>      {
>         open (My_File, ">>myfile");

Why don't you just open myfile once at the start and then write to it
as necessary. You should also be checking for the success of open, as
you do with the other two files.

>         print My_File "@var1_1\n";
>         ****** jump out from the loop, cont'd the outer loop ******

		last;			# I think this was the answer you wanted

The 'last' exits the closest loop, i.e.

   while (<Second_File>)
   {
   }

You can find more about this in perlsyn in the Perl documentation on
your hard disk.

>      }
>	}
>}

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: 30 Mar 2001 10:48:49 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Newbie
Message-Id: <slrn9c8p36.1uj.damian@puma.qimr.edu.au>

Mark Jason Dominus chose Thu, 29 Mar 2001 19:18:48 GMT to say this:
>
>...
> I don't know just what you're thinking, but whatever it is, this isn't
>doing it. 

This is one for the fortune cookie database (well, mine at least). 

>I hope this is helpful.

It is for me, never mind the OP :-).

( actually, I do care -- to the OP: pay attention to what this man says, it
will serve you well. )

Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...


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

Date: 30 Mar 2001 00:32:28 -0800
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: NT file permissions
Message-Id: <9a1gas066a@edrn.newsguy.com>

In article <3ac40838.17596882@wa.nnrp.telstra.net>, garyp@bgm.com.au says...

>>> This script runs fine from the command prompt but fails from
>>> the browser.

>>> I tried to get the apache service to run under another
>>> username but it wont even start.

>> This is not really a perl problem.

Agreed.
He is trying to make use of Perl, though.

> The log file gives me 'Cannot opendir .' yet I can from a command
> prompt on the server.

I have never used Apache on a Win32 system, but I assume it installs itself to
run as the _local_ System Account by default.
If you need to access resources on other computers in the domain, you need to
run the web server under another account, which has the correct domain
privileges.
You do need to add the "run as service" right to the account you choose,
otherwise the web-server won't be able to start.
Good luck.


Petri Oksanen



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

Date: 30 Mar 2001 12:12:46 +0100
From: nobull@mail.com
Subject: Re: Passing arguments to subroutines...
Message-Id: <u9k857ldch.fsf@wcl-l.bham.ac.uk>

"Eric" <eric.kort@vai.org> writes:

> sub Hello
> {
>   $audience = shift;

Should be:

  my $audience = shift;

Please do not teach bad habits.

>   # $audience = $_[0] would also work

As would:

    my ($audience) = @_;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 30 Mar 2001 06:21:31 -0600
From: James Meade <bones3d@charter.net>
Subject: Re: Perl is much simpler than it looks!
Message-Id: <bones3d-B7BBF1.06213130032001@corp.supernews.com>

I'm a bit of a power-monger myself. I get a kind of "hacker" rush from 
the language, knowing the finished script will execute some control over 
my ISP web server! I don't get that effect from shockwave and java 
development.

Overall, I haven't been this excited about programming since my days on 
the Apple ][s! I probably would've gotten into the whole Commodore 
64/128 hacking/cracking scene during the 80's if I hadn't been so darned 
young back then.

It's too bad you can't get away with doing stuff like that anymore, 
though. I'll bet it was a blast! ;-)

8==8 Bones 8==8


In article <vdWv6.4028$45.20900@newsfeeds.bigpond.com>,
 "Gregory Toomey" <gtoomey@usa.net> wrote:

> I was amazed how fast I paicked up Perl too - I have a Unix background
> and Perl is a revelation and revolution ;-).
> 
> As an aside, I have found out ASP and Cold Fusion run undex Linux-
> why would anyone bother with IIS??
> 
> gtoomey


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

Date: 30 Mar 2001 12:13:45 +0100
From: nobull@mail.com
Subject: Re: Perl Mail Headers
Message-Id: <u9itkrldau.fsf@wcl-l.bham.ac.uk>

director@internetsubmit.net writes:

> I am trying to use Mail and put in these Headers! Does anyone know
> how?

Just do it.

> I am trying to send an HTML file and have it appear as HTML.
> 
> 	"Mime-Version: 1.0\n\n";
> 	"Content-Type: text/html; charset=iso-8859-1\n\n";

Remove supprious extra \n.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


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