[19389] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1584 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 22 06:05:50 2001

Date: Wed, 22 Aug 2001 03:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998474711-v10-i1584@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 22 Aug 2001     Volume: 10 Number: 1584

Today's topics:
        [Q] crontab message.... <umatrix@hanmail.net>
    Re: [Q] crontab message.... <Tassilo.Parseval@post.rwth-aachen.de>
        Bug with -X operator and *foo{IO} ? <goldbb2@earthlink.net>
    Re: Calling several '.bat' files from ActivePerl <bcaligari@fireforged.com>
    Re: Calling several '.bat' files from ActivePerl <philippe.perrin@sxb.bsf.alcatel.fr>
        CGI redirect <guymal@__NOSPAM__hotmail.com>
    Re: CGI redirect <mbudash@sonic.net>
    Re: Comma's at end of list can break program?? <goldbb2@earthlink.net>
    Re: Embedded perl question <goldbb2@earthlink.net>
    Re: embedding perl in java (Charles DeRykus)
    Re: For loop iterator variable not working correctly?? (Anno Siegel)
    Re: For loop iterator variable not working correctly?? (Anno Siegel)
    Re: Format error?? (Damian Conway)
    Re: Help w/grep (Ian Boreham)
        keyboardstatus <martin@ppmedia.at>
    Re: keyboardstatus (Rafael Garcia-Suarez)
    Re: Last index of array referenced in a scalar?? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Last index of array referenced in a scalar?? <miscellaneousemail@yahoo.com>
    Re: Last index of array referenced in a scalar?? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Last index of array referenced in a scalar?? (Eric Bohlman)
    Re: Microsoft Perl <paul@net366.com>
        mod_perl problems - core dump using Socket or IO:Socket <stephen.wylie@xko.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Aug 2001 13:28:53 +0900
From: "hyunyoung lee" <umatrix@hanmail.net>
Subject: [Q] crontab message....
Message-Id: <9lvbss$sul$1@hiline.shinbiro.com>

i maked a test.pl
[perl script].

and the test.pl is regularly executed by cron.

but following message is mailed by cron.

PLZ, help me..
------------------------------------------
cron message
------------------------------------------
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LC_ALL = (unset),
        LC__FASTMSG = "true",
        LC_MESSAGES = "C@lft",
        LANG = "ko_KR"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").


*************************************************
Cron: The previous message is the standard output
      and standard error of one of your cron commands.





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

Date: Wed, 22 Aug 2001 09:14:47 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: [Q] crontab message....
Message-Id: <3B835BE7.3090703@post.rwth-aachen.de>

hyunyoung lee wrote:
> i maked a test.pl
> [perl script].
> 
> and the test.pl is regularly executed by cron.
> 
> but following message is mailed by cron.
> 
> PLZ, help me..
> ------------------------------------------
> cron message
> ------------------------------------------
> perl: warning: Setting locale failed.
> perl: warning: Please check that your locale settings:
>         LC_ALL = (unset),
>         LC__FASTMSG = "true",
>         LC_MESSAGES = "C@lft",
>         LANG = "ko_KR"
>     are supported and installed on your system.
> perl: warning: Falling back to the standard locale ("C").

This is in fact not a Perl-problem. It has something to do with your 
locale-package that is obviously screwed up. Try running 'locale' on the 
console and verify the output. Especially 'LC_MESSAGE' = "C@lft"' looks odd.

Have a look at /etc/locale.gen. Uncomment a few lines there for testing 
purpose and run (as root) locale-gen to generate the locales defined 
there. Then try exporting LC_ALL="ko_KR" or so on your console and run 
the script again till you found your settings.

Anyway, nothing to do with Perl.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Wed, 22 Aug 2001 03:40:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Bug with -X operator and *foo{IO} ?
Message-Id: <3B8361E4.EA60606E@earthlink.net>

I'm not sure if this is a bug:

$ perl -e 'print 0+-t *STDIN{IO},"\n"'
0
$ perl -e 'print 0+-t *STDIN,"\n"'
1

I would think that the first would also print 1, but it does not.

