On Fri, Dec 16, 2011 at 09:36:53PM -0600, Chris Stinemetz wrote: > This program does all I need it to do. I am having some difficulty > wrapping my head around it though. Mainly the for loop. Did Rob use > special varible? > > If any one can explain it to me so I can have a better understanding > that would be great!
Is this the part that you don't understand? > > for my $i (0 .. $#headers) { > > printf "%s=%s\n", $headers[$i], $data[$i]; > > } There are no special variables here. $#headers is the upper-bound (i.e., last) index of the @headers array. It uses the $# "operator"[1] to do it. It's equivalent to @headers - 1 (AKA the length of the @headers array minus one, because arrays are 0-indexed in Perl). It seems to be mentioned in 'perldoc perldata', and you can find examples of its usage in a few other documents with something like /\$# (i.e., search forward in the pager). The rest is pretty self explanitory. He's using the printf function with a format string to create the name and value line output. HTH, -- Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org> Castopulence Software <https://www.castopulence.org/> Blog <http://www.bamccaig.com/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' [1] I don't know if it's a sigil, operator, or something else; but it behaves a bit like both, I guess.
signature.asc
Description: Digital signature