[18461] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 629 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 4 18:06:53 2001

Date: Wed, 4 Apr 2001 15:05:23 -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: <986421923-v10-i629@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 4 Apr 2001     Volume: 10 Number: 629

Today's topics:
    Re: $word$ literal in a .pl? <c_clarkson@hotmail.com>
        'system' in perl script <bing-du@tamu.edu>
    Re: 'system' in perl script <chrekh@chello.se>
    Re: 'system' in perl script <bing-du@tamu.edu>
    Re: a question about * (Mark Jason Dominus)
        Autovivication and pure scalar (Honza Pazdziora)
    Re: Autovivication and pure scalar <uri@sysarch.com>
    Re: Autovivication and pure scalar <ren@tivoli.com>
    Re: Bulk renaming files <lmoran@wtsg.com>
    Re: Bulk renaming files <lmoran@wtsg.com>
        Can module distinguish between "use" and exec invocatio (Sweth Chandramouli)
    Re: Can module distinguish between "use" and exec invoc (Mark Jason Dominus)
    Re: Can module distinguish between "use" and exec invoc (Sweth Chandramouli)
    Re: Can module distinguish between "use" and exec invoc (Sweth Chandramouli)
    Re: Difference  between $! and $@ (Vera Serganova)
    Re: Does localtime() handle daylight savings <khera@kciLink.com>
    Re: Does localtime() handle daylight savings <c_clarkson@hotmail.com>
    Re: GD::Graph again <jdpepin@optonline.net>
    Re: Graphical Counter interpretation <wayne.keenan@ntlworld.com>
    Re: grepping while tailing (Mark Jason Dominus)
    Re: help calling sub routines in perl on NT <clinton.munden@alcatel.com>
    Re: Hmmm... Which PERL Book Is Best Suited For This??? <moiraine{NOSPAM}@qwest.net>
    Re: Hmmm... Which PERL Book Is Best Suited For This??? <uri@sysarch.com>
        How do I get html from a website? <todd@designsouth.net>
    Re: How do I get html from a website? <jesse@uchicago.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 4 Apr 2001 15:21:00 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: $word$ literal in a .pl?
Message-Id: <BCF34B4D656043D9.F54C8D40A81D37FD.E5A119747640BB9A@lp.airnews.net>

/Bruce/ asked:

: In short, the following line must appear in the .pl file:
: $key = "$word$";

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

 . . .

__END__

$key = "$word$";


HTH,
Charles K. Clarkson





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

Date: Wed, 04 Apr 2001 16:03:52 -0500
From: Bing Du <bing-du@tamu.edu>
Subject: 'system' in perl script
Message-Id: <3ACB8C38.C09FD4DE@tamu.edu>

The following script does not mail the content of $file to me.  It says
the message body is null.

Seems the perl script creates another shell to execute the 'system'
command, but the child shell knows nothing in the perl script above it.

Do I have to use the mail module (e.g. Net::SMTP) to handle the mail
delivery?

#!/usr/local/bin/perl

$file = 'test';
open(F,">$file");
print F "for testing\n";
system("cat $file|mailx -s 'test only' bing-du\@tamu.edu");

Ideas?

Bing



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

Date: Wed, 04 Apr 2001 21:27:24 GMT
From: Christer Ekholm <chrekh@chello.se>
Subject: Re: 'system' in perl script
Message-Id: <86k850nyu0.fsf@jane.localdomain>

Bing Du <bing-du@tamu.edu> writes:

> The following script does not mail the content of $file to me.  It says
> the message body is null.
> 
> Seems the perl script creates another shell to execute the 'system'
> command, but the child shell knows nothing in the perl script above it.
> 
> Do I have to use the mail module (e.g. Net::SMTP) to handle the mail
> delivery?
> 
> #!/usr/local/bin/perl
> 
> $file = 'test';
> open(F,">$file");
> print F "for testing\n";

close(F);

> system("cat $file|mailx -s 'test only' bing-du\@tamu.edu");
> 
> Ideas?
> 
> Bing

The content of the file is in perl-buffer only, you just need to close
the file first. :-)

But may I suggest another approach. open a filehandle to your program,
and write directly to it.