-- 
$u=q{M``````````#@1<['"3E?]!TDB@C1*"*B("&10?A*$?%]%8D8PI>*B.B;1!01
}. q{MHEA$1$$9'(<0A1PB^A(``````````/!\)X@<)WUG@"A(011%)4@#1%\)OB\9
}. q{<7QG@^480?<'XQ@!!4((HBDI0``B^]$21D[XT````};$j=unpack("u",$u);
for(0..938){print vec($j,$_,1)?"8":" ";print"\n"unless(($_+1)%67)}


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

Date: Wed, 22 Aug 2001 06:57:57 -0000
From: "Brendon Caligari" <bcaligari@fireforged.com>
Subject: Re: Calling several '.bat' files from ActivePerl
Message-Id: <9lvdp20edf@enews4.newsguy.com>


> I'm trying to call several '.bat' files from a perl script. Most of
> the '.bat' files run conginuously (they never end until ctrl-c). How
> can I call a series of '.bat' files, some of which end and some
> of which do not end?
>

you can try system() and the windows/dos 'start'
This works for me on Win2k pro.
Try "start /?" at your windows command prompt.


---------------
D:\test>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]
 .
 .
--------------

print "hello\n";
system("start cmd /c one.bat");
system("start cmd /c two.bat");
print "goodbye\n";

Doing just a
    system("start one.bat");
will not close the DOS window once one.bat terminates

B






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

Date: Wed, 22 Aug 2001 09:13:25 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: Calling several '.bat' files from ActivePerl
Message-Id: <3B835B95.A523FDDD@sxb.bsf.alcatel.fr>

70262.1046@compuserve.com wrote:
> I'm trying to call several '.bat' files from a perl script. Most of
> the '.bat' files run conginuously (they never end until ctrl-c). How
> can I call a series of '.bat' files, some of which end and some
> of which do not end?

Not really an answer, but... why using .bat files and not perl scripts ?

-- 
PhP

($r1,$r2,$r3,$r4)=("19|20","0|1","28|29","5|24");($r5,$r6)=("9|10|15|16|$r1|$r2","9|10|$r3");%h=("1|",$r6,"1=","[1-5]|2[0-4]","1/","0|19","1\\","6|25","2|","0|6|19|25|$r6","2/","1|20","2\\",$r4,"3|","$r2|6|$r1|25|$r6","3/",$r4,"4|","$r2|$r1|$r6","4=","2|3|4|11|12|13|14|21|22|23","4/",$r4,"4\\",15,"5|","$r2|9|15|$r1|20|$r3","5/",10,"6|",$r5,"7|",$r5,"7/",$r3);for($l=1;$l<8;$l++){b:for($i=0;$i<30;$i++){c:foreach(keys
%h){next c if(!(/^$l(.*)$/));$a=$1;if($i=~/^($h{$_})$/){print $a;next
b;}}print " ";}print "\n";}


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

Date: Wed, 22 Aug 2001 07:05:10 +0200
From: "Guy" <guymal@__NOSPAM__hotmail.com>
Subject: CGI redirect
Message-Id: <3b832ff4@news.barak.net.il>

How can I redirect to a url, using POST, and pass it some parameters?

I'm using CGI.pm to open a saved query:
open(OLD_Q,"$saved_query_path")|| die "Error: $! in file: ".__FILE__." line:
".__LINE__."Cannot open saved query $saved_query_path \n";
  my $old_query=new CGI(OLD_Q);
close(OLD_Q);

and I would like to redirect to a url as if the user submitted a form (the
parameters from the saved query) to the new url:

print $old_query->redirect("http://my-server.com/cgi-bin/a-script.pl"); #but
I need to pass all saved parameters using POST

