Re: Can't install Inline::Java
On Apr 23, 2010, at 11:40 AM, Alexander Koenig wrote: Hi all, I just tried to install Inline::Java from CPAN and it didn't work. The install process just stopped after some time. When I tried it the second time it stopped again at the same time. There was no error message or anything, it just stopped. Here is the output from CPAN when I ran it the second time, I hope one of you can help me. cpan[4] install Inline::Java Running install for module 'Inline::Java' Running make for P/PA/PATL/Inline-Java-0.52.tar.gz Has already been unwrapped into directory /home/alekoe/.cpan/build/Inline-Java-0.52-lSMcKs Has already been made Running make test make[1]: Entering directory `/home/alekoe/.cpan/build/Inline-Java-0.52-lSMcKs/Java' make[1]: Leaving directory `/home/alekoe/.cpan/build/Inline-Java-0.52-lSMcKs/Java' PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_harness(0, 'blib/lib', 'blib/arch') t/*.t t/01_init.t Perl version is 5.01 Inline version is 0.46 Inline::Java version is 0.52 J2SDK version is 1.6.0_0, from /usr/lib64/jvm/java CLASSPATH is empty t/01_init.t ok t/02_primitives.t .. ok t/02_primitives_1_4.t .. ok t/03_objects.t . ok t/04_members.t . ok t/05_arrays.t .. ok t/06_static.t .. ok t/07_polymorph.t ... ok t/08_study.t ... ok t/09_usages.t .. ok t/10_1_shared_alone.t .. ok t/10_2_shared_start.t .. 1/3 Looks like the second test in the test script t/10_2_share_start.t is hanging. You may want to look at the test results on CPAN testers for the platform you are installing this module on in case there are any known problems with this test. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Modules download from CPAN
On Apr 9, 2010, at 4:19 PM, Open Source wrote: I would like to download all the modules (atleast important ones) from cpan website and keep them in my local disk rather going into www everytime. Can someone tell how to download all of them? Cheers Sorry, my previous email was a little too short. What I ought to have said was look at the minicpan module on CPAN, it will allow you to do what you want. regards, Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Object Oriented
On Mar 24, 2010, at 1:42 PM, Pry, Jeffrey wrote: Does the moose page provide an OOP conceptual overview as well; if not does anyone know where to find one? Not really. Moose is built upon Class::MOP which is a tool to manipulate object systems. Moose then goes on to build a complete, alternative, and many would say better, object system in perl. As such, it is relatively new, and while it is excellently documented, the documentation relies somewhat on one already understanding how Object Orientation works in general and to some degree how it works in perl in particular. There are many ways to learn about Perl OO, in fact you've already received some good suggestions. I'd add Damian Conway's book http://books.perl.org/book/171 to that list as well. It will explain Object Orientation thoroughly as well as perl object orientation in practice. It does not go in to Moose though. You'll have to wait for a Moose book which I think is coming, though I am not sure from where, although I hope chromatic's publishing company comes out with a book because it will be good. Currently his Modern Perl has a section on Moose available on Github: http://github.com/chromatic/modern_perl_book http://cpan.uwinnipeg.ca/htdocs/Class-MOP/Class/MOP.html http://en.wikipedia.org/wiki/Moose_(Perl) Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Any Good SCM tool to manage Perl Code locally
On Mar 16, 2010, at 7:44 AM, Parag Kalra wrote: Just couple of questions - How can I make my code readonly using Git such that it can be edited only when it is checked out. If your code is 'readonly' then you cannot edit it. You cannot write to something that is read only. Also if I want to take entire code base to particular revision, I guess I need to use - 'git checkout commit_name'. So is commit name something like - '11666c32ad1008a88a603d7ebc5cea144495789e' That is a SHA1 sum that is connected to your commit. You can tag your code with an arbitrary tag like 0.1 if you want to. Google for the Git Community Book, you'll find lots of helpful info there. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Any Good SCM tool to manage Perl Code locally
On Mar 15, 2010, at 2:12 PM, Eric Veith1 wrote: Shlomi Fish shlo...@iglu.org.il wrote on 03/15/2010 08:33:30 AM: Please don't recommend CVS for new development. There are much superior and/or open-source alternatives now. See: http://better-scm.berlios.de/ I'm honestly curious why nobody has explicitly suggested git so far. Shlomi mentioned git early on in this thread. All the cool kids use git: http://github.com search for perl. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Controlling one process depending on the status of another
On Mar 5, 2010, at 20:22, Bob McConnell wrote: From: Jay Savage On Wed, Mar 3, 2010 at 8:28 AM, Bob McConnell r...@cbord.com wrote: [snip] However, if the application is this complex, is Perl really the best language to use? It would not be my first choice. That is a very strange statement to make on a Perl beginners list, not least because it's complete bosh. It is bosh. Perl's socket implementations and vast library make it ideal for this sort of programming domain. What better language to simple network control structures? This is exactly the sort of task that Perl accomplishes better and more easily than any other language out there, and why it's the glue of the internet. In particular, all too often I see warnings that threads are still not handled very well in Perl. Until that changes, I will not consider Perl for anything that requires multi-threaded code. I wouldn't use perl threads because I wouldn't use threads. Quoting someone way smarter than me: Unix processes are one of two techniques for achieving reliable concurrency and parallelism in server applications. Threads are out. You can use processes, or async/events, or both processes and async/events, but definitely not threads. Threads are out.[0] It also appears the OP knows what he is doing and has already some working code, looks like perl made this hard task at least possible. Jeremiah 0. http://tomayko.com/writings/unicorn-is-unix -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Controlling one process depending on the status of another
On Feb 26, 2010, at 10:34 PM, Eric Veith1 wrote: Dear list, I'm wrinting a perl program that works with different threads. Your first sentence already has me worried. Threads are un-fun. Those threads depend on each other, not all in the same way. Some threads should stop when others are finished with their work, and again others are to be started afterwards. Now getting really complex. I have six worker machines, M1 to M6, and a controller machine, M0. The perl program runs on the controller machine. This program is basically a dispatcher I control from a command line interface. A command causes two threads to be started, say on M1 and M2. At this point, these are really processes. Threads are in the kernel, you are just starting a separate process on two different machines. One thread on M1 produces work, the other on M2 plots the network traffic. When M1 is finished, I want the thread M0 that caused the workload to signal to the dispatcher that M1 is finished. The dispatcher then shall signal M2 to stop monitoring. Afterwards, I want the results from both M1 and M2, preferably in form of a perl structure. These are all separate processes, not threads. Are you sure you need to use threads? In general a thread is something that runs _inside_ a process. http://en.wikipedia.org/wiki/Thread_(computer_science) First of all, is that possible? Yes. Not that hard. You have exit values from your process so you can trap that and do something based on your exit value. I have already looked at threads, threads::shared and the traditional fork(). With the standard IPC stuff, I'm able to signal and trap that in the master process with a signal handler. But I cannot, however, get the PID of the child that emitted the signal, thus I'm not able to send a SIGTERM to another process. I'm also not sure how I could get my result data. Well, why not just create something in a perl structure and just use something like the Storable module or YAML to dump it to disk and you can read it from your other machine. threads::shared allows me to share a perl structure I could fill, but I don't know how to signal the master thread. Passing a subroutine reference doesn't work, of other options I don't know. I'd very much appreciate any hints. I would avoid threads. I would have a program / process on machine 0 that fires off another program / process on machine 1. Then I guess you need to fire off your program on machine 2 to do network monitoring (?). When the program on 1 is finished, it dumps its data to disk and call machine 0 who in turn calls 2. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl CGI advise/feedback please ...
On Feb 11, 2010, at 3:18, newbie01 perl wrote: Hi all, I am wanting some advise/input on setting up some sort of intranet site to allow system operators to manage the servers, mostly UNIX servers and some Windows. I am constrained by not being able to install new modules or a database, for example, MySQL. The web server will be Apache. Given the choice between PHP and CGI-BIN. I've chosen CGI-BIN, is that a wise choice ... :-) PHP is a templating language, though it does more than that nowadays. PHP makes it fairly easy to combine logic with presentation, or code with html. The Common Gateway Interface (cgi) allows for you to interact with a computer over http(s). This means you can write programs in many languages, not just perl. Obviously this is only a brief explanation so take it with a grain of salt. For access, instead of a MySQL database, the only alternative that I can think of is reading the login information from a CSV delimited file for instance since I am not allowed to edit the htaccess and htpasswd files so am looking to somehow to be able to mask at least the password to keep it secret There are a number of ways to keeping data other than a relational database like MySQL (which is owned by Oracle.) There is a 'NoSQL' movement going on nowadays that builds persistent data structures without the help of a RDMS. Plus there are things like Kioku DB, CouchDB, etc. I need some guidance if someone know of any existing set of CGI-BIN scripts that I can just plug it and used for this purpose. Read the easily accessible CGI.pm perl documentation if you want to use perl. `perldoc CGI.pm` In its simplest form for a start, am looking at being able to present a page for login, once the user manages to login then, then I want to be able to allow it to run some basic UNIX commands, for example, df, top, rm old files from /tmp via a UNIX script etc. For some logins, they will not be allowed to run commands, but merely be presented with some server health information, i.e. for example output from a sar or vmstat or df or top report. Any guidance on where or how to start will be very much appreciated. Thanks in advance. This is already done for you. Look at Nagios, Munin, RRDtool or any of the many very good open source monitoring projects. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Simple cgi email
On Feb 2, 2010, at 19:46, Uri Guttman wrote: RH == Robert H sigz...@gmail.com writes: RH I am just trying to do a simple emailer for a site. I came up with the RH following and was wondering if there are any security issues that jump RH out. check out NMS versions of the classic cgi mail script. it works and it is secure. don't reinvent this wheel one more time. This is good advice. RH I don't have the option of using anything from cpan for the most RH part. Fortunately the script in question, formmail, is fairly self-contained and requires few or no dependencies from CPAN. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: listing all modules
I googled this question, here is the results of my clicking on the first link that came up: This is answered in the Perl FAQ, the answer which can be quickly found with perldoc -q installed. In short, it comes down to using ExtUtils::Installed or using File::Find, variants of both of which have been covered previously in this thread. You can also find the FAQ entry How do I find which modules are installed on my system? in perlfaq3. You can see a list of all FAQ answers by looking in perlfaq. Credit should be given to brian d. foy and pjf for the answer above. Jeremiah On Jan 29, 2010, at 4:55 PM, ANJAN PURKAYASTHA wrote: Hi, Is there a command that lists all installed perl modules in my .cpan directory? TIA, Anjan -- = anjan purkayastha, phd * research associate* fas center for systems biology, * harvard university * = -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: System question
On Jan 14, 2010, at 12:43 AM, Jim Gibson wrote: On 1/13/10 Wed Jan 13, 2010 3:28 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com scribbled: Hi, Suppose I run an application from within a perl script, with system (eg system (myfavprogram input_file out_file)). Is there a way to let the script know that the program has finished running and that I can move on to the next step in the perl script? The system function will wait for the external process to terminate before continuing. See 'perldoc -f system'. So unless your external process does something funny, like starting its own processes and returning early to its caller before finishing, you shouldn't have to do anything special in your Perl program. The 'system' command is often considered hard to interpret - its output can be cryptic. There are tools on the CPAN to help with using 'system', things like IPC::Run and IPC::System::Simple. Perhaps after you looked at the code synopses there you might find something that does what you want. Jeremiah
Re: chroot as non-root?
On Jan 4, 2010, at 11:34, Trevor Vallender wrote: Hi, I am designing a system in which scripts are installed into their own directory, by a non-root user, under their home directory. Hi Trevor, 1. You subject is slightly off-topic for a beginner's perl list. Maybe consider a POSIXy admin list? 2. Look at debian's schroot package: schroot allows users to execute commands or interactive shells in different chroots. Any number of named chroots may be created, and access permissions given to each, including root access for normal users, on a per-user or per-group basis. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Please help to load script from secure server HTTPS in Safari and Opera
On Jan 4, 2010, at 11:49, Simphiwe Mkhize wrote: Good new year Can any one please help me to solve problem with Safari, Google Chrome and Opera. my script has to load from secure server HTTPS for security reason. It works fine from IE and Firefox. Here are the errors I get 1. Opera Error! Could not connect to remote server You tried to access the address https://secure.followme2africa.com/cgi-bin/followme/scripts/checkout1.pl, which is currently unavailable. Please make sure that the Web address (URL) is correctly spelled and punctuated, then try reloading the page. Make sure your Internet connection is active and check whether other applications that rely on the same connection are working. 2. Safari can't connect to the server. Safari can't open the page https://secure.followme2africa.com/cgi-bin/followme/scripts/checkout1.pl; because it could not connect to the server secure.followme2africa.com. What makes you believe this is a perl error and not a network or User Agent issue? Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Please help to load script from secure server HTTPS in Safari and Opera
On Jan 5, 2010, at 1:03, Steve Bertrand wrote: Jeremiah Foster wrote: On Jan 4, 2010, at 11:49, Simphiwe Mkhize wrote: Good new year Can any one please help me to solve problem with Safari, Google Chrome and Opera. my script has to load from secure server HTTPS for security reason. It works fine from IE and Firefox. What makes you believe this is a perl error and not a network or User Agent issue? The OP never said that it was believed that this was an issue with Perl. As a matter of fact, it was stated clearly and specifically which user agents that the CGI does and does not work with. My understanding is that this was a beginners perl list. The original poster might find better, more complete advice on a forum dedicated to web browser technology. Unless of course he believes the issue resides with the perl code. Jeremaih -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perl expect script to login to multiple machines
On Jan 4, 2010, at 24:15, Alvaro Mantilla Gimenez wrote: Hello, I know this is a Perl question but is not more easier to log in with ssh public key method and execute the commands inside the foreach and don't do all the username/password code? Sometimes - like when you have a cluster of machines - it is easier and faster to write a command once and have it execute on all the machines. Expect is really good for this since you can just feed it a list of machines and commands and expect just goes and does its thing. foreach (10.10.10.1, 10.10.10.2) { print Spawning to the $_\n; $exp-spawn(ssh -l username $_) or warn unable to spawn: $!; Don't you think it is much clearer to add a name to the default var? Like this: my @servers = qw/ 10.10.10.1 10.10.10.2 /; foreach my $server (@servers) print Spawning to $server\n; $exp-spawn(ssh -l username $_) or warn unable to spawn: $!; #This part checks for the password prompt, if it doesn't get the password prompt the errors are displayed. unless($exp-expect(10, '-re','.*password:\s*')){ I haven't tested all your code, but expect is notoriously difficult to use. Matching the prompt and such exactly is a pain. Expect itself offers a little bit easier debugging output sometimes too. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Upgrade CPAN when I don't have root permission
On Dec 31, 2009, at 3:59, Peng Yu wrote: I run perl -MCPAN -e shell cpaninstall Devel::REPL It gave me a lot of output on the screen. Unfortunately, you didn't paste anything that I can see is problematic for installation. Yes, I can see that all the tests fail, but I can't see why though I suspect you need to have permission to build and install software in the directories at issue. You arguments to 'make_install_arg' might have to be filled in. Read cpan's help information on that by doing $ cpan cpan[1] h Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: color and newline problem (Term::ANSIColor)
On Dec 31, 2009, at 14:05, Francesco Stablum wrote: Hello everyone, i'm a newbie, and I'm trying to write a simple perl script that takes the stdin and prints it to stdout adding colors that alternates on odd and even lines. The problem is that the newline charachter seems to align to the next line colors and not of the current. [code] use Term::ANSIColor; foreach(STDIN){ $c = (++$i % 2 == 0)? 'white on_black' : 'black on_white'; print colored ($_, $c); } [/code] Perl actually has a special variable called $. which is the current line number (so you don't need to count line numbers with i. Here is an example of using that variable, making the whole program more perlish. #!/usr/bin/perl -w use strict; use Term::ANSIColor; # change the output color of every other line while (STDIN) { if ($. % 2) { print color 'white'; print $. $_; } else { print color 'yellow'; print $. $_; } } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Test file is not readable, while running make test
On Dec 30, 2009, at 16:05, Shankar wrote: On Dec 30, 9:39 am, shlo...@iglu.org.il (Shlomi Fish) wrote: On Wednesday 30 Dec 2009 08:12:24 Shankar wrote: Thanks a lot for the replies. I'll check to see if I may update perl. If I'm unable, is it okay to do the following: 1. Run the first two steps of the installation process (perl Makefile.PL and make) for each module I manually uncompress the tarball and install. This populates the blib/lib directory for each module. 2. Simply manually put all the various contents of each of the above populated blib/lib directories (one for each module I install) into a common lib directory that I'll create on my home directory. 3. Give the above commnon lib directory higher precedence than the default perl paths. Will the above effectively accomplish what is needed to use these modules from my home directory? Yes it should - but this is not a sustainable practice, you won't be able to install dozens of modules this way. I strongly recommend looking into local::lib which will help you automate this process. It is designed for the installation of modules when you don't have admin rights. http://cpan.uwinnipeg.ca/dist/local-lib Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Reference subroutine as parameter
On Dec 30, 2009, at 15:54, Trevor Vallender wrote: Hi, I have just moved a piece of code into a separate module. However, the subroutine in the new module needs to reference a subroutine in the script it's called from. Is there any way around this? Basically, I am using AnyEvent::XMPP, and want the setup code in the module. This code sets up which subroutines to call when certain events occur, and all these will be in the calling script. Can I pass the names of subroutines in the calling script to the subroutine in the module somehow? Thanks, and sorry if my question is a little jumbled, I'm having problems explaining it clearly. Hopefully you understand what I mean. Code snippets are always useful for clarifying your question. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Test file is not readable, while running make test
On Dec 30, 2009, at 7:12, Shankar wrote: Hello, I'm using perl on AIX, and my version is v5.8.2. I know it is no help to say you should upgrade your perl or your OS, but sometimes that makes a huge difference in your day to day perl programming. :) (Also, I'm a regular user, with no write permissions to run make install, so installing everything on my local home directory). There is a perl module that helps with that, called local::lib. It allows you to install things in a directory that you have read/write access to. It is very useful and I can recommend it. http://cpan.uwinnipeg.ca/dist/local-lib My primary interest is in module Mail::Box. I downloaded this, and realized that I needed to install several pre-requisites. Subsequently, I tried installing pre-requisites such as, TimeDate-1.20, Encode-2.39, and so on. For each of these, as per instructions, I tried the following steps in sequence: 1. perl Makefile.PL 2. make 3. make test 4. make install (This fails, I think, because I don't have any root or super user permissions to make a site-wide install. Is that correct? This would be my guess as well, though I can't be certain. You may want to use the cpan perl tool to do your installing of modules, it does this Make incantation for you and you can add parameters like sudo so you can install stuff system wide if you need that. Steps 1 and 2 succeeded. Step 3 in each of the modules that I attempted to install on my home directory, gives an error that seems to say none of the *.t files are readable. Where is the the testing directory? I mean where is it physically located on your file system? When I download Time::Date 1.20 and cd into the dir, make test runs fine. The test files, i.e. everything under t/ is owned by me, so I cannot reproduce your error. Example error is below. Am I doing something wrong? I don't think so. Can someone please help? Can you post more information? Also, I should be able to use the modules locally from my home directory's subdirectories, even though Step 4 fails. Is that right? If the tests don't pass, you may not be able to access the code in the modules without explicitly defining the path to the code. So it will be a little tricky. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: CGI.pm post types
On Dec 30, 2009, at 23:28, Bruce Ferrell wrote: I see on the CGI web page that this: === use CGI; $q = new CGI; $query = $q-param( 'POSTDATA' ); === will return the contents of this URI: http://server/cgi.cgi?POSTDATA=posteddata How do I code so that I don't have to use POSTDATA? It was you who defined the variable name, i.e. POSTDATA. You can change the name to something else. Or are you trying to get rid of the key value pairs entirely? That unfortunately won't work since HTTP is a 'stateless' protocol and if you want the remote machine to calculate something with your input you'll have to provide input and key value pairs is the way its done. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Upgrade CPAN when I don't have root permission
On Dec 29, 2009, at 20:37, Peng Yu wrote: I'm trying to update CPAN, but I don't have root permission. I'm wondering where the update is installed. In general without root or sudo access you'll not be able to install perl modules - you can install them in directories where you have write access to though. You may want to look at the local::lib perl module for installing without root permissions. I have the following line in ~/.cpan/CPAN/MyConfig.pm. Will the updated be installed in ~/site? No. In general perl modules get install in three locations: Vendor, Site, or Core. Core is where perl installs stuff, Vendor is where your package manager installs stuff, and Site is where you install stuff. But they all are different directories on your system and to make it more confusing, they differ depending on operating system. What your cpan configuration is telling you is that cpan is installing perl modules in the Site directories on your computer. On my computer that directory is /usr/local/share/perl/5.10.0. You'll have to find out where that is on your machine. More on this issue here: http://use.perl.org/~schwern/journal/39246 Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Autovivification of hash from an array
Hi there! This may or may not be a beginners question. If not, please let me know where I ought to post. :-) I have a data structure, a simple array. It is made up of sections of files I have slurped; sub _build_packages { use Perl6::Slurp; my @pkgs; # iterate over the packages slurping them into one map { push @pkgs, (slurp $_, {irs = qr/\n\n/xms}) } @packages; return \...@pkgs; } (The above code is in the class declaration) Now in my program which subclasses that array ref, after de-referencing I have this idiom; my %versions; map { my $package = $_; # autovivfy a hash with versions of packages $versions{$package} = [ ] unless exists $versions{$package}; } @packages So my questions are: Is this an efficient way to do this? Am I using the idiom correctly? Could I make it more readable? Is my predilection for map over foreach making this less readable? Or is that only a question of style? Thanks for any feedback. Regards, Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Autovivification of hash from an array
Edit: Added missing 'push' to code example. On Nov 28, 2009, at 14:13, Jeremiah Foster wrote: Hi there! This may or may not be a beginners question. If not, please let me know where I ought to post. :-) I have a data structure, a simple array. It is made up of sections of files I have slurped; sub _build_packages { use Perl6::Slurp; my @pkgs; # iterate over the packages slurping them into one map { push @pkgs, (slurp $_, {irs = qr/\n\n/xms}) } @packages; return \...@pkgs; } (The above code is in the class declaration) Now in my program which subclasses that array ref, after de-referencing I have this idiom; my %versions; map { my $package = $_; # autovivfy a hash with versions of packages $versions{$package} = [ ] unless exists $versions{$package}; push @{ $versions{$package} = $version } @packages So my questions are: Is this an efficient way to do this? Am I using the idiom correctly? Could I make it more readable? Is my predilection for map over foreach making this less readable? Or is that only a question of style? Thanks for any feedback. Regards, Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Autovivification of hash from an array
On Nov 28, 2009, at 15:25, Shawn H Corey wrote: Jeremiah Foster wrote: my %versions; map { my $package = $_; # autovivfy a hash with versions of packages $versions{$package} = [ ] unless exists $versions{$package}; push @{ $versions{$package} = $version } @packages You don't need to store an anonymous array before a push Ah okay. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; # Make Data::Dumper pretty $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; # Set maximum depth for Data::Dumper, zero means unlimited $Data::Dumper::Maxdepth = 0; I learned a bit about data dumper here, thanks! my %hash = (); for my $key ( 'a' .. 'z' ){ for my $value ( 'a' .. $key ){ push @{ $hash{$key} }, $value; } } print 'hash = ', Dumper \%hash; Thanks Shawn. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: regex question
On Nov 9, 2009, at 16:25, axr0284 wrote: Hi, I am completely stumped with how to proceed with this. I have a program where the user inputs a path to a file. This is under windows xp The path can be relative ..\..\..\synthesis\int_code.psm .\program\synthesis\int_code.psm or absolute c:\command\tool\program\synthesis\int_code.psm I do not know what it is in advance. 1)I would need perl to be able to distinguish between a relative and absolute path Fortunately there are lots of tools to do this in perl. :) 2) If the path is relative, create an absolute path from that. My orignal idea was to locate ..\ with regex using m/([.]{2}\\)/ This would indicate if the path is relative or not use cd to obtain the present working directory. Is there a better way to do this??? Yes; Cwd To find out more, look up Cwd in perl documentation. In short its like this: use Cwd; my $dir = getcwd; use Cwd 'abs_path'; my $abs_path = abs_path($file); Can anybody help me with this or can you think of a better idea. Avoid starting your solution with a regex if you can. Regexes tend to get complicated quickly. :) Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Script check !!!
On Nov 5, 2009, at 19:18, Shlomi Fish wrote: if ( !$filename ) { print $q-header ( ); print There was a problem uploading your file.\n; exit; } This is invalid HTML. It does not matter here a lot, though. Yeah, you could use: print $q-h2('There was a problem uploading your file.'); my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' ); You may want to look at File::Basename for this type of file name parsing, it works really well: use File::Basename; my $filename = basename $path-with-file; Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Move to more recent gcc version.. what to expect
On Nov 2, 2009, at 17:07, Harry Putnam wrote: I noticed I've been masking gcc beyond version 4.3.2-r3, and have forgotten why I had it masked. I'm updating world right now, and wondered if I were to move up to most recent gcc (4.4.2), which would be a 5 version jump, what I could expect in the way of problems. Would I need to re-emerge just about everything? Harry, this appears to be off topic since it does not deal directly with beginner's perl questions. I think you may find better response on a Gentoo list. Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: tried to install my first module (Mac OSX 10.4.11)
On Nov 2, 2009, at 20:38, tom smith wrote: On Mon, Nov 2, 2009 at 8:02 AM, Peter Scott pe...@psdt.com wrote: On Mon, 02 Nov 2009 04:25:18 -0700, Tom Smith wrote: I believe that your HTML::Parser needs upgrading. But you're getting the system one, which is often dangerous to touch. I think you should make an enitrely new Perl from scratch, installed to a different location, then you never have to worry about these conflicts. Ok, sounds good. I'll see if I can figure out how to install perl. What version would you recommend? I read that perl 5.10 back ports some perl 6 stuff, and I tend to shy away from hybrid releases. Perl 5.10 is a great release with lots of great features and bug fixes. I would not call it a 'hybrid' release but you are right that there are elements from perl 6 in perl 5.10. You don't need to use many of them if you don't want to and you will often have to call them explicitly; i.e. with a 'use' declaration like this; use feature ':5.10'; Debian has perl 5.10.1 in testing so if you want the latest stable perl release you may consider using perl 5.10.1 and not 5.10. I think there is a developer release out too, 5.11. (Perl tends to have developer releases end in odd numbers and stable releases as even numbers.) Jeremiah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Can't get Socket module
In article [EMAIL PROTECTED], Jeremiah Foster wrote: Hello there! I am having difficulty downloading the Socket module to make a script work. Below is the result of my attempt installing from the command line via Perl; Any suggestions? Perhaps looking at one of the HOWTO's on the web for installing Perl modules without root access will be useful for you: http://people.nl.linux.org/~joor/noroot.shtml Mark Thanks Mark, that link was helpful and I read it, though I usually do download and install from tarred, gunzipped archives. Also, I do have root permission on this machine. I saw that the file that the interactive module script couldn't fetch was simply a text file that I could cut and paste with a browser. The weird thing was that it kept saying; Warning: expected file [yes/sources/modules/03modlist.data.gz] doesn't exist but I could go to that link and view it. Isn't it something other than not just being root? Is there a flaw in the script? Jeremiah -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can't get Socket module
Hello there! I am having difficulty downloading the Socket module to make a script work. Below is the result of my attempt installing from the command line via Perl; Any suggestions? Jeremiah Trying with /usr/bin/wget -O - to get ftp://ftp.loaded.net/pub/CPAN/modules/03modlist.data.gz --12:05:09-- ftp://ftp.loaded.net/pub/CPAN/modules/03modlist.data.gz = `-' Resolving ftp.loaded.net... done. Connecting to ftp.loaded.net[12.30.171.126]:21... connected. Logging in as anonymous ... Logged in! == SYST ... done.== PWD ... done. == TYPE I ... done. == CWD /pub/CPAN/modules ... No such directory `pub/CPAN/modules'. System call /usr/bin/wget -O - 'ftp://ftp.loaded.net/pub/CPAN/modules/03modlist.data.gz' yes/sources/modules/03modlist.data returned status 1 (wstat 256) Warning: expected file [yes/sources/modules/03modlist.data.gz] doesn't exist Issuing /usr/bin/ftp -n Local directory now /home/jeremiah/perl_scripts/log_manage/yes/sources/modules CPAN: Permission denied modules: No such file or directory 03modlist.data.gz: No such file or directory Bad luck... Still failed! Can't access URL ftp://ftp.loaded.net/pub/CPAN/modules/03modlist.data.gz. Please check, if the URLs I found in your configuration file (ftp://ftp.loaded.net/pub/CPAN/) are valid. The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/' Could not fetch modules/03modlist.data.gz Going to write yes/Metadata Warning: Cannot install Socket, don't know what it is. Try the command i /Socket/ to find objects with matching identifiers. cpan i /Socket/ No objects found of any type for argument /Socket/ cpan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cgi session
I just want to make a 'secure site' that need username and password. The easiest way to do this is probably not in perl. I recommend putting an .htaccess file in the directory where you have the file that you want password protected. This is a good method if you do not have the ability to configure the Apache server yourself. Here is more on the .htaccess file; http://httpd.apache.org/docs/howto/htaccess.html#what After that, I will call /cgi-bin/checkpasswd.pl, if OK then user will be transfered to another page This will happen if you protect a directory with the .htaccess file, once the user fills in their information they get into the directory and you can load index.html automatically. I hope this information is helpful. Jeremiah -- ___ http://www.freyafilm.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]