Re: Any way to get hashes to loop in order?

2017-09-29 Thread ToddAndMargo

On 09/29/2017 07:25 PM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 9:55 PM, ToddAndMargo > wrote:


for %SmtpIni.kv -> $key, $value { say $key; }

Does "say" the keys in the order that I created them.

Is there a way to get them to do so?


Not without storing that order somewhere yourself and using it to 
retrieve values. The point of a hash is that it computes hash values 
from its keys for fast lookup, and to the extent that any order can be 
said to exist for keys in a hash, it will be related somehow to those 
hash values. As a practical matter, Hashes are not considered to have 
any ordering.


Poop!

Thank you for the education.

-T


Re: Any way to get hashes to loop in order?

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 9:55 PM, ToddAndMargo  wrote:

> for %SmtpIni.kv -> $key, $value { say $key; }
>
> Does "say" the keys in the order that I created them.
>
> Is there a way to get them to do so?
>

Not without storing that order somewhere yourself and using it to retrieve
values. The point of a hash is that it computes hash values from its keys
for fast lookup, and to the extent that any order can be said to exist for
keys in a hash, it will be related somehow to those hash values. As a
practical matter, Hashes are not considered to have any ordering.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Any way to get hashes to loop in order?

2017-09-29 Thread ToddAndMargo

On 09/29/2017 06:55 PM, ToddAndMargo wrote:

Hi List,

for %SmtpIni.kv -> $key, $value { say $key; }

Does "say" the keys in the order that I created them.

  Does not

Stinking typos



Is there a way to get them to do so?


Many thanks,
-T



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Any way to get hashes to loop in order?

2017-09-29 Thread ToddAndMargo

Hi List,

for %SmtpIni.kv -> $key, $value { say $key; }

Does "say" the keys in the order that I created them.

Is there a way to get them to do so?


Many thanks,
-T


Re: write bytes requires an object with REPR MVMOSHandle

2017-09-29 Thread ToddAndMargo