What I basically need is how to do something like this:
my $one=$old_query->param('param_1');
my $two=$old_query->param('param_2');
print
$old_query->redirect("http://my-server.com/cgi-bin/a-script.pl?param_1=$one&
param_2=$two....");

but using POST.

TIA,
Guy

_______________
Remove the __NOSPAM__ in order to reply to my e-mail.




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

Date: Wed, 22 Aug 2001 06:48:50 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: CGI redirect
Message-Id: <mbudash-C673C4.23485221082001@news.sonic.net>

In article <3b832ff4@news.barak.net.il>, "Guy" 
<guymal@__NOSPAM__hotmail.com> wrote:

> How can I redirect to a url, using POST, and pass it some parameters?
> 
> I'm using CGI.pm to open a saved query:
> open(OLD_Q,"$saved_query_path")|| die "Error: $! in file: ".__FILE__." 
> line:
> ".__LINE__."Cannot open saved query $saved_query_path \n";
>   my $old_query=new CGI(OLD_Q);
> close(OLD_Q);
> 
> and I would like to redirect to a url as if the user submitted a form 
> (the
> parameters from the saved query) to the new url:
> 
> print $old_query->redirect("http://my-server.com/cgi-bin/a-script.pl"); 
> #but
> I need to pass all saved parameters using POST
> 
> What I basically need is how to do something like this:
> my $one=$old_query->param('param_1');
> my $two=$old_query->param('param_2');
> print
> $old_query->redirect("http://my-server.com/cgi-bin/a-script.pl?param_1=$on
> e&
> param_2=$two....");
> 
> but using POST.

use the LWP perl module (which can be found at 
http://www.perl.com/CPAN-local/modules/by-module/LWP/ as libwww-perl)

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Wed, 22 Aug 2001 01:06:06 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Comma's at end of list can break program??
Message-Id: <3B833DBE.D4F308FE@earthlink.net>

Uri Guttman wrote:
[snip]
> if you heeded tom's advice here (and most others concur with it), the
> last list entry would have a , after it. a comma is needed between
> every pair of items in a list but with perl it is ok to put a
> superfluous comma after the last item.in many languages, the extra
> comma there is actually illegal. so by always ending the last element
> with a comma, you don't have to worry as much about noticing if a
> comma is missing when editing the list.

Although this isn't really related to defensive programming, there are
occasions when you want to write code which generates code, and perl's
allowing an extra comma makes life easier.  In these cases, particularly
in writing the contents of a list with a for or while loop, it is *much*
simpler to simply print a comma after every item, than to have to check
whether this is the last item to see if you need a comma.

eg:
print "my \@list = (\n";
print "\t$_,\n" while defined $_ = gen_next_item;
print ");\n";

If perl didn't allow the extra comma at the end of the list, this would
have to be something like:

print "my \@list = (\n";
if( defined $_ = gen_next_item ) {
	print "\t$_";
	print ",\n\t$_" while defined $_ = gen_next_item;
	print "\n";
}
print ");\n";

Which is less clear and less pretty.

-- 
I'm not a programmer but I play one on TV...


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

Date: Wed, 22 Aug 2001 04:35:41 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Embedded perl question
Message-Id: <3B836EDD.3715B334@earthlink.net>

Robert J. Lee wrote:
> 
> Benjamin Goldberg wrote:
> > Robert J. Lee wrote:
> > > Benjamin Goldberg wrote:
> > > > Robert J. Lee wrote:
> > > > >
> [snip]
> 
> [snip of confusing bit where I got confused between subroutines and
> functions]

Eh?  subs and functions are the same... It's getting confused between
data and subs/functions which causes problems.

> > I'm not sure what you mean.  If a variable is successfully restored
> > by whatever mechanism reads it from the file, then there's no need
> > for it to be re-initialized.  Why do you assume that it would be
> > 'initialized' when it doesn't need to be?
> 
> Okay; that wasn't very clear. If the programmer says something like:
> 
> $my_variable = 14;
> 
> to set the initial value of $my_variable, then every time that line is
> processed, it will set the value of $my_variable to 14, even if it has
> changed. This could cause problems if that line lies in a block of
> code which is read in and processed every time the MUD is started. (As
> the MUD is supposed to assume the same state when it starts as it had
> when it last ended). This problem goes away when you override it by
> loading the variable from a file, but that means working out which
> variables to save and load in the first place.

"Doctor, it hurts when I do this."

Solution: Don't do that.

Don't put in files things like "$my_variable = 14", just put in
subroutines and variable declarations.  The only assignments should be
*within* your subroutines.  Allow within each file an sub named "init"
which takes a 1/0 parameter determining if the file is being called at
mud reboot, or if it's being called due to the script being loaded for
the first time ever.  It does an if/then, and either gives the
persistant variables their first ever values, or else it restores the
persistant variables from a file.

> [snip]
> > There's an easier way.  Just *ask* your authors which variables need
> > to be made persistant.  Use packages to keep namespaces seperate,
> > and when each function is completed, print to the author a list of
> > already-persistant variables, and ask if there are any variables
> > used by the function which should be persistant but aren't.
> 
> Keeping an editable list of the names of all data to be saved is easy
> enough.
>
> > > > What are you adding scripting for?[snip]
> > >
> > > The idea is that administrators of the MUD can write subroutines
> > > to control how the mud operates (every time someone does
> > > something, a perl subroutine is called that checks if any others
> > > need to be called to change anything in the MUD). That way,
> > > administrators can control exactly what the MUD does in any
> > > situation without learning C++, writing lots of messy code and
> > > shutting the MUD down to recompile, and without needing direct
> > > access to the server to recompile everything.
> > > Thus leaving me free to focus on implementing more C++ things.
> >
> > If you require that the admins put their code in packages [or better
> > yet, have the editor prefix their code with appropriate package
> > declarations], you should be able to do this without needing any
> > special "save everything" module.
> 
> Saving the code itself isn't too much of a problem; just put in a
> filter in the C++ side to say "save anything typed in in 'perl mode'
> to a file". My problem was that I didn't see how to cope with
> variables being changed in 'perl mode'. But with a list of variables
> to be saved, this shouldn't be too much of a problem.
> 
> > > > Anyway, do you really expect that the perl code you had before a
> > > > compile will work well with everything after a recompile?  I
> > > > don't think so.
> > >
> > > I don't know. I would have thought that as long as the perl side
> > > stays the same, and it doesn't use any callbacks into C++ code,
> > > that recompiling the C++ side shouldn't make any difference.
> > > Wether it would work after being reloaded into memory, I have no
> > > idea (pointers to memory areas that have moved etc.). If it *can*
> > > be done, then I'm sure someone here will know how...
> >
> > The thing is, there obviously have to be some callbacks to the C++
> > for the perl code to do anything useful.
> 
> Not necessarily. The C++ code can just look directly at the state of
> the perl code and see what's changed after calling a perl function (if
> all variables are in perl, there's no reason for the C++ code to even
> know anything more than "this is the text to give to user number 3").
> But it might be easier if it did use callbacks.
> 
> > > > Any bits of perl code you need should probably be put each in
> > > > their own file, and loaded from those files when the MUD starts
> > > > [or better yet, only when they're needed].  Saving the state
> > > > that the loaded pieces of code were in when the mud was last up
> > > > is probably wrong.
> > >
> > > Except if their state has changed since they were put each in
> > > their own file. Which is very likely in this case.
> >
> > I think you're confusing data with code.  You put the code [the
> > subroutines] into files when it's written.  You put the data into
> > files once when it's created [by the subroutines], plus every X
> > minutes as backup, and once when the mud shuts down.
> >
> > The code [the subroutines] is initially in files, it gets loaded
> > when users first enter the part of the mud it's relevant to [or
> > loaded when the mud boots up], the BEGIN blocks in the code are
> > called, which register various callbacks and load the data from the
> > files, and registers the data with some sort of backup mechanism. 
> > The callbacks do whatever special behaviour the admins need.
> 
> Code is just data treated in a special way :)
> 
> Only thing I don't understand is how exactly one says "save this datum
> to a file when it gets created"?