# if running 5.6.0 ( or higher )
open(MAIL,"|-","mailx -s 'test only' bing-du\@tamu.edu");
print MAIL "for testing\n";
close(MAIL);

# if older than 5.6.0
# open(MAIL,"|mailx -s 'test only' bing-du\@tamu.edu");

--
  Christer


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

Date: Wed, 04 Apr 2001 16:37:53 -0500
From: Bing Du <bing-du@tamu.edu>
Subject: Re: 'system' in perl script
Message-Id: <3ACB9431.F8EBEF8F@tamu.edu>

D'oh!   I forgot to close.  I like your 'open' idea.  I should have know that
too :).

Many thanks!

Bing

Christer Ekholm wrote:

> Bing Du <bing-du@tamu.edu> writes:
>
> > The following script does not mail the content of $file to me.  It says
> > the message body is null.
> >
> > Seems the perl script creates another shell to execute the 'system'
> > command, but the child shell knows nothing in the perl script above it.
> >
> > Do I have to use the mail module (e.g. Net::SMTP) to handle the mail
> > delivery?
> >
> > #!/usr/local/bin/perl
> >
> > $file = 'test';
> > open(F,">$file");
> > print F "for testing\n";
>
> close(F);
>
> > system("cat $file|mailx -s 'test only' bing-du\@tamu.edu");
> >
> > Ideas?
> >
> > Bing
>
> The content of the file is in perl-buffer only, you just need to close
> the file first. :-)
>
> But may I suggest another approach. open a filehandle to your program,
> and write directly to it.
>
> # if running 5.6.0 ( or higher )
> open(MAIL,"|-","mailx -s 'test only' bing-du\@tamu.edu");
> print MAIL "for testing\n";
> close(MAIL);
>
> # if older than 5.6.0
> # open(MAIL,"|mailx -s 'test only' bing-du\@tamu.edu");
>
> --
>   Christer



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

Date: Wed, 04 Apr 2001 18:17:56 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: a question about *
Message-Id: <3acb6561.6d12$2d8@news.op.net>
Keywords: Ceylon, deuce, goad, problem


