[33147] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4426 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 4 11:09:19 2015

Date: Mon, 4 May 2015 08:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 4 May 2015     Volume: 11 Number: 4426

Today's topics:
    Re: Backticks status in scalar context: bug or missunde <rweikusat@mobileactivedefense.com>
    Re: Backticks status in scalar context: bug or missunde <ams@luminous.ludd.ltu.se>
        Cannot pass an argument to expect script from my perl s <soorajspadmanabhan@gmail.com>
    Re: Cannot pass an argument to expect script from my pe <bauhaus@futureapps.invalid>
    Re: Cannot pass an argument to expect script from my pe nikhilclt87@gmail.com
    Re: Cannot pass an argument to expect script from my pe soorajspadmanabhan@gmail.com
    Re: Cannot pass an argument to expect script from my pe soorajspadmanabhan@gmail.com
    Re: Cannot pass an argument to expect script from my pe <bauhaus@futureapps.invalid>
        custom 'multigrep' <fillmore_remove@hotmail.com>
    Re: custom 'multigrep' <jurgenex@hotmail.com>
    Re: custom 'multigrep' <ben.usenet@bsb.me.uk>
    Re: custom 'multigrep' <jurgenex@hotmail.com>
    Re: custom 'multigrep' <fillmore_remove@hotmail.com>
    Re: custom 'multigrep' <derykus@gmail.com>
    Re: custom 'multigrep' sharma__r@hotmail.com
    Re: custom 'multigrep' <ben.usenet@bsb.me.uk>
    Re: custom 'multigrep' <fillmore_remove@hotmail.com>
    Re: Folding dirpath into wildcard for fileglob. <news@todbe.com>
    Re: Folding dirpath into wildcard for fileglob. <whynot@pozharski.name>
        mind.pl showing storage and retrieval from memory mentificium@gmail.com
    Re: mind.pl showing storage and retrieval from memory <news@lawshouse.org>
    Re: mind.pl showing storage and retrieval from memory <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 03 May 2015 20:06:58 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Backticks status in scalar context: bug or missunderstanding
Message-Id: <87r3qx1nvx.fsf@doppelsaurus.mobileactivedefense.com>

Martin Str|mberg <ams@ludd.ltu.se> writes:
> Tim McDaniel <tmcd@panix.com> wrote:
>> That said, I agree that it could and should be expressed more
>> precisely:
>
>> "The collected standard output of the command is returned. ... In
>> scalar context, it comes back as a single string, or undef only if the
>> command does not exist and it is executed directly instead of via your
>> system's command shell."
>
>> and maybe copy the text from perlfunc on exec explaining about shell
>> metacharacters.
>
>
> Also some text refering to $@ would perhaps triggered a rethink about
> undef. Something like last in the first paragraph (on qx/STRING/ in
> perlop):
>
> To get the exit status of the command, check the variable $@.
>
> As far as I can see there is no reference to that variable at all in
> that text.

Considering that $@ is the special variable holding an exception trapped
by eval while the exit status variable is $?, why should the text
mention the former?

[rw@doppelsaurus]~#perl -e 'print qx(ls /; exit 1); print("\$@ ", $@, " \$? ",$?, "\n")' 
bin
boot
data
dev
etc
home
initrd.img
lib
lib32
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
selinux
srv
sys
tmp
usr
var
vmlinuz
$@  $? 256


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

Date: Mon, 4 May 2015 05:25:39 +0000 (UTC)
From: Martin Str|mberg <ams@luminous.ludd.ltu.se>
Subject: Re: Backticks status in scalar context: bug or missunderstanding
Message-Id: <mi6vsh$s2c$1@speranza.aioe.org>

Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> Martin Str|mberg <ams@ludd.ltu.se> writes:
> > Also some text refering to $@ would perhaps triggered a rethink about
> > undef. Something like last in the first paragraph (on qx/STRING/ in
> > perlop):
> >
> > To get the exit status of the command, check the variable $@.
> >
> > As far as I can see there is no reference to that variable at all in
> > that text.

> Considering that $@ is the special variable holding an exception trapped
> by eval while the exit status variable is $?, why should the text
> mention the former?