use vars ($persista, $persistb);
sub initialize {
	my $is_mud_rebooting = shift @_;
	if( $is_mud_rebooting ) {
		MudPersist->restoreme(\$persista, \$persistb);
	} else {
		$persista = 42;
		$persistb = 7;
		MudPersist->saveme(\$persista, \$persistb);
	}
}

sub shutdown {
	MudPersist->saveme(\$persista, \$persistb);
}

Or, if you are using an editable list of what variables should be
persistant, you could simply compare the old list and the new one
whenever the list is changed, and whenever something is added to the
list, save it right then.

> Again, there's quite a bit of work in writing the code to
> auto-generate all the save and restore code compared to a complete
> save/restore state option. But I guess this is the next best thing.
> 
> > > It looks like I'll have to save the subroutines as they are
> > > created, and re-load them first on start-up, saving the variables
> > > on shut-down, and re-loading them after subroutines to change
> > > their values back to what they should be. I was hoping that it
> > > could be done more easily than this.
> >
> > This is exactly the way to do it, except that you can write it so
> > don't necessarily need to think about it this way.
> >
> > For instance:
> > package Administorators::AdminName::foo;
> > use MudUtilities::Persistant;
> > MudUtilities::Persistant::MakePersist \( our ($foo, $bar, $blah) )
> >       or do {
> >       $foo = .... initializer for $foo goes here ...;
> >       $bar = ....;
> >       $blah = ....;
> > }
> > ... code which uses $foo, $bar, $blah ...
> > sub asdf {
> > }
> > __END__
> >
> > The thing is, some code in the file gets run when the file is
> > loaded, [including the *definitions* of the subs], but the subs
> > don't actually get called until they're called.  So you can
> > initialize them however you want.  Some of this stuff can be
> > auto-generated, too, to make things easier.  MakePersist can look at
> > caller() to figure out what file called it, and use that to figure
> > out where to put the data [each admin's data should be seperate from
> > each other admin's data, and for that matter, each admin might want
> > each file, each group of subroutines to have seperate data files].
> 
> This still looks to me like quite a complicated solution to a trivial
> problem; I want to add a perl interpretor to a MUD, create new data
> and code on demand, and have the state saved to a file so I can reload
> after a shutdown at the same place as I left off.