In article <3ACB28AE.1FA3152A@writeme.com>,
Remington Gao (=?iso-8859-1?Q?=B8=DF=C3=F7?=)  <pangpang@writeme.com> wrote:
>Hi,
>
>I have a question when i study some code, there's some lines below:
>
>sub ReadParse {
>    local (*in) = @_ if @_;
>    ......
>
>Could you please tell me what the * mark means?

*in is a 'glob' that gathers together $in, @in, %in, and some other 'in's.

If you pass ReadParse() an argument which is a second glob, like this:

        ReadParse(*Foo);

then the line you showed has the effect of making the 'in' variables
aliases for the corresponding 'Foo' variables within the function, so
that when the function modifies $in, it is actuaally modifying $Foo,
and when it creates a hash %in it is actually creating %Foo.

I believe the comment on the subroutine (which you omitted) says
something to this effect.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 2 Apr 2001 19:44:45 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Autovivication and pure scalar
Message-Id: <slrn9chllb.12fr.adelton@nemesis.fi.muni.cz>


Hello,

this code

	$x->{a} = 1;
	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
	__END__
	HASH; HASH(0x1001f850); 1: a1 HASH(0x1001f850)

prints that as expected, anonymous hash has been created upon
assigning to $x->{a}. But this

	$x = 5;
	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
	$x->{a} = 1;
	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
	__END__
	; 5; :  5
	; 5; 1: a1 5

shows that the original plain value of 5 survived the autovivication
and that even if the $x->{a} value exists and the hash %$x exists, the
$x still shows the original value.

Assigning $x = {}; makes the $x into hash reference, but why does not
$x->{a} = 1; achieve the same?

I've tried to find the answer in the documentation and my Perl books
but as far as I could find and understand, after assigning to $x->{a},
the $x should hold an hash reference no matter what.

What am I missing? I've tested this on 5.004_04 and 5.6.1-trial2.

Thanks for any hints,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
 .project: Perl, mod_perl, DBI, Oracle, auth. WWW servers, XML/XSL, ...
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Wed, 04 Apr 2001 20:20:22 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Autovivication and pure scalar
Message-Id: <x766gkto1l.fsf@home.sysarch.com>

>>>>> "HP" == Honza Pazdziora <adelton@fi.muni.cz> writes:

  HP> 	$x = 5;
  HP> 	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
  HP> 	$x->{a} = 1;
  HP> 	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
  HP> 	__END__
  HP> 	; 5; :  5
  HP> 	; 5; 1: a1 5

  HP> shows that the original plain value of 5 survived the autovivication
  HP> and that even if the $x->{a} value exists and the hash %$x exists, the
  HP> $x still shows the original value.

that is using a symbolic reference and not a real reference. since $x ==
5, then ${$x} is basically %5 which is why you don't get a ref value
printed in either line as it is not a hard reference.

  HP> Assigning $x = {}; makes the $x into hash reference, but why does not
  HP> $x->{a} = 1; achieve the same?

$x has to have the undef value for it to be autovivified. if it has a
value, you deref it when assigning 1 to it (or to $x->{a}).

read my tutorial on autovivification for more:

http://tlc.perlarchive.com/articles/perl/ug0002.shtml

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: 04 Apr 2001 15:05:09 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Autovivication and pure scalar
Message-Id: <m3zodwfn2i.fsf@dhcp9-175.support.tivoli.com>

On Mon, 2 Apr 2001, adelton@fi.muni.cz wrote:

> 	$x = 5;
> 	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
> 	$x->{a} = 1;
> 	print ref $x, "; $x; $x->{a}: ", %$x, " $x\n";
> 	__END__
> 	; 5; :  5
> 	; 5; 1: a1 5

[snip]

> What am I missing? I've tested this on 5.004_04 and 5.6.1-trial2.

What you're missing is that this uses symbolic references.  Place a
"use strict;" at the start and you'll get something like:

Can't use string ("5") as a HASH ref while "strict refs" in use at - line 3.

For more information, see:

http://perl.plover.com/varvarname.html
http://perl.plover.com/varvarname2.html
http://perl.plover.com/varvarname3.html

(Which I hope cover this specific case, but didn't explicitly check for.)

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 04 Apr 2001 15:04:20 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Bulk renaming files
Message-Id: <c1rmctk6a7oum36a2s85n3mssmmie01465@4ax.com>

On 04 Apr 2001 18:32:10 +0100, nobull@mail.com wrote wonderful things
about sparkplugs:

>> redid it to ask questions and such BUT what I'd like is for the script
>> to auto-increment the file name like so:
>> 
>> somename001.doc
>> somename002.doc 
>
>(my $newname = $file) =~ s/\.doc\.(\d+)$/$1.doc/;
>
>> -I know how to auto-increment numbers (++) but this method is
>> producing results that are unexpected to me.
>
>Huh?  What's with the sudden change of topic?  Where does
>auto-increment fit in?

big fan here no-bull... I wanted to auto increment the whole time (see
above)

--
print "\x{263a}" 


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

Date: Wed, 04 Apr 2001 15:46:07 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Bulk renaming files
Message-Id: <ncumct4h494g7i66ede67f1mj5k9io28vp@4ax.com>

On 04 Apr 2001 18:32:10 +0100, nobull@mail.com wrote wonderful things
about sparkplugs:


>(my $newname = $file) =~ s/\.doc\.(\d+)$/$1.doc/;

Your code works as expected but in a directory of say 25-50
file.doc.001's I'd have run this for each file.

I thought I would get the filename and have it do them in one fell
swoop.  But your RegEx has me on the right track thanks.

>
>> -I know how to auto-increment numbers (++) but this method is
>> producing results that are unexpected to me.
>
>Huh?  What's with the sudden change of topic?  Where does
>auto-increment fit in?


--
print "\x{263a}" 


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

Date: Wed, 04 Apr 2001 18:38:52 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Can module distinguish between "use" and exec invocations?
Message-Id: <0TJy6.22388$iU.4180441@news1.rdc1.md.home.com>

+	Is there an easy way for a module to distinguish between
when it is being invoked via a "use Modulename" statement, versus when
it is being executed directly (say, as an executable from the command 
line)?  The only way that I can think of that might work would be to
define a new import function in the module, which set some variable
and then called Exporter::import explicitly; the module could then test
for the presence of that variable to know if it had been "use"d.  (That
would also match for a manual import, of course, but that's good enough
for me.) Would that work?
	(What I was originally trying to do was put some debugging into
my modules, so that if I just invoked them from the command line, they
would give me a dump of a bunch of different configs, but would not do
so when actually used in scripts.  If there's a better way to do that
than what I'm describing, then I'd love to hear about that as well; I'm
now intrigued by the excuse to finally muck around with how modules get
imported, so I'd still apreciate any comments people have on my
actual question.)

	TIA,

	Sweth.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: Wed, 04 Apr 2001 18:40:56 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Can module distinguish between "use" and exec invocations?
Message-Id: <3acb6ac4.6d88$282@news.op.net>


In article <0TJy6.22388$iU.4180441@news1.rdc1.md.home.com>,
Sweth Chandramouli <sweth+perl@gwu.edu> wrote:
>+	Is there an easy way for a module to distinguish between
>when it is being invoked via a "use Modulename" statement, versus when
>it is being executed directly (say, as an executable from the command 
>line)?  

if ((caller)[0]) {
  print "Module.\n";
} else {
  print "Standalone.\n";
}

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 04 Apr 2001 18:53:47 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: Can module distinguish between "use" and exec invocations?
Message-Id: <%4Ky6.22413$iU.4184631@news1.rdc1.md.home.com>

In article <3acb6ac4.6d88$282@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>if ((caller)[0]) {
>  print "Module.\n";
>} else {
>  print "Standalone.\n";
>}
	This only works from inside a subroutine invoked
from outside of the module, though--right?  That is, if I have
module Foo with sub bar, running './Foo.pm' from the shell wouldn't
print anything, would it?  Similarly, if I had a script that use-d Foo,
nothing would be printed until that script called Foo::bar (assuming
the above was in the definition of bar, of course).

	-- Sweth.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: Wed, 04 Apr 2001 19:03:04 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: Can module distinguish between "use" and exec invocations?
Message-Id: <IdKy6.22427$iU.4186741@news1.rdc1.md.home.com>

In article <%4Ky6.22413$iU.4184631@news1.rdc1.md.home.com>,
Sweth Chandramouli <sweth+perl@gwu.edu> wrote:
>	This only works from inside a subroutine invoked
>from outside of the module, though--right?  That is, if I have
>module Foo with sub bar, running './Foo.pm' from the shell wouldn't
>print anything, would it?  Similarly, if I had a script that use-d Foo,
>nothing would be printed until that script called Foo::bar (assuming
>the above was in the definition of bar, of course).
	Hmm... thinking about this some more, this also means that
tricks with import wouldn't work either--what I need is a way for the
module to, when run, distinguish between an explicit invocation and
a "require", since I'm trying to do something when the import _doesn't_
happen, not when it does.  Is there anything visible to the module that
would let it make that distinction?

	-- Sweth.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: 4 Apr 2001 18:20:26 GMT
From: serganov@math.berkeley.edu (Vera Serganova)
Subject: Re: Difference  between $! and $@
Message-Id: <9afola$q0m$1@agate.berkeley.edu>
Keywords: Crusoe, nose, riverside, sibling

In article <3acb3955.695e$24d@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
> $! is set by the OS when an OS error occurs, typically by file
> functions like 'open', 'rename', 'unlink', 'chdir', and so on; and by
> process control functions like 'fork', 'exec', and 'kill'.

Strictly speaking, OS sets $^E, and CRT dumbifies this to $!.  Except
on systems which lack the "detailed" error indicator, so have $^E same
as $!.

Ilya


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

Date: 04 Apr 2001 14:37:06 -0400
From: Vivek Khera <khera@kciLink.com>
Subject: Re: Does localtime() handle daylight savings
Message-Id: <x71yr8y0j1.fsf@onceler.kciLink.com>

>>>>> "YNH" == Your Name Here <Your_Name_Here> writes:

YNH> Hi,
YNH>    Does anyone know whether localtime functions handles the daylight
YNH> savings correctly on WINNT 4.0
YNH> If I run the below two lines, I still see the old timings. Rebooting my
YNH> machine has not helped. 

YNH> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
YNH> print "time $mday-$months[$mon]-$year.$hour:$min:$sec\n";

Apparently this is a bug in Windoze not recognizing the switchover DST
properly.  Go sue Microsoft for selling you defective software.


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/


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

Date: Wed, 4 Apr 2001 15:30:55 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Does localtime() handle daylight savings
Message-Id: <6D4734168490E107.167AA2089C032495.05E4AB253C04DF97@lp.airnews.net>


chidam <ramu_chidambaram@agilent.com> wrote
: Hi,
:    Does anyone know whether localtime functions handles the daylight
: savings correctly on WINNT 4.0
: If I run the below two lines, I still see the old timings. Rebooting my
: machine has not helped.
:

    Did you see the message subject:
'localtime and Win32: The april fool's bug'
    on this usenet group?

HTH,
Charles K. Clarkson






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

Date: Wed, 04 Apr 2001 21:13:33 GMT
From: "Joseph Pepin" <jdpepin@optonline.net>
Subject: Re: GD::Graph again
Message-Id: <18My6.127876$K54.15864970@news02.optonline.net>

Any plans for this?

"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn9cidr6.jrg.mgjv@verbruggen.comdyn.com.au...
> On Mon, 02 Apr 2001 15:29:39 -0700,
>
> but rotated 90 degrees, right? GD::graph doesn't do horizontal charts
> at the moment.
>





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

Date: Wed, 04 Apr 2001 22:35:21 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: Re: Graphical Counter interpretation
Message-Id: <3ACB9398.C027C835@ntlworld.com>

if you had ever had the joy of using an Acorn BBC/ Archimedes (the people
that went on to create the ARM processor) they you might go:
oh, wait a minut,e that looks like the VDU23,x,y,........  commands I used to
use to create
new bitmaps in the character font RAM.

what you'll find is that the hex digits here would be better represented as a
binary string.
hex digit one =  top pixel line of character
hex digit two=   (top -1) pixel line of character

where in the binary representation  1 means pixel the is on, where there is a
0 the pixel is off.
look at numbers 1& 9

see the left (i.e. 'top') digitts 'look' the same?
/probably/ goes something like this:

(its an 8  x10 font)     ((8bit hex vals)  x (10 x hex vals) )

c3=  01111110
99=  10000001

so
    ("c3 99 99 99 99 99 99 99 99 c3",             # 0

is:

011111110
100000001
100000001
100000001
100000001
100000001
100000001
100000001
100000001
011111110

maybe!


but thats no perl, so I didn't answer it....

"M. Lacey" wrote:

> This may seem like a dumb question, but I would like to know the
> relationship of the code below to the output.
> The code generates a white number on a black background, and would like to
> know what the numerical format of each line represents to achieving the
> color and each number.
>
>     ("c3 99 99 99 99 99 99 99 99 c3",             # 0
>                  "cf c7 cf cf cf cf cf cf cf c7",             # 1
>                  "c3 99 9f 9f cf e7 f3 f9 f9 81",         # 2
>                  "c3 99 9f 9f c7 9f 9f 9f 99 c3",        # 3
>                  "cf cf c7 c7 cb cb cd 81 cf 87",       # 4
>                  "81 f9 f9 f9 c1 9f 9f 9f 99 c3",         # 5
>                  "c7 f3 f9 f9 c1 99 99 99 99 c3",      # 6
>                  "81 99 9f 9f cf cf e7 e7 f3 f3",          # 7
>                  "c3 99 99 99 c3 99 99 99 99 c3",   # 8
>                  "c3 99 99 99 99 83 9f 9f cf e3");     # 9
>
> many thanks
>
> Michael
> michael_faulkes@hotmail.com



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

Date: Wed, 04 Apr 2001 18:24:11 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: grepping while tailing
Message-Id: <3acb66d7.6d25$3df@news.op.net>
Keywords: Fruehauf, McConnel, fauna, sue


In article <3ACB4F40.E93D202C@forthnet.gr>,
Tassos Chatzithomaoglou  <achatz@forthnet.gr> wrote:
>How is it possible to do the following in perl?
>
>A syslogd is used to create the file.log. Then i do :
>
>tail -f file.log
>
>and while the file is printed on screen, i want to get each line "grepped" through some strings
>and sent to different files.
>

        open LOG, "< file.log" or die "Couldn't open file.log: $!";
        
        while (1) {
          while (<LOG>) {
            if (/foo/) {
               print FOO;
            } elsif (/bar/) {
               print BAR;
            }
          }
          sleep 2;
          seek LOG, 0, 1;
        }

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 04 Apr 2001 17:48:05 -0400
From: Clinton Munden <clinton.munden@alcatel.com>
Subject: Re: help calling sub routines in perl on NT
Message-Id: <3ACB9695.12DE591B@alcatel.com>

HI there,

take the () from the name of your sub.   Just write &step_1;

then write

sub step_1 {
 # your code here
}

James Nelson wrote:

> I am in the process of writing my first perl script on NT and have come
> across a problem I am not being able to find info on in the man pages.
>
> When I try and run my simple script I get the following error:
>
> The specified CGI application misbehaved by not returning a complete set of
> HTTP headers. The headers it did return are:
>
> syntax error at
> D:\Inetpub\secure.someserver.com\somedirectory\cgi-bin\regform.pl line 43,
> near "sub step_1 "
> syntax error at
> D:\Inetpub\secure.someserver.com\somedirectory\cgi-bin\regform.pl line 108,
> near "}"
> Execution of
> D:\Inetpub\secure.someserver.com\somedirectory\cgi-bin\regform.pl aborted
> due to compilation errors.
>
> The following is how I call the sub routine:
>
> &step_1();
>
> Now here is the subroutine:
>
> sub step_1 {  # line 43
> print header;
> &print_header();
> print <<END;
>       <p align="left"><b><font face="Arial" size="4">Account
> Registration<br>
> END
> &print_footer();
> } # line 108
>
> I removed the some lines from the print <<END for purposes of reability
>
> Thanks in advance for your help, please email me at james@kcnet.com



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

Date: Wed, 04 Apr 2001 13:15:11 -0700
From: A_Geekette <moiraine{NOSPAM}@qwest.net>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <3ACB80CF.80A62A3E@qwest.net>


--------------CB372105A660EF51417BBE2D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Jacko wrote:

>
>
>      The camel book (Larry Wall's Programming Perl, O'Reilly &
>      Associates) is a must-have. It's got the indexing you want
>      (the best indexing I've seen, IMHO) plus it's written by
>      Larry Himself. It's an absolute necessity for anybody who
>      has ever thought about potentially maybe sometime possibly
>      viewing/editing/creating perl code. I open my copy every
>      day, usually several times a day, and I already know perl
>      quite well.
>
>
>
>      I beg to differ, the Camel book stinks as do most O'Reilly
>      books -- they are only any good if you have some expertise
>      already. For newbies, I wholeheartedly recommend "Perl, the
>      Complete Reference" from Osborne. Much more enlightening.
>

That's why the O'Reilly books give the Learning series.  Learning Perl
is written by Randal Schwartz, and Tom Christiansen (THE Camel was
written by those two as well as the Perl creator himself, Larry Wall).
One can often find Mr. Schwartz on this newsgroup.  (btw Mr. Schwartz is
one of the big cahunas when it comes to Perl.  He helped make it....)
If you find THE Camel a little fast, then I suggest you get THE Llama
(Learning Perl).  It goes over the basics a lot more, which helps to
tackle the Camel book.


Besides.....I'm a girl....I like animals.  ;-)
--
Geekette

"Try Not.  Do or do not.  There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)

"Nothing is impossible, no matter how improbable."
-Anonymous


--------------CB372105A660EF51417BBE2D
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
Jacko wrote:
<blockquote TYPE=CITE><style></style>
&nbsp;
<blockquote 
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">The
camel book (Larry Wall's <u>Programming Perl</u>, O'Reilly &amp; Associates)
is a must-have. It's got the indexing you want (the best indexing I've
seen, IMHO) plus it's written by Larry Himself. It's an absolute necessity
for anybody who has ever thought about potentially maybe sometime possibly
viewing/editing/creating perl code. I open my copy every day, usually several
times a day, and I already know perl quite well.
<br>&nbsp;
<br>&nbsp;
<p>I beg to differ, the Camel book stinks as do most O'Reilly books --
they are only any good if you have some expertise already. For newbies,
I wholeheartedly recommend "Perl, the Complete Reference" from Osborne.
Much more enlightening.</blockquote>
</blockquote>

<p><br>That's why the O'Reilly books give the Learning series.&nbsp; Learning
Perl is written by Randal Schwartz, and Tom Christiansen (THE Camel was
written by those two as well as the Perl creator himself, Larry Wall).&nbsp;
One can often find Mr. Schwartz on this newsgroup.&nbsp; (btw Mr. Schwartz
is one of the big cahunas when it comes to Perl.&nbsp; He helped make it....)&nbsp;
If you find THE Camel a little fast, then I suggest you get THE Llama (Learning
Perl).&nbsp; It goes over the basics a lot more, which helps to tackle
the Camel book.
<br>&nbsp;
<p>Besides.....I'm a girl....I like animals.&nbsp; ;-)
<br>--
<br>Geekette
<p>"Try Not.&nbsp; Do or do not.&nbsp; There is no try."
<br>-If you don't know who said this,
<br>I don't want to talk to you. ;-)
<p>"Nothing is impossible, no matter how improbable."
<br>-Anonymous
<br>&nbsp;
</body>
</html>

--------------CB372105A660EF51417BBE2D--



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

Date: Wed, 04 Apr 2001 21:39:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <x7vgoks5tp.fsf@home.sysarch.com>

>>>>> "AG" == A Geekette <moiraine{NOSPAM}@qwest.net> writes:

  AG> That's why the O'Reilly books give the Learning series.  Learning
  AG> Perl is written by Randal Schwartz, and Tom Christiansen (THE
  AG> Camel was written by those two as well as the Perl creator
  AG> himself, Larry Wall).  One can often find Mr. Schwartz on this
  AG> newsgroup.  (btw Mr. Schwartz is one of the big cahunas when it
  AG> comes to Perl.  He helped make it....)  If you find THE Camel a
  AG> little fast, then I suggest you get THE Llama (Learning Perl).  It
  AG> goes over the basics a lot more, which helps to tackle the Camel
  AG> book.

if you are going to try to help, get your facts correct. the camel 3
book is not written by randal. he was replaced by jon orwant. and llama
3 (learning perl) is being readied and tom christiansen will not be one
of its authors.

  AG> Content-Type: text/html; charset=us-ascii

and did posting in html help you in any way? because it doesn't help
anyone else and it annoys most (if not all) of the regulars here. don't
do it. usenet is a plain text medium.

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: Wed, 04 Apr 2001 19:00:02 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: How do I get html from a website?
Message-Id: <SaKy6.7681$C51.2569789@news1.rdc1.tn.home.com>

I'm writing a program that plays Lycos Gamesville bingo online for me. The
url that the game
starts off with, which I need to send and get back the html so my program
can see the bingo boards, is very very long.

I tried "$result = `lynx -dump $url`, but a result never comes back. I've
tried LWP::UserAgent, but it says the site doesn't allow connections to it's
HTTP port, and sometimes i just get a "Connection timed out" error.

So my question is, how does a regular browser connect to a site and get back
a result so fast, and how can I do it the same way?






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

Date: Wed, 04 Apr 2001 15:52:28 -0500
From: Jesse James Jensen <jesse@uchicago.edu>
Subject: Re: How do I get html from a website?
Message-Id: <3ACB898C.30377430@uchicago.edu>

Todd Smith wrote:
> 
> I'm writing a program that plays Lycos Gamesville bingo online for me. The
> url that the game
> starts off with, which I need to send and get back the html so my program
> can see the bingo boards, is very very long.
> 
> I tried "$result = `lynx -dump $url`, but a result never comes back. I've
> tried LWP::UserAgent, but it says the site doesn't allow connections to it's
> HTTP port, and sometimes i just get a "Connection timed out" error.
> 
> So my question is, how does a regular browser connect to a site and get back
> a result so fast, and how can I do it the same way?

CHEATER!


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

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 629
**************************************


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