Indeed. I meant $?.


-- 
MartinS


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

Date: Mon, 4 May 2015 03:21:30 -0700 (PDT)
From: emagnun <soorajspadmanabhan@gmail.com>
Subject: Cannot pass an argument to expect script from my perl script
Message-Id: <bf79c9de-0201-4c52-8504-f95c7012d278@googlegroups.com>

I wrote such a simple perl code to pass a command to an expect script. I don't find anything wrong in this but I don't know why the heck this is not working.

myScript.pl
=============
#!/usr/bin/perl
my $script = "/root/alex/myScript.expect";
my $cmd = "hello";
print "\nEXECUTE: #$script $cmd#\n";
system($script $cmd);

myScript.expect
================
#!/usr/bin/expect -f
set cmd [lindex $argv 0]
puts "COMMAND: #$cmd#\n"

When I execute myScript.pl, myScript.expect script doesn't receive the command.

[root@localhost alex]# /root/alex/myScript.pl

EXECUTE: #/root/alex/myScript.expect hello#
COMMAND: ##

But when I execute the above command directly, its getting executed fine.
[root@localhost alex]# /root/alex/myScript.expect hello
COMMAND: #hello#

What is wrong with my perl code. This is disturbing. Please help me out.


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

Date: Mon, 04 May 2015 13:31:10 +0200
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: Cannot pass an argument to expect script from my perl script
Message-Id: <mi7l7v$4fs$1@dont-email.me>

On 04.05.15 12:21, emagnun wrote:
> system($script $cmd);

Try a comma after `$script'.



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

Date: Mon, 4 May 2015 04:49:35 -0700 (PDT)
From: nikhilclt87@gmail.com
Subject: Re: Cannot pass an argument to expect script from my perl script
Message-Id: <20661f95-79fa-4151-b67f-1bb9ba9c0411@googlegroups.com>

On Monday, May 4, 2015 at 7:31:13 PM UTC+8, G.B. wrote:
> On 04.05.15 12:21, emagnun wrote:
> > system($script $cmd);
> 
> Try a comma after `$script'.

Thanks G.B. for the reply. I will give a try tomorrow as I don't have access to the server now. 

I din't actually understand your logic. This is the way I've wrote the program many times and they were all fine. The command is the argument to the script. If I put "," the whole idea is changed right? Could you please let me know what does "," do here? 


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

Date: Mon, 4 May 2015 04:53:37 -0700 (PDT)
From: soorajspadmanabhan@gmail.com
Subject: Re: Cannot pass an argument to expect script from my perl script
Message-Id: <9810221b-507f-4457-b70c-a1d8606653b5@googlegroups.com>