The main problem is that you can save data, but you can't save
functions.  So you've got to do two things when the mud reboots --
require/do/eval all of the textfiles which contain code defining the
functions, and you have to restore the data used by those pieces of
code... as two or more seperate steps -- and unfortunaly, the code being
loaded may need the data to be in loaded, and the data may need the code
to be loaded.

> If perl had a "save-everything" and a "load-everything" command then
> it would be a lot easier (since I have a fair amount of disk space to
> throw at it).
> Oh well, it's still easier than writing my own parsing language...

-- 
I'm not a programmer but I play one on TV...


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

Date: Wed, 22 Aug 2001 07:23:20 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: embedding perl in java
Message-Id: <GIGKIw.o0@news.boeing.com>

In article <o20g7.1706$ca2.289477810@newssvr17.news.prodigy.com>,
abdul  bahar <BAHA0011@prodigy.net> wrote:
>Can anyone point me to a good reference or site that has details on how to
>embed perl in java?
>
Do a search on JPL ("Java Perl Lingo") - Larry's cross
compiler which enables you to embed Perl in Java.

I believe  O'Reilly's site still has some of the "Perl
Resource Kit" online which includes a chapter on JPL.

--
Charles DeRykus


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

Date: 22 Aug 2001 09:32:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <9lvu6s$b43$1@mamenchi.zrz.TU-Berlin.DE>

According to Carlos C. Gonzalez  <miscellaneousemail@yahoo.com>:
> Eric Bohlman at ebohlman@omsdev.com said...

> > You want $$new here, not @$new.  I'd actually write it as $new->[0], but 
> > that's a matter of personal preference.
> 
> @$new seems to work fine Eric. ...

More evidence that the DWIMmer is a corrupter of innocent minds.

Anno


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

Date: 22 Aug 2001 09:43:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <9lvus0$b43$2@mamenchi.zrz.TU-Berlin.DE>

According to Tad McClellan <tadmc@augustmail.com>:
> Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:

[...]
 
> If you want real undefs, then you cannot use qw//:
> 
>    my @new = ( 'harry@tiger.net', undef, undef, 'Russia', undef, undef);

 ...or perhaps

    my @new;
    @new[ 0, 3] = qw( harry@tiger.net Russia);

though that doesn't set the length of @new to 6.

Anno


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

Date: 22 Aug 2001 06:15:14 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Format error??
Message-Id: <9lvili$l2n$1@towncrier.cc.monash.edu.au>

