Mark Sargent wrote: > Hi All, Hello,
> can anyone point me to some sites(tutorials) that deal with Perl and > Linux(Unix) admin stuff.? I'm hoping to use Perl for just that, as > opposed to Web stuff etc. I've been following this tutorial, > http://www.codebits.com/p5be/ which is great. Certainly well written for > a newbie. According to: http://affy.blogspot.com/p5be/ch01.htm <quote> > Hopefully, the response will be similar to this: > > This is perl, version 5.001 > Unofficial patchlevel 1m. > Copyright 1987-1994, Larry Wall > Win32 port Copyright (c) 1995 Microsoft Corporation. > All rights reserved. > Developed by hip communications inc., http://info.hip.com/info/ > Perl for Win32 Build 107 > Built Apr 16 [EMAIL PROTECTED]:47:22 > Perl may be copied only under the terms > of either the Artistic License or the > GNU General Public License, which > may be found in the Perl 5.0 source kit. </quote> So this tutorial applies to a ten year old version of Perl. The author is incorrect in the distinction between lists and arrays. <quote from: http://affy.blogspot.com/p5be/ch02.htm> > Example: Printing an Array > In this section, we'll look at printing an array and see how arrays are > represented in Perl source code. > > This example shows an empty array, an array of numbers and an array of > strings. Figure 2.4 shows the output of Listing 2.3. > > Pseudocode > Print the contents of an empty array. > > Print the contents of an array of numbers. > > Print the contents of an array of strings. > > Print the contents of a array with different data types. > > Listing 2.3 - 02LST03.PL - Printing Some Array Literals > > > > print "Here is an empty array:" . () . "<-- Nothing there!\n"; > print (12, 014, 0x0c, 34.34, 23.3E-3); > print "\n"; > print ("This", "is", 'an', "array", 'of', "strings"); > print "\n"; > print ("This", 30, "is", 'a', "mixed array", 'of', 0x08, "items"); > > Fig. 02.4 - The output from Listing 2.3, showing different array literals. > > The fourth line of this listing shows that you can mix single- and > double-quoted strings in the same array. You can also mix numbers and strings > interchangeably, as shown in the last line. > > Note > Listing 2.3 uses the period, or concatenation, operator to join a string > representation of the empty array with the string "Here is an empty array:" > and the string "<-- Nothing there!\n". You can read more about operators in > Chapter 4, "Operators." > > In this and other examples in this chapters, the elements of an array will be > printed with no spaces between them. You will see how to print with spaces in > the section "Strings Revisited" in Chapter 4,"Variables" . > Example: Nesting Arrays > Many times a simple list is not enough. If you're a painter, you might have > one array that holds the names of orange hues and one that holds the names of > yellow hues. To print them, you can use Perl's ability to specify a sub-array > inside your main array definition. > > While this example is not very "real-world," it gives you the idea behind > specifying an array by using sub-arrays. > > Pseudocode > Print an array that consists of two sub-arrays. > > Print an array that consists of an array, a string, and another array. > > print (("Bright Orange", "Burnt"), ("Canary Yellow", "Sunbeam")); > print (("Bright Orange", "Burnt"), " Middle ", ("Canary Yellow", "Sunbeam")); </quote> All of these examples are using LISTS! An array is something with a '@' sigil in front of it. Also chapter 8 has examples where he shows passing a reference to a list (and calling it an array) in a sub and dereferencing it as an array which will not work. He also uses deprecated hash dereferences. There are also various errors throughout although I only got up to chapter 10. So unless you are still using Perl version 5.001 I would recommend that you get a more up-to-date tutorial. > Also, are there any books written specifically with Unix/Linux > admin in mind.? http://www.oreilly.com/catalog/perlsysadm/ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>