On Monday, May 4, 2015 at 7:31:13 PM UTC+8, G.B. wrote:
> On 04.05.15 12:21, emagnun wrote:
> > system($script $cmd);
> 
> Try a comma after `$script'.

Thanks G.B for the reply. I will give a try tomorrow as my access is closed for the day. 

By the way, command is an argument to the script. So I did not quite understand the idea of putting a comma there. Could you please let me know more.


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

Date: Mon, 4 May 2015 04:57:13 -0700 (PDT)
From: soorajspadmanabhan@gmail.com
Subject: Re: Cannot pass an argument to expect script from my perl script
Message-Id: <08600a84-a625-4dbc-92b9-2a8e402262c9@googlegroups.com>

On Monday, May 4, 2015 at 6:21:38 PM UTC+8, emagnun wrote:
> I wrote such a simple perl code to pass a command to an expect script. I don't find anything wrong in this but I don't know why the heck this is not working.
> 
> myScript.pl
> =============
> #!/usr/bin/perl
> my $script = "/root/alex/myScript.expect";
> my $cmd = "hello";
> print "\nEXECUTE: #$script $cmd#\n";
> system($script $cmd);
> 
> myScript.expect
> ================
> #!/usr/bin/expect -f
> set cmd [lindex $argv 0]
> puts "COMMAND: #$cmd#\n"
> 
> When I execute myScript.pl, myScript.expect script doesn't receive the command.
> 
> [root@localhost alex]# /root/alex/myScript.pl
> 
> EXECUTE: #/root/alex/myScript.expect hello#
> COMMAND: ##
> 
> But when I execute the above command directly, its getting executed fine.
> [root@localhost alex]# /root/alex/myScript.expect hello
> COMMAND: #hello#
> 
> What is wrong with my perl code. This is disturbing. Please help me out.

I got the answer by the way. I was so stupid. I had to put double quotes inside the system call ike this: system("$script $cmd");

My Bad!!


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

Date: Mon, 04 May 2015 14:57:58 +0200
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: Cannot pass an argument to expect script from my perl script
Message-Id: <mi7qan$man$1@dont-email.me>

On 04.05.15 13:57, soorajspadmanabhan@gmail.com wrote:
> I had to put double quotes inside the system call ike this: system("$script $cmd");

That's one way. Be sure to check the differences between
passing a string and passing program + list of arguments.
See

$ perldoc -f system




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

Date: Sun, 03 May 2015 20:13:50 -0400
From: Fillmore <fillmore_remove@hotmail.com>
Subject: custom 'multigrep'
Message-Id: <mi6dju$pj5$2@speranza.aioe.org>

Hi,

here is what I am aiming for:

#./mymultigrep.pl <file> key1 key2 ....keyN

where the number of keys is up to the use to decide.

<file> would be a text file of ASCII lines


What I need is that each line gets selected iff:

$line =~ /$key1/ && $line =~ /$key2/ && $line =~ /$keyN/

the result would be similar to shell commands

#grep key1 <file> | grep key2| .... | grep keyN


I know how to implement this easily with a fixed number of Keys, but the 
varying number of keys is confusing me.

The next step is to allow the '!keyN' syntax to allow users to negate 
the presence of a substring/token/regexp (think grep -v)

Is there a RegExp way to match a string that does not match a token? hmmmm

Thanks

Fillmore


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

Date: Sun, 03 May 2015 19:11:52 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: custom 'multigrep'
Message-Id: <bvkdkap5akput6t6th3hn18pgcfjs4kcdj@4ax.com>

Fillmore <fillmore_remove@hotmail.com> wrote:
>here is what I am aiming for:
>#./mymultigrep.pl <file> key1 key2 ....keyN
>where the number of keys is up to the use to decide.
><file> would be a text file of ASCII lines
>
>What I need is that each line gets selected iff:
>$line =~ /$key1/ && $line =~ /$key2/ && $line =~ /$keyN/
>the result would be similar to shell commands
>
>#grep key1 <file> | grep key2| .... | grep keyN

Then why don't you do exactly that?
Unless your file is truly humongous just read the content into a
variable and then while() there is still a command line argument left
just grep() the matching lines and store them back into the variable.

>I know how to implement this easily with a fixed number of Keys, but the 
>varying number of keys is confusing me.

Use a loop, Luke.

>Is there a RegExp way to match a string that does not match a token?

Not directly. But in grep() you can simply negate the expression.

jue


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

Date: Mon, 04 May 2015 03:22:13 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: custom 'multigrep'
Message-Id: <87a8xlf5ey.fsf@bsb.me.uk>

Fillmore <fillmore_remove@hotmail.com> writes:

> here is what I am aiming for:
>
> #./mymultigrep.pl <file> key1 key2 ....keyN
>
> where the number of keys is up to the use to decide.
>
> <file> would be a text file of ASCII lines
>
>
> What I need is that each line gets selected iff:
>
> $line =~ /$key1/ && $line =~ /$key2/ && $line =~ /$keyN/
>
> the result would be similar to shell commands
>
> #grep key1 <file> | grep key2| .... | grep keyN
>
>
> I know how to implement this easily with a fixed number of Keys, but
> the varying number of keys is confusing me.
>
> The next step is to allow the '!keyN' syntax to allow users to negate
> the presence of a substring/token/regexp (think grep -v)
>
> Is there a RegExp way to match a string that does not match a token?
> hmmmm

You might want to consider building complex "matcher" functions from
simpler ones like this:

  sub mk_true
  {
      return sub { return 1; };
  }

  sub mk_re_match
  {
      my ($re) = @_;
      return sub { $_[0] =~ qr/$re/; };
  }
   
  sub mk_and
  {
      my ($mf1, $mf2) = @_;
      return sub { return &$mf1($_[0]) && &$mf2($_[0]); }
  }
   
  sub mk_not
  {
      my ($mf) = @_;
      return sub { return !&$mf($_[0]); };
  }
   
You'd process the argument list like this:

  my $mf = mk_true;
  foreach (@ARGV) {
      /^(!?)(.*)/;
      my $f = mk_re_match($2);
      $f = mk_not($f) if $1 eq '!';
      $mf = mk_and($mf, $f);
  }

and print lines like this:

  while (<STDIN>) {
      print if &$mf($_)
  }

It might be overkill, but you can build arbitrarily complex match
expressions this way.

-- 
Ben.


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

Date: Sun, 03 May 2015 19:26:38 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: custom 'multigrep'
Message-Id: <q4mdkapfduhip7sts4eoqi8bi1o16d8o56@4ax.com>

Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>It might be overkill, but you can build arbitrarily complex match
>expressions this way.

You are aware that grep() supports arbitrary expression, aren't you?

jue


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

Date: Sun, 03 May 2015 22:48:43 -0400
From: Fillmore <fillmore_remove@hotmail.com>
Subject: Re: custom 'multigrep'
Message-Id: <mi6mma$c8l$1@speranza.aioe.org>


Thank you, Jurgen. I think I'll follow your advice and use a loop


On 05/03/2015 10:11 PM, Jürgen Exner wrote:
> Fillmore <fillmore_remove@hotmail.com> wrote:
>> here is what I am aiming for:
>> #./mymultigrep.pl <file> key1 key2 ....keyN
>> where the number of keys is up to the use to decide.
>> <file> would be a text file of ASCII lines
>>
>> What I need is that each line gets selected iff:
>> $line =~ /$key1/ && $line =~ /$key2/ && $line =~ /$keyN/
>> the result would be similar to shell commands
>>
>> #grep key1 <file> | grep key2| .... | grep keyN
>
> Then why don't you do exactly that?
> Unless your file is truly humongous just read the content into a
> variable and then while() there is still a command line argument left
> just grep() the matching lines and store them back into the variable.
>
>> I know how to implement this easily with a fixed number of Keys, but the
>> varying number of keys is confusing me.
>
> Use a loop, Luke.
>
>> Is there a RegExp way to match a string that does not match a token?
>
> Not directly. But in grep() you can simply negate the expression.
>
> jue
>



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

Date: Sun, 3 May 2015 20:15:16 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: custom 'multigrep'
Message-Id: <bf11c5c7-e25e-4ecc-9a1e-7913778de106@googlegroups.com>

On Sunday, May 3, 2015 at 5:13:53 PM UTC-7, Fillmore wrote:
> Hi,
> 
> here is what I am aiming for:
> 
> #./mymultigrep.pl <file> key1 key2 ....keyN
> 
> where the number of keys is up to the use to decide.
> 
> <file> would be a text file of ASCII lines
> 
> 
> What I need is that each line gets selected iff:
> 
> $line =~ /$key1/ && $line =~ /$key2/ && $line =~ /$keyN/
> 
> the result would be similar to shell commands
> 
> #grep key1 <file> | grep key2| .... | grep keyN
> 
> 
> I know how to implement this easily with a fixed number of Keys, but the 
> varying number of keys is confusing me.
> 
> The next step is to allow the '!keyN' syntax to allow users to negate 
> the presence of a substring/token/regexp (think grep -v)
> 
> Is there a RegExp way to match a string that does not match a token? hmmmm


Although glacially slow, perhaps some variant of the look-ahead, eg,

$re .= "(?=.*$_)" for @ARGV;

say "matched" if $line =~ /$re/;  

-- 
Charles DeRykus





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

Date: Sun, 3 May 2015 22:58:15 -0700 (PDT)
From: sharma__r@hotmail.com
Subject: Re: custom 'multigrep'
Message-Id: <c6c28cc7-6f6d-4ce4-a07d-5ae009d8ed0e@googlegroups.com>

On Monday, 4 May 2015 05:43:53 UTC+5:30, Fillmore  wrote:
> Hi,
> 
> here is what I am aiming for:
> 
> #./mymultigrep.pl <file> key1 key2 ....keyN
> 
> where the number of keys is up to the use to decide.
> 
> <file> would be a text file of ASCII lines
> 
> 
> What I need is that each line gets selected iff:
> 
> $line =~ /$key1/ && $line =~ /$key2/ && $line =~ /$keyN/
> 
> the result would be similar to shell commands
> 
> #grep key1 <file> | grep key2| .... | grep keyN
> 
> 
> I know how to implement this easily with a fixed number of Keys, but the 
> varying number of keys is confusing me.
> 
> The next step is to allow the '!keyN' syntax to allow users to negate 
> the presence of a substring/token/regexp (think grep -v)
> 
> Is there a RegExp way to match a string that does not match a token? hmmmm
> 

You can put the List::MoreUtils module to good use for your scenario.
It has functions "all" , "none" which are suitable for use here, e.g.,


# load up perl with strict/warnings & the useful List routines
perl -Mstrict -Mwarnings -MList::MoreUtils="all,none" -lne '

BEGIN{ @::REs = splice @ARGV, 1, @ARGV-1; }

my $L = $_; # put the current line as this $_ gets masked inside the {...}

# print the current only if all the keys are found in it.
print if all { $L =~ /\Q$_\E/ } @::REs;

# print the current line only if none of the keys are found in it.
print if none { $L =~ /\Q$_\E/ } @::REs;

' input_file key1 key2 key3 ... keyN


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

Date: Mon, 04 May 2015 14:04:21 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: custom 'multigrep'
Message-Id: <87twvseboq.fsf@bsb.me.uk>

Jürgen Exner <jurgenex@hotmail.com> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>>It might be overkill, but you can build arbitrarily complex match
>>expressions this way.
>
> You are aware that grep() supports arbitrary expression, aren't you?

Yes, I am.

-- 
Ben.


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

Date: Mon, 04 May 2015 09:37:14 -0400
From: Fillmore <fillmore_remove@hotmail.com>
Subject: Re: custom 'multigrep'
Message-Id: <mi7sm9$5oc$2@speranza.aioe.org>


Thank you. You are obviously very very skilled with Perl


On 05/04/2015 01:58 AM, sharma__r@hotmail.com wrote:
> On Monday, 4 May 2015 05:43:53 UTC+5:30, Fillmore  wrote:
>> Hi,

> # print the current line only if none of the keys are found in it.
> print if none { $L =~ /\Q$_\E/ } @::REs;
>
> ' input_file key1 key2 key3 ... keyN
>



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

Date: Sat, 02 May 2015 17:27:17 -0700
From: "$Bill" <news@todbe.com>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <mi3pvb$h5u$1@dont-email.me>

On 5/2/2015 14:03, gamo wrote:
> El 02/05/15 a las 22:32, $Bill escribió:
>>
>> How does that work with Rainer's test code:  subr(0.0);
>
> I think that good:
>
> $ perl test.def
> 0
> $ cat test.def
> #!/usr/bin/perl -w
>
> print subsr(0.0),"\n";
>
> sub subsr{
>      return shift // '.';
> }

I'd never seen/used that operator before and it took a lot
of searching to find it (possibly it was added after I did
my introductory study back in the days of v4.

A quick search finds it was added in 5.10 - didn't notice
I guess.  I think I will find it useful in the future - thanks
Rainer/Gamo.




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

Date: Sun, 03 May 2015 11:25:56 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <slrnmkbmsk.iil.whynot@orphan.zombinet>

with <mi3c6o$q9p$1@dont-email.me> $Bill wrote:

*SKIP*
> How does that work with Rainer's test code:  subr(0.0);

Now that's odd.  For a long time I believed that in this case PV would
be kept forever, apparently it's not.

	% perl -MDevel::Peek -wle 'Dump 0.0'          
	SV = NV(0x8818868) at 0x8812040
	  REFCNT = 1
	  FLAGS = (PADTMP,NOK,READONLY,pNOK)
	  NV = 0

No matter how many zeros after decimal point:

	% perl -MDevel::Peek -wle 'Dump 0.000000'
	SV = NV(0x83e6868) at 0x83e0048
	  REFCNT = 1
	  FLAGS = (PADTMP,NOK,READONLY,pNOK)
	  NV = 0

Even underscore doesn't help:

	% perl -MDevel::Peek -wle 'Dump 0.000_000'
	SV = NV(0x9845868) at 0x983f048
	  REFCNT = 1
	  FLAGS = (PADTMP,NOK,READONLY,pNOK)
	  NV = 0

Zeros before a decimal point, reading from STDIN and @ARGV are OK
though.  Then must be a compiler thingie.  I've greped through perldata
for hints and didn't found anything.  Where is it discussed in details?

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

Date: Mon, 4 May 2015 00:12:58 -0700 (PDT)
From: mentificium@gmail.com
Subject: mind.pl showing storage and retrieval from memory
Message-Id: <1404344c-f468-413c-968b-7e133b435d69@googlegroups.com>

#!/usr/bin/perl
use strict;     # PERL by Example (2015) p. 77 
use warnings;   # PERL by Example (2015) p. 85 
our $age = 0;   # Temporary age for loop-counting and loop-exit.
our @aud = " "; # PERL by Example (2015) p. 17: auditory array
our $cns = 32;  # size of AI memory for central nervous system.
our $IQ = 0;    # PERL by Example (2015) p. 689 
our $msg = " "; # Variable holds a "message" of input from AudInput.
our $pho = "";  # $pho is for a "phoneme" or character of input.
our $t = 0;     # Lifetime experiential time "$t"
our $t2s = 0;   # auditory text-to-speech index for @aud array
sub AudInput;   # PERL by Example p. 351 Forward declaration 
sub sensorium;  # PERL by Example p. 351 Forward declaration 
sub think;      # PERL by Example p. 351 Forward declaration 
sub VisRecog;   # PERL by Example p. 351 Forward declaration 

TabulaRasa: {   # PERL by Example (2015), p. 204: Labels
  my $trc = 0;  # $trc variable is "tabula rasa counter".
  print "Size of experiential memory is $cns \n";  # Increase as needed. 
  until ($trc == $cns) {  # PERL by Example (2015), p. 193: "Loops".
    $aud[$trc] = " ";     # Fill CNS memory with blank spaces.
    $trc++;       # PERL by Example (2015) p. 21: autoincrement $trc.
  }  # End of loop filling auditory memory with blank engrams.
}  # End of TabulaRasa "clean slate" sequence. 

EnBoot: {  # http://mind.sourceforge.net/enboot.html 
  $t = 0;  # English Bootstrap sequence stretches over mental time "$t". 
  print "English bootstrap is loading into memory... \n"; 
  $t = 0; $aud[$t] = "H";  # Indexing of array begins with zero.
  $t = 1; $aud[$t] = "E";  # Single elements of array use $aud not @aud.
  $t = 2; $aud[$t] = "L";  # PERL by Example (2015), p. 95: Elements
  $t = 3; $aud[$t] = "L";  # AudMem() stores new words at higher $t values.
  $t = 4; $aud[$t] = "O";  # Bootstrap "HELLO" is not permanently here. 
  $t = 5;                  # A blank gap is necessary between words. 
  $t = 6;                  # More bootstrap words will be needed.
};  # http://code.google.com/p/mindforth/wiki/EnBoot

while ($t < $cns) {  # PERL by Example (2015), p. 190 
  $age = $age + 1;   # Increment $age variable with each loop.
  print "\nMain loop cycle ", $age, "  \n";  # Display loop-count.
  sensorium(); # PERL by Example p. 350: () empty parameter list 
  think();     # PERL by Example p. 350: () empty parameter list 
  if ($age eq 999) { die "Perlmind dies when time = $t \n" }; # safety
}  # End of main loop calling mind.pl Strong AI subroutines 

sub sensorium() {  # Start sensory input through sensory modalities.
  print " Sensorium: Calling AudInput subroutine: \n"; 
  AudInput();   # PERL by Example p. 350: () empty parameter list 
# VisRecog(); -- non-existent subroutine is shown but commented out
}  # End of sensorium subroutine in Perl artificial intelligence

sub AudInput() {  # As if keyboard input were auditory hearing. 
  print "Enter a word of input, then press RETURN: "; 
  $msg = <STDIN>;  # PERL by Example (2015), p. 50: Filehandle STDIN 
  print "AudInput: You entered the word: $msg"; 
  AudMem();  # Calling the memory-insertion subroutine
} # End of auditory input for human-computer interaction

sub AudMem() {  # http://mind.sourceforge.net/audstm.html
  chop($msg);   # PERL by Example (2015), p. 111: chop Function
  my $reversed = reverse $msg;  # PERL by Example (2015), p. 125: reverse
  print "Input word reversed is: $reversed";  # PERL by Example, p. 125
  do {   # PERL by Example (2015), p. 194: do/until Loops
    $pho = chop($reversed);  # "chop" returns the chopped character as $pho.
    print "\nAudMem: Storing ", $pho, " at time = ", "$t"; 
    $aud[$t] = $pho;  # Store the input phoneme in the auditory memory array.
    $t++ ;   # Increment time $t to store each input character separately. 
  } until $pho eq "";  # Store the whole word until $pho is empty.
  $t++ ;   # Add one more time point for a blank engram on-screen.
  print "\n";          # Show a new-line gap on-screen. 
}  # http://code.google.com/p/mindforth/wiki/AudMem

sub think() {   # Start showing output as if generated by thinking. 
  print "\nThink: ";  # Display a new-line before "Think: "
  $t2s = 0;   # Speak all of $cns memory. 
  do {        # PERL by Example (2015), p. 194: do/until Loops
    print $aud[$t2s]; # Show each successive character in memory.
    $t2s++ ;   # Increment time-to-speech to advance thru memory. 
  } until $t2s eq $cns;  # Show the whole array of AI Mind memory.
  print "...comes from auditory memory. \n";   # 
}  # http://ai.neocities.org/AiSteps.html 


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

Date: Mon, 04 May 2015 14:32:04 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: mind.pl showing storage and retrieval from memory
Message-Id: <SMOdnT8wE7RB6drInZ2dnUU78SWdnZ2d@giganews.com>

On 04/05/15 08:12, mentificium@gmail.com wrote:
> #!/usr/bin/perl
> use strict;     # PERL by Example (2015) p. 77
> use warnings;   # PERL by Example (2015) p. 85
> our $age = 0;

 ... etc.

In case someone comes across this thread: do not use this program as an 
example, learning aid or piece of boilerplate.  While it may well work 
(in the sense that it runs and meets some requirement or other), in 
style terms it's shockingly bad Perl, written by someone who hasn't much 
understanding of the language.

Don't try this at home, children.

-- 

Henry Law            Manchester, England


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

Date: Mon, 04 May 2015 07:57:13 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: mind.pl showing storage and retrieval from memory
Message-Id: <bo1fkad9rl1ev0ivp0tjgtcu6dp8g4tnct@4ax.com>

mentificium@gmail.com wrote:
>#!/usr/bin/perl
>use strict;     # PERL by Example (2015) p. 77 
>use warnings;   # PERL by Example (2015) p. 85 
>our $age = 0;   # Temporary age for loop-counting and loop-exit.
>our @aud = " "; # PERL by Example (2015) p. 17: auditory array
[...]

What is the purpose of this forest of characters? If you are trying to
hide your code among useless comments, then you are doing a great job.

You are missing to tell the purpose of you posting.
You are missing the purpose of the code. There is neither a (formal or
informal) spec nor even a hint of what it is supposed to do.
There is no input and no expected or actual output.

Just a chunk of impenetrable, very poorly written code.

jue


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 4426
***************************************


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