array like split of string
I have this regex expression in a script that appears to do an array like split of a string but I cannot figure out how it does so. Any help appreciated $fname = ($0 =~ m[(.*/)?([^/]+)$])[1] ; print 7 $errlog\n; $fpath = ($0 =~ m[(.*/)?([^/]+)$])[0] ; print 8 $errlog\n; The array elements 0 and 1 above extract the path to the executable and the executable filename but there is no array definition anywhere -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Reading a value from a hash using a variable for the key
On Jan 21, 4:30 pm, rob.di...@gmx.com (Rob Dixon) wrote: On 21/01/2011 05:50, Erez Schatz wrote: On 20 January 2011 15:38, Eyal B.ewinst...@gmail.com wrote: I'm getting an error on the line where I should use the TTL variable - and take the right value from the hash (%list) :Use of uninitialized value in print at D:\system\perl\os-rec\os-rec5_.pl line 24 ,HANDLE line 3. Any idea ? if($line =~ TTL=) { $line =~ s/.*TTL=//; print TTL = $line\n; print $list{$line} ; # print Machine $machine_IP is $list{$line} ; last; } Assuming a specific line is made of nothing but TTL=, then $line =~ s/.*TTL=//; will erase the line, leaving you with an empty (uninitialized) $line variable. No it won't, it will leave $line containing a null (zero-length) string. There is no way to change a string value to uninitialized (undef) by deleting characters from it. - Rob ok. So why on print TTL = $line\n; I do get TTL = 125, if it's undefined ? Thanks, Rob, for your answer. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: array like split of string
Peter K. Michie wrote: I have this regex expression in a script that appears to do an array like split of a string but I cannot figure out how it does so. Any help appreciated $fname = ($0 =~ m[(.*/)?([^/]+)$])[1] ; print 7 $errlog\n; $fpath = ($0 =~ m[(.*/)?([^/]+)$])[0] ; print 8 $errlog\n; The array elements 0 and 1 above extract the path to the executable and the executable filename but there is no array definition anywhere A regular expression with capturing parentheses will return a list of those captures in list context. The particular item from the list is extracted via a list slice with one index. You could combine those two captures and you wouldn't need the list slice: ( $fpath, $fname ) = $0 =~ m[(.*/)?([^/]+)$] Or, what you should do is use a module designed for this specific task: use File::Basename; my $fname = basename( $0 ); my $fpath = dirname( $0 ); Or perhaps use the File::Spec module. John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Music Tagging Modules.
Hi all. I am starting a new project to expand my Perl skills. I am seeking for a module that will read Mp3 and Apple Audio files tags. If the file does not have any tags at all. I am hoping for a module that will take a sample and send it to a server on the net to identify the song/artist/etc. I believe Music Brain's does something like this. but the Perl modules for this server looks like to only modify the Tag information. But doesn't send any sample of the music to assist with identification. I have over 700 songs that don't have any identification. Also I have over 700 songs that don't have the right classification. In fact, I think majority of my music doesn't have the right classification. Any thoughts or comments on this project are more than welcome. I want a script to do the heavy load, rather than myself. I wouldn't mind finding an module that would link up to a audio book or book site to grab details of books and stor it locally. Even if it only does the extraction of the books details. If there isn't such a beast. Then what is a good site for details on books. EG: Series of the book, author name, classification, books in serieies, overview, etc. Thanks in advance. Sean
Re: Dereference Links
On Fri, 21 Jan 2011 08:01:03 -0600, Mike Flannigan wrote: I'm trying to dereference the @{$links} produced by WWW::SimpleRobot and am having a heck of a time getting it done. Can anybody help? You can see some of the things I have tried below. That module hasn't been updated since 2001. You'll have a much easier time using WWW::Mechanize and many more people will be in a position to help you. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/courses/perl3/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Dereference Links
You also might want to look into Data::Dumper to see exactly what you're working with. Off the top though: map {@$_} @$arr might be a start.
How to monitor Windows CPU usage in Linux Server
Hello, guys: is there any information in the MIB about the CPU-usage. I am monitoring Windows-machines using whatsup and the goal is to raise an alarm if the usage passes a certain threshold. By the way , I want to monitor them in Linux Server (CentOS), and the Windows is Windows XP . Thanks in advances.