Re: Fork
Thank you. Yes I am forking more process from a CGI script because I want to let them run on the server then end loading the current page immediately. Can you give me a short example about how I should create that loop? Thank you. - Original Message - From: Wiggins d Anconia [EMAIL PROTECTED] To: Octavian Rasnita [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, December 08, 2003 6:58 AM Subject: Re: Fork Hi all, Please tell me how could I fork more child processes. I want to fork let's say 10 child processes. I know that I can do something like the following, but I am wondering if there is a clearer method: if (my $pid = fork) { #parent if(my $pid2 = fork) { #parent 2 if (my $pid3 = fork) { #parent3 } elsif(defined $pid3) { #child3 } } elsif(defined $pid2) { #child2 } } elsif(defined $pid) { #child1 } But this method is very confusing if I want to fork more child processes, and I want to let the user choose how many processes wants. Thank you. How about a loop? Storing the PIDs to an array/hash? Are you really forking processes from a CGI script? http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Fork
On Dec 9, 2003, at 9:53 AM, Octavian Rasnita wrote: Can you give me a short example about how I should create that loop? a strategy I proposed over on the beginner's list would look like say: http://www.wetware.com/drieux/pbl/Sys/gen_sym_big_dog.txt That of course was built for a command line interface and hence loops back for checking the Children with the classical sig_handler model of REAPER from the perlipc pod... In your case you would probably want merely the simpler dispatcher system and the 'runner()' model. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
javascript error
Hi, I'm trying to include javascript code in my perl script but I'm getting the following error 'Can't find string terminator quot;EOFquot; anywhere before EOF at calendar.pl Anyone have any ideas why I might be getting this error. Using the following code to refer to javascript: #opening a new window my $JSmakepage=EOF; EOF ** This document is strictly confidential and is intended for use by the addressee unless otherwise indicated. Allied Irish Banks ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Fork
Octavian == Octavian Rasnita [EMAIL PROTECTED] writes: Octavian Yes I am forking more process from a CGI script because I want to let them Octavian run on the server then end loading the current page immediately. Octavian Can you give me a short example about how I should create that loop? Any one of the articles you get from the following google search: site:stonehenge.com cgi fork should be able to help you out. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: javascript error
mark o' sullivan [EMAIL PROTECTED] asked: I'm trying to include javascript code in my perl script but I'm getting the following error 'Can't find string terminator quot;EOFquot; anywhere before EOF at calendar.pl Anyone have any ideas why I might be getting this error. Usually that's either because there's some whitespace stuck on the offending here document terminator (i.e. your terminator reads EOF ) or the EOF is on the last line of your code. In both cases Perl will not be able to locate the terminator. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: This seems to ease
At lest I like the idea. Seems like English. I don't care for the speed(other wise I would use C/C++), running all the scripts where I work takes some hours and so this will not be a big overhead. I didn't think in the if ($this{big}-[$idx]{thing} in @set) { ... } before I sent the e-mail. To this I have to think in function as well. Like I seed this seems to ease. For the rest of the answers. I didn't know List::Util, but I have something done by myself. Probably everyone that don't know this module has one. Now the grep I use grep some times, but I always have to sink to understands what is doing if I have a block. So instead of in ($xxx = a, 5) I would have grep {($xxx cmp $_) == 0} (abc, 5) or grep {not ($xxx cmp $_)} (abc, 5). Am I the only one with this problem? The OO approach is out of question. Object are good for simplifying code, in this case I don't see any simplification. Marcos -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 3:04 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: This seems to ease On Dec 8, [EMAIL PROTECTED] said: I did the 'in' function for seeing if one element is inside on list like. Well, although it's overkill, Quantum::Superpositions has a 'any' function that can be used like so: if ($x == any(1, 4, 9, 16)) { ... } But Q::SP is a really big module, and won't work as efficiently as it theoretically should. sub in { my $match = shift; foreach (@_) { return 1 if $match eq $_; } return 0; } That's a very succinct function, and probably the best way to write it. package MyFilter; use Filter::Simple; use vars qw (@ISA @EXPORT @EXPORT_OK); require Exporter; push(@ISA, qw(Exporter)); @EXPORT_OK = qw(in); FILTER_ONLY code = sub { my $ph = $Filter::Simple::placeholder; s/(((\$[a-zA-Z_0-9]+)|\-?[0-9]+(\.[0-9]+)?|$ph))\sin\s/in $1, /g; }; This seems to work. Can someone test some more and give some bugs? Is there a generic module for doing operators? I've never used Filter::Simple, so I don't know what $ph is representing, so I'd like to know if your module can handle if ($this{big}-[$idx]{thing} in @set) { ... } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
On Dec 8, 2003, at 2:50 PM, Tassilo von Parseval wrote: [..] The current set of perl-porters that are able and willing to work on the core are with not many exceptions people with academic degrees. [..] hypothetical question, would one need to be a perl-porter to write good perl? { would it be impolite to note in which language/languages the perl executable is 'written in'??? } at which point of course we could get massively pedantic and ask why a variety of critical encryption modules are delivered as assembler, and not even as 'c' code... but let us not get too morosse about the limitations of the autodidact. { god, but it's been some time since anyone has called me, or implied, such a polysyllabicsequipedalianism in my direction. } but since you have been ever so polite as to offer the opportunity, allow me to note one of my most favorite and silly misadventures in AcadamiaLand, that charming dashing PhD from MIT who was trying to explain 'security' based upon calculations of the 'cost' of a brute force attack ... and I tried to disabuse him of his computational wizBangery that if one is actually seeking to crack SIGINT that is not how one goes about it. The more pleasant times of course were fun with the fine prof with at least a sense of elan about the limitation of what he could teach UnderGrads in a computer class on statistical modeling. Fortuitously for me he was 'moon lighting' at the Naval War College, and so was willing to be frank about the folly of statistical analysis, and that there is an 'art' that is not merely the computational component. Or what those of use who had done 'TMA' - Target Motion Analysis - always cite the venerable 'still bill' - and here you do a 'package check', and if they are big and brassy... Needless to say the real fun was meeting the gentleman, who wound up as a co-worker, who had introduced my 'academic advisor' to fortran, and then having the fun of sharing my concerns with my former academic advisor as to why it was that they had not introduced, or discussed, say lex or yacc, and the general issues of Regular Expression Engines as a part of the core of their under-grad programme - never mind 'make' et al and there wasn't so much as a by your leave about the importance, and/or socio-cultural issues, with 'source code control systems' { funny the drieux should be whining about this with source code control build and release installation process documentation, and prefers to do his RegEx in Perl than in flex/byacc... } I could go on about the Fun Filled Excitement of reaching for my knuth, and remembering having seen a reference, and then finding that the idea was for the volume he never published... Oye the Pain, had to fix it in code myself the old fashion way... So when you put my comments to Jason, and those who like jason, may be having issues with the INSANITY of the american educational system, back into their context, then you might want to actually go back and re-read them for what they are. American society has a lot of issues, and the 'snobbery' of our psuedo intellectuals IS a part of that problem. So when folks step back and put all of that undergrad/gradSchool gambiting back into context it is a whole lot simpler to live with. As I tried to explain to annie who was at Harvard Divinity and complaining about the 'pasty faced' nature of those gradBoys, a part of the problem was that she had taken a bit of time out for things like Refugee Relief Groups and had the misfortune of being involved with people who had a wider range of life experiences than merely trying claw their way to the top of the old academic food chain by any means possible. People who's whole sense of Self rested upon such chimera as their SAT/MSAT/GSAT numbers and their 'certifications' rather than any actual real live, this is no shit, you should have been with us when... So when I am attacking 'support' for my kvetching at the limitations of the actual academic rigour that college can not teach one to THINK, but can at best provide one with a context to develop the habit of formal analysis it might be useful to try to come at me with something a bit more loaded than the perl-porters capabilities. I can and DO appreciate that there are still too many in america who have tied too much of their sense of self and identity into the importance of their college degree as some gateway... but maybe detaching one's self from such false Idolatry Might help??? yes, yes, I know you are posting from aachen, so take the liberty moment and enjoy that I am not complaining about Germany... But if you wish I can do a few Herr Doktor stories if that would make you feel fuzzyWarm? now let us return to the comical part: IF you learned how to do the process of learning, Then WHY get a college degree??? IF your skill mix is taking you where you want to be, then rock ON! if it is not, figure out where you want to be and go there. I am sorry.
Re: sorter script [was: Frustrated newbie question]
On Dec 8, 2003, at 9:30 PM, Bryan Harris wrote: [..] Sometimes perl isn't quite the right tool for the job... % man sort % man uniq If you code it correctly (unlike the program at the URL above) then a perl version will be more efficient and faster than using sort and uniq. Please explain... That's the last conclusion I thought anyone would be able to reach. [..] For many simple things 'sort -u' will suffice, which I presume was your argument. the problem of course is getting what john asserts as 'code it correctly'. oye - I finally used stuart clemmon's suggestion { thank you stuart! } to peek at the code. OYE! I will defer to john as to which piece has him going OYE! more than the funkadelic of the URL's my @sorted = sort INFILE; and then a bunch of file IO as well... but back to your side of the question, as you may have noticed from using 'sort' even if you are running 'sort -u' there is a bunch of problems that can come as the volume of data grows - that will lead to the creation of a bunch of cache files. Ironically, uh, duh, given tassilo's recent thumping of me for whining about acadamia - there are some ugly 'sorting algorithms' that have to be 'ugly' to be 'general enough' that are, well, ugly. You might want to get your hands on Knuth's and crawl the searching and sorting algorithm sections if you are really interested in some serious analysis of good ways and bad ways to think about solving sorting algorithms. may I recommend that you peak at perldoc -q sort and then look at @sorted = map { $_-[0] } sort { $a-[1] cmp $b-[1] } map { [ $_, uc( (/\d+\s*(\S+)/)[0]) ] } @data; and think about what that MIGHT mean were it to have been plugged into the process. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
passing code inside function
I would like to read something about passing code inside function. Lets say that: This works: perl -e 'sub a(){print({$_[0]}, /n};$_=0; a {$_++} foreach 1..100' This don't work perl -e 'sub a{print({$_[0]}, /n};$_=0; a {$_++} foreach 1..100' can someone give me some links Thanks MArcos -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: passing code inside function
On Dec 9, 2003, at 12:14 AM, [EMAIL PROTECTED] wrote: I would like to read something about passing code inside function. Lets say that: This works: perl -e 'sub a(){print({$_[0]}, /n};$_=0; a {$_++} foreach 1..100' what you might want to think about is trying that as 'code' rather than as a command line gambit. What you seem to be interested in is doing what is elsewhere known as a 'call back' - and one of the better places to peek would be in perldoc -m File::Find to look at the actual implementation in the module, perldoc File::Find to look at the POD about the module. HTH. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
On Dec 8, 2003, at 10:31 PM, Tim Johnson wrote: [..] I will admit that the level of dedication and self-sacrifice required is exceedingly rare, and I'm stretching the analogy pretty thin anyway, so I'll leave it there. [..] Since I have stirred up some apparent confusion here, let me try to be clear in the response. I am not now, nor am I in any way impugning the technical expertise or skill of the perl porters, by what ever means that they have acquired their expertise. An argument of 'academic' v. 'autodidactic' is functionally useless - since there are those who learn best from hands on experience, and those who learn from a more formal approach to the pedagogical arts. The challenge for the student is to figure out which is the better course of action for themselves. The problem then is resolving the relationship between what one 'knows' and what one can 'sell'. Allow me to offer an argument by analogy that may help clarify the position. I was standing the duty as the AJOD ( Assitant Junior Officer of the Deck ) to a BM2 Holly ( boy does that tell you where we were on the pecking order ) and I asked him why, with his skill set he had not gone into the 'data processing' ratings. He shared with me the very useful perspective. As a simple (HA!) boatswain's mate he had a better line of advancement than had he gone into the canonical path for persons who were rated to work with 'information technology systems' - and could also secure for himself the time to 'screw around with computers' that he preferred to do, and was really good at doing, and as such was providing the 1st Lt's Locker with a-j-squared away 'computer support' that they could not otherwise secure by 'formal and official' channels. Perl as a tool is the Boatswain's Best Friend. I would not at all be surprised to find Holly Hacking Perl. He had a keen intuitive understanding for what was USEFUL. As I would explain to the VP of Engineering at one place, when he failed to understand the deep inner 'religious commitment' that some of us have for 'jury rigging', it is that FINE ART of getting the ship back to port so that all of them thar High Priced Naval Engineers can do the voodoo they do so well. But that potential availablity of the 'high priced help' is really not gonna do anyone any good over the 50 fathom curve if we turn into REEF FODDER. So if, as Dan Muey has found the inclination, one is interested in better understanding say 'c' and how to deal with 'pointers' and memory allocations, then please avail one's self of the same 'learning to learn' skills that one acquired to learn about Perl to learn about 'c code'. And IF one really does need to be implementing 'cost effective' algorthims, please, do not let me be the excuse for NOT getting the level of competent training that would help you get there. IF one REALLY wants to do that with some sense of funk, then download the current release of the perl source code and rummage around in it. Just as you would rummage round in a Perl Module. IF you don't get it, then send email off to the cat who cut the code and say, Hey, in foo.c you did most of them will be more than willing to explain why they went that way... But just like you learned how to learn Perl remember that 'c', et al, has it's, well, foibles, arcanea, and whizz bangery stuff... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: passing code inside function
probably what I need is something about 'call back' Another example inside one script. this works: use Data::Dumper; sub a { return Dumper({$_[0]}); } print(a sub {$_ = 5;}); This also works: use Data::Dumper; sub a() { return Dumper({$_[0]}); } print(a {$_ = 5;}); This no longuer works use Data::Dumper; sub a { return Dumper({$_[0]}); } print(a {$_ = 5;}); Is there some documentaction about this magic? MArcos -Original Message- From: drieux [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 9:39 AM To: Perl Perl Subject: Re: passing code inside function On Dec 9, 2003, at 12:14 AM, [EMAIL PROTECTED] wrote: I would like to read something about passing code inside function. Lets say that: This works: perl -e 'sub a(){print({$_[0]}, /n};$_=0; a {$_++} foreach 1..100' what you might want to think about is trying that as 'code' rather than as a command line gambit. What you seem to be interested in is doing what is elsewhere known as a 'call back' - and one of the better places to peek would be in perldoc -m File::Find to look at the actual implementation in the module, perldoc File::Find to look at the POD about the module. HTH. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
On Mon, Dec 08, 2003 at 11:33:08PM -0800 drieux wrote: On Dec 8, 2003, at 2:50 PM, Tassilo von Parseval wrote: [..] The current set of perl-porters that are able and willing to work on the core are with not many exceptions people with academic degrees. [..] hypothetical question, would one need to be a perl-porter to write good perl? Had you questioned that one needs an academic degree to learn Perl, this would be a viable question. But that was not what you said. Let's refresh your memory: Learn to be nice to undergrads and grad students. Think about the unpleasant lack of experience that they have in a wide range of issues. Most of them grew up in normal homes with median types of families. ALL they have to 'validate their personhood' IS that college degree, and their 'connections'. Unlike the rest of us who have different sets of 'connections' and different sets of Rules that drive our 'risk analysis'. You were referring to a 'wide range of issues' and not to Perl in particular. I was targetting the cited paragraph. I don't argue that you need the academic background to learn a programming language. However, knowing a language itself isn't very much compared to the problems that are waiting to be solved using this language. { would it be impolite to note in which language/languages the perl executable is 'written in'??? } Not at all, why should it? but since you have been ever so polite as to offer the opportunity, allow me to note one of my most favorite and silly misadventures in AcadamiaLand, [ little fairy-tail snipped ] You'll have a hard time trying to induce the general from the particular case. You'd need a proper induction for that which you haven't provided. So when you put my comments to Jason, and those who like jason, may be having issues with the INSANITY of the american educational system, back into their context, then you might want to actually go back and re-read them for what they are. Unfortunately, you haven't provided this context. Furthermore, I don't find any notion of the word America or American in your posting I was referring to. Hence I must assume that you were talking about academia in general. yes, yes, I know you are posting from aachen, so take the liberty moment and enjoy that I am not complaining about Germany... But if you wish I can do a few Herr Doktor stories if that would make you feel fuzzyWarm? No, it wouldn't. Besides, I take the liberty to claim that I have in general quite a good insight into the German academic system. It does have its rotten parts but it clearly does not suffer from any of the points that you mentioned. I can appreciate that I clearly must have ruffled some feathers, but could the issue be that there is a boring practicality to Perl that still escapes you? Me escaping Perl's practicality? No, I don't think so. And I wouldn't indulge with Perl if I found it boring, would I? A practicality that any reasonable person can acquire??? If on the other hand what they WANT is to understand 'algorithm construction' and sound 'performance analysis' - and the only place that one can do that is, allegedly, in 'the university' then go to it! DO THAT! But suddenly one has a Reasonable Excuse to be IN COLLEGE somewheres! But if the programme is not taking you where you want to go, BAIL! GET OUT! RUN AWAY! Anyway, you are switching topic once again. I can only follow-up to things that have actually been there. None of the above was to be found in this previous posting of yours though. The credo of your original message was rather flat and shallow: Avoid university at all costs because it can't teach you anything worthwhile. This is an immature statement which I addressed. Tassilo -- $_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Problems installing modules on OS X Panther
Hello list! I am starting to dig deeper into Perl, after having successfully written my first working script :-) I am trying to install modules on my Mac OS X 10.3 Server machine, but I usually end up getting errors like this for the GD package (1) or this for the Bundle::LWP (2). I did install gdlib2 via fink and libwww as well, but I keep getting the errors nevertheless. I tried installing as an admin user, root, even through webmin, but I always ended up unsuccessful. There are even more modules I cannot install, like DBD::Pg, Bundle::DBI worked fine though (via webmin). Bundle::CPAN did install partly with an error (3). I am using OS X' pre-installed Perl 5.8.1-RC3 Do I need to install certain things first? Is that my or my machines fault? Any help is greatly appreciated! Stephan (1) Error produced by perl -MCPAN -e 'install GD' /private/var/root/.cpan/build/GD-2.11/blib/arch/auto/GD/GD.bundle undefined reference to _gdImagePngPtrEx expected to be defined in a dynamic image t/Polylinedubious Test returned status 0 (wstat 5, 0x5) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed --- t/GD.t 0 510 20 200.00% 1-10 t/Polyline.t0 5 12 200.00% 1 Failed 2/2 test scripts, 0.00% okay. 11/11 subtests failed, 0.00% okay. make: *** [test_dynamic] Error 2 /usr/bin/make test -- NOT OK Running make install make test had returned bad status, won't install without force (2) Error produced by perl -MCPAN -e 'install GD' Failed 4/28 test scripts, 85.71% okay. 47/388 subtests failed, 87.89% okay. make: *** [test] Error 2 /usr/bin/make test -- NOT OK Running make install make test had returned bad status, won't install without force Bundle summary: The following items in bundle Bundle::LWP had installation problems: Net::FTP LWP (3) Error produced by perl -MCPAN -e 'install Bundle::CPAN' Running make install Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Writing ///Library/Perl/5.8.1/darwin-thread-multi-2level/auto/Data/Dumper/ .packlist Appending installation info to ///System/Library/Perl/5.8.1/darwin-thread-multi-2level/perllocal.pod /usr/bin/make install -- OK Net::Telnet is up to date. Net::Cmd is up to date. Bundle summary: The following items in bundle Bundle::libnet had installation problems: Data::Dumper Term::ReadKey is up to date. Term::ReadLine::Perl is up to date. CPAN is up to date. Bundle summary: The following items in bundle Bundle::CPAN had installation problems: Bundle::libnet and the following items had problems during recursive bundle calls: Data::Dumper -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
On Dec 9, 2003, at 1:24 AM, Tassilo von Parseval wrote: [..] hypothetical question, would one need to be a perl-porter to write good perl? [..] let us get simple. how about answering the simple question. it was the core of your alleged argument. IF you can make it fly, great. Otherwise, feel free to deal with what ever issue you think you need to deal with. I proposed the question based upon your argument and the amusement from an interview in which I had a lot of fun with their 'perl guy' as we were playing around and got into those 'and how is this implemented in perl' stuff that had to deal with all of this interesting intellectualizing about perl at IT's code level, vice Perl the coding language, at which point I merely countered with the classical, If run time efficiency is our issue, then why exactly are we buying that overhead to have a run time compile of the code vice a pre-built build of the code optimized for the hardware specific OS and it's implementation of that Machine Language? So Please. Carry On with your crusade... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: passing code inside function
On Tue, Dec 09, 2003 at 09:14:52AM +0100 [EMAIL PROTECTED] wrote: I would like to read something about passing code inside function. Lets say that: This works: perl -e 'sub a(){print({$_[0]}, /n};$_=0; a {$_++} foreach 1..100' This don't work perl -e 'sub a{print({$_[0]}, /n};$_=0; a {$_++} foreach 1..100' It will work once you do perl -e 'sub a{print({$_[0]}, \n)}; a sub {$_++} foreach 1..100' The prototype '' will let perl treat a bare block as a codereference. If there is no such prototype, you have to construct the code-ref yourself, which can happen in several ways: \func; # reference to the named function 'func' sub { ... } # reference to an anonymous function Tassilo -- $_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
On Dec 9, 2003, at 1:57 AM, [EMAIL PROTECTED] wrote: Before I can say that I'm a Perl Programmer, I have to say that I'm a Programmer. why? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: The True Path to Learning Perl Re: [OT] Education Level
please let's do a split(/\s/, Perl Programmer). this return one array with two scalar: Perl Programmer that's why -Original Message- From: drieux [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 11:01 AM To: Perl Perl Subject: Re: The True Path to Learning Perl Re: [OT] Education Level On Dec 9, 2003, at 1:57 AM, [EMAIL PROTECTED] wrote: Before I can say that I'm a Perl Programmer, I have to say that I'm a Programmer. why? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sorter script [was: Frustrated newbie question]
Bryan Harris wrote: Sometimes perl isn't quite the right tool for the job... % man sort % man uniq If you code it correctly (unlike the program at the URL above) then a perl version will be more efficient and faster than using sort and uniq. Please explain... That's the last conclusion I thought anyone would be able to reach. How about a little demo. The times posted are the fastest from ten runs of the same programs. $ perl -le'print int(rand(10_000)+50_000) for 1 .. 1_000_000' random.txt $ time sort random.txt | uniq sorted.shell real0m38.799s user0m34.880s sys 0m2.920s $ time sort -u random.txt sorted.shell real0m23.452s user0m22.520s sys 0m0.720s $ time perl -lne'$h{$_}=()}{print for sort keys%h' random.txt sorted.perl real0m18.450s user0m17.880s sys 0m0.450s $ diff -s sorted.shell sorted.perl Files sorted.shell and sorted.perl are identical The sort | uniq version has to run two processes and pass the whole file through the pipe from one process to the next. The sort -u version has to sort the whole file first and then outputs only the unique values. The perl version uses a hash to store the unique values first and then outputs the sorted values. Depending on the number of duplicate values, the perl version will usually be faster as it has to sort a smaller list. 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
Re: The True Path to Learning Perl Re: [OT] Education Level
On Tue, Dec 09, 2003 at 01:43:06AM -0800 drieux wrote: On Dec 9, 2003, at 1:24 AM, Tassilo von Parseval wrote: [..] hypothetical question, would one need to be a perl-porter to write good perl? [..] let us get simple. how about answering the simple question. it was the core of your alleged argument. No, it wasn't. Since you are so sure about it, maybe you just quote the relevant parts of what I wrote instead of making wild assumptions. The core of my statement was that Perl wouldn't be Perl as we know it if there hadn't been some people with academic backgrounds working on its core. This was a direct reply to your claim that academic education is essentially useless. Tassilo -- $_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: @INC paths on an IIS server
-Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 8:42 PM To: Ron Goral Cc: Perl Beginners Subject: Re: @INC paths on an IIS server This strikes me as strange, because I have never had any problems using module placed correctly in relative paths, and I've never had to modify @INC to do so. This includes working with IIS. Are you sure that the filename is an exact case-sensitive match for the class name? Windows doesn't care, but Perl does. Yes, I am ensuring the case of the file names called. Have you telnetted into the directory to see what the view looks like from there? It should work. Hmmm, what version of Windows and Perl is running on the server? The box is mine at home. I am operating Windows 2000 Pro with IIS installed. The Perl version is 5.61. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: passing code inside function
Hi Marcos. First let's remove some fog from your code. Your anonymous subroutine sub {$_ = 5;} is returning the value '5' because that's the value of the assignment operator '='. The assigment to $_ is serving no useful purpose as $_ isn't used anywhere else. So we can reduce this to sub { return 5 } Right, now lets fix some over-compression. your various versions of sub a { } are indirecting stuff off the stack and returning the result of a procedure call, all in one line. In addition your call to Dumper return Dumper({$_[0]}) has an explcit 'return' and explicit list delimiters '()' whereas the call to a a sub {$_ = 5;} instead of a(sub {return $_ = 5}) has the opposite convention. Now then, one by one: Marcos Rebelo wrote: probably what I need is something about 'call back' Another example inside one script. this works: use Data::Dumper; sub a { return Dumper({$_[0]}); } print(a sub {$_ = 5;}); Is the same as sub a { my $sub = shift; return Dumper $sub; } my $routine= sub {return 5}; print(a $routine); This also works: use Data::Dumper; sub a() { return Dumper({$_[0]}); } print(a {$_ = 5;}); Is the same as sub a() { my $sub = shift; return Dumper $sub; } print(a {return 5}); The difference here is that the prototype sub a() turns the subroutine into a list operator, and insists that the the list be either a code block (which it is) a single subroutine reference. If you were to call a(99) with the prototype set up then at run-time the program would fail at the call because the parameter was of the wrong type. Without it it would fail at the Dumper $sub line because any parameter type was OK but it couldn't be dereferenced here as a subroutine. And, finally This no longuer works use Data::Dumper; sub a { return Dumper({$_[0]}); } print(a {$_ = 5;}); Is simply invalid syntax because a {$_ = 5;} is using a bare code block in place of the parameter to a. This is different entirely from an anonymous subroutine. (You can pass a code block as a parameter only if the subroutine is prototyped as above. Otherwise you have to pass an anonymous subroutine.) With the prototype you used in the second example this would be OK. Like this: sub a() { my $sub = shift; return Dumper $sub; } print(a {return 5}); Is there some documentaction about this magic? Your best place is perldoc perlsub but don't get too engrossed in the fancy stuff. You will almost never need subroutine prototypes. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Getting a local file
Hi Jason. Jason Chinnes wrote: I am using mod_perl with Apache 1.3 (Win32) and am having difficulty with the following code. -- use CGI; use Data::Dumper; use HTTP::Request; use LWP::UserAgent; my $q = new CGI; $ua = new LWP::UserAgent; $site = 'http://www.example.com/'; print $q-header; # create the HTTP header $request = new HTTP::Request GET = $site; $response = $ua-request($request); print $response-content; -- You're getting a confused here. The CGI module is for server-side applications while LWP is client-side. If all you're doing is trying to fetch a file from the Internet then the above reduces to: use strict; use warnings; use LWP::UserAgent; my $ua = new LWP::UserAgent; my $site = 'http://www.example.com/'; my $response = $ua-get($site); print $response-content; Printing an HTTP header to STDOUT has no useful purpose at all. This works fine when $site = 'http://www.example.com/' or anything else that's not on my server. When it is on my server (say 'http://localhost/') the client hangs. Apache's access.log file lists: It sounds like your local machine isn't an HTTP server. If that's the case then just use the file 'protocol' instead: my $site = 'file:/home/rob/test.txt'; 127.0.0.1 - - [08/Dec/2003:16:57:30 -0500] GET / HTTP/1.1 200 3337 But, this file never seems to make it back to my script. http://localhost/ comes up fine in a browser, and when I telnet in and make the request manually. Now it looks like you /are/ in fact living on an HTTP server. But you need to find the scope of directories that Apache will serve. Have you tried my $site = 'http://localhost/'; without any explicit filename? That should bring in the default 'index.htm' (or whatever). HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Getting a local file
Rob, Thanks for your reduction of the code, and for your input in general. I have tried http://localhost/ w/o a file name. In a browser, I get the apache generated directory index. From the script, however, I get the same hanging behavior untill it times out. In regardes to your comment: Printing an HTTP header to STDOUT has no useful purpose at all. this is not compleate task at hand. It is simply my simplification of the exact problem I'm having. The full task at hand involves java servlets which are generating binary files which will be further manipulated by my scripts, but the details of that are beyond the scope of this issue. Thank you again for your help with this. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: perl and qmail aliases
I wrote a Perl script that runs a query against a MySQL db to get a list of customer email addresses. This script then takes a full email for input and rewrites the 'To' header and sends it with qmail-inject for each email address from the db. I have an alias set up in qmail that pipes anything sent through it into this script that I wrote. This setup works just fine, except when an email address no longer exists. The MTA of the server where the email no longer exists sends the failure notice to alias@myhost instead of to originalsender@myhost. Does anyone know why this is? Something in the headers I bet. What do the qmail logs say? Is your script modifying the headers at all? Also, does anyone see any ways I could optimize my script? My script is below. #!/usr/bin/perl use DBI(); Just do use DBI; my $counter = 0; my @email; my $dbh = DBI-connect(DBI:mysql:database=db;host=ip, ...connect('DBI:mysql:Dbname:host','user','pass')... username, password, {'RaiseError' = 1}); my $query = SELECT fname, lname, homeemail, officeemail FROM people WHERE current=1; my $sth = $dbh-prepare($query); Instead of the prepare, execute, finish dance you could try one of the variouse versions of selectall_* I like to do this usually: for(@{$dbh-selectall_arrayref(SELECT foo,bar FROM JoeMama WHERE BenDover=0)}) { my ($foo,$bar) = @{$_}; Process record here } You can do that with a heash ref like you're using here. Simplfies it a bit for easier debugging, etc.. $sth-execute(); HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: The True Path to Learning Perl Re: [OT] Education Level
please let's do a split(/\s/, Perl Programmer). this return one array with two scalar: Perl Programmer that's why Back to semantics, define Programmer. Your definition of programmer, if it requires any knowledge of UML, is so strict that it will not work in 99% of circles where the term is thrown around *today*. Admittedly I have very little knowledge of UML, but my employer seems very happy with my abilities as a programmer, and from what little I have seen and read around the subject UML is a colossal waste of time on any real programming project. http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Problems installing modules on OS X Panther
On Dec 9, 2003, at 3:37 AM, Stephan Hochhaus wrote: Hello list! I am starting to dig deeper into Perl, after having successfully written my first working script :-) I am trying to install modules on my Mac OS X 10.3 Server machine, but I usually end up getting errors like this for the GD package (1) or this for the Bundle::LWP (2). I did install gdlib2 via fink and libwww as well, but I keep getting the errors nevertheless. I tried installing as an admin user, root, even through webmin, but I always ended up unsuccessful. There are even more modules I cannot install, like DBD::Pg, Bundle::DBI worked fine though (via webmin). Bundle::CPAN did install partly with an error (3). I am using OS X' pre-installed Perl 5.8.1-RC3 Do I need to install certain things first? Is that my or my machines fault? Any help is greatly appreciated! I don't have a lot of insight to offer on your problems, unfortunately. I've had a lot of success installing modules on my Mac OS X box, but it's not Server. What I did want to offer though, is to make sure you know there is a Mac OS X Perl mailing list where I bet they could fix you right up. You can find it here: http://lists.perl.org/showlist.cgi?name=macosx James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What are the dangers of leaving a cgi-bin directory CHMOD 777
On Dec 8, 2003, at 3:15 PM, Dan Anderson wrote: I have a perl script that writes to its directory, and as such the directory is CHMOD 777 in my cgi-bin. (Linux box) I figured this might be dangerous, but didn't think there was any harm in it. Am I right or will the script kiddies be all over me? remember the basic permission issues, that final 7 is the killer, it will allow anyone who can get to it to 'write' to it. Which I think might need to be clarified a bit... Anyone that can get to it implies local server access rather than simply a web browser anywhere in the world. Which would allow them to install anything in that directory that they would want to install, and then call it... Again installing has a bigger definition than merely writing a file into a directory, but regardless the web server still has to have the ability to do this installing or to provide access to write a file into an arbitrary location (*and* with proper executable permissions so that it will execute). general practice is maybe 755 for a cgi bin directory since there really is no gooder reason for group to have 'write' access to the directory. Having clarified that, the security risk of *just* having a 777 directory is not as many elsewhere would have you think, it is still not good practice. There are times I think when having group write permission on a directory is a conscious decision, but it *needs* to be (a conscious decision), before one applies said permissions. This is where we get into the domain of best practices in order to reduce vulnerability rather than absolute musts to insure even minimal security. Of course all of this hinges on the server software and configuration thereof. If your server software allows PUT request methods then all bets are off http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: This seems to ease
On Dec 9, 2003, at 1:28 AM, [EMAIL PROTECTED] wrote: I didn't know List::Util, but I have something done by myself. Probably everyone that don't know this module has one. List::Util is a standard module now and worth a look. perldoc List::Util James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Getting a local file
Jason Chinnes wrote: Thanks for your reduction of the code, and for your input in general. I have tried http://localhost/ w/o a file name. In a browser, I get the apache generated directory index. From the script, however, I get the same hanging behavior untill it times out. In regardes to your comment: Then the only other thing I can think of is that Perl is using a different proxy setup from your browser. Check out the POD for LWP and LWP::UserAgent which shows you how to define a proxy for an LWP::UserAgent object. You may need to talk to your sysadmin for the details. In any case it would be an odd way to set up a network to force internal IP addresses through a proxy by default. You might even try finding out your real IP address and using that instead of the 'localhost' loopback. After that then I'm stumped. Does the GET just hang forever or does it time out? If it finishes eventually Have you done: print $response-status_line to see what the final status is. Rob wrote: Printing an HTTP header to STDOUT has no useful purpose at all. this is not compleate task at hand. It is simply my simplification of the exact problem I'm having. The full task at hand involves java servlets which are generating binary files which will be further manipulated by my scripts, but the details of that are beyond the scope of this issue. OK, so you're both server and client, which makes sense. Have you always run this code as a CGI fire up by Apache? If so, then you would do better to make it work stand-alone from your command line before simultaneously battling the restrictions imposed on the server's login. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: perl and qmail aliases
Dan Muey wrote: I wrote a Perl script that runs a query against a MySQL db to get a list of customer email addresses. This script then takes a full email for input and rewrites the 'To' header and sends it with qmail-inject for each email address from the db. I have an alias set up in qmail that pipes anything sent through it into this script that I wrote. This setup works just fine, except when an email address no longer exists. The MTA of the server where the email no longer exists sends the failure notice to alias@myhost instead of to originalsender@myhost. Does anyone know why this is? Something in the headers I bet. What do the qmail logs say? Is your script modifying the headers at all? The script only modifies to 'To' header. Also, does anyone see any ways I could optimize my script? My script is below. #!/usr/bin/perl use DBI(); Just do use DBI; my $counter = 0; my @email; my $dbh = DBI-connect(DBI:mysql:database=db;host=ip, ...connect('DBI:mysql:Dbname:host','user','pass')... username, password, {'RaiseError' = 1}); my $query = SELECT fname, lname, homeemail, officeemail FROM people WHERE current=1; my $sth = $dbh-prepare($query); Instead of the prepare, execute, finish dance you could try one of the variouse versions of selectall_* I like to do this usually: for(@{$dbh-selectall_arrayref(SELECT foo,bar FROM JoeMama WHERE BenDover=0)}) { my ($foo,$bar) = @{$_}; Process record here } You can do that with a heash ref like you're using here. Simplfies it a bit for easier debugging, etc.. I'll look into this. $sth-execute(); -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sorter script [was: Frustrated newbie question]
Bryan Harris wrote: Sometimes perl isn't quite the right tool for the job... % man sort % man uniq If you code it correctly (unlike the program at the URL above) then a perl version will be more efficient and faster than using sort and uniq. Please explain... That's the last conclusion I thought anyone would be able to reach. How about a little demo. The times posted are the fastest from ten runs of the same programs. [stuff cut out] The sort | uniq version has to run two processes and pass the whole file through the pipe from one process to the next. The sort -u version has to sort the whole file first and then outputs only the unique values. The perl version uses a hash to store the unique values first and then outputs the sorted values. Depending on the number of duplicate values, the perl version will usually be faster as it has to sort a smaller list. I see! I just don't understand... I thought perl's memory management, code interpretation, overhead in creating hashes and just in running would've taken far longer than sort. Heck, why don't they just rewrite sort in perl if it's that much faster? - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
wildcard File::Copy
Hi all, Anyone know how to do a wildcard file::copy? E.g. I want to copy a file with a certain name but different extensions. I have tried concatenating .* to the end of a filename (without an extension obviously) but it fails. This is what I had in mind...it's just a scribble and not exactly the way the code will go. $string2 = $string[1]..*; copy($string2,$destination) || warn could not copy files: $!; Thanx Ben __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
command line commands passed to perl script?
Hi all, Sorry, should have added this to my last email. Does anyone know how to pass values to a perl script through the command line? Do you use param as in CGI scripting/ I want a user to be able to specify certain parameters for the perl script (in case they want to run an overnight scheduler on it). Eg. testscript.pl /? gives you help or testscript /a gives you another capability... Ben __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: command line commands passed to perl script?
Nameofperlscript command1 command2 command3 Params stored in global variable @ARGV -Original Message- From: Ben Crane [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 11:23 AM To: [EMAIL PROTECTED] Subject: command line commands passed to perl script? Hi all, Sorry, should have added this to my last email. Does anyone know how to pass values to a perl script through the command line? Do you use param as in CGI scripting/ I want a user to be able to specify certain parameters for the perl script (in case they want to run an overnight scheduler on it). Eg. testscript.pl /? gives you help or testscript /a gives you another capability... Ben __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
SMTP From field using MIME::Lite
I wrote the following code: MIME::Lite-send('smtp', mail.myserver.com, Timeout=60); $msg = MIME::Lite-new( From =[EMAIL PROTECTED], To ='[EMAIL PROTECTED]', Subject =TEST, Data =TEST, ); $msg-send; I want to have a display name present in the From field. In other words, I would like the 'From' field to read: Reporting Agent [EMAIL PROTECTED] I can't seem to do this no matter what I try. Can I do this with MIME::Lite? --Paul
RE: SMTP From field using MIME::Lite
I wrote the following code: MIME::Lite-send('smtp', mail.myserver.com, Timeout=60); $msg = MIME::Lite-new( From =[EMAIL PROTECTED], To ='[EMAIL PROTECTED]', Subject =TEST, Data =TEST, ); $msg-send; I want to have a display name present in the From field. In other words, I would like the 'From' field to read: Your code is correct. I would write the from as '[EMAIL PROTECTED]' to avoid esaping the @. What do you get back when this is sent? This is a text only message correct? Here are some examples from the docs... Create a simple message containing just text $msg = MIME::Lite-new( From ='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED], [EMAIL PROTECTED]', Subject ='Helloo, nurse!', Data =How's it goin', eh? ); Create a simple message containing just an image $msg = MIME::Lite-new( From ='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED], [EMAIL PROTECTED]', Subject ='Helloo, nurse!', Type ='image/gif', Encoding ='base64', Path ='hellonurse.gif' ); Create a multipart message ### Create the multipart container: $msg = MIME::Lite-new( From='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED], [EMAIL PROTECTED]', Subject ='A message with 2 parts...', Type='multipart/mixed' ); ### Add the text message part: ### (Note that attach has same arguments as new): $msg-attach(Type ='TEXT', Data =Here's the GIF file you wanted ); ### Add the image part: $msg-attach(Type ='image/gif', Path ='aaa000123.gif', Filename ='logo.gif', Disposition = 'attachment' ); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: wildcard File::Copy
On Dec 9, 2003, at 8:12 AM, Ben Crane wrote: [..] $string2 = $string[1]..*; copy($string2,$destination) || warn could not copy files: $!; It does not appear that $string2 is a FileHandle glob - which I think is your issue here. cf: perldoc -f glob perldoc File::Glob ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sorter script [was: Frustrated newbie question]
On Dec 9, 2003, at 7:45 AM, Bryan Harris wrote: [..] Heck, why don't they just rewrite sort in perl if it's that much faster? http://www.perl.com/language/ppt/src/sort/index.html since you asked... 8-) ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
Drieux wrote: [snip OP] first off you really SHOULD NOT scare people with phrases like write microcode for and then refer to a four digit chipset. WAY BAD FORM. { and yes, doing the Motorola side of the assembler on a RISC was much easier, none of that reverse polish notation smack... } IYHO presumably? The best way to learn perl is to have someone on site who can mentor you, since that way you have the constraint of professional requirements, and can see where perl fits into the flow. IF you can not find a SithLord, then, well, join the rest of us the old fashion way, vote for comp.lang.perl - oh yeah, that's already happened... Buy the Big Book, make mistakes, enjoy... IYHO presumably? The hardest part is getting the knack for telling which things are worth knowing, and which are merely passing fads, the cult du jure... ... 'culte du jour'. now back to the academic side of the chat. On Dec 8, 2003, at 4:07 AM, Rob Dixon wrote: Marcos Rebelo wrote: [..] from this side the University is very important. Most of all, for learning how to think. Exactly. And that's the basis of all the best English universities which are, sadly, being swamped by all of our 'polytechnics' being rebranded. If you can't think, then no amount of 'Computer Science' lectures will help you to program. I'm not sure that I like the phrase learning how to think as much as I would probably argue for develop the habit of formal analysis Well, for me, 'formal analysis' belongs alongside 'writing in Perl'. If I paraphrase myself: Rob wrote: If you can't think, then no amount of 'Computer Science' lectures will help you to [develop the habit of formal analysis]. I start to think about a seven-layer model of understanding ;) and from there hopefully move on into the rest of the process of being able to present that analysis in some polite way, eg: Well now that is Organic Fertilizer,... rather than merely blurting out say: smells like dung to moi... This sounds just like the anti-jargon argument over again. The people who need to distinguish finely between very similar ideas will always have to use 'specialist' phrases which are impenetrable to most. What would be useful of the undergrad liberal arts world would be a more active engagement in the fine art of 'learning to learn' - namely that it is not simply something that happens IN the hallowed halls of the Ivory Tower, but is a fundamental survival skill mix that separates the eaters from the food. It is a BAD SIGN when On Dec 8, 2003, at 8:39 AM, Robert Brown wrote: [..] I spent my freshman year at Duke in 1969 and got kicked out because the second semister I lived in the computer center and never went to class. [..] IYHO presumably? I believe that ability (especially in the more mental subjects) comes from ideas and not vice-versa. I would compare an analyst's job with that of a journalist's, both of who need primarily to be able to think, and secondarily to be able to express those thoughts. One of the other things that one should be learning as an undergrad is a bit about 'time management' as well as the various social and cultural skills that make the university environment the recruiting grounds for various spying organizations... And there is where we primarily differ. From two or three years old I was able to decide what I wanted to do and when. Making the commercial process more efficient is surely the job of 'management', whether it be government or parenthood? Wasn't 'spying organizations' somewhat tongue-in-cheek? Education is nice, but the economy is the governing factor. I still have that wife and daughter I told you about! This, unfortunately, is NOT something that most universities will teach you up front. Having all of the brilliance in the world does NOT mean that it will make a job possible. Nor for that matter, that one can figure out a way to sustain a long term growing set of personal relationships. Ah! A new word - 'brilliance' - which is even more vague than 'science' or 'knowledge'. It sounds to me as if your argument is for perceived achievement as opposed to personal fulfillment. A 'job' and 'relationships' are purely personal goals. I have felt as much fulfilled by my studies of Latin and Greek as by my prenatal classes and basketball training. With a skewed perception the classical languages have provided insight even into ball games. There is also nested in Robert's presentation that more interesting idea - namely that one go back and attend university anyway, and this time to do it with an intention to graduate, and in a field that you find at least interesting and amusing. Nothing Screws Up the Kiddies like Grey Panthers arriving back 'from the fleet' with 'additional perspective' not included in the SillyBuy from the Prof Erm. Pass. I didn't understand a word of that. Ultimately one needs to re-read Marcos' other line:
Re: command line commands passed to perl script?
You should use this: testscript.pl blah where blah is the value to pass. Ben Crane wrote: Hi all, Sorry, should have added this to my last email. Does anyone know how to pass values to a perl script through the command line? Do you use param as in CGI scripting/ I want a user to be able to specify certain parameters for the perl script (in case they want to run an overnight scheduler on it). Eg. testscript.pl /? gives you help or testscript /a gives you another capability... Ben __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: SMTP From field using MIME::Lite
I want to be able to add a display name as well. For example: Paul Harwood instead of the SMTP address. I wrote the following code: MIME::Lite-send('smtp', mail.myserver.com, Timeout=60); $msg = MIME::Lite-new( From =[EMAIL PROTECTED], To ='[EMAIL PROTECTED]', Subject =TEST, Data =TEST, ); $msg-send; I want to have a display name present in the From field. In other words, I would like the 'From' field to read: Your code is correct. I would write the from as '[EMAIL PROTECTED]' to avoid esaping the @. What do you get back when this is sent? This is a text only message correct? Here are some examples from the docs... Create a simple message containing just text $msg = MIME::Lite-new( From ='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED], [EMAIL PROTECTED]', Subject ='Helloo, nurse!', Data =How's it goin', eh? ); Create a simple message containing just an image $msg = MIME::Lite-new( From ='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED], [EMAIL PROTECTED]', Subject ='Helloo, nurse!', Type ='image/gif', Encoding ='base64', Path ='hellonurse.gif' ); Create a multipart message ### Create the multipart container: $msg = MIME::Lite-new( From='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED], [EMAIL PROTECTED]', Subject ='A message with 2 parts...', Type='multipart/mixed' ); ### Add the text message part: ### (Note that attach has same arguments as new): $msg-attach(Type ='TEXT', Data =Here's the GIF file you wanted ); ### Add the image part: $msg-attach(Type ='image/gif', Path ='aaa000123.gif', Filename ='logo.gif', Disposition = 'attachment' );
Re: sendmail error: No reciient address found in header
I got it. I never thought indentation could cause sendmail to mess up. As a beginner, I need you try everything possible to know their pros and cons. Next time - I may consider using a CPAN module. :-) Thanks Wiggins d'Anconia wrote: B. Fongo wrote: It's my first time to use sendmail. I want to my script to send a mail to [EMAIL PROTECTED] or whoever is in the To: line. The script warns:No recipient name found in the header and dies, even though there's a recipient. I'm puzzled. ### #!/usr/bin/perl -w use strict; mail_users(); sub mail_users{ open(MAILPROG, |/usr/sbin/sendmail -oi -t) || die Can't open sendmail: $!\n; print MAILPROG END_MAIL; From: ftp_update.pl To: root [EMAIL PROTECTED] Subject: Software updates Hello You may copy and paste this at the shell-prompt to test dependencies: You may also use this command to install the Packages: END_MAIL close(MAILPROG); # Well obviously it isn't that you are missing a curly brace in your post as that gives a syntax error. Your example brings up two very good points, 1) why I don't drool over using heredocs as much as some of the other Perl gurus, too much can go wrong too fast, 2) why you should not mess with sending e-mail in a manual way such as piping a poorly made message into an incredibly complex program such as sendmail, but should instead employ one of the plethora of modules available from your local CPAN distributor. I *believe* the reason why your message is failing is because the header is not being constructed properly, because the header lines start with a 'tab' rather than being left aligned as they are supposed to be. I realize that you did so to follow indenting standards, an excellent idea, one that wouldn't affect HTML or the like, but has a large impact on the mail standards, which naturally you could have avoided had you used a module because in that case you were not likely to use a heredoc. That was a tough one, and yes I am a big geek who has worked on e-mail systems too long if I can spot that one HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: The True Path to Learning Perl Re: [OT] Education Level
Wiggins d Anconia writes: please let's do a split(/\s/, Perl Programmer). this return one array with two scalar: Perl Programmer that's why Back to semantics, define Programmer. Your definition of programmer, if it requires any knowledge of UML, is so strict that it will not work in 99% of circles where the term is thrown around *today*. Admittedly I have very little knowledge of UML, but my employer seems very happy with my abilities as a programmer, and from what little I have seen and read around the subject UML is a colossal waste of time on any real programming project. UML does not help you program; it helps you design. UML is a diagramming tool to help you think about the relationships between verious things that could make up a system. It is a way to view the big picture. Typical UML shows the relationships and data flow between many computers and many programs and the data flowing between them all. That does indeed turn out to be pretty useless when you are trying to code an optimal loop to perform efficiently inside one of those programs. When people abuse UML to the point of trying to express line-by-line details of a single program in UML, they need to be slapped! I do not write UML, but I can read it, and use the diagrams to discuss how a system design might be improved. It has proved very helpful to me on the few projects where the chief architect has used it properly. I come from the old school, having written my first program in 1967. I use any informal diagramming technique that helps me visualize and think about the problem at hand. This helps me a lot, but sometimes other people do not understand what I mean in these ad hoc diagrams. UML is an attempt to standardize the diagramming conventions to achieve protability among system architects. I remember having to throw out the idea of classical flow charts when I started writing context switching code for operating system internals in 1973. The classical flow chart could not capture the idea of parallelism. Of course, that was back in the good old days, when I had 8K 16 bit words of real magnetic core memory and a 2.5 microsecond cycle time -- translates to 32 KB main memory and 0.4 MHz on a 16 bit machine,and everything was coded in assembler. The smallest machine I ever programmed was 1 KB or ROM and 64 bytes of RAM; that was for a robotic tool that worked inside of a sewer pipe in 1982. Today I work on little PC's that have half a terabyte of disk, several gigabytes of RAM, and run at several GHz. They are networked together and function as a single system. In the words of Sun, The network *IS* the computer! Hardware guys make progress much easier than software guys. As we encounter new problems, we find that we need new tools to think about them. UML is a pretty good formal tool right now, but don't ever think that is is the end-all. I still like my informal diagrams for brainstorming. The formalizers can convert them into UML for the system documentation. They need to, as I will probably be long gone (I am a consultant) before some maintenence programmer read the docs when trying to fix some nasty bug. He needs to be able to understand the diagrams too, so formalization is necessary for portability between people who never get to communicate with each other any other way. -- And there came a writing to him from Elijah [2Ch 21:12] R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 847 543-4060 Elijah Laboratories Inc. 457 Signal Lane, Grayslake IL 60030 fax 847 543-4061 - M o d e l i n g t h e M e t h o d s o f t h e M i n d -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
removing duplicate lines
I am writing a Perl script to automatically generate a netlogon.bat file for Samba whenever a user logs onto a domain. The only parameter that is passes to it is the username. My problem is that different groups get some of the same mappings. What I really need to do is filter out duplicate lines in the finished output. I tried piping the output through 'uniq' but it only filters successive duplicate lines. Anyone have any suggestions? #!/usr/bin/perl my $user = shift; my $drives = {F = NET USE F: SKYLINE\\SKYLINEF\r\n, H = NET USE H: SKYLINE\\SHARE\r\n, I = NET USE I: SHIPPING1\\INVENTORY\r\n, M = NET USE M: SKYLINE\\SKYLINEM\r\n, S = NET USE S: SHIPPING1\\SHOP\r\n, Y = NET USE Y: ACCOUNTING\\FLTSCHOOL\r\n, Z = NET USE Z: ACCOUNTING\\MAINT\r\n}; my $which = {accounting = F H I M S Y Z, mech = I M S Z, dispatch = M, instructors = M}; my $groups = `cat /etc/group | grep ${user} | cut -d ':' -f 1`; $groups =~ s/\n/\:/sg; # Start generating logon script #open LOGON, /usr/local/samba/netlogon/${user}.bat; open LOGON, /tmp/${user}.bat; print LOGON [EMAIL PROTECTED] OFF\r\n; foreach $group (split /:/, $groups) { foreach $drive (split / /, $which-{$group}) { print LOGON $drives-{$drive}; } } close LOGON; -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
Drieux wrote: In PART because with things like the Internet, IF one wants to learn, one can and at far cheaper rates. if this is a joke, it's laughable. if it's not a joke, you are laughable. david -- s,.*,,e,y,\n,,d,y,.s,10,,s .ss.s.s...s.sss.s.ss s.s.s...s...s..s ...s.ss..s.sss..ss.sss.s s.s.s...ss.sss.s ..s..sss.s.ss.sss... ..ssss.sss.sss.s ,{4},|?{*=}_'y!'+0!$; ,ge,y,!#:$_(-*[./[EMAIL PROTECTED],b-t, .y...,$~=q~=?,;^_#+?{~,,$~=~ y.!-*-/:[EMAIL PROTECTED] ().;s,;, );,g,s,s,$~s,g,y,y,%,,g,eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
Hi Everyone, I would like to suggest that we drop the thread or bring it to focus on something less invidious than students vs. townies. I think it goes without saying that academia has many faults - but the autodidact is often a victim of his own whims and idiosyncracies. If this thread is to go on, it would surely be more polite (and more instructive) if the autodidacts spoke a little bit about the problems with their method and the academically trained made note of the various problems with academia. I am currently entering into a CS program, so I guess I fall into the second category. However, I am going to hold my tongue. - Jason Let everyone sweep in front of his own door and the whole world will be clean. -Goethe
Re: pid of process opened by system
[EMAIL PROTECTED] wrote: This doesn't work, because system forks itself: Parent `- child1 (opened by fork) `- child2 (opend by system of child1) yes and sorry i misunderstood your question. david -- s,.*,,e,y,\n,,d,y,.s,10,,s .ss.s.s...s.sss.s.ss s.s.s...s...s..s ...s.ss..s.sss..ss.sss.s s.s.s...ss.sss.s ..s..sss.s.ss.sss... ..ssss.sss.sss.s ,{4},|?{*=}_'y!'+0!$; ,ge,y,!#:$_(-*[./[EMAIL PROTECTED],b-t, .y...,$~=q~=?,;^_#+?{~,,$~=~ y.!-*-/:[EMAIL PROTECTED] ().;s,;, );,g,s,s,$~s,g,y,y,%,,g,eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing duplicate lines
Andrew Gaffney wrote: I am writing a Perl script to automatically generate a netlogon.bat file for Samba whenever a user logs onto a domain. The only parameter that is passes to it is the username. My problem is that different groups get some of the same mappings. What I really need to do is filter out duplicate lines in the finished output. I tried piping the output through 'uniq' but it only filters successive duplicate lines. Anyone have any suggestions? [snip code] Hi Andrew. The quick answer is: perldoc -q dupl If you need any more then ask again :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: command line commands passed to perl script?
On Dec 9, 2003, at 8:38 AM, Paul Kraus wrote: [..] Nameofperlscript command1 command2 command3 Params stored in global variable @ARGV ben, the alternative of course is to look into perldoc Getopt::Long where you can do many majical voodoo with... Oh dear, just found my old DOG about getopt http://www.wetware.com/drieux/pbl/Sys/NextStuff/getOptStd.txt oye is that old... and yes it was built to have code start code that does the GetOpt stuff... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Pattern Match
Hi All, I am very new to Perl, but I sense a great adventure ahead after just programming with Cobol, Pascal, and C over the last umpteen years. I have written a perl script where I am trying to detect a non-printing character(Ctrl@ - Ctrl_) and then substitute a printing ASCII sequence such as ^@ in its place, but it does not seem to work as I would like. Any advice would be greatly appreciated. Thank YouEric Sand $in_ctr=0; $out_ctr=0; while ($line = STDIN) { chomp($line); $in_ctr ++; if ($line = s/\c@,\cA,\cB,\cC,\cD,\cE,\cF,\cG,\cH,\cI,\cJ,\cK, \cL,\cM,\cN,\cO,\cP,\cQ,\cR,\cS,\cT,\cU,\cV,\cW, \cX,\cY,\cZ,\c[,\c\,\c],\c^,\c_ /^@,^A,^B,^C,^D,^E,^F,^G,^H,^I,^J,^K, ^L,^N,^N,^O,^P,^Q,^R,^S,^T,^U,^V,^W, ^X,^Y,^Z,^[,^\,^],^^,^_/) { $out_ctr ++; printf(Non-printing chars detected in: %s\n,$line); } } printf(Total records read = %d\n,$in_ctr); printf(Total records written with non-printing characters = %d\n,$out_ctr); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
[ADMIN] Re: The True Path to Learning Perl Re: [OT] Education Level
It was Tuesday, December 09, 2003 when david took the soap box, saying: : Drieux wrote: : : In PART because with things like the Internet, IF : one wants to learn, one can and at far cheaper rates. : : if this is a joke, it's laughable. if it's not a joke, you are laughable. Picking a random post to respond to in this very lengthy OT thread... let's move on. I think the issues have been well discussed. So well, that we've degenerated. So feel free to continue in private, but I think we need to get back to helping folks in need. Thanks! Casey West -- Shooting yourself in the foot with APL You hear a gunshot and there's a hole in your foot, but you don't remember enough linear algebra to understand what has happened. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing duplicate lines
Rob Dixon wrote: Andrew Gaffney wrote: I am writing a Perl script to automatically generate a netlogon.bat file for Samba whenever a user logs onto a domain. The only parameter that is passes to it is the username. My problem is that different groups get some of the same mappings. What I really need to do is filter out duplicate lines in the finished output. I tried piping the output through 'uniq' but it only filters successive duplicate lines. Anyone have any suggestions? [snip code] Hi Andrew. The quick answer is: perldoc -q dupl If you need any more then ask again :) I was able to indirectly get the answer from that. Reading that, I realized that if I run my output through 'sort' and then 'uniq' or even just 'sort -u', it does what I want it to do. -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sendmail error: No reciient address found in header
Please bottom post I got it. I never thought indentation could cause sendmail to mess up. As a beginner, I need you try everything possible to know their pros and cons. Next time - I may consider using a CPAN module. :-) Thanks I would disagree here, as a beginner you should worry about the importance of *your code* and let those that have come before you (and failed before you) provide you with the pieces such to remove unneeded complexity. While I agree that attempting to code, what someone else may have already accomplished, is a worthy way to learn, using code for anything remotely important that you are learning with is probably not a good idea, at least in the case that there is already a module available. The problem (and you are not the first to have it) is not understanding the complexity involved in a particular process up front, e-mail is incredibly complex, and sendmail is incredibly complex on top of that so you were inevitably going to hit some obscure bug eventually. So the best answer is use a module when one is available, if you want to *learn* how something is handled then rather than poke around yourself guessing and testing, instead go to the module source! That is the beauty of this open source model! The other nice thing is that by piecing together other people's work, you will gain a familarity with respect to interface design, encapsulation, etc. so that you don't have to fail in the same way others have failed before (aka they had to change things to make them work). http://danconia.org snip old post -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Who can I tell what perl modules I have installed ?
Is there an easy way to list out all the perl modules I have installed ? I can list out everything in /usr/lib/perl/ but i figure there must be a better way ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing duplicate lines
Andrew Gaffney wrote: Rob Dixon wrote: Andrew Gaffney wrote: I am writing a Perl script to automatically generate a netlogon.bat file for Samba whenever a user logs onto a domain. The only parameter that is passes to it is the username. My problem is that different groups get some of the same mappings. What I really need to do is filter out duplicate lines in the finished output. I tried piping the output through 'uniq' but it only filters successive duplicate lines. Anyone have any suggestions? [snip code] Hi Andrew. The quick answer is: perldoc -q dupl If you need any more then ask again :) I was able to indirectly get the answer from that. Reading that, I realized that if I run my output through 'sort' and then 'uniq' or even just 'sort -u', it does what I want it to do. I'm reluctant to let this go, but a 'proper' answer would have to be of the, I wouldn't start from here, type. You've used Perl as a scripting language, which it isn't. Perl's very good at doing anything you need on a platform-independent basis, and shelling out with 'system' calls or backticks is almost never necessary and makes the whole program platform and shell-specific. If this is even a semi-permanent piece of software then, if I were you, I would let the group blitz it just to show you what can be done. You might even want to see that anyway as a learning exercise. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Who can I tell what perl modules I have installed ?
perldoc perllocal -will show the modules YOU have installed -Wade -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 1:50 PM To: [EMAIL PROTECTED] Subject: Who can I tell what perl modules I have installed ? Is there an easy way to list out all the perl modules I have installed ? I can list out everything in /usr/lib/perl/ but i figure there must be a better way ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Eric Sand wrote: I am very new to Perl, but I sense a great adventure ahead after just programming with Cobol, Pascal, and C over the last umpteen years. I have written a perl script where I am trying to detect a non-printing character(Ctrl@ - Ctrl_) and then substitute a printing ASCII sequence such as ^@ in its place, but it does not seem to work as I would like. Any advice would be greatly appreciated. Thank YouEric Sand Your obvious guess is to write Perl as if it were C. That's slightly better than treating it as a scripting language, but there are many joys left to be found! $in_ctr=0; $out_ctr=0; while ($line = STDIN) { chomp($line); $in_ctr ++; if ($line = s/\c@,\cA,\cB,\cC,\cD,\cE,\cF,\cG,\cH,\cI,\cJ,\cK, \cL,\cM,\cN,\cO,\cP,\cQ,\cR,\cS,\cT,\cU,\cV,\cW, \cX,\cY,\cZ,\c[,\c\,\c],\c^,\c_ /^@,^A,^B,^C,^D,^E,^F,^G,^H,^I,^J,^K, ^L,^N,^N,^O,^P,^Q,^R,^S,^T,^U,^V,^W, ^X,^Y,^Z,^[,^\,^],^^,^_/) { $out_ctr ++; printf(Non-printing chars detected in: %s\n,$line); } } printf(Total records read = %d\n,$in_ctr); printf(Total records written with non-printing characters = %d\n,$out_ctr); I would write this as below. The first things is to *always* use strict; use warnings; after which you have to declare all of your variables with 'my'. The second is to get used to using the default $_ variable which is set to the value for the current 'while()' or 'for' loop iteration, and is a default parameter for most built-in functions. Finally, in your particular case you're using the s/// (substitute) operator wrongly. The first part, s/here//, is a regular expression, not a list of characters. You'll need to read up on these at perldoc perlre The second part, s//here/, is a string expression which can use 'captured' sequences (anything in brackets) from the first part and, with the addition of the s///e (executable) qualifier can also be an executable statement. Here I've used it to add 0x20 to the ASCII value of the control character grabbed by the regex. A lot of this won't make sense until you learn some more, but I hope you'll agree that this code is cuter than your original? HTH, Rob use strict; use warnings; my $in_ctr = 0; my $out_ctr = 0; while () { chomp; $in_ctr++; if (s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg) { $out_ctr++; printf Non-printing chars detected in: %s\n, $_; } } printf Total records read = %d\n, $in_ctr; printf Total records written with non-printing characters = %d\n, $out_ctr; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Recommendations?
Where might I find reference (conceptual) stuff about how to launch a JAVA app via CGI (or vice versa)? Still working it out, but it appears that I may need to get some CGI variables into a JAVA App. Surely this is too difficult to be encapsulated in a website or two? -d
index syntax change, base36 conversion?
While attempting to figure out a way to do conversion of large (overly) integers from base 10 to base 36, and back again I naturally went to CPAN and looked at Math::Base36, which appears to have a bug in its use of 'index' to determine if a character is not a valid base36 character, at least by the versions of the docs for index that I have access to. 'index' returns 0 or greater for the position, with -1 being a not found. Has this changed? Did 'index' start at 1 in the past? The module also appears to have some other problems with arbitrarily large integers despite its use of Math::BigInt, though I couldn't really tell whether it was just using that module improperly, or whether the apparently ancient version of BigInt I have ($VERSION says 0.01) (my Perl is at 5.6.1) is buggy (which from my other tests it does appear to be), or maybe a little of both. Also not sure whether the Math::Base36 module is being maintained (or should have made it to CPAN in the first place) but I am asking about index to properly word my e-mail to the author, is this a bug or a syntax change? Seems like a pretty big one to be the latter... Any one out there have a better approach to wrangling conversions of large ints to and from base36? At this point I may have to roll my own, icky. http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Recommendations?
On Dec 9, 2003, at 2:01 PM, Derek Brinson wrote: Where might I find reference (conceptual) stuff about how to launch a JAVA app via CGI (or vice versa)? Still working it out, but it appears that I may need to get some CGI variables into a JAVA App. Surely this is too difficult to be encapsulated in a website or two? My suggestion would be to post this to a Java list, instead of this Perl list. When you do, go ahead and spell Java correctly, to get off on the right foot with them. It's not an acronym, so it doesn't need all those capitals. It's just Java. Good luck. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Recommendations?
On Dec 9, 2003, at 12:01 PM, Derek Brinson wrote: [..] Where might I find reference (conceptual) stuff about how to launch a JAVA app via CGI (or vice versa)? Still working it out, but it appears that I may need to get some CGI variables into a JAVA App. [..] The direction might be of concern. You could write a simple piece of Perl using the CGI.pm module that would launch the Java app, and/or query a running one - for that you will want a better understanding of CGI. May I recommend my own kvetching: http://www.wetware.com/drieux/CS/Proj/TPFH/gen_doc.html Where I try to list the basic reading material that will be useful in the 'web and perl' side of the process. You are unfortunately correct, the problem of web-technologies is not one simple thing in one simple place because you have at least four issues you have stumbled into a. HTTP b. HTML/xHTML - for returning to a browser c. CGI - the common gateway interface between the web-server and your application d. Your cgi code and the rest of the code you will want to work and play well with. If on the other hand, you are hoping to go from some Java App to something that would talk to a browser, or negotiate in the 'common gateway interface', with the web-server - that you will need to go through the 'javadocs' for that set of issues. But the Perl Side of building the CGI, that we can help you with perldoc... ciao drieux --- That which is hateful to you, do not do to your neighbor. That is the whole Torah; the rest is commentary. Go and study it. - Hillel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Pattern Match
Rob, can you explain the details of that replace? That's pretty slick. I see you're adding the hex value to get to the appropriate ASCII value, but didn't know you could do some of that gyration inside a regex. Thanks. -Tom Kinzer -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 11:58 AM To: [EMAIL PROTECTED] Subject: Re: Pattern Match Eric Sand wrote: I am very new to Perl, but I sense a great adventure ahead after just programming with Cobol, Pascal, and C over the last umpteen years. I have written a perl script where I am trying to detect a non-printing character(Ctrl@ - Ctrl_) and then substitute a printing ASCII sequence such as ^@ in its place, but it does not seem to work as I would like. Any advice would be greatly appreciated. Thank YouEric Sand Your obvious guess is to write Perl as if it were C. That's slightly better than treating it as a scripting language, but there are many joys left to be found! $in_ctr=0; $out_ctr=0; while ($line = STDIN) { chomp($line); $in_ctr ++; if ($line = s/\c@,\cA,\cB,\cC,\cD,\cE,\cF,\cG,\cH,\cI,\cJ,\cK, \cL,\cM,\cN,\cO,\cP,\cQ,\cR,\cS,\cT,\cU,\cV,\cW, \cX,\cY,\cZ,\c[,\c\,\c],\c^,\c_ /^@,^A,^B,^C,^D,^E,^F,^G,^H,^I,^J,^K, ^L,^N,^N,^O,^P,^Q,^R,^S,^T,^U,^V,^W, ^X,^Y,^Z,^[,^\,^],^^,^_/) { $out_ctr ++; printf(Non-printing chars detected in: %s\n,$line); } } printf(Total records read = %d\n,$in_ctr); printf(Total records written with non-printing characters = %d\n,$out_ctr); I would write this as below. The first things is to *always* use strict; use warnings; after which you have to declare all of your variables with 'my'. The second is to get used to using the default $_ variable which is set to the value for the current 'while()' or 'for' loop iteration, and is a default parameter for most built-in functions. Finally, in your particular case you're using the s/// (substitute) operator wrongly. The first part, s/here//, is a regular expression, not a list of characters. You'll need to read up on these at perldoc perlre The second part, s//here/, is a string expression which can use 'captured' sequences (anything in brackets) from the first part and, with the addition of the s///e (executable) qualifier can also be an executable statement. Here I've used it to add 0x20 to the ASCII value of the control character grabbed by the regex. A lot of this won't make sense until you learn some more, but I hope you'll agree that this code is cuter than your original? HTH, Rob use strict; use warnings; my $in_ctr = 0; my $out_ctr = 0; while () { chomp; $in_ctr++; if (s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg) { $out_ctr++; printf Non-printing chars detected in: %s\n, $_; } } printf Total records read = %d\n, $in_ctr; printf Total records written with non-printing characters = %d\n, $out_ctr; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
On Dec 9, 2003, at 2:37 PM, Tom Kinzer wrote: Rob, can you explain the details of that replace? That's pretty slick. I see you're adding the hex value to get to the appropriate ASCII value, but didn't know you could do some of that gyration inside a regex. The big secret there is the /e modifier at the end of that regex. That allows the use of Perl code (to be evaled) as the replacement string. You're right though, I thought it was slick too. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Recommendations?
Hi Derek, On Tue, 2003-12-09 at 21:01, Derek Brinson wrote: Where might I find reference (conceptual) stuff about how to launch a JAVA app via CGI (or vice versa)? Could you specify what kind of Java application you're talking about? The Java *applications* (as opposed to servlets, EJBs etc.) I know can be invoked via the command line. Still working it out, but it appears that I may need to get some CGI variables into a JAVA App. If it's a normal application, it should be quite easy - something like this (roughly sketched and not syntax-checked): use CGI; my $query = new CGI; # this is the actual HTML form - could be out-sourced with # HTML::Template or something like that in order not to mix # HTML and your code too much my $HTML_FORM = END form input type=text name=java_class_name/br/ input type=text name=argument1/br/ input type=submit name=btn value=go/ /form END # get the parameters from the CGI query my $class_name = $query-param('java_class_name'); my $arg = $query-param('argument1'); # start printing the response print $query-header(); print $query-start_html(); # have we been called with parameters (i.e. did the user press the button?) if ($class_Name) { # assemble the command line to execute: # you should be able to find the java executable in # $JAVA_HOME/bin # (this assumes that JAVA_HOME is set, of course, but # normally this should be the case) my $command = $ENV{'JAVA_HOME'} . '/bin/java '; $command .= $main_class . ' ' . $arg; # call java to execute your classes main method my $result = system($command) / 256; # print the result to the browser print invoked the java application.br/\n; print the result is . $result . br/\n; } else { # no parameters -- display the form print $HTML_FORM; } print $query-stop_html(); This is more or less it - I'm doing something like this in one of my scripts, and it's working reasonably well; there are of course some minor issues you've got to think about, such as: - do you need libraries to include into your classpath? (if yes, you can specify them using the -cp argument to java) - Do you need to get a result from the Java application? Does it print stuff into the console? Does it have a return value? - How long does the application take to execute? In my case, the application can take more than 1 hour to complete, so I fork and inform the user per mail about the result. HTH, Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
index syntax change, base36 conversion?
Wiggins d Anconia writes: While attempting to figure out a way to do conversion of large (overly) integers from base 10 to base 36, and back again I naturally went to CPAN and looked at Math::Base36, which appears to have a bug in its use of 'index' to determine if a character is not a valid base36 character, at least by the versions of the docs for index that I have access to. 'index' returns 0 or greater for the position, with -1 being a not found. Has this changed? Did 'index' start at 1 in the past? When number = index(string, pattern); was first introduced in the late 1960's in PL/1, all arrays were 1-origin indexing by default, and so were strings. intex() returned zero to indicate not found. I myself, and probably many other old timers still make the mistake of reverting back to he way we originaly learned it, probably because it was so handy to just check for zero to see if it found anything. Admittedly, 0-origin indexing for arrays and strings makes more methematical sense, as remaindering can then be used to calculate subscripts, but old habits die hard. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Tom Kinzer wrote: Rob Dixon wrote: Eric Sand wrote: I am very new to Perl, but I sense a great adventure ahead after just programming with Cobol, Pascal, and C over the last umpteen years. I have written a perl script where I am trying to detect a non-printing character(Ctrl@ - Ctrl_) and then substitute a printing ASCII sequence such as ^@ in its place, but it does not seem to work as I would like. Any advice would be greatly appreciated. Thank YouEric Sand Your obvious guess is to write Perl as if it were C. That's slightly better than treating it as a scripting language, but there are many joys left to be found! $in_ctr=0; $out_ctr=0; while ($line = STDIN) { chomp($line); $in_ctr ++; if ($line = s/\c@,\cA,\cB,\cC,\cD,\cE,\cF,\cG,\cH,\cI,\cJ,\cK, \cL,\cM,\cN,\cO,\cP,\cQ,\cR,\cS,\cT,\cU,\cV,\cW, \cX,\cY,\cZ,\c[,\c\,\c],\c^,\c_ /^@,^A,^B,^C,^D,^E,^F,^G,^H,^I,^J,^K, ^L,^N,^N,^O,^P,^Q,^R,^S,^T,^U,^V,^W, ^X,^Y,^Z,^[,^\,^],^^,^_/) { $out_ctr ++; printf(Non-printing chars detected in: %s\n,$line); } } printf(Total records read = %d\n,$in_ctr); printf(Total records written with non-printing characters = %d\n,$out_ctr); I would write this as below. The first things is to *always* use strict; use warnings; after which you have to declare all of your variables with 'my'. The second is to get used to using the default $_ variable which is set to the value for the current 'while()' or 'for' loop iteration, and is a default parameter for most built-in functions. Finally, in your particular case you're using the s/// (substitute) operator wrongly. The first part, s/here//, is a regular expression, not a list of characters. You'll need to read up on these at perldoc perlre The second part, s//here/, is a string expression which can use 'captured' sequences (anything in brackets) from the first part and, with the addition of the s///e (executable) qualifier can also be an executable statement. Here I've used it to add 0x20 to the ASCII value of the control character grabbed by the regex. A lot of this won't make sense until you learn some more, but I hope you'll agree that this code is cuter than your original? HTH, Rob use strict; use warnings; my $in_ctr = 0; my $out_ctr = 0; while () { chomp; $in_ctr++; if (s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg) { $out_ctr++; printf Non-printing chars detected in: %s\n, $_; } } printf Total records read = %d\n, $in_ctr; printf Total records written with non-printing characters = %d\n, $out_ctr; Rob, can you explain the details of that replace? That's pretty slick. I see you're adding the hex value to get to the appropriate ASCII value, but didn't know you could do some of that gyration inside a regex. I didn't think it was slick at all. In fact I was disappointed that it looked such a mess, but I don't see a better way. Anyway, the statement is s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg where the regex is ([\x00-\1F]) The enclosing parentheses capture the entire regex as $1 for use later in the replacement expression or even in a later statement. Within that is a character class [ .. ] which is simply all control characters. It's the first 'column' of the 7-bit 128-character ASCII set with byte values 0 through 31 or 0x00 through 0x1F. It would be better expressed as [[:cntrl:]] which is identical but describes what you /mean/ rather than how your machine should do it. OK, so we've captured one control character into $1. Then comes the replacement string, which can be an executable expression with the /e modifier on the substitution. Note that for simple interpolation of variables like the captured $1, $2 etc, and in fact any variable (including arrays and hashes) in scope, there is no need for /e. It is only necessary if there are operators or subroutines that need to be executed to build the replacement string. It's a mess because there is no way of relating control characters (e.g. CR) with their alphabetic equivalents (e.g. CTRL/M) without doing character arithmetic. And that's not what characters do in /real/ life. In '^'.chr(ord($1) + 0x40) ord($1) returns the byte value of the control character. + 0x40 moves that byte value from the first column (control characters) to the third column (capital alphas) chr() turns that byte value back into a one-character ASCII string. '^'. appends a caret before that character. Hence \cM becomes '^M'. All that is left is the /g modifier, which simply replaces all instances of the regex instead of just the first one found. I hope this
How do I set up bidirectional pipes over a network connection?
I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? Thanks in advance, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Syntax a little funny ....
[EMAIL PROTECTED] wrote: On 12/08/03 19:33 or thereabouts, John W. Krahn scribbled: [EMAIL PROTECTED] wrote: If that is so, what is all that business with the curly braces ? I thought curly braces are supposed to denote code sections ? Yes, exactly, the curly braces allow the use of a code block instead of a simple expression. Having a code block means that you can have multiple statements and lexical variables. I just read the function prototype for grep, and indead they have grep BLOCK LIST down as a possibility. This using a BLOCK where I usually expect something like int x or String name is sort of funny. %^) Is this fairly normal ? For a function to take a BLOCK as an argument like this ? Well, it's not un-normal. :-) do, eval, grep, map, sort and sub can all use a block as the first argument. I'm going to experiment with this, but I take it the BLOCK has to exit with a true/false value to let grep know whether to take that list item or not ? That is correct. But other than that, I guess I could have print i'm a grep block inside there if i wanted ? Yes, and the returned value from print would have determined whether to pass the list element through or not. Have you read the documentation for grep in perlfunc.pod? Ohh no ! Of course not. as usual I'm in too much of a hurry to learn everything all at once there is only so much time to read man/info/perldoc pages after all. %^) One last thing. I noticed some people talking about the use of || vs. or. I'm sure this is in my Learning Perl book somewhere, but I would have guessed these were one and the same ... just alternate notations. They do the same thing, however || has the same relative precedence as its C language counterpart while Perl's 'not', 'and', 'or' and 'xor' have lower precedence then all other operators. perldoc perlop 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
RE: How do I set up bidirectional pipes over a network connection?
Your first step should be to read the contents of perldoc perlipc. Then you will probably be able to ask more specific questions on how to go about it. -Original Message- From: Dan Anderson [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 1:19 PM To: Perl Beginners Subject: How do I set up bidirectional pipes over a network connection? I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection?
On Dec 9, 2003, at 3:19 PM, Dan Anderson wrote: I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? It's very possible and there are many modules to help. Help us help you though, what are you trying to do? It could make a big difference. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Rob Dixon writes: Tom Kinzer wrote: I didn't think it was slick at all. In fact I was disappointed that it looked such a mess, but I don't see a better way. Yes, it is indeed a mess, not only syntacticly, but also semantically. While it might make a good teaching example to show what you can do in a perl regex, it might not be a very good way to do what is ultimately accomplished. First, a regular expression pattern match is conducted to find all chars in the string that are in the desired special processing range. Note that these are each individual characters, not substrings, so the regex match is gross overkill from a computational complexity point of view. Second, all that is desired is to insert a circumflex and then the character plus a bias to make it printable. Now if this is all that has to be done, and you want to do it to a bunch of large files, then the way you show is a poor way to do it. A simple C program could be written to get a character from stdin, check it in an if statement to see if it is in the desired range, and then output the circumflex followied by the biased character to stdout if it is in the range, or else just output the character. This simple one-char-at-a-time streaming filter approach would be considerably simpler computationally than the method you provide. Now if you only need to do this to massage a few lines of output in a program with a much larger overall purpose, then perhaps your example is the way to go. My question is, how does perl's regex compiler handle the code you gave? Does it optimize it to a similar level of complexity as my C example, or does it smash it with a one-size-fits-all regular expression engine? I know regular expressions can be highly optimized at compile time, so this is an important question. If the regex is sufficiently optimized, then it would always be the way to go. Bob Rj Brown -- And there came a writing to him from Elijah [2Ch 21:12] R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 847 543-4060 Elijah Laboratories Inc. 457 Signal Lane, Grayslake IL 60030 fax 847 543-4061 - M o d e l i n g t h e M e t h o d s o f t h e M i n d -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection?
On Tue, 2003-12-09 at 16:31, James Edward Gray II wrote: On Dec 9, 2003, at 3:19 PM, Dan Anderson wrote: I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? It's very possible and there are many modules to help. Help us help you though, what are you trying to do? It could make a big difference. I'm writing a perl daemon to do two things: back up important files on multiple boxen so if one gets taken out another will survive, and sync files in users directory from a main server -- i.e. I want to be able to do something like $ ./distribute.pl --file and have it sent to all boxen's ~/distributed/ directory. -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How do I set up bidirectional pipes over a network connection ?
Dan Anderson wrote: On Tue, 2003-12-09 at 16:31, James Edward Gray II wrote: On Dec 9, 2003, at 3:19 PM, Dan Anderson wrote: I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? You're talking about a TCP connection, which is bidirectional. It's very possible and there are many modules to help. Help us help you though, what are you trying to do? It could make a big difference. I'm writing a perl daemon to do two things: back up important files on multiple boxen so if one gets taken out another will survive, and sync files in users directory from a main server -- i.e. I want to be able to do something like $ ./distribute.pl --file and have it sent to all boxen's ~/distributed/ directory. You might look at the standard rdist(1) utility for this kind of thing. For crafting network daemons in Perl, Net::Daemon is a good place to start, IMO. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How do I set up bidirectional pipes over a network connection ?
You might look at the standard rdist(1) utility for this kind of thing. For crafting network daemons in Perl, Net::Daemon is a good place to start, IMO. What I am trying to do is too complex to successfully implement using a standard utility like rdist or CVS. Besides, rolling my own is so much more interesting. :-D -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection ?
On Dec 9, 2003, at 3:49 PM, Dan Anderson wrote: You might look at the standard rdist(1) utility for this kind of thing. For crafting network daemons in Perl, Net::Daemon is a good place to start, IMO. What I am trying to do is too complex to successfully implement using a standard utility like rdist or CVS. Besides, rolling my own is so much more interesting. :-D Spoken like a man who REALLY needs a copy of Network Programming with Perl. ;) James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection?
On Dec 9, 2003, at 3:40 PM, Dan Anderson wrote: On Tue, 2003-12-09 at 16:31, James Edward Gray II wrote: On Dec 9, 2003, at 3:19 PM, Dan Anderson wrote: I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? It's very possible and there are many modules to help. Help us help you though, what are you trying to do? It could make a big difference. I'm writing a perl daemon to do two things: back up important files on multiple boxen so if one gets taken out another will survive, and sync files in users directory from a main server -- i.e. I want to be able to do something like $ ./distribute.pl --file and have it sent to all boxen's ~/distributed/ directory. How many boxes are we talking about here? What you're talking about is no small feat. How can we help you? You want a server and a client, right? Could it be and FTP server and a script client? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: wildcard File::Copy
Ben Crane wrote: Hi all, Hello, Anyone know how to do a wildcard file::copy? E.g. I want to copy a file with a certain name but different extensions. I have tried concatenating .* to the end of a filename (without an extension obviously) but it fails. This is what I had in mind...it's just a scribble and not exactly the way the code will go. $string2 = $string[1]..*; ^ ^ ^ ^ copy($string2,$destination) || warn could not copy files: $!; ^^ ^^ ^^ ^^ perldoc -q What\'s wrong with always quoting \\\$vars\? You can't simply use a wildcard in a string, you have to expand the wildcard to a list and iterate over the list. Something like: use File::Copy; my $filename = 'filename'; # use glob to expand wildcard for my $file ( $filename.* ) { # copy each individual file copy( $file, $filename.newext ) or warn Cannot copy $file: $!; } 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
Re: command line commands passed to perl script?
Ben Crane wrote: Hi all, Hello, Sorry, should have added this to my last email. Does anyone know how to pass values to a perl script through the command line? Do you use param as in CGI scripting/ I want a user to be able to specify certain parameters for the perl script (in case they want to run an overnight scheduler on it). Eg. testscript.pl /? gives you help or testscript /a gives you another capability... If you want to use the DOS command line switch (/) you could write your own parser for the @ARGV array however Perl provides the Getopt::Std and Getopt::Long modules which use the more standard '-' and '--' for processing command line switches. perldoc Getopt::Std perldoc Getopt::Long 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
Re: How do I set up bidirectional pipes over a network connection?
How many boxes are we talking about here? Well starting off, 2. But I would like to expand to several more. Probably never more then 10. What you're talking about is no small feat. How can we help you? You want a server and a client, right? Could it be and FTP server and a script client? Well, I was planning to implement the file transfers using Net::FTP or something similar to keep the problems down. But I want every node to be able to talk to other nodes, i.e. each node be able to send every other node a request to download a file and put it in directory . There will be one daemon functioning as the master to regulate, which will provide a database with the IP addresses and port/sockets the other daemons are listening on. -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: command line commands passed to perl script?
IMHO, parsing command-line options sounds a lot easier than it is. Definitely use the modules unless you have a good reason for not doing so. The author(s) of the module have probably already dealt with the forehead-slappers that might not be obvious right off the bat, and it will save you a lot of time down the road. Save your brainpower for the more important parts of your program rather than reinventing this particular wheel. Again, it's just my opinion... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection?
How many boxes are we talking about here? Well starting off, 2. But I would like to expand to several more. Probably never more then 10. What you're talking about is no small feat. How can we help you? You want a server and a client, right? Could it be and FTP server and a script client? Well, I was planning to implement the file transfers using Net::FTP or something similar to keep the problems down. But I want every node to be able to talk to other nodes, i.e. each node be able to send every other node a request to download a file and put it in directory . There will be one daemon functioning as the master to regulate, which will provide a database with the IP addresses and port/sockets the other daemons are listening on. And this is where Wiggins, once again, interrupts everyone's fun by interjecting, POE. http://poe.perl.org is ideal for this kind of stuff, and since you already stated learning curves aren't a problem then. I would suggest looking very briefly through the cookbook, then have a look at the power point presentations, then go back to the cookbook and dissect the examples. http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Robert Brown wrote: Rob Dixon writes: Tom Kinzer wrote: I didn't think it was slick at all. In fact I was disappointed that it looked such a mess, but I don't see a better way. Yes, it is indeed a mess, not only syntacticly, but also semantically. While it might make a good teaching example to show what you can do in a perl regex, it might not be a very good way to do what is ultimately accomplished. First, a regular expression pattern match is conducted to find all chars in the string that are in the desired special processing range. Note that these are each individual characters, not substrings, so the regex match is gross overkill from a computational complexity point of view. Second, all that is desired is to insert a circumflex and then the character plus a bias to make it printable. Now if this is all that has to be done, and you want to do it to a bunch of large files, then the way you show is a poor way to do it. A simple C program could be written to get a character from stdin, check it in an if statement to see if it is in the desired range, and then output the circumflex followied by the biased character to stdout if it is in the range, or else just output the character. This simple one-char-at-a-time streaming filter approach would be considerably simpler computationally than the method you provide. Now if you only need to do this to massage a few lines of output in a program with a much larger overall purpose, then perhaps your example is the way to go. My question is, how does perl's regex compiler handle the code you gave? Does it optimize it to a similar level of complexity as my C example, or does it smash it with a one-size-fits-all regular expression engine? I know regular expressions can be highly optimized at compile time, so this is an important question. If the regex is sufficiently optimized, then it would always be the way to go. Thanks Robert, but I wonder if you expect us to take you seriously? In which case I'll happily reply. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Rob Dixon writes: Robert Brown wrote: Rob Dixon writes: Tom Kinzer wrote: I didn't think it was slick at all. In fact I was disappointed that it looked such a mess, but I don't see a better way. Yes, it is indeed a mess, not only syntacticly, but also semantically. While it might make a good teaching example to show what you can do in a perl regex, it might not be a very good way to do what is ultimately accomplished. [ some words deleted here ... ] My question is, how does perl's regex compiler handle the code you gave? Does it optimize it to a similar level of complexity as my C example, or does it smash it with a one-size-fits-all regular expression engine? I know regular expressions can be highly optimized at compile time, so this is an important question. If the regex is sufficiently optimized, then it would always be the way to go. Thanks Robert, but I wonder if you expect us to take you seriously? In which case I'll happily reply. Rob Yes! Please take my request seriously. I hope you can show me that the regex approach you used pays no penalty other than perhaps a few extra miliseconds of compilation time, and that it executes very efficiently. That is what I want to see. I know it *CAN* (theoretically) be done; I am just wondering if it indeed has been done. Rj -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection?
On Dec 9, 2003, at 4:12 PM, Dan Anderson wrote: Well, I was planning to implement the file transfers using Net::FTP or something similar to keep the problems down. But I want every node to be able to talk to other nodes, i.e. each node be able to send every other node a request to download a file and put it in directory . There will be one daemon functioning as the master to regulate, which will provide a database with the IP addresses and port/sockets the other daemons are listening on. Could every box but the main one be running an FTP server and then you only have to write the master script? I'm just throwing out ideas, to see if anything sparks. This one is probably too clumsy though, if you want to be able to trigger moves from the non-master boxes. Doesn't sound to me like your getting out of this one easy, so the suggestion to go for a framework like POE is looking better and better, I would think. And again, Network Programming with Perl covers all this and much more. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Robert Brown wrote: Rob Dixon writes: Robert Brown wrote: Rob Dixon writes: Tom Kinzer wrote: I didn't think it was slick at all. In fact I was disappointed that it looked such a mess, but I don't see a better way. Yes, it is indeed a mess, not only syntacticly, but also semantically. While it might make a good teaching example to show what you can do in a perl regex, it might not be a very good way to do what is ultimately accomplished. [ some words deleted here ... ] My question is, how does perl's regex compiler handle the code you gave? Does it optimize it to a similar level of complexity as my C example, or does it smash it with a one-size-fits-all regular expression engine? I know regular expressions can be highly optimized at compile time, so this is an important question. If the regex is sufficiently optimized, then it would always be the way to go. Thanks Robert, but I wonder if you expect us to take you seriously? In which case I'll happily reply. Rob Yes! Please take my request seriously. I hope you can show me that the regex approach you used pays no penalty other than perhaps a few extra miliseconds of compilation time, and that it executes very efficiently. That is what I want to see. I know it *CAN* (theoretically) be done; I am just wondering if it indeed has been done. Yes, I'd gladly trade in my Honda 750cc for a lightcycle: I know it *CAN* (theoretically) be done. I'm sure you have something useful to say. This seems such a waste of your effort. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing duplicate lines
Andrew Gaffney wrote: I am writing a Perl script to automatically generate a netlogon.bat file for Samba whenever a user logs onto a domain. The only parameter that is passes to it is the username. My problem is that different groups get some of the same mappings. What I really need to do is filter out duplicate lines in the finished output. Whenever you want unique values think hash. I tried piping the output through 'uniq' but it only filters successive duplicate lines. Anyone have any suggestions? Your example does not have 'uniq' (or 'sort -u') in it so I am not sure what you are trying to do. #!/usr/bin/perl use warnings; use strict; my $user = shift; my $drives = {F = NET USE F: SKYLINE\\SKYLINEF\r\n, H = NET USE H: SKYLINE\\SHARE\r\n, I = NET USE I: SHIPPING1\\INVENTORY\r\n, M = NET USE M: SKYLINE\\SKYLINEM\r\n, S = NET USE S: SHIPPING1\\SHOP\r\n, Y = NET USE Y: ACCOUNTING\\FLTSCHOOL\r\n, Z = NET USE Z: ACCOUNTING\\MAINT\r\n}; Why not just use a hash instead of a reference to a hash? The use of \r\n is non-portable, you should use \015\012 instead. my $CRLF = \015\012; my %drives = ( F = 'NET USE F: \\SKYLINE\SKYLINEF' . $CRLF, H = 'NET USE H: \\SKYLINE\SHARE' . $CRLF, I = 'NET USE I: \\SHIPPING1\INVENTORY' . $CRLF, M = 'NET USE M: \\SKYLINE\SKYLINEM' . $CRLF, S = 'NET USE S: \\SHIPPING1\SHOP' . $CRLF, Y = 'NET USE Y: \\ACCOUNTING\FLTSCHOOL' . $CRLF, Z = 'NET USE Z: \\ACCOUNTING\MAINT' . $CRLF, ); my $which = {accounting = F H I M S Y Z, mech = I M S Z, dispatch = M, instructors = M}; You should probably use a hash of arrays for this (so you don't have to split the string later): my %which = ( accounting = [ qw(F H I M S Y Z) ], mech= [ qw(I M S Z) ], dispatch= [ qw(M) ], instructors = [ qw(M) ], ); my $groups = `cat /etc/group | grep ${user} | cut -d ':' -f 1`; Ick, ick, ick! Perl provides built-in functions to access /etc/group and /etc/passwd perldoc -f getgrnam perldoc -f getgrgid perldoc -f getgrent perldoc -f setgrent perldoc -f endgrent perldoc -f getpwnam perldoc -f getpwuid perldoc -f getpwent perldoc -f setpwent perldoc -f endpwent $groups =~ s/\n/\:/sg; # Start generating logon script #open LOGON, /usr/local/samba/netlogon/${user}.bat; open LOGON, /tmp/${user}.bat; You should _ALWAYS_ verify that the file opened correctly. open LOGON, /tmp/$user.bat or die Cannot open /tmp/$user.bat: $!; print LOGON [EMAIL PROTECTED] OFF\r\n; foreach $group (split /:/, $groups) { foreach $drive (split / /, $which-{$group}) { print LOGON $drives-{$drive}; } } close LOGON; 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
Re: The True Path to Learning Perl Re: [OT] Education Level
Tassilo von Parseval wrote: The credo of your original message was rather flat and shallow: Avoid university at all costs because it can't teach you anything worthwhile. This is an immature statement which I addressed. Tassilo Actually, the first message I saw from drieux on this thread did not scorn the academic route It simply took it with a grain of salt. The more recent response was to an individual who was expressing disenchantment with academia while at the same time pursuing the academic route--because it was supported. I believe that it was to this cognitive dissonance that drieux was responding. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: wildcard File::Copy
From: Ben Crane [EMAIL PROTECTED] Anyone know how to do a wildcard file::copy? E.g. I want to copy a file with a certain name but different extensions. I have tried concatenating .* to the end of a filename (without an extension obviously) but it fails. This is what I had in mind...it's just a scribble and not exactly the way the code will go. $string2 = $string[1]..*; copy($string2,$destination) || warn could not copy files: $!; If you happen to need it just for Windows: use Win32::FileOp qw(Copy); Copy file.*, $destination; you can even get confirmation and progress dialogs from the module if you like ;-) You can install it with PPM from http://Jenda.Krynicky.cz/perl Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Problems compiling Perl 5.6.1
When I try to compile Perl 5.6.1 (can't find any RPMs and, yes, I need 5.6.1), I get the following error: make[1]: Leaving directory `/root/perl-5.6.1/utils' Making x2p stuff make[1]: Entering directory `/root/perl-5.6.1/x2p' make[1]: *** No rule to make target `built-in', needed by `hash.o'. Stop. make[1]: Leaving directory `/root/perl-5.6.1/x2p' make: *** [translators] Error 2 What does that mean? -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Eric Sand wrote: Hi All, Hello, I am very new to Perl, Welcome. :-) but I sense a great adventure ahead after just programming with Cobol, Pascal, and C over the last umpteen years. Thinking in Perl may take a while but it is not your grandfather's programming language (sorry COBOL.) I have written a perl script where I am trying to detect a non-printing character(Ctrl@ - Ctrl_) Your idea of non-printing seems to conflict with industry standards as CtrlG - CtrlM are all printable. Also you are using perl's standard readline and chomp()ing the input so you are not converting the CtrlJ character at all. and then substitute a printing ASCII sequence such as ^@ in its place, but it does not seem to work as I would like. Any advice would be greatly appreciated. use warnings; use strict; $in_ctr=0; $out_ctr=0; Whitespace is free and makes your code more readable and maintainable. my $in_ctr = 0; my $out_ctr = 0; while ($line = STDIN) { chomp($line); $in_ctr ++; if ($line = s/\c@,\cA,\cB,\cC,\cD,\cE,\cF,\cG,\cH,\cI,\cJ,\cK, \cL,\cM,\cN,\cO,\cP,\cQ,\cR,\cS,\cT,\cU,\cV,\cW, \cX,\cY,\cZ,\c[,\c\,\c],\c^,\c_ /^@,^A,^B,^C,^D,^E,^F,^G,^H,^I,^J,^K, ^L,^N,^N,^O,^P,^Q,^R,^S,^T,^U,^V,^W, ^X,^Y,^Z,^[,^\,^],^^,^_/) As Rob pointed out, this is not the correct way to use the substitution operator (see below.) { $out_ctr ++; printf(Non-printing chars detected in: %s\n,$line); You shouldn't use printf unless you really have to and in this case you don't really have to. print Non-printing chars detected in: $line\n; } } printf(Total records read = %d\n,$in_ctr); printf(Total records written with non-printing characters = %d\n,$out_ctr); print Total records read = $in_ctr\n; print Total records written with non-printing characters = $out_ctr\n; I would probably write it like this: use warnings; use strict; my $out_ctr = 0; while ( STDIN ) { next unless s/([[:cntrl:]])/'^' . ( $1 | \x40 )/eg; $out_ctr++; print Non-printing chars detected in: $_\n; } print Total records read = $.\n; print Total records written with non-printing characters = $out_ctr\n; __END__ 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
Re: sorter script [was: Frustrated newbie question]
drieux wrote: Ironically, uh, duh, given tassilo's recent thumping of me for whining about acadamia - there are some ugly 'sorting algorithms' that have to be 'ugly' to be 'general enough' that are, well, ugly. Hmmm. I don't know about that. Most sorting algorithms I have seen are quite beautiful conceptually. Even the rather primitive bubble sort can look pretty viewed in its single dimension. Each of the recursive algorithms has its own style of elegance. The mechanics of dealing with various types or shapes of data can usually be abstracted with a function call: my @sorted = sort {shape_to_fit($a, $b)} @source; I do see something like this when it comes to storage structure, though. I love Balanced Tree structures from a conceptual perspective, for instance, because I see a real elegance in them. Still I cannot ignore the difference between their O(log n) times and the O(1) time characteristic of the hash. To me hashes are like sausage to a carnivore--I love the end product, but have no desire to look too closely at the process. You might want to get your hands on Knuth's and crawl the searching and sorting algorithm sections if you are really interested in some serious analysis of good ways and bad ways to think about solving sorting algorithms. may I recommend that you peak at perldoc -q sort and then look at @sorted = map { $_-[0] } sort { $a-[1] cmp $b-[1] } map { [ $_, uc( (/\d+\s*(\S+)/)[0]) ] } @data; and think about what that MIGHT mean were it to have been plugged into the process. ciao drieux I'm sorta stumped, I must admit. Looks like you have material with a single numeric prefix that is extraneous to your need, and a single token that you are seeking, per line--and that you want it all to SHOUT. I'd suggest abstracting most of this into your shape_to_fit().when looking at it in the context of the sort. Of course, a specific name for the shape_to_fit function would aid comprehension greatly. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: SMTP From field using MIME::Lite
This code works for me - #!/usr/bin/perl use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite-new( From = 'Paul Kraus [EMAIL PROTECTED]', To = '[EMAIL PROTECTED]', Subject = 'RE:SMTP From field using MIME::Lite - Test Send', Data = 'This message sent with mime lite' ); MIME::Lite - send ('smtp','my.mailserver.com' ); $msg - send; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Pattern Match
Rob Dixon wrote: I didn't think it was slick at all. In fact I was disappointed that it looked such a mess, but I don't see a better way. Anyway, the statement is s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg where the regex is ([\x00-\1F]) Oops. That matches the characters \0, \1 and 'F'. It should be ([\x00-\x1F]) :-) 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
Re: Problems compiling Perl 5.6.1
On Tue, Dec 09, 2003 at 07:09:15PM -0500, Dan Anderson wrote: When I try to compile Perl 5.6.1 (can't find any RPMs and, yes, I need 5.6.1), I get the following error: make[1]: Leaving directory `/root/perl-5.6.1/utils' Making x2p stuff make[1]: Entering directory `/root/perl-5.6.1/x2p' make[1]: *** No rule to make target `built-in', needed by `hash.o'. Stop. make[1]: Leaving directory `/root/perl-5.6.1/x2p' make: *** [translators] Error 2 What does that mean? It probably means that you should be compiling 5.6.2 instead. 5.6.2 was released to be backwards compatible with 5.6.1, but able to compile on modern systems. Otherwise, you could try running the following: perl -ni~ -we 'print unless /: /' x2p/makefile makefile -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How do I set up bidirectional pipes over a network connection?
Dan Anderson wrote: On Tue, 2003-12-09 at 16:31, James Edward Gray II wrote: On Dec 9, 2003, at 3:19 PM, Dan Anderson wrote: I have 2 Linux boxes I want to talk to each other over the local network using a Perl script. Is it possible to set up a bidirectional pipe so that 2 perl daemons can communicate with each other? How would I go about doing this and are there any modules to help? It's very possible and there are many modules to help. Help us help you though, what are you trying to do? It could make a big difference. I'm writing a perl daemon to do two things: back up important files on multiple boxen so if one gets taken out another will survive, and sync files in users directory from a main server -- i.e. I want to be able to do something like $ ./distribute.pl --file and have it sent to all boxen's ~/distributed/ directory. Could you not use NFS to mount the users directories from the main server and use the appropriate RAID arrays and backups on the main server? 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
Re: Reading a log file, again
Tom Kinzer wrote: -Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 7:02 PM To: Tom Kinzer Cc: Katka a Daniel Dunajsky; Beginners Perl Subject: Re: Reading a log file, again Tom Kinzer wrote: Try this: Caveat: This all assumes LOTS about the format of your data being ... -Tom Kinzer Hi Tom, I think this may be getting too complicated. My understanding is that the OP was actually interested in a single datum, the total figure at the bottom. I haven't seen any clarification indicating otherwise, so I would suggest just doing it: OP said: From what I understand, your script looks for 'Total:' and then for following line with numbers, reads them and prints them. That is what I need. However, there are 3 sections with 'Total:' and I am interested only in one of them. 2 preceding bits of info determine which is the right one. -Tom Kinzer Hi Tom, Sorry for the misunderstanding. It arose, though, from top posting. The relevant material you were responding to was buried down in the bottom of the post--on another thread.. I still didn't see an example of the real data being sampled, though. Please avoid top-posting. You have some very good input, but it is much harder to follow the thread of discussion, if we have to hunt for the specific material you are referring to. I'm still not quite sure how the discussion got from the simple data sample that showed in his OP, and the more comlex data structure he indicates at the tail of one of your messages. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing duplicate lines
John W. Krahn wrote: Andrew Gaffney wrote: I am writing a Perl script to automatically generate a netlogon.bat file for Samba whenever a user logs onto a domain. The only parameter that is passes to it is the username. My problem is that different groups get some of the same mappings. What I really need to do is filter out duplicate lines in the finished output. Whenever you want unique values think hash. Well, it would have been weird to have a hash with keys named 'NET USE F: SKYLINE\\SKYLINEF\r\n'. I tried piping the output through 'uniq' but it only filters successive duplicate lines. Anyone have any suggestions? Your example does not have 'uniq' (or 'sort -u') in it so I am not sure what you are trying to do. I mean that I tried 'cat /tmp/user.bat uniq' after the script had run to see how it would work. #!/usr/bin/perl use warnings; use strict; my $user = shift; my $drives = {F = NET USE F: SKYLINE\\SKYLINEF\r\n, H = NET USE H: SKYLINE\\SHARE\r\n, I = NET USE I: SHIPPING1\\INVENTORY\r\n, M = NET USE M: SKYLINE\\SKYLINEM\r\n, S = NET USE S: SHIPPING1\\SHOP\r\n, Y = NET USE Y: ACCOUNTING\\FLTSCHOOL\r\n, Z = NET USE Z: ACCOUNTING\\MAINT\r\n}; Why not just use a hash instead of a reference to a hash? The use of \r\n is non-portable, you should use \015\012 instead. I'm not that worried about portability since this was something I threw together for use on MY system with MY particular setup. my $CRLF = \015\012; my %drives = ( F = 'NET USE F: \\SKYLINE\SKYLINEF' . $CRLF, H = 'NET USE H: \\SKYLINE\SHARE' . $CRLF, I = 'NET USE I: \\SHIPPING1\INVENTORY' . $CRLF, M = 'NET USE M: \\SKYLINE\SKYLINEM' . $CRLF, S = 'NET USE S: \\SHIPPING1\SHOP' . $CRLF, Y = 'NET USE Y: \\ACCOUNTING\FLTSCHOOL' . $CRLF, Z = 'NET USE Z: \\ACCOUNTING\MAINT' . $CRLF, ); my $which = {accounting = F H I M S Y Z, mech = I M S Z, dispatch = M, instructors = M}; You should probably use a hash of arrays for this (so you don't have to split the string later): my %which = ( accounting = [ qw(F H I M S Y Z) ], mech= [ qw(I M S Z) ], dispatch= [ qw(M) ], instructors = [ qw(M) ], ); I'll probably change this. my $groups = `cat /etc/group | grep ${user} | cut -d ':' -f 1`; Ick, ick, ick! Perl provides built-in functions to access /etc/group and /etc/passwd perldoc -f getgrnam perldoc -f getgrgid perldoc -f getgrent perldoc -f setgrent perldoc -f endgrent perldoc -f getpwnam perldoc -f getpwuid perldoc -f getpwent perldoc -f setpwent perldoc -f endpwent This script wasn't much more than a quick hack, anyway. I'll work on stuff like that later. $groups =~ s/\n/\:/sg; # Start generating logon script #open LOGON, /usr/local/samba/netlogon/${user}.bat; open LOGON, /tmp/${user}.bat; You should _ALWAYS_ verify that the file opened correctly. open LOGON, /tmp/$user.bat or die Cannot open /tmp/$user.bat: $!; I agree. I just modified existing code and didn't think about that. print LOGON [EMAIL PROTECTED] OFF\r\n; foreach $group (split /:/, $groups) { foreach $drive (split / /, $which-{$group}) { print LOGON $drives-{$drive}; } } close LOGON; John Thanks for all the suggestions. -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
passing an array
Hello, what is the best way to pass an array to a sub routine, IE. my @fields = qw(one two three); send_array(@fields); sub send_array { my @ary = @_; # do stuff here } is this the most effective way to pass an array to sub routine or is there a better way to do this. thx's -- MikemickaloBlezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Quality Web Hosting http://www.justlightening.net MSN: [EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: The True Path to Learning Perl Re: [OT] Education Level
Wiggins d Anconia wrote: please let's do a split(/\s/, Perl Programmer). this return one array with two scalar: Perl Programmer that's why Back to semantics, define Programmer. Your definition of programmer, if it requires any knowledge of UML, is so strict that it will not work in 99% of circles where the term is thrown around *today*. Admittedly I have very little knowledge of UML, but my employer seems very happy with my abilities as a programmer, and from what little I have seen and read around the subject UML is a colossal waste of time on any real programming project. http://danconia.org UML? Isn't that the stuff the once-long-ago-knew-how-to-code professional sycophants use to make pretty pictures for execs, so that the execs can go to bed in the warm contented illusion that they actually understand something about the systems they are paying for? Joseph Boycott the Sugar Bowl! You couldn't pay me to watch that game. Okay. So what is it about the Sugar Bowl? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response