Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-26 Thread JPH
I think the below answers my question. I thought maybe the code was doing some perl magic, but it is probably just a leftover from something else. Also I wasn't aware of the || construction to use for setting default values when ARGV (in this case) is undefined. Thnx all! On 11/24/2011 09:05 P

"$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-24 Thread JPH
I found the script below at http://hints.macworld.com/dlfiles/is_tcp_port_listening_pl.txt I am trying to figure out what's happening at lines 20-23. Why is the author using 'shift ||' and not a plain $host = $hostname; Anyone to enlighten me? Thanks! JP --- 1 #!/usr/bin/perl -w 2 # 3

Re: sub local variable changes global variable.

2011-10-16 Thread JPH
Thanks! My script seems to work with dclone. Though the (deep) recursion takes a lot of time ... What is your opinion, would it pay off (in performance) when I rewrite the script in such a way that I do not use dclone, but string manipulation routines instead? So: - passing a single dimension

Re: sub local variable changes global variable.

2011-10-16 Thread JPH
You got me there, John. Indeed I do expect it to contain ' ' and not 0 like I stated. If you originally assign " " to $a[ 0 ][ 1 ] why would you now expect it to contain 0? John -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.

sub local variable changes global variable.

2011-10-15 Thread JPH
Hi all, I am passin a two-dimensional array to a sub and when the sub returns, the original array has changed. Eventually I want to pass the array into a recursive sub, so I want to find a way to circumvent this behaviour. Notice how my global is "@a" and the sub local is "@b" - Why is this hap

Re: s/// and \n question

2011-07-22 Thread JPH
Are you familiar with chomp( $str ) ? Often you will want to use chomp to get rid of trailing newlines on your input lines. On 07/21/2011 11:11 PM, Mike McClain wrote: Given the following snippet of code could someone explain to me why the linefeed gets included in $num? mike@/deb40a:~/perl>

Re: Convert spreadsheet to jpeg

2011-06-21 Thread JPH
First print your Excel sheet to PDF, this shouldn't be too difficult as long as the Excel file is saved exactly the way you want it printed ... Then convert the PDF files to JPG using ImageMagick. On 06/20/2011 09:57 PM, andrewmchor...@cox.net wrote: Hello I am not an expert in perl and so bef

Re: Loading library different per Operating System

2011-06-12 Thread JPH
Here is how I solved it: use if $^O eq "linux" , "Device::SerialPort" => qw( :PARAM :STAT 0.07 ); use if $^O eq "MSWin32" , "Win32::SerialPort" => qw( :PARAM :STAT 0.19 ); Thanks! On 06/12/2011 03:13 AM, Dr.Ruud wrote: On 2011-06-11 17:20, JP wrote: How can I load a library depending on