tadmc@augustmail.com (Tad McClellan) writes:

>>> formats will be removed from the core in perl6.
>>> The payback you get for learning them is not worth the trouble, IMO.
>>
>>Makes sense.  Now that I know they are being removed in Perl6 I will 
>>definitely get away from using them.

>They will be available as a module in Perl 6, I believe.

Yes, and the module will probably be some evolutionary descendent
of Text::Reform.

Damian


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

Date: 22 Aug 2001 01:48:14 -0700
From: ianb@ot.com.au (Ian Boreham)
Subject: Re: Help w/grep
Message-Id: <f02c4576.0108220048.2d019cac@posting.google.com>

gnari <gnarinn@hotmail.com> wrote in message news:<998418421.259762815665454.gnarinn@hotmail.com>...
> In article <3B7AA3DC.4D001409@cca-int.com>, jlm  <jlm@cca-int.com> wrote:
> >I wrote a search engine in perl/cgi for our web site that searches for
> >files containing user supplied text string.
> >@farr = `find $dir -type f -exec grep -il $text {} \\;`;
> 
> 
> i usually just pipe the output to another grep process:
> 
>   grep foo pod/*.pod | grep bar

This will only find files with those two strings on the same line.

I'm not much of a shell hacker (hey, this is a perl list...), but you
could do something like:

 find $dir -type f | xargs grep -il $text1 | xargs grep -il $text2

A better (shell) solution would be to group the two greps within the
-exec, but the curly braces make that difficult (at least, for me).

Otherwise, populate @farr using perl to join multiple greps, or open
the files and simulate grep in perl (and I wouldn't use perl's grep to
do that - that would require you to read in the whole of each file
first) by matching patterns against each line.

Bear in mind also that if you use grep or line-based pattern matching
on text files that you will miss some potential matches (when phrases
are broken over lines).

Regards,


Ian


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

Date: Wed, 22 Aug 2001 11:25:35 +0200
From: Martin <martin@ppmedia.at>
Subject: keyboardstatus
Message-Id: <3B837A8F.ED48AC73@ppmedia.at>

i want to read a character from keyboard in a shellscript but without
strike enter but ??

2. how can i print on screen in color under linux?


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

Date: 22 Aug 2001 09:34:46 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: keyboardstatus
Message-Id: <slrn9o6vg4.jlh.rgarciasuarez@rafael.kazibao.net>

Martin wrote in comp.lang.perl.misc:
} i want to read a character from keyboard in a shellscript but without
} strike enter but ??
} 
} 2. how can i print on screen in color under linux?

Search the FAQ before you post :

    perldoc -q keyboard
    perldoc -q color

gives you the answers to your questions (use Term::ReadKey and
Term::ANSIColor).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 22 Aug 2001 08:55:38 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <3B83576A.5090308@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:

> Can you clarify for me how to use the $new->[-1] method to get the last 
> index value?  I have tried "$#new->[-1]", "$#{$new->[-1]}" and some 
> others without any success.  

Ah, sorry, my fault. I did not read carefully. Indeed, for retrieving 
the last index-value you have to use either $#$ref or, if you like it 
perhaps slightly clearer, "scalar @{$ref} - 1".
If you often work with array-refs, you could always set up a 
sub-routine, that does the job:

sub lidx {
	return $#_       if @_ > 1; # called with an array
	return $#{$_[0]} if @_ == 1 && ref $_[0] eq 'ARRAY';
			            # called with an array-ref
}

Not sure whether the above catches all possible cases, but if you either 
call it with an array or an array-ref as the only parameters, this 
should work.
	
	
Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Wed, 22 Aug 2001 07:00:00 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <MPG.15ed062c5ed82fdc989789@news.edmonton.telusplanet.net>

Tad McClellan at tadmc@augustmail.com said...

> Or, better yet, a LoH:
> 
> my @data = (
>  { address => 'jack@ardvark.com', 
>    name    => 'Jack',
>    date    => '020010812 18:34', 
>    country => 'Canada', 
>    city    => 'Kissimee', 
>    wanna   =>'Yes'},
>  { ... },
> );

This is an interesting construct Tad.  I think I see what you are doing 
and I know in concept that arrays can normally hold references to other 
objects but I don't ever recall seeing an example of this.  Until 
yours.  It looks like you are setting the elements of an array to hold 
references to anonymous hashes.  I will have to study possible uses of 
this too.  

I'll tell you one thing.  Perl sure seems to have a lot of depth to it.  
That's a good thing.  

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so please don't 
subscribe.  Thanks.


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

Date: Wed, 22 Aug 2001 09:27:26 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <3B835EDE.2030802@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:

> This is an interesting construct Tad.  I think I see what you are doing 
> and I know in concept that arrays can normally hold references to other 
> objects but I don't ever recall seeing an example of this.  Until 
> yours.  It looks like you are setting the elements of an array to hold 
> references to anonymous hashes.  I will have to study possible uses of 
> this too.  

Yes, much so indeed. Get yourself some pots of steaming coffee and read 
perldsc.pod from beginning to end and then again. A delightful lectures. ;-)

Keep in mind that suitable data-structures will dramatically ease your 
approach to proper and easily maintainable algorithms as well.

And think of this: If you ever wished to have variables with dynamic 
names (such as the name coming from the value of another variable), then 
you did something wrong. You didn't yet ask about it here but you might 
have thought about it already. That is EVIL. ;-)


Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 22 Aug 2001 08:24:46 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <9lvq8e$t4g$2@bob.news.rcn.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
> Tad McClellan at tadmc@augustmail.com said...

>> Or, better yet, a LoH:
>> 
>> my @data = (
>>  { address => 'jack@ardvark.com', 
>>    name    => 'Jack',
>>    date    => '020010812 18:34', 
>>    country => 'Canada', 
>>    city    => 'Kissimee', 
>>    wanna   =>'Yes'},
>>  { ... },
>> );

> This is an interesting construct Tad.  I think I see what you are doing 
> and I know in concept that arrays can normally hold references to other 
> objects but I don't ever recall seeing an example of this.  Until 
> yours.  It looks like you are setting the elements of an array to hold 
> references to anonymous hashes.  I will have to study possible uses of 
> this too.  

That's exactly what he's doing.  It's Perl's idiom for an array of 
"records" or "structs."  The perllol document describes this, and other 
uses of nested data structures, in great detail.


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

Date: Wed, 22 Aug 2001 09:23:26 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: Microsoft Perl
Message-Id: <998468530.17953.0.nnrp-01.d4f094e4@news.demon.co.uk>


"Phil Hibbs" <phil.hibbs@capgemini.co.uk> wrote in message
news:153e25f0.0108210710.549d1926@posting.google.com...
> Is anyone familiar with this version of perl? I have to get to know
> and love it, because it's installed on a customer site.
>
> Phil.

I think your customer would love you forever if you deleted it and installed
ActivePerl :)





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

Date: Wed, 22 Aug 2001 10:45:33 +0100
From: "Stephen Wylie" <stephen.wylie@xko.co.uk>
Subject: mod_perl problems - core dump using Socket or IO:Socket in startup.pl
Message-Id: <3b837e2f$1$8506$cc9e4d1f@news.dial.pipex.com>

I am trying to use binary distros of Apache, mod_perl and Perl supplied by
IBM and Bull for the AIX platform. Unfortunately they aren't all singing
from the same hymn sheet. The Bull mod_perl wouldn't go in unless I
installed their Perl 5.6, which wouldn't go in unless I installed IBM's Perl
5.005003. I glued them together using symbolic links. (I know, I know, but
it's very difficult to compile Perl for AIX).

Oddly, the Bull mod_perl stuff installed itself round the IBM Perl 5.005003
distro and ignored their 5.6 libraries. If I try to use a non-existent
module in my mod_perl startup.pl the diagnostics show that @INC is ignoring
the 5.6.1 library tree. The actual Perl binary on the machine is the 5.6
one, which the mod_perl package insisted on. If I try to use Socket in my
startup, I get a core dump on starting Apache, which I am guessing is due to
a version problem. Can I manipulate the mod_perl @INC? What controls the
actual perl binary used by mod_perl? Any ideas?

TIA
Steve




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

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


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