[plug] perl script

Ryan ryan at is.as.geeky.as
Fri Sep 26 16:33:57 WST 2003


On Fri, 2003-09-26 at 15:55, Adam Hewitt wrote:
> Hi All,
> 
> I have written a basic perl script that adds email domains to a file via
> a web interface. The problem that I am having is that if I add a domain
> to the existing list it all works as expected, however if I add a second
> domain to the list, the second domain is joined to the first one I just
> added. For example if I add test2.com.au to the list I get:

Everyone has already answered, but if you wanted to know why:

The comma is most commonly a list separator and in this context you are
assigning a list (multiple items) to a scalar (single item).  It only
accepts the first element of your list and throws the other items away,

You can however use a comma in a print statement because it knows how to
deal with lists .. hence the confusion I guess.

It is possibly interesting to note that most Perl documentation would
dictate the that "\n" would be assigned , ie: former elements get
evaluated and thrown away and then the last element gets assigned, but
this is obviously not the case:

      Comma Operator

      Binary "," is the comma operator.  In scalar context it
      evaluates its left argument, throws that value away, then
      evaluates its right argument and returns that value.  This
      is just like C's comma operator.

      In list context, it's just the list argument separator,
      and inserts both its arguments into the list.

Ryan

_______________________________________________
plug mailing list
plug at plug.linux.org.au
http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug


More information about the plug mailing list