On 09/29/2017 12:22 PM, ToddAndMargo wrote:
On Fri, Sep 29, 2017 at 1:49 AM, ToddAndMargo > wrote:


    Hi All,

    I am stumped.  This only screws up in the for loop.

    This is only the chopped up version

    
    #!/usr/bin/env perl6

    my $SmtpIniFileName = $?FILE ~ ".ini";
    my %SmtpIni = [ 'DebugTrace' => "",  #   1 | 0  (-vvv)
 'smtp'   => "",  # smtp.zoho.com
    
 'port'   => "",  #   465 (ssl), 587 (tls),
    25, 80, 3535 etc.
 'username'   => "",  #   Typically the sender's
    eMail address, but not always.
  #   Blank will default
    tothe sender's eMail address;
 'password'   => "",  #   User's ($username)
    password
 'from'   => "",  #   The sender's eMail
    address;
 'to' => @[""],   #   qw [ la...@zoho.com
     cur...@gmail.com 
    ];   # This is an array, not a string; delimit with a space
 'Subject'    => "",  #   Subject of the eMail
 'Text'   => "",  #   Body (verbage) of the
    eMail
 'FileName'   => @[""] ]; #   attachment path and
    name. Leave blank for no attachment


    sub PrintRed    ( $Str ) { print color('bold'), color('red'), 
  "$Str", color('reset'); }

    sub PrintGreen  ( $Str ) { print color('bold'), color('green'),
    "$Str", color('reset'); }
    sub PrintBlue   ( $Str ) { print color('bold'), color('blue'), 
    "$Str", color('reset'); }

    sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'),
    "$Str", color('reset'); }

    sub CreateSmtpIni () {
 my $SmtpHandle = open( $SmtpIniFileName, :rw );  #
    Read/write, create if does not exist
 chmod 0o400, $SmtpIniFileName;   #
    Read//write to root only
 RunNoShell ( "chown root.root $SmtpIniFileName" );

 $SmtpHandle.print( "# SmtpIni file for for $IAm\n" );
 $SmtpHandle.print( "#    This file must be owned by
    root.root and have a permission of 400\n" );
 $SmtpHandle.print( "#    Do not use a space after the =
    sign.  \n" );
 $SmtpHandle.print( "#\n" );

 for %SmtpIni.kv -> $key, $value {
 PrintGreen ( "key = <$key>  value =<$value>\n" );
    if    ( $key eq "to" )   { $SmtpHandle.print( "$key=
    #delimiter is a comma\n" ); }
    elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key=
    #delimiter is a comma\n" ); }
    else { $SmtpHandle.print( "$key=\n" ); }
 close ( $SmtpHandle ); }

 PrintRedErr ( "$SmtpIniFileName was not found.  Recreating
    a blank template.\n" );
 PrintRedErr ( "Please edit this template and try again. 
    Cowardly existing.  Bummer dude.\n\n" );

 exit 2;
    }

    CreateSmtpIni();

    

    # CheckRaid.pl6
    key =   value =<>
    key =   value =<>
    write bytes requires an object with REPR MVMOSHandle (got VMNull
    with REPR Null)
   in sub CreateSmtpIni at ./CheckRaid.pl6 line 52
   in sub GetSmtpIni at ./CheckRaid.pl6 line 62
   in block  at ./CheckRaid.pl6 line 143

    Line 52 is
 else { $SmtpHandle.print( "$key=\n" ); }

    # cat CheckRaid.pl6.ini
    # SmtpIni file for for CheckRaid.pl6
    #    This file must be owned by root.root and have a permission 
of 400

    #    Do not use a space after the = sign.
    #
    Subject=




On 09/29/2017 11:59 AM, Andy Bach wrote:

 close ( $SmtpHandle ); }

Your indenting has done you wrong - you close the file handle inside 
the loop for loop, so it closed after the first print.




Hi Andy,

AH POOP!  I was closing the handle after each iteration of the loop.
I must have stared at that 1000 times.  I move the close outside
the loop and happy camping returned.

Great catch.  Thank you for the second pair of eyes!

-T


Hi Andy,

A double thank you!  I am now making progress on the coding at
a great clip whilst debugging Samba log on scripts (big wait times
between workstation log outs and log ins)!

-T


Re: Need append help

2017-09-29 Thread ToddAndMargo

On 09/29/2017 12:41 PM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 3:27 PM, ToddAndMargo > wrote:


I do not understand.  :'(


There's not enough syntax to go around, so perl 6 has to use spaces 
sometimes to figure out what you want.


$ perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix


I explained this one earlier. Things would go faster if you read entire 
messages.


The sequece `$x[` could potentially mean that $x is an array stored in a 
scalar variable, and you are asking for a particular item from the 
array. Or it could mean the start of a complex operator to be applied to 
$x. You need a space to tell it which you intend: without the space it 
sees the indexing operation, without it sees the complex operator.


Ding!   It finally sunk in.  "$x[" is an index, where "$x [" means an
operation.  Took a bit, but I finally got there.



In this case, the complex operator is composed of a basic operator '~' 
(string concatenation), modified twice: once with the reversing 
metaoperator (Rop), and a second time with the in-place assigment 
operator (postfix =). Just as you need to use parentheses in `2 + 3 * 5` 
if you want it to be (2 + 3) * 5 instead of 2 + (3 * 5), you need braces 
to tell it how to combine these special operators --- and you must *not* 
have a space before the postfix =. Which is why you got this error:


$ perl6 -e 'my $x="abc"; $x [R~] = "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Preceding context expects a term, but found infix = instead


With the space before it, it is no longer a modifier for the reversed 
concatenation [R~] but a standalone assignment operator, which can't 
happen there because it already has an operator [R~] so now it needs to 
see a term (expression, roughly).


Hi Brandon,

Some of my issues comes from Modula2 where stings and arrays of 
characters.  And perl 5 with is "~=" or "=~".  I forget.


Thank you for your patience!

-T


Re: Need append help

2017-09-29 Thread ToddAndMargo

On 09/29/2017 12:43 PM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 3:36 PM, ToddAndMargo > wrote:


This is the correct one. The warning about "useless use" here is
a bug
in rakudo. It's meant to warn for things like

Another bug.  Lucky me, again.   :'(

Thank you!


Also, this is about the third time in the past 2 days that I pointed out 
something like this to you, then you hit it later and it was somehow 
something you had never seen before.
Perhaps I should stop trying to explain things, since you aren't 
actually reading?


Hi Brandon,

Sometimes, things take a bit to sink in.  Do not misinterpret
my not understanding with my not reading.  I often "scour"
what you write me several times and many times write them
down in my keepers file.

Also, I wasn't meaning anything by the "Lucky me" remark.  I think
Perl 6 is a remarkable example of Kaisen (Constant Improvement).
I am actually marveling at the pace of development and the
conscientious nature of the the developers.  As I trip across
bugs, I am astonished at how fast the developed pounce on them
and fix them.  (Then a little annoyed at waiting for Red Hat
to catch up.)

I am currently stuck running from an Anti-Kaisen OS (Scientific Linux
7.4, a clone of Red Hat Enterprise Linux) on my main office 
workstation/server.


   it

drives

  me

around

  the

 bend

And believe me, the words I use when bitching about it are
far too blue to print (no an admission that I cuss).

I sincerely appreciate all the help you have given me!

-T


Re: Need append help

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 3:36 PM, ToddAndMargo  wrote:

> This is the correct one. The warning about "useless use" here is a bug
>> in rakudo. It's meant to warn for things like
>>
> Another bug.  Lucky me, again.   :'(
>
> Thank you!
>

Also, this is about the third time in the past 2 days that I pointed out
something like this to you, then you hit it later and it was somehow
something you had never seen before.
Perhaps I should stop trying to explain things, since you aren't actually
reading?

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Need append help

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 3:27 PM, ToddAndMargo  wrote:

> I do not understand.  :'(
>

There's not enough syntax to go around, so perl 6 has to use spaces
sometimes to figure out what you want.


> $ perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say $x;'
> ===SORRY!=== Error while compiling -e
> Missing required term after infix
>

I explained this one earlier. Things would go faster if you read entire
messages.

The sequece `$x[` could potentially mean that $x is an array stored in a
scalar variable, and you are asking for a particular item from the array.
Or it could mean the start of a complex operator to be applied to $x. You
need a space to tell it which you intend: without the space it sees the
indexing operation, without it sees the complex operator.

In this case, the complex operator is composed of a basic operator '~'
(string concatenation), modified twice: once with the reversing
metaoperator (Rop), and a second time with the in-place assigment operator
(postfix =). Just as you need to use parentheses in `2 + 3 * 5` if you want
it to be (2 + 3) * 5 instead of 2 + (3 * 5), you need braces to tell it how
to combine these special operators --- and you must *not* have a space
before the postfix =. Which is why you got this error:


> $ perl6 -e 'my $x="abc"; $x [R~] = "yyz"; say $x;'
> ===SORRY!=== Error while compiling -e
> Preceding context expects a term, but found infix = instead


With the space before it, it is no longer a modifier for the reversed
concatenation [R~] but a standalone assignment operator, which can't happen
there because it already has an operator [R~] so now it needs to see a term
(expression, roughly).

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Need append help

2017-09-29 Thread ToddAndMargo

On 09/29/2017 12:30 PM, Timo Paulssen wrote:

On 09/29/2017 09:27 PM, ToddAndMargo wrote:

$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
Potential difficulties:
     Useless use of [R~]= in sink context
     at -e:1
     --> my $x="abc"; $x ⏏[R~]= "yyz"; say $x;
yyzabc


This is the correct one. The warning about "useless use" here is a bug
in rakudo. It's meant to warn for things like

     perl6 -e '1 + 2';

where you calculate something and do nothing with it. Here it just
forgets to take into account that this is an assignment operation.



Another bug.  Lucky me, again.   :'(

Thank you!


Re: Need append help

2017-09-29 Thread Timo Paulssen
On 09/29/2017 09:27 PM, ToddAndMargo wrote:
> $ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
> Potential difficulties:
>     Useless use of [R~]= in sink context
>     at -e:1
>     --> my $x="abc"; $x ⏏[R~]= "yyz"; say $x;
> yyzabc

This is the correct one. The warning about "useless use" here is a bug
in rakudo. It's meant to warn for things like

    perl6 -e '1 + 2';

where you calculate something and do nothing with it. Here it just
forgets to take into account that this is an assignment operation.


Re: Need append help

2017-09-29 Thread ToddAndMargo

On 09/29/2017 12:12 PM, Andy Bach wrote:

Hmm
$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
yyzabc

no space:
$ perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
     expecting any of:
     prefix
     term

$ perl6 -v
This is Rakudo version 2016.10-285-gee8ae92 built on MoarVM version 
2016.10-55-g20c8591

implementing Perl 6.c.

$ rakudo-star-2017.07/install/bin/perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

$ rakudo-star-2017.07/install/bin/perl6 -e 'my $x="abc"; $x [R~]= "yyz"; 
say $x;'

Potential difficulties:
     Useless use of [R~]= in sink context
     at -e:1
     --> my $x="abc"; $x ⏏[R~]= "yyz"; say $x;
yyzabc

no space
$ rakudo-star-2017.07/install/bin/perl6 -e 'my $x="abc"; $x[R~]= "yyz"; 
say $x;'

===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
     expecting any of:
     prefix
     term


On Fri, Sep 29, 2017 at 1:59 PM, ToddAndMargo > wrote:


On 09/29/2017 11:32 AM, Sean McAfee wrote:

On Fri, Sep 29, 2017 at 11:27 AM, Brandon Allbery

>> wrote:

     On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo

     >> wrote:


         Question:  Is thee a pretty way like the above to do a
prepend?


     No, sorry.


Actually, there seems to be:

  > my $x = "abc"
abc
  > $x [R~]= "xyz"
xyzabc
  > $x
xyzabc


:'(

What am I doing wrong?


$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
     expecting any of:
         prefix
         term



I do not understand.  :'(


$ perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.


$ perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
expecting any of:
prefix
term


$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
Potential difficulties:
Useless use of [R~]= in sink context
at -e:1
--> my $x="abc"; $x ⏏[R~]= "yyz"; say $x;
yyzabc


$ perl6 -e 'my $x="abc"; $x[R~] = "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏] = "yyz"; say $x;
expecting any of:
prefix
term

$ perl6 -e 'my $x="abc"; $x [R~] = "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Preceding context expects a term, but found infix = instead
at -e:1
--> my $x="abc"; $x [R~] =⏏ "yyz"; say $x;


Re: Need append help

2017-09-29 Thread Andy Bach
Hmm
$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
yyzabc

no space:
$ perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
expecting any of:
prefix
term

$ perl6 -v
This is Rakudo version 2016.10-285-gee8ae92 built on MoarVM version
2016.10-55-g20c8591
implementing Perl 6.c.

$ rakudo-star-2017.07/install/bin/perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

$ rakudo-star-2017.07/install/bin/perl6 -e 'my $x="abc"; $x [R~]= "yyz";
say $x;'
Potential difficulties:
Useless use of [R~]= in sink context
at -e:1
--> my $x="abc"; $x ⏏[R~]= "yyz"; say $x;
yyzabc

no space
$ rakudo-star-2017.07/install/bin/perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say
$x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
expecting any of:
prefix
term


On Fri, Sep 29, 2017 at 1:59 PM, ToddAndMargo  wrote:

> On 09/29/2017 11:32 AM, Sean McAfee wrote:
>
>> On Fri, Sep 29, 2017 at 11:27 AM, Brandon Allbery > > wrote:
>>
>> On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo > > wrote:
>>
>>
>> Question:  Is thee a pretty way like the above to do a prepend?
>>
>>
>> No, sorry.
>>
>>
>> Actually, there seems to be:
>>
>>  > my $x = "abc"
>> abc
>>  > $x [R~]= "xyz"
>> xyzabc
>>  > $x
>> xyzabc
>>
>>
> :'(
>
> What am I doing wrong?
>
>
> $ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
> ===SORRY!=== Error while compiling -e
> Missing required term after infix
> at -e:1
> --> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
> expecting any of:
> prefix
> term
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Need append help

2017-09-29 Thread ToddAndMargo

On 09/29/2017 11:32 AM, Sean McAfee wrote:
On Fri, Sep 29, 2017 at 11:27 AM, Brandon Allbery > wrote:


On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo > wrote:


Question:  Is thee a pretty way like the above to do a prepend?


No, sorry.


Actually, there seems to be:

 > my $x = "abc"
abc
 > $x [R~]= "xyz"
xyzabc
 > $x
xyzabc



:'(

What am I doing wrong?


$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
expecting any of:
prefix
term



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: write bytes requires an object with REPR MVMOSHandle

2017-09-29 Thread Andy Bach
close ( $SmtpHandle ); }

Your indenting has done you wrong - you close the file handle inside the
loop for loop, so it closed after the first print.

On Fri, Sep 29, 2017 at 1:49 AM, ToddAndMargo  wrote:

> Hi All,
>
> I am stumped.  This only screws up in the for loop.
>
> This is only the chopped up version
>
> 
> #!/usr/bin/env perl6
>
> my $SmtpIniFileName = $?FILE ~ ".ini";
> my %SmtpIni = [ 'DebugTrace' => "",  #   1 | 0  (-vvv)
> 'smtp'   => "",  #   smtp.zoho.com
> 'port'   => "",  #   465 (ssl), 587 (tls), 25, 80,
> 3535 etc.
> 'username'   => "",  #   Typically the sender's eMail
> address, but not always.
>  #   Blank will default tothe
> sender's eMail address;
> 'password'   => "",  #   User's ($username) password
> 'from'   => "",  #   The sender's eMail address;
> 'to' => @[""],   #   qw [ la...@zoho.com
> cur...@gmail.com ];   # This is an array, not a string; delimit with a
> space
> 'Subject'=> "",  #   Subject of the eMail
> 'Text'   => "",  #   Body (verbage) of the eMail
> 'FileName'   => @[""] ]; #   attachment path and name.
> Leave blank for no attachment
>
>
> sub PrintRed( $Str ) { print color('bold'), color('red'),   "$Str",
> color('reset'); }
> sub PrintGreen  ( $Str ) { print color('bold'), color('green'), "$Str",
> color('reset'); }
> sub PrintBlue   ( $Str ) { print color('bold'), color('blue'),  "$Str",
> color('reset'); }
> sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'),
> "$Str", color('reset'); }
>
> sub CreateSmtpIni () {
> my $SmtpHandle = open( $SmtpIniFileName, :rw );  # Read/write,
> create if does not exist
> chmod 0o400, $SmtpIniFileName;   # Read//write to
> root only
> RunNoShell ( "chown root.root $SmtpIniFileName" );
>
> $SmtpHandle.print( "# SmtpIni file for for $IAm\n" );
> $SmtpHandle.print( "#This file must be owned by root.root and
> have a permission of 400\n" );
> $SmtpHandle.print( "#Do not use a space after the = sign.  \n"
> );
> $SmtpHandle.print( "#\n" );
>
> for %SmtpIni.kv -> $key, $value {
> PrintGreen ( "key = <$key>  value =<$value>\n" );
>if( $key eq "to" )   { $SmtpHandle.print( "$key=
> #delimiter is a comma\n" ); }
>elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key= #delimiter
> is a comma\n" ); }
>else { $SmtpHandle.print( "$key=\n" ); }
> close ( $SmtpHandle ); }
>
> PrintRedErr ( "$SmtpIniFileName was not found.  Recreating a blank
> template.\n" );
> PrintRedErr ( "Please edit this template and try again.  Cowardly
> existing.  Bummer dude.\n\n" );
> exit 2;
> }
>
> CreateSmtpIni();
>
> 
>
> # CheckRaid.pl6
> key =   value =<>
> key =   value =<>
> write bytes requires an object with REPR MVMOSHandle (got VMNull with REPR
> Null)
>   in sub CreateSmtpIni at ./CheckRaid.pl6 line 52
>   in sub GetSmtpIni at ./CheckRaid.pl6 line 62
>   in block  at ./CheckRaid.pl6 line 143
>
> Line 52 is
> else { $SmtpHandle.print( "$key=\n" ); }
>
> # cat CheckRaid.pl6.ini
> # SmtpIni file for for CheckRaid.pl6
> #This file must be owned by root.root and have a permission of 400
> #Do not use a space after the = sign.
> #
> Subject=
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Need append help

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 2:32 PM, Sean McAfee  wrote:

> On Fri, Sep 29, 2017 at 11:27 AM, Brandon Allbery 
> wrote:
>
>> On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo 
>> wrote:
>>
>>>
>>> Question:  Is thee a pretty way like the above to do a prepend?
>>>
>>
>> No, sorry.
>>
>
> Actually, there seems to be:
>
> > my $x = "abc"
> abc
> > $x [R~]= "xyz"
> xyzabc
> > $x
> xyzabc
>

Suppose that depends on your definition of "pretty". I find that use of R
metaop more obfuscatory than pretty,

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Need append help

2017-09-29 Thread Sean McAfee
On Fri, Sep 29, 2017 at 11:27 AM, Brandon Allbery 
wrote:

> On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo 
> wrote:
>
>>
>> Question:  Is thee a pretty way like the above to do a prepend?
>>
>
> No, sorry.
>

Actually, there seems to be:

> my $x = "abc"
abc
> $x [R~]= "xyz"
xyzabc
> $x
xyzabc


Re: Need append help

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo  wrote:

> $ perl6 -e 'my $x="abc"; $x ~= "def"; say $x;'
> abcdef
>
> Perfect!  Thank you!
>
> I am slowly getting away from my Modula 2 "Array of Characters" days.
>
> Question:  Is thee a pretty way like the above to do a prepend?
>

No, sorry. The downside of this is that it's easy to string-append but hard
to string-prepend without having to move stuff around in memory. (The
future may have string-aggregate types, commonly known as "ropes", which
would make this easier.)

As for "array of characters", this quickly turns into a problem --- and
languages that take the 'array of characters' approach are still struggling
with it.

Quick: how many 'characters' is "ň"?

Turns out the answer is: one grapheme OR two Unicode codepoints (Latin
letter lowercase n, combining caron) OR 3 bytes in UTF-8 encoding (2 bytes
for the combining caron). (Among others. Java sees two codepoints in UTF-16
encoding, for 4 bytes. C wants a trailing NUL character, also adding a 4th
byte.) And which one is the correct way to look at it depends on what you
are doing with it.

(This may not matter much to you if you only ever deal with basic Latin-1
like the US uses. But for the past several days I've had to deal with the
names of sports teams from various European countries, with things like ň
and ğ and ş in them --- and that's ignoring the names in Cyrillic or Hebrew
characters. The U.S. is not the whole world. And it's helpful when the
language doesn't force me to jump through weird hoops to deal with them.)

A string can't simultaneously be three different lists. So it ends up being
one thing, and we provide ways to decompose it into the various other
forms. But if you are just thinking of strings of text, we don't make you
think about that; we provide specific string operations instead of making
you figure out which way to decompose it and add the new part and recompose
it. The string operations operate at grapheme level, because when you are
thinking of it as text, that's usually what you intend: you see one
'character' (grapheme) there, not the two codepoints or the 3 bytes or
whatever --- but they have to be clever, because what if you are appending
another combining character?

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Need append help

2017-09-29 Thread ToddAndMargo

On 09/29/2017 10:54 AM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 1:49 PM, ToddAndMargo > wrote:


I am trying to find a shorter way of doing
      $x = $x ~ "def"

But I can't seem to master "append"

What am I doing wrong?


Again (as with last night in IRC) you are treating a string as a list. 
But a string is a single thing; it doesn't make sense to list-append to it.


     $x ~= "def";


$ perl6 -e 'my $x="abc"; $x ~= "def"; say $x;'
abcdef


Perfect!  Thank you!

I am slowly getting away from my Modula 2 "Array of Characters" days.

Question:  Is thee a pretty way like the above to do a prepend?


Re: Need append help

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 1:49 PM, ToddAndMargo  wrote:

> I am trying to find a shorter way of doing
>  $x = $x ~ "def"
>
> But I can't seem to master "append"
>
> What am I doing wrong?
>

Again (as with last night in IRC) you are treating a string as a list. But
a string is a single thing; it doesn't make sense to list-append to it.

$x ~= "def";

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Need append help

2017-09-29 Thread ToddAndMargo

Hi All,

I am trying to find a shorter way of doing
 $x = $x ~ "def"

But I can't seem to master "append"

What am I doing wrong?

Many thanks,
-T


https://docs.perl6.org/routine/append
$ perl6 -e 'my $x="abc"; $x.append("def"); say $x;'

Cannot resolve caller append(Str: Str); none of these signatures match:
(Any:U \SELF: |values is raw)
  in block  at -e line 1


Re: -f ???

2017-09-29 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 9:53 AM, Parrot Raiser <1parr...@gmail.com> wrote:

> Discussing the full implications of these tests could probably keep a
> philosophy class busy for an afternnon. It might even rise to an
> LPU[1] paper.
>

It's even more involved than you think; I have notes for what could
potentially be an "interesting" LTA bug report that could possibly turn
into three and have implications beyond file tests.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: -f ???

2017-09-29 Thread Parrot Raiser
>> In other words, I think we should change the Perl 6 spec to define .f as 
>> "exists and is a file".
>>
>> --
>>   Mark Montague

Mark and I appear to be having a vigorous agreement about the
principle of Least Surprise.

If -f X is defined as meaning "X exists and is a  file", then
obviously if it doesn't exist the first part of the "and" fails so
there's no reason to check the second. Conformity to the general
behaviour is the most desirable. Anything else would merely annoy
people whose expectations had been violated and generate unwanted FAQs
all over the Web.


Re: -f ???

2017-09-29 Thread Fernando Santagata
One might argue that -f returning Failure is like a SQL query returning
NULL, which is appealing to me.

On Fri, Sep 29, 2017 at 4:05 PM, Mark Montague  wrote:

> On 2017-09-29 09:53, Parrot Raiser wrote:
>
>> -e is fairly easy. It asks if something exists. Ignoring Schrodinger,
>> either it does (i.e True) or it doesn't. (False)
>> -f is more ambiguous. It asks if something has a property (fileness)
>> or not. If it exists, it either does or doesn't. [...]
>>
>> Bash appears to err on the pragmatic side, returning "fail" for both
>> -e and -f on a non-existent file.
>>
>
> But that's not what Bash (and the original implementation, /bin/test) do.
> From "man test":
>
>-e FILE
>   FILE exists
>
>-f FILE
>   FILE exists and is a regular file
>
> The problem is that Perl 6 is currently asking "is something a regular
> file?" which leads to this debate about what should happen if the thing
> doesn't exist.  I think it would be easier and clearer if Perl 6 instead
> adopted the standard meaning /bin/test, Bash, Python, and other languages
> use.  This is arguably the most common thing to test for, and it is also
> what most programmers will expect (principal of least surprise).   I the
> less common case where someone wants to do different things depending on
> whether something does not exist or is/isn't a regular file, then instead
> of calling $file.f and differentiating between two non-True values, I think
> the code would be clearer if they tested $file.e first and then $file.f --
> this should be nearly equal in efficiency since the file metadata (the
> results of the stat() system call on POSIX-like operating systems) should
> be cached.
>
> In other words, I think we should change the Perl 6 spec to define .f as
> "exists and is a file".
>
> --
>   Mark Montague
>   m...@catseye.org
>



-- 
Fernando Santagata


Re: -f ???

2017-09-29 Thread Mark Montague

On 2017-09-29 09:53, Parrot Raiser wrote:

-e is fairly easy. It asks if something exists. Ignoring Schrodinger,
either it does (i.e True) or it doesn't. (False)
-f is more ambiguous. It asks if something has a property (fileness)
or not. If it exists, it either does or doesn't. [...]

Bash appears to err on the pragmatic side, returning "fail" for both
-e and -f on a non-existent file.


But that's not what Bash (and the original implementation, /bin/test) 
do.  From "man test":


   -e FILE
  FILE exists

   -f FILE
  FILE exists and is a regular file

The problem is that Perl 6 is currently asking "is something a regular 
file?" which leads to this debate about what should happen if the thing 
doesn't exist.  I think it would be easier and clearer if Perl 6 instead 
adopted the standard meaning /bin/test, Bash, Python, and other 
languages use.  This is arguably the most common thing to test for, and 
it is also what most programmers will expect (principal of least 
surprise).   I the less common case where someone wants to do different 
things depending on whether something does not exist or is/isn't a 
regular file, then instead of calling $file.f and differentiating 
between two non-True values, I think the code would be clearer if they 
tested $file.e first and then $file.f -- this should be nearly equal in 
efficiency since the file metadata (the results of the stat() system 
call on POSIX-like operating systems) should be cached.


In other words, I think we should change the Perl 6 spec to define .f as 
"exists and is a file".


--
  Mark Montague
  m...@catseye.org


Re: -f ???

2017-09-29 Thread Parrot Raiser
Discussing the full implications of these tests could probably keep a
philosophy class busy for an afternnon. It might even rise to an
LPU[1] paper.

-e is fairly easy. It asks if something exists. Ignoring Schrodinger,
either it does (i.e True) or it doesn't. (False)
-f is more ambiguous. It asks if something has a property (fileness)
or not. If it exists, it either does or doesn't.
If it doesn't exist, it certainly can't possess the required property,
but can it be said "not" to possess that property? Anybody know any
convenient Buddhists?

Summarised:   Exists  Has Desired Property Response
  Yes   Yes True
  Yes   No   False
   NoN/A?   ??

Bash appears to err on the pragmatic side, returning "fail" for both
-e and -f on a non-existent
file. After all, we usually only want to proceed if the thing exists
&& is what we want. It would probably be least confusing to default to
the same behaviour, but perhaps returning different kinds of "False"?

[1] Least Publishable Unit

On 9/29/17, Timo Paulssen  wrote:
>> This sounds broken, actually; I understand that a Failure treated as > a
>> Bool prevented it from throwing, so it should have simply returned
>> False. > > Checking it for .defined *does* prevent throwing. Still
> seems like a > bug.
> It doesn't get "treated as a Bool"; any Failure makes it through a
> return typecheck as if it were the right type, that's why you can "fail"
> in a method that has its return type set to be "Int", even though
> Failure doesn't derive from Int. So we don't have to go around giving
> every single method a return type like "Any where { Failure | Int }".
>
> I see .f as "is it a file". "Is /blahblah a file? Oops! I can't check
> that, because /blahblah doesn't exist". It's a different use case from
> "does it exist". You'd likely want to have something more like
>
>     my $file = "/home/linuxutil/erasxeme.txt".IO; say $file.e &&
> $file.f.Bool;
>
> i.e. first check if it exists, then check if it's actually a file.
> Though something could have deleted the file between checking if it
> exists and whether it's a file or not, that's why i'm putting a .Bool
> after the .f check, too.
>
> hope that makes sense
>   - Timo
>


Re: -f ???

2017-09-29 Thread Timo Paulssen
> This sounds broken, actually; I understand that a Failure treated as > a Bool 
> prevented it from throwing, so it should have simply returned
> False. > > Checking it for .defined *does* prevent throwing. Still
seems like a > bug.
It doesn't get "treated as a Bool"; any Failure makes it through a
return typecheck as if it were the right type, that's why you can "fail"
in a method that has its return type set to be "Int", even though
Failure doesn't derive from Int. So we don't have to go around giving
every single method a return type like "Any where { Failure | Int }".

I see .f as "is it a file". "Is /blahblah a file? Oops! I can't check
that, because /blahblah doesn't exist". It's a different use case from
"does it exist". You'd likely want to have something more like

    my $file = "/home/linuxutil/erasxeme.txt".IO; say $file.e &&
$file.f.Bool;

i.e. first check if it exists, then check if it's actually a file.
Though something could have deleted the file between checking if it
exists and whether it's a file or not, that's why i'm putting a .Bool
after the .f check, too.

hope that makes sense
  - Timo


write bytes requires an object with REPR MVMOSHandle

2017-09-29 Thread ToddAndMargo

Hi All,

I am stumped.  This only screws up in the for loop.

This is only the chopped up version


#!/usr/bin/env perl6

my $SmtpIniFileName = $?FILE ~ ".ini";
my %SmtpIni = [ 'DebugTrace' => "",  #   1 | 0  (-vvv)
'smtp'   => "",  #   smtp.zoho.com
'port'   => "",  #   465 (ssl), 587 (tls), 25, 
80, 3535 etc.
'username'   => "",  #   Typically the sender's 
eMail address, but not always.
 #   Blank will default tothe 
sender's eMail address;

'password'   => "",  #   User's ($username) password
'from'   => "",  #   The sender's eMail address;
'to' => @[""],   #   qw [ la...@zoho.com 
cur...@gmail.com ];   # This is an array, not a string; delimit with a space

'Subject'=> "",  #   Subject of the eMail
'Text'   => "",  #   Body (verbage) of the eMail
'FileName'   => @[""] ]; #   attachment path and name. 
Leave blank for no attachment



sub PrintRed( $Str ) { print color('bold'), color('red'),   "$Str", 
color('reset'); }
sub PrintGreen  ( $Str ) { print color('bold'), color('green'), "$Str", 
color('reset'); }
sub PrintBlue   ( $Str ) { print color('bold'), color('blue'),  "$Str", 
color('reset'); }
sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'), 
"$Str", color('reset'); }


sub CreateSmtpIni () {
	my $SmtpHandle = open( $SmtpIniFileName, :rw );  # Read/write, create 
if does not exist

chmod 0o400, $SmtpIniFileName;   # Read//write to root 
only
RunNoShell ( "chown root.root $SmtpIniFileName" );

$SmtpHandle.print( "# SmtpIni file for for $IAm\n" );
	$SmtpHandle.print( "#This file must be owned by root.root and have 
a permission of 400\n" );

$SmtpHandle.print( "#Do not use a space after the = sign.  \n" );
$SmtpHandle.print( "#\n" );

for %SmtpIni.kv -> $key, $value {
PrintGreen ( "key = <$key>  value =<$value>\n" );
	   if( $key eq "to" )   { $SmtpHandle.print( "$key= 
#delimiter is a comma\n" ); }
   elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key= 
#delimiter is a comma\n" ); }

   else { $SmtpHandle.print( "$key=\n" ); }
close ( $SmtpHandle ); }

	PrintRedErr ( "$SmtpIniFileName was not found.  Recreating a blank 
template.\n" );
	PrintRedErr ( "Please edit this template and try again.  Cowardly 
existing.  Bummer dude.\n\n" );

exit 2;
}

CreateSmtpIni();



# CheckRaid.pl6
key =   value =<>
key =   value =<>
write bytes requires an object with REPR MVMOSHandle (got VMNull with 
REPR Null)

  in sub CreateSmtpIni at ./CheckRaid.pl6 line 52
  in sub GetSmtpIni at ./CheckRaid.pl6 line 62
  in block  at ./CheckRaid.pl6 line 143

Line 52 is
else { $SmtpHandle.print( "$key=\n" ); }

# cat CheckRaid.pl6.ini
# SmtpIni file for for CheckRaid.pl6
#This file must be owned by root.root and have a permission of 400
#Do not use a space after the = sign.
#
Subject=


Re: -f ???

2017-09-29 Thread Simon Proctor
So

$f = so "eraseme.txt".IO.f;

Would do the trick?

On Fri, 29 Sep 2017, 6:56 am Norman Gaywood,  wrote:

> On 29 September 2017 at 15:10, Brandon Allbery 
> wrote:
>
>>
>> (And, Norman? It produces a Failure, not a hard exception. You can
>> introspect Failures to keep them from getting thrown.)
>>
>
>  Yep, that's what I thought I'd said :-) Obviously not clearly.
>
> Another way of looking at it:
>
> $ perl6 -e 'my $f = "eraseme.txt".IO.f;say $f.WHAT'
> (Failure)
>
> and you can coerce that to a bool without throwing as other examples in
> the thread have shown.
>
> perl6 -e 'my $f = "eraseme.txt".IO.f; say $f.WHAT; say ?$f'
> (Failure)
> False
>
> Or plain old verbose:
>
> if "eraseme.txt".IO.f {
> say "exists";
> } else {
> say "does not exist";
> }
>
> It seems to me it only looks buggy when you are trying to do one liners
> and you don't naturally get a boolean context.
>
> --
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
>
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
>
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
>