double quotes are needed

2010-01-06 Thread Grove, Michael
Can someone tell me why I need double quotes for this to work at the line with: 
print $first, $second, $third\n;

#!/usr/bin/perl -w

$first = 0xFF;
$second = 0377;
$third = 0b;
print $first, $second, $third\n;
$answer = $first + $second + $third;
print $answer\n;

It only gives this output when I write double quotes print $first, $second, 
$third\n;

255, 255, 255
765


Mike Grove | AIX System Administrator
OIT - BIO - Server Farms Division
PA Department of Labor  Industry
651 Boas Street Room 124 | Harrisburg, PA 17121
Phone: 717-705-2724 | Fax: 717-783-6364
AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502








Re: double quotes are needed

2010-01-06 Thread Shlomi Fish
Hi Mike!

On Wednesday 06 Jan 2010 19:27:59 Grove, Michael wrote:
 Can someone tell me why I need double quotes for this to work at the line
  with: print $first, $second, $third\n;
 
 #!/usr/bin/perl -w
 

Don't use -w. Add use strict; and use warnings;. Then fix the errors.


 $first = 0xFF;
 $second = 0377;
 $third = 0b;
 print $first, $second, $third\n;

$third\n is invalid code. The \n must be placed inside a string.

Regards,

Shlomi Fish

 $answer = $first + $second + $third;
 print $answer\n;
 
 It only gives this output when I write double quotes print $first,
  $second, $third\n;
 
 255, 255, 255
 765
 
 
 Mike Grove | AIX System Administrator
 OIT - BIO - Server Farms Division
 PA Department of Labor  Industry
 651 Boas Street Room 124 | Harrisburg, PA 17121
 Phone: 717-705-2724 | Fax: 717-783-6364
 AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502
 

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman

Bzr is slower than Subversion in combination with Sourceforge. 
( By: http://dazjorz.com/ )

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: double quotes are needed

2010-01-06 Thread Robert Wohlfarth
On Wed, Jan 6, 2010 at 11:27 AM, Grove, Michael migr...@state.pa.us wrote:

 Can someone tell me why I need double quotes for this to work at the line
 with: print $first, $second, $third\n;

 #!/usr/bin/perl -w

 $first = 0xFF;
 $second = 0377;
 $third = 0b;
 print $first, $second, $third\n;


This passes a list to the print command. It's equivalent to saying...
my @list = ($first, $second, $third);
print @list;

$answer = $first + $second + $third;
 print $answer\n;

 It only gives this output when I write double quotes print $first,
 $second, $third\n;

 255, 255, 255
 765


print $first, $second, $third\n prints a single, scalar value.

-- 
Robert Wohlfarth


Re: double quotes are needed

2010-01-06 Thread Jim Gibson
On 1/6/10 Wed  Jan 6, 2010  9:27 AM, Grove, Michael migr...@state.pa.us
scribbled:

 Can someone tell me why I need double quotes for this to work at the line
 with: print $first, $second, $third\n;
 
 #!/usr/bin/perl -w
 
 $first = 0xFF;
 $second = 0377;
 $third = 0b;
 print $first, $second, $third\n;
 $answer = $first + $second + $third;
 print $answer\n;
 
 It only gives this output when I write double quotes print $first, $second,
 $third\n;
 
 255, 255, 255
 765

What output do you get when you do not write double quotes? I get 'Backslash
found where operator expected at ...'. Is that what you get? (It helps to
let us know what you are getting from your original version).

The print function prints strings. The unquoted \n is not a string - it is a
syntax error. If the \n is enclosed in double quotes, it will generate a
newline character.

Did you really mean print $first, $second, $third\n
or did you mean print $first, $second, $third\n ?
The former is a standalone string and does nothing. The latter will print
the results as you have shown.

You should put 'use strict;' at the top of your program, and remove the '-w'
and replace it with 'use warnings;'.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: double quotes are needed

2010-01-06 Thread Grove, Michael
Thanks.

Is this better?

print $first, $second, $third,\n;

255, 255, 255
765

If I put the second set of quotes after the last comma, I get an error.

I am only on pg 21 of Learning Perl 5th ed. I am trying as many variations of 
the examples just to mess around and see what happens with different characters.


Mike Grove | AIX System Administrator
OIT - BIO - Server Farms Division
PA Department of Labor  Industry
651 Boas Street Room 124 | Harrisburg, PA 17121
Phone: 717-705-2724 | Fax: 717-783-6364
AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502





-Original Message-
From: Shlomi Fish [mailto:shlo...@iglu.org.il]
Sent: Wednesday, January 06, 2010 12:45 PM
To: beginners@perl.org
Cc: Grove, Michael
Subject: Re: double quotes are needed

Hi Mike!

On Wednesday 06 Jan 2010 19:27:59 Grove, Michael wrote:
 Can someone tell me why I need double quotes for this to work at the line
  with: print $first, $second, $third\n;

 #!/usr/bin/perl -w


Don't use -w. Add use strict; and use warnings;. Then fix the errors.


 $first = 0xFF;
 $second = 0377;
 $third = 0b;
 print $first, $second, $third\n;

$third\n is invalid code. The \n must be placed inside a string.

Regards,

Shlomi Fish

 $answer = $first + $second + $third;
 print $answer\n;

 It only gives this output when I write double quotes print $first,
  $second, $third\n;

 255, 255, 255
 765


 Mike Grove | AIX System Administrator
 OIT - BIO - Server Farms Division
 PA Department of Labor  Industry
 651 Boas Street Room 124 | Harrisburg, PA 17121
 Phone: 717-705-2724 | Fax: 717-783-6364
 AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502


--
-
Shlomi Fish   http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman

Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: double quotes are needed

2010-01-06 Thread Shlomi Fish
On Wednesday 06 Jan 2010 20:38:29 Grove, Michael wrote:
 Thanks.
 
 Is this better?
 
 print $first, $second, $third,\n;
 

Yes, but you can also write it as:


print $first, $second, $third\n;


 255, 255, 255
 765
 
 If I put the second set of quotes after the last comma, I get an error.
 

What do you mean by that? How are you writing it?

Also, please avoid top-posting and quote my reply:

http://en.wikipedia.org/wiki/Posting_style

Regards,

Shlomi Fish

 I am only on pg 21 of Learning Perl 5th ed. I am trying as many variations
  of the examples just to mess around and see what happens with different
  characters.
 
 
 Mike Grove | AIX System Administrator
 OIT - BIO - Server Farms Division
 PA Department of Labor  Industry
 651 Boas Street Room 124 | Harrisburg, PA 17121
 Phone: 717-705-2724 | Fax: 717-783-6364
 AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

Bzr is slower than Subversion in combination with Sourceforge. 
( By: http://dazjorz.com/ )

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: double quotes are needed

2010-01-06 Thread Jim Gibson
On 1/6/10 Wed  Jan 6, 2010  10:38 AM, Grove, Michael migr...@state.pa.us
scribbled:

 Thanks.
 
 Is this better?
 
 print $first, $second, $third,\n;

I would just use:

print $first, $second, $third\n;

 
 255, 255, 255
 765
 
 If I put the second set of quotes after the last comma, I get an error.

Not sure what you mean. Can you show us the exact line and the exact error
you are getting?




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: double quotes are needed

2010-01-06 Thread Grove, Michael
Thanks everyone.

The one line I wrote was a mistake in quote placement for this message:
print $first, $second, $third\n

meant

print $first, $second, $third, \n

But I don't want the last comma in the output, so I wrote this with your help:

#!/usr/bin/perl

$first = 0xFF;
$second = 0377;
$third = 0b;
print $first, $second, $third,\n;
$answer = $first + $second + $third;
print $answer\n;

or is this way preferred?

#!/usr/bin/perl

$first = 0xFF;
$second = 0377;
$third = 0b;
print $first, $second, $third\n;
$answer = $first + $second + $third;
print $answer\n;




Mike Grove | AIX System Administrator
OIT - BIO - Server Farms Division
PA Department of Labor  Industry
651 Boas Street Room 124 | Harrisburg, PA 17121
Phone: 717-705-2724 | Fax: 717-783-6364
AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502





-Original Message-
From: Shlomi Fish [mailto:shlo...@iglu.org.il]
Sent: Wednesday, January 06, 2010 1:48 PM
To: beginners@perl.org
Cc: Grove, Michael
Subject: Re: double quotes are needed

On Wednesday 06 Jan 2010 20:38:29 Grove, Michael wrote:
 Thanks.

 Is this better?

 print $first, $second, $third,\n;


Yes, but you can also write it as:


print $first, $second, $third\n;


 255, 255, 255
 765

 If I put the second set of quotes after the last comma, I get an error.


What do you mean by that? How are you writing it?

Also, please avoid top-posting and quote my reply:

http://en.wikipedia.org/wiki/Posting_style

Regards,

Shlomi Fish

 I am only on pg 21 of Learning Perl 5th ed. I am trying as many variations
  of the examples just to mess around and see what happens with different
  characters.


 Mike Grove | AIX System Administrator
 OIT - BIO - Server Farms Division
 PA Department of Labor  Industry
 651 Boas Street Room 124 | Harrisburg, PA 17121
 Phone: 717-705-2724 | Fax: 717-783-6364
 AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502

--
-
Shlomi Fish   http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: double quotes are needed

2010-01-06 Thread Grove, Michael
Shlomi, what is top posting? where you said: please avoid top-posting and 
quote my reply

Fyi I used use strict; and use warnings;
And got a bunch of global errors to I put my in front of all of my variables. 
I have a lot to learn still.


#!/usr/bin/perl

use strict;
use warnings;

my $first = 0xFF;
my $second = 0377;
my $third = 0b;
print $first, $second, $third\n;
my $answer = $first + $second + $third;
print $answer\n;

Mike Grove | AIX System Administrator
OIT - BIO - Server Farms Division
PA Department of Labor  Industry
651 Boas Street Room 124 | Harrisburg, PA 17121
Phone: 717-705-2724 | Fax: 717-783-6364
AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502





-Original Message-
From: Shlomi Fish [mailto:shlo...@iglu.org.il]
Sent: Wednesday, January 06, 2010 1:48 PM
To: beginners@perl.org
Cc: Grove, Michael
Subject: Re: double quotes are needed

On Wednesday 06 Jan 2010 20:38:29 Grove, Michael wrote:
 Thanks.

 Is this better?

 print $first, $second, $third,\n;


Yes, but you can also write it as:


print $first, $second, $third\n;


 255, 255, 255
 765

 If I put the second set of quotes after the last comma, I get an error.


What do you mean by that? How are you writing it?

Also, please avoid top-posting and quote my reply:

http://en.wikipedia.org/wiki/Posting_style

Regards,

Shlomi Fish

 I am only on pg 21 of Learning Perl 5th ed. I am trying as many variations
  of the examples just to mess around and see what happens with different
  characters.


 Mike Grove | AIX System Administrator
 OIT - BIO - Server Farms Division
 PA Department of Labor  Industry
 651 Boas Street Room 124 | Harrisburg, PA 17121
 Phone: 717-705-2724 | Fax: 717-783-6364
 AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502

--
-
Shlomi Fish   http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: double quotes are needed

2010-01-06 Thread Grove, Michael
Ok, this is my final draft.

Though it is syntactically correct, is it a good way to assign variables?

#!/usr/bin/perl

use strict;
use warnings;

my $first = 0xFF;
my $second = 0377;
my $third = 0b;
my $answer = $first + $second + $third;

print $first, $second, $third\n;
print $answer\n;

Mike Grove | AIX System Administrator
OIT - BIO - Server Farms Division
PA Department of Labor  Industry
651 Boas Street Room 124 | Harrisburg, PA 17121
Phone: 717-705-2724 | Fax: 717-783-6364
AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502





-Original Message-
From: Shlomi Fish [mailto:shlo...@iglu.org.il]
Sent: Wednesday, January 06, 2010 1:48 PM
To: beginners@perl.org
Cc: Grove, Michael
Subject: Re: double quotes are needed

On Wednesday 06 Jan 2010 20:38:29 Grove, Michael wrote:
 Thanks.

 Is this better?

 print $first, $second, $third,\n;


Yes, but you can also write it as:


print $first, $second, $third\n;


 255, 255, 255
 765

 If I put the second set of quotes after the last comma, I get an error.


What do you mean by that? How are you writing it?

Also, please avoid top-posting and quote my reply:

http://en.wikipedia.org/wiki/Posting_style

Regards,

Shlomi Fish

 I am only on pg 21 of Learning Perl 5th ed. I am trying as many variations
  of the examples just to mess around and see what happens with different
  characters.


 Mike Grove | AIX System Administrator
 OIT - BIO - Server Farms Division
 PA Department of Labor  Industry
 651 Boas Street Room 124 | Harrisburg, PA 17121
 Phone: 717-705-2724 | Fax: 717-783-6364
 AIX Hot Line 717-525-5598 | AIX Cell 717-329-0502

--
-
Shlomi Fish   http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: double quotes are needed

2010-01-06 Thread Shlomi Fish
Hi!

On Wednesday 06 Jan 2010 21:10:16 Grove, Michael wrote:
 Shlomi, what is top posting? where you said: please avoid top-posting
  and quote my reply

Please see: http://en.wikipedia.org/wiki/Posting_style . I gave you that link 
in my reply.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Parody on The Fountainhead - http://shlom.in/towtf

Bzr is slower than Subversion in combination with Sourceforge. 
( By: http://dazjorz.com/ )

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/