Re: 4 questions
Is there a 'bible' out there to read? Depending on you level of faith: learning perl by randal schwartz tom phoenix the camel book by Larry wall bless you, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: a regular expression issue
hi, #!/usr/bin/perl use strict; use warnings; my $file; my @xfiles; @xfiles = (canada, cane, cane02, ca.e.02, canine, .hidden); foreach $file (@xfiles){ #want canada only for this iteration if ($file =~ /(canada)/){print $file\n - end first if - \n;} #wb: (expression) groups what you want to find - ie dont search for c,a,n,d... but for the whole word canada , no next required since if you match canada, elsif wil not be executed (thats what else means, right?) #then want cane, canine, ca.e.02 elsif ($file =~ /(^cane$)|(canine)|(ca.e.02)/){ print $file\n; } } #wb: same as above, | lists alternatives, ie either cane or canine or .. ^ matches beginning of word, $ matches end Cheers, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
edit pdf
hi there, I have a pile of pdf documents which may or may not contain email adresses. Now I do have to mask the [EMAIL PROTECTED] adresses into something like xyAT whereever.dot I looked at CAM::PDF and PDF::API2 - my CAM::PDF code would look like foreach my $file (@todo){ my $doc=CAM::PDF-new($file); my $pagenumber = $doc-numPages(); for (my $i=1; $i=$pagenumber; $i++){ my $page=$doc-getPageContent($i); $page =~ s/\@/AT/; $doc-setPageContent($page); } $doc-save(); } That however keeps on repeating a loop somewhere in CAM::PDF forever: --snip-- ET Tw ( ) TjTD25 0.75 re fw ( ) [EMAIL PROTECTED]) Tjrite.de/) Tj) Tjanke Kinder, CVK) Tjj Use of uninitialized value in hash element at /usr/lib/perl5/site_perl/5.8.5/CAM/PDF.pm line 2811. Argument BT\r70.5 49.5 TD\r0 0 0 rg \r/F0 9.75 Tf\r-0.2025 Tc ... isn't numeric in numeric lt () at /usr/lib/perl5/site_perl/5.8.5/CAM/PDF.pm line 2060. ET Tw ( ) TjTD25 0.75 re fw ( ) [EMAIL PROTECTED]) Tjrite.de/) Tj) Tjanke Kinder, CVK) Tjj Use of uninitialized value in length at /usr/lib/perl5/site_perl/5.8.5/CAM/PDF.pm line 3600. Argument BT\r70.5 49.5 TD\r0 0 0 rg \r/F0 9.75 Tf\r-0.2025 Tc ... isn't numeric in numeric lt () at /usr/lib/perl5/site_perl/5.8.5/CAM/PDF.pm line 2060. --snap-- With PDF::API2 I manage to get a PDF::API2::Content::Text object - just that I cant find out what to do with it. How the heck do I find out whether there are emails to be masked in that obj? Does anybody - know where to find documentation an a PDF::API2::Content::Text obj? - know why ma CAM::PDF call end in an endless loop - have any other idea how to replace certain strings in a pdf? - know a docu on how pdf works - which I obviously dont know... Thanks a lot in advance, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Checking filenames? [:: ?Kinda Solved? ::]
On Friday 05 March 2004 02:03, Sumit Kaur generously enriched virtual reallity by making up this one: Hi, Hi, I have to write my first Perl script . This scripts Searches for rare = codons in nucleotide sequence . The nucleotide sequence is entered by = the user in the format ATTGCAA.. and then the program breaks this = sequence in the groups of three alphabets like ATT,GCA...so no.=20 Please suggest . I first of all suggest you use new subject line... Then: read Learning perl by Randal Schwartz and Tom Phoenix and tell us if you are learning perl as a first language or allready know about control structures, filehandles and regluar expressions Then: what do you mean by rare - do you want the program to figure out, what the least frequent codons are and list/count/whatever them or do you have a prior definition of rare. Further (given your example above): ATTGCAA ATT TTG TGC are all these codons or do you assume your user supplied sequence starts somewhere you know and goes on in triplets from there on? (That is, does the user supply only exons starting with the start tripplet?) Once you get past the first steps: look at the bioperl modules at cpan and at www.Bioperl.org Enjoy -Wolf -- 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 IDE
On Friday 05 March 2004 18:26, Alexander Douglas generously enriched virtual reallity by making up this one: Hello Hello I am new to perl and hence needs some help.. 1) Is there a good IDE to build perl forms for web. Emacs, VIM :-) Use the CGI module. 2) If i have to connect perl to firebird database just the DBI module from perl is enough or do i need any more drivers, The OS is solaris and linux with wiindows clients for developement. DBI implements the API to Database programing in perl and is database independet. For each seperate database you want to work on using DBI you further need the appropriate DB driver module: DBD::InterBase for Interbase and Firbird RDBMS available via CPAN. Enjoy - Wolf -- 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 IDE
On Friday 05 March 2004 18:26, Alexander Douglas generously enriched virtual reallity by making up this one: Hello Hello I am new to perl and hence needs some help.. 1) Is there a good IDE to build perl forms for web. Emacs, VIM :-) Use the CGI module. 2) If i have to connect perl to firebird database just the DBI module from perl is enough or do i need any more drivers, The OS is solaris and linux with wiindows clients for developement. DBI implements the API to Database programming in perl and is database independet. For each seperate database you want to work on using DBI you further need the appropriat DB driver module: DBD::InterBase for Interbase and Firbird RDBMS available via CPAN. Enjoy - Wolf -- 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 Data Between Servers
On Thursday 04 March 2004 22:26, Tim generously enriched virtual reallity by making up this one: Paul, Network Programming with Perl by Stein is a good place to start. It discusses forking children, blocking and non-blocking I/O, among others, which will be considerations you'll want to make. ...and at least the scripts are available on the net: http://modperl.com:9000/perl_networking Have fun, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Checking filenames? [:: ?Kinda Solved? ::]
On Friday 05 March 2004 02:03, Sumit Kaur generously enriched virtual reallity by making up this one: Hi, Hi, I have to write my first Perl script . This scripts Searches for rare = codons in nucleotide sequence . The nucleotide sequence is entered by = the user in the format ATTGCAA.. and then the program breaks this = sequence in the groups of three alphabets like ATT,GCA...so no.=20 Please suggest . I first of all suggest you use new subject line... Then: read Learning perl by Randal Schwartz and Tom Phoenix and tell us if you are learning perl as a first language or allready know about control structures, filehandles and regluar expressions Then: what do you mean by rare - do you want the program to figure out, what the least frequent codons are and list/count/whatever them or do you have a prior definition of rare. Further (given your example above): ATTGCAA ATT TTG TGC are all these codons or do you assume your user supplied sequence starts somewhere you know and goes on in triplets from there on? (That is, does the user supply only exons starting with the start tripplet?) Once you get past the first steps: look at the bioperl modules at cpan and at www.Bioperl.org Enjoy -Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Forking
On Wednesday 03 March 2004 20:47, Price, Jason generously enriched virtual reallity by making up this one: Hi Thanks for the input - it's quite helpful. and nice:-) However, I don't fully understand some of the code - maybe you could help clear it up for me. The parts I'm unclear on are: - the usage of pipe READER, WRITER, and then the subsequent references to READER and WRITER. pipe takes two filehandles: a readhandle and a writehandle. all children inherit filehandles of the parent process as a copy. Now the children close the readhandle, since they only want to repord back to the parent and make the writehandle the default filehandle for output using the select command. The parent on the other hand doesnt need the writehandle and reads from the readhandle until eof, which occours after every child has closed the readhandle(by exiting) - the OS keeps track of the handle and closes it only after the last process using it closed it. - the usage of $| $| 0 enables autoflush, ie turns buffering off and thus gives you a hot pipe - eg., STDOUT is usally line bufferd. Default for $| is 0. - 1 while wait() 0 translates to: Do nothing while i still have children out there. wait() waits for the child to teminate and returns its pid once it died. Hmm...I guess that's the majority of the script. :) I can follow what it does, but I'm not entirely sure why it does it. Also, is there any way I can self-contain the output from each child process? what about prependin a $$ says: to each line of child output and doing a m // in the parent process? (Not to smart but all I can come up with and less complicated then having seperate handles for each child :-) Id be interested in how you solf that. HTH, Wolf Thanks. Jason -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 03, 2004 1:17 PM To: 'Price, Jason'; '[EMAIL PROTECTED]' Subject: RE: Forking Price, Jason wrote: Not sure if this is the right list for this - if it's not, please direct me to the proper list. You've come to the right place. Anyway, I'm trying to get my hands around forking, and was hoping you all could help me out. Basically, I'm trying to find a way to fire off a remote script on numerous boxes in parallel, returning their results to the parent script. Here's the basic flow I'm after: 1. User brings up web page for an on-demand report. Provides user input, hits submit, which fires off the parent script. 2. Parent script takes user input, and fires off a remote script located on all servers provided by user input. 3. Remote scripts return results to an array in the parent script. 4. Parent script compiles results and formats output for web display. The process currently works, but runs each remote server in series, which takes a considerable amount of time. I've had a hell of a time finding a good explanation of forking, and I only seem to be able to figure out how to fork one process at a time. I'm also unsure if the parent can utilize variables populated in a child, or if they're completely independent after the fork. No. The parent cannot see any variables in the child. You need to use some form of IPC to communicate between the processes. I would suggest using a pipe. Here's an example of a parent that forks off three children, and then reads data back from the children through a common pipe: #!/usr/bin/perl use strict; $| = 1; my $nc = 3; # number of children to create pipe READER, WRITER;# pipe for communication for my $c (1 .. $nc) { # create a child process defined(my $pid = fork) or die Couldn't fork: $!; next if $pid; # parent loops to create next child # child does it's thing and writes back to parent through pipe close READER; select WRITER; $| = 1; print Hello, I am child $c, and my PID is $$\n; sleep rand(5) + 1; print Goodbye from child $c\n; exit; # child exits (IMPORTANT!) } # parent reads from children # pipe will close when last child exits close WRITER; while(READER) { print $_; } 1 while wait() 0; # reap all exit statuses Sample output: $ perl myscript.pl Hello, I am child 1, and my PID is 16774 Hello, I am child 2, and my PID is 16775 Hello, I am child 3, and my PID is 16776 Goodbye from child 2 Goodbye from child 1 Goodbye from child 3 If you need explanation of any of that, 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
Re: Forking
On Wednesday 03 March 2004 21:57, Bob Showalter generously enriched virtual reallity by making up this one: Hi, - 1 while wait() 0 That just reaps the exit statuses to prevent zombies; the children have already exited (otherwise the loop wouldn't have exited.) You might want the exit statuses or not. You can also usually use $SIG{CHLD} = 'IGNORE' prior to the forking loop if you don't care about exit statuses. see perldoc perlipc Uh, I appologize - anyway, could you explain that last part to me? Do you create zombies if you dont handle the exit status of you child by either wait()ing or setting the signal handler? An what does that zombie do anyway. Thx, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Help with Radio_group
On Sunday 29 February 2004 17:20, [EMAIL PROTECTED] generously enriched virtual reality by making up this one: Hi I have a script that processes a form input. What I want to do is this: I assume you are talking about a html form. I have form elements: -radio_group1 -radio_group2 -textfield: takes 6 digits depending on the user' selection. I want the textfield to be populated with 00 if the user select radio_group2. Any idea on how to do that and thanks in advance! ---snip--- #! /usr/bin/perl use strict; use warnings; use CGI qw(:standard); my $p = new CGI; my $myself =$p-url; my $text; if ($p-param){ if ($p-param('radio') eq 'take') {$text=$p-param('textfield');} else {$text='00';} print $p-start_html('Results'), $p-h1('Results'), $p-p($text), $p-end_html; } else { print $p-start_html('Form'), $p-start_form(), #defaults are this script, post, x-www-urlencoded $p-textfield(-name='textfield'), $p-radio_group(-name='radio', -values=['take','delete']), $p-submit, $p-end_form, $p-end_html; } ---snap--- prints a form with two radiobuttons (in the same group, 'radio') if the script s caled without parameters. If parameters are returned, $text is set to the content of your texfield if radio=take, otherwise $txt is se to '00'. Read the CPAN docu for the CGI module if you need help with it - tons of examples. Enjoy, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Help with Radio_group
On Monday 01 March 2004 02:06, wolf blaum generously enriched virtual reality by making up this one: On Sunday 29 February 2004 17:20, [EMAIL PROTECTED] generously enriched virtual reality by making up this one: Hi I have a script that processes a form input. What I want to do is this: I assume you are talking about a html form. I have form elements: -radio_group1 -radio_group2 -textfield: takes 6 digits depending on the user' selection. I want the textfield to be populated with 00 if the user select radio_group2. Any idea on how to do that and thanks in advance! ---snip--- #! /usr/bin/perl use strict; use warnings; use CGI qw(:standard); my $p = new CGI; my $myself =$p-url; my $text; print $p-header; Sorry, I forgot. Wolf -- 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 matching problem
On Thursday 26 February 2004 12:28, Henry Todd generously enriched virtual reality by making up this one: On 2004-02-26 00:43:21 +, [EMAIL PROTECTED] (Wolf Blaum) said: As I understand Biology, there is 4 nucleotid acids which gives 4**2 combinaions for dupplets. So you need 8 vars to count the occourence of all douplets. Worse for triplets. (24) As I understand genetics, triplets are what matters, since the rma transcriptase reads triplets as code of amino acids. You might give my updates un my biol. knowledge:-) Wolf - It's been a while since my A-Level biology days, but I believe you're correct. However, this particular coursework was to create two programs for a different purpose than I think you're imagining: Hi, as you can tell form my mail it has been a while since my basic math classes, too: 4**2 =8? 4**3=24? Uhuh... However, the real bug was for (my $i=0;$i length($sequence) - $wordsize;$i++){ which should be for (my $i=0;$i = length($sequence) - $wordsize;$i++){ beause it misses the last douplet/triplet/... otherwise. transition.pl: returns tables of transition probabilities for plus and minus models (exon and non-exon regions) as well as beta values (log-odds ratios) to compare the two models. The transition probability for AT for example (the probability that adenine will be followed by thymine) is calculated thus: tp(AT) = |AT| / |A_| The total number of occurrences of AT divided by the total number of A followed by anything. The program can also write the transition probabilities to a file to be used as input for the other program... ok - but once you end up with a hash containing all the douplets as there keys and frequency as values that should be doable as long as you know the members of your alphabet. I dont know if there is such a thing as transition probabilitis for codons (ie triplets) as well - if there is, then this should manifest as transition probilities for amino accids. In that case, creating the hash of wmers is done by just feeding the script another sequence. The only thing to change would be add knowledge about the AA alphabet to your script. simulation.pl: which asks the user to specify the length of the sequence they want, then generates it according to the model file used as input (by simulating a Markov chain). So if you supply a file containing the transition probabilities of a typical exon (coding) region, the simulation will use them to generate a typical exon sequence. This gets really of topic: Just interested: How do you choose which Letter to start with since there is no tp for nothing folowed by whatever? Sounds like a fun problem:) G'day, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Array question
On Friday 27 February 2004 01:18, Chris generously enriched virtual reality by making up this one: Hi Guys, I have a problem with e-mail address's and an array. I have some code that will be a documentation spider to go through all our technical documentation, extract e-mail address's and attempt to sort and exclude certain e-mails/patterns. All documentation is in plain text, so no filters, etc are needed. The first array will have every e-mail address found pushed into it. The second array will be an exclude array, in which I would like to search through, and remove from the email array, if found. The following code will loop through the email array and the exclude array, and successfully removes the emails from the email array that are specified in the exclude array: my %found = (); foreach (@emails) { $found{$_}++ }; foreach (@exclude) { exists $found{$_} and delete $found{$_} } BUT, if I print out the hash with this: foreach my $key (keys %found) { print $key\n; } The output comes up messed up for example: chris.com instead of: [EMAIL PROTECTED] hi, this one: ---snip--- #! /usr/bin/perl use strict; use warnings; my @emails = qw/[EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]/; my @exclude = qw/[EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]/; my %found = (); foreach (@emails) { $found{$_}++; } foreach (@exclude) { exists $found{$_} and delete $found{$_}; } foreach my $key (keys %found) { print $key\n; } ---snap--- prints on my box ---snip--- #~ ./douglas_in_bloom_county.pl [EMAIL PROTECTED] [EMAIL PROTECTED] ---snap--- so I think your @emails doesnt hold what you think it does. How do you [EMAIL PROTECTED] Why is this happening? Also, if I wanted to add for example: info without @domain.xxx to the exclude array, how can I remove any e-mail in the emails array based on a partial match? You could replace foreach (@exclude) { exists $found{$_} and delete $found{$_}; } with foreach my $key (keys %found) { foreach (@exclude) { delete $found{$key} if $key=~/$_/; } } and add zappod to @exclude (no xxx). However, this takes the whole sense of using a hash in the problem so instead of looping over the keys, loop over @email and @exclude. Or someone suggests a smarter way whih I would be interested in! Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Is there an etc. command in perl?
On Wednesday 25 February 2004 21:52, Joel generously enriched virtual reality by making up this one: Hi, Is there an et cetera type command in perl? Specifically, what I want to do is to go from is there an etc command in any other programing language? while (1) { my $num = shift @numarray; if ($num % 2==0) { and if the modulus of 2 is 0, find the modulus of 3 and so on. Can anyone give me some suggestions? What about this one: ---snip--- #! /usr/bin/perl use strict; use warnings; my @numarray=qw/2 6 13 18 24 33 120/; foreach (@numarray){ print \nMODing $_: ; for (my $i=1; $i0;$i++){ print $i ; print doesnt MOD it. and last if ($_ % $i != 0); print MODs ; } } print \n; ---snap--- prints ---snip--- #~ ./mod.pl MODing 2: 1 MODs 2 MODs 3 doesnt MOD it. MODing 6: 1 MODs 2 MODs 3 MODs 4 doesnt MOD it. MODing 13: 1 MODs 2 doesnt MOD it. MODing 18: 1 MODs 2 MODs 3 MODs 4 doesnt MOD it. MODing 24: 1 MODs 2 MODs 3 MODs 4 MODs 5 doesnt MOD it. MODing 33: 1 MODs 2 doesnt MOD it. MODing 120: 1 MODs 2 MODs 3 MODs 4 MODs 5 MODs 6 MODs 7 doesnt MOD it. ---snap--- on my box. Is that what you want? May I ask what you are planning to do? Enjoy, Wolf -- 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 matching problem
On Wednesday 25 February 2004 17:35, Henry Todd generously enriched virtual reality by making up this one: Hi, I'm having trouble counting the number of specific substrings within a string. I'm working on a bioinformatics coursework at the moment, so my string looks like this: $sequence = caggaactttcggaagaccatgta; I want to count the number of occurrences of each pair of letters, for example: Number of occurrences of aa Number of occurrences of gt Number of occurrences of cc This is how I'm counting the number of cc pairs at the moment ($cc is my counter variable): $cc++ while $sequence =~ /cc/gi; As I understand Biology, there is 4 nucleotid acids which gives 4**2 combinaions for dupplets. So you need 8 vars to count the occourence of all douplets. Worse for triplets. (24) As I understand genetics, triplets are what matters, since the rma transcriptase reads triplets as code of amino acids. You might give my updates un my biol. knowledge:-) To make your code reusable in upcomming classworks I suggest: ---snip--- #! /usr/bin/perl use strict; use warnings; my %wmers; my $sequence = caggaactttcggaagaccatgta; my $wordsize = 2; for (my $i=0;$i length($sequence) - $wordsize;$i++){ $wmers{substr($sequence,$i,$wordsize)}++; } foreach (keys %wmers) { print $_ = $wmers{$_}\n; } ---snap--- prints on my box: ---snip--- #~ ./gataca.pl at = 1 ct = 2 ag = 2 tt = 1 cc = 4 aa = 2 gt = 1 ga = 3 tg = 1 ca = 2 tc = 2 gg = 2 cg = 1 ac = 2 ---snap--- The Idea is simple: imitate the rma transcriptase (I know you are talking about dna, but does that matter?) by sliding a $wordsize window over the sequenze. For each window content inc the value of the corosponding hash field, create if necessary. I bet, there is a smarter solution using pos and regexes and a character class [gatc]{ $wordsize} - that would even make the thing usable for proteins by changing the character class to the protein alphabet But im getting OT her - maybe I should have done something else for a living:-) Enjoy (and reproduce), Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: can't bind a reference using Tk
On Tuesday 24 February 2004 04:29, Michael Ragsdale generously enriched virtual reality by making up this one: .. However, dont pass the object - pass a refernece to it in line 2, like: my $go = $right-Button(-text='Get Data',-command=sub{compute(\ $ent)})-pack(-side='top'); and use $$_[0]-get in compute I see the advantages of passing by reference, however, when I added the \ to pass the reference of $ent and the $ to dereference $_[0], it no longer worked. These were the only two changes and it left me with... my $go = $right-Button(-command=sub{compute(\$ent)})-pack; sub compute{ my $input = $$_[0]-get(); $sth-execute($input) or die. } The error was can't call method get on an undefined value. Now I'm really confused. Why would passing the object work, but passing the reference and then dereferencing in the sub doesn't? my fault: my $input = ${$_[0]}-get(); should work. I usually use something like : my $passed_ref=shift; and then work from there on. Enjoy: wolf -- 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 Newbie
On Tuesday 24 February 2004 15:49, Peterson, Darren - Contractor.Westar generously enriched virtual reality by making up this one: Hello, all. I'm as green a Perl programmer as can be. As a matter of fact, I am green in OO programming and network communications. I spent 12 years maintaining FORTRAN code on 1970's mainframe computers. I do love FORTRAN... welcome to perl then:-) But my boss has asked me to coordinate app execution on a handful of mixed boxes on a small LAN. The boxes are W2K and Linux. A network savvy friend of mine suggested Perl. As I work through a tutorial (Beginning Perl @ learn.perl.org, anyone have chapter 11?) on Perl starting this morning, what I really need immediate help with is TCP communication between a master app and a slave app. As a base upon which to build I would like to set up a script on one box that throws a message, any message, through any port to a script on another box. The second script should loop until message is received, then print and die. Look at http://modperl.com:9000/perl_networking/source/ch5/ for code examples. That is code from Lincoln Steins excellent book Network Programming with Perl. Briefly: read about file handles the non OO way. Then read about IO::File and IO::Socket. Both inherit most (all) methods from IO::Handle, thus making the scource of your input / the destination of your output pretty arbitrary. ie: reading from a socket is no more difficult than reading from a file. and: www.perldoc.com Enjoy, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: can't bind a reference using Tk
On Monday 23 February 2004 18:31, Michael Ragsdale generously enriched virtual reality by making up this one: .. Hi Mike, my $ent =$right-Entry(-width=8,-background='white')-pack(-side='left'); ^line 1 my $go = $right-Button(-text='Get Data',-command=sub{compute($ent)})-pack(-side='top'); ^line2 MainLoop(); sub compute { my $data_source = DBI:Oracle:host=*..***.***;sid=; my $dbh = DBI-connect($data_source,*,**) or die Cannot connect to $data_source; $DBI::errstr\n; my $sth = $dbh-prepare(qq(SELECT cuid, cuname FROM fcustomer WHERE cuid = ?)) or die Cannot prepare query: $DBI::errstr\n; $sth-execute($_[0]) or die Cannot execute query: $DBI::errstr\n; ^line 3 my @row = $sth-fetchrow_array; $id_txt-configure(-text=$row[0]); $name_txt-configure(-text=$row[1]); $sth-finish(); $dbh-disconnect; } When I enter an id in the Entry widget and click on the button, I get the following error message: .. I've tried to dereference $ent by sending $$ent but that didn't work either and gave me the error of not a SCALAR reference. Any suggestions welcome. In line 1 you create an Entry Widget object $ent. In line 2 you pass that object to sub compute when the button is pressed. And in line three you expect a number (whatever was enterd into $ent). This sub compute { my $msg = You passed .$_[0]-get(). to compute.; $main-messageBox(-message=$msg, -type='OK',-icon='info'); } works. However, dont pass the object - pass a refernece to it in line 2, like: my $go = $right-Button(-text='Get Data',-command=sub{compute(\ $ent)})-pack(-side='top'); and use $$_[0]-get in compute OR: associate a (global) variable with the entry widget in line 1 like: my $entryvar; my $ent =$right-Entry(-width=8,-background='white', - textvariable = \ $entryvar)-pack(-side='left'); This way you allways end up having the actual value shown in $entryvar. You get a new global, but you dont have to pass an object (or a reference to one) if you dont need to for other reasons. HTH, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Checking for calling context
Hey there, Hi I have a set of functions that send an XML element, wait for a response, parse the response, and return it. However, there are often cases where the resulting XML is never used, and so parsing it is pointless. Is there a way that a sub can tell where the result is going to go, so that it can not do the parsing if the result is going to be immediatly discarded? If you are asking how to teel between: $var=sub; and sub; - not that I know. However, there is a way to tell who asked for the result: read perldoc -f caller but why dont you pass a parameter to the sub that tells it? Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Which is better, opening and closing, or a massive file opening and a massive closing?
For Quality purpouses, [EMAIL PROTECTED] 's mail on Wednesday 11 February 2004 22:08 may have been monitored or recorded as: Hi, I'm still working on the script, though it is cleaning up even better, I even have it running cleaner by dumping anything not matching some specs. What I am trying to figure out though is this: I have 42 places for the output to go, 1 of those is a constant dump, the others are all based on whether or not there is data in a field. If the data is in the field, the data writes to a file with the same name as the data checked. If not then it writes to a global catch-all. If I recall your last mail correctly you were opening a lot of file handles, than running into the switch kind of thing and than closing all the files again. That was: a lot of system calls (open) to eventually write to a few of the files in the SWITCH (the accumulated ifs) and then again a lot of sys calls to closethem, where you have actually writen to only a few of the opend files. That sounds slow. Wiggins allready suggested if (grep $fields[4] == $_, @cities) { $tmptxt = $fields[10]; } else { $tmptxt = '1-' . $fields[10]; } for the first SWITCH like construct. For the second one id say, make an array of your filenames and use the contend of filed[11] as index, like: my @file_names=qw (/home/multifax/everyone /home/multifax/ pack-fishbait .); if (defined $file_name[$fields[11] - 102]) { open OUTFILE ${file_name[$fields[11] - 102]} or die Cant open ${file_name[$fields[11] - 102]}:$!; print OUTFILE [EMAIL PROTECTED]; #your trailing ID close OUTFILE; } else { open OUTFILE default.out or die Cant open default.out :$!; print OUTFILE [EMAIL PROTECTED]; #your trailing ID close OUTFILE; } However, this assumes that you have continous values from 102 upwards in $fields[11] - if not, come up with a formula that gives you the index of the wanted filename in @file_names depending on $fields[11]or use a hash instead: $file_name{102}=whatever/filename/you.want; I suggest you tell us, what the logic behind all these different files is, ie, what goes where of which cause: maybe someone can come up with a hash structure that incoorporates this knowledge. Dont open and close 42 files if you only will ever print to 2 of them. Enjoy, Wolf -- 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 to Implement a BNF syntax in perl?
For Quality purpouses, Balaji Thoguluva 's mail on Friday 06 February 2004 18:49 may have been monitored or recorded as: Hi, Hi I have a long BNF (Backus-naur form) for parsing a protocol message. Suppose I want to implement a BNF like this Response = Status-line *(message-header) CRLF [Message-body] status-Line = SIP-Version SP Status-Code SP Reason-Phrase CRLF SP = space character .. . Like this I have a very long BNF. How can I implement this BNF and parse a message that satisfies this BNF in perl ? Any suggestions would be of great help to me. Maybe Config::Natural is good to you. Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Script to parse files
For Quality purpouses, LoneWolf 's mail on Friday 06 February 2004 16:57 may have been monitored or recorded as: I've been working with this since wolf and jeff and john sent me some stuff, I think I actually based everything on wolf's code excerpts. I'm sure my final code is going to not be perfect, but at least I have the piece of mind of knowing that I can get this thing some better then it was. I'm still not sure on making it a sub that I can use on anything, but I'll deal with that issue another day. easy: (notice: thats the same script as priviously but has the parse in a sub:) ---snip--- #!/usr/bin/perl use strict; use warnings; my (@fields, $lng); sub whatever { if (@_) { foreach my $infile (@_) { my ($i,$rec); open INFILE, $infile or die Can't open $infile: $!; open OUTFILE, ${infile}.out or die Can't open ${infile}.out at home: $!; while (INFILE) { $rec++; chomp; [EMAIL PROTECTED] = split /\s*\|\s*/, $_; $fields[0] =~ s/^\s+//; #there is probably a way to get rid of the trailing spaces in the first entry using split,I just couldnt think of any. $lng = @fields unless $lng; #set $lng for first record print The following record: $i has , scalar @fields, fields as compared to $lng fields in the first record! Skip. : $_\n and next unless $lng == @fields; #poor quality control of your input data: check if all reords have the same number of fields or skip and print record otherwise. $i++; print OUTFILE $i; print OUTFILE |$_ foreach (@fields); print OUTFILE |$fields[0]\n; #your trailing ID } close INFILE; close OUTFILE; print Read $rec records from ./sql/$infile and printed $i into ./ ${infile}.out\n; } #end foreach return 1; } else {return undef;} } #end sub whatever ---snap--- call it with whatever('path/to/firstfile', 'path/to/secondfile',...) Enjoy, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Reg. string matching using reg-exp
For Quality purpouses, Balaji Thoguluva 's mail on Friday 06 February 2004 20:44 may have been monitored or recorded as: Hi, I am a novice to perl programming. When I execute the following code, I get always No Match. I guess my reg-exp is correct. I also tried changing $line= INVITE sip:[EMAIL PROTECTED] SIP/2.0; to have double quotes and a backslash char before @ symbol. Even then it gives me No Match. I appreciate your help. #!/usr/bin/perl -w my $line= 'INVITE sip:[EMAIL PROTECTED] SIP/2.0'; if($line =~ /^\s*(\w+)\s*(.*)\s+(sip\/\d+\.\d+)\s*\r\n/i) Do you have the \r\n at the end of $line? Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Script to parse files
For Quality purpouses, wolf blaum 's mail on Friday 06 February 2004 20:15 may have been monitored or recorded as: easy: (notice: thats the same script as priviously but has the parse in a sub:) ---snip--- #!/usr/bin/perl use strict; use warnings; my (@fields, $lng); ... and that my (@fields, $lng); belings in the sub wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Remote script execution
For Quality purpouses, Thind, Aman 's mail on Thursday 05 February 2004 06:24 may have been monitored or recorded as: Hello Friends, Hi I want to write a script that when executed will get lots of details from 10 different Unix(AIX) and Windows(XP) boxes and generate a report. The details to be gathered about the machines include : 1) Names and versions of all the softwares on the machines. 2) Disk space usage. Etc... my ideas: either see if you can get these information from each of these machines by establishing a telnet or ssh connection to them and remotly executing commands (maybe own perlscripts) on the remote machines - Net::Telnet from CPAN allows you client side connections using the telnet protocol. Net::SSH goes for ssh. Or - but that gets complicated: write client and server side software using IO::Socket and establish your own commands. Since you will probably need OS depending software on the remote machines anyway to get you infos I would go with the first solution. Also take a look at the available remote backup solutions on the net: maybe you find something to modify. But maybe you first want to see how OS dependend your queries are and what lots means: your network admin might appreciate the idea of localy generating the reports and sending them to the query machine at once instead of generating them by remotly executing commands. I think, whether you go with a centralisied or local solution depends on how often you expect to change the details you want to query and the frequency in which new systems and OSs are added to your net. If seldom or never, you might think of generating the reports localy and mailing them independently to the query machine (eg, via email). If frequently, then you might not want to run arround and change your local scripts everytime - see first ideas. You see: it gets out of hand - i better stop here. good luck, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
For Quality purpouses, Lone Wolf 's mail on Thursday 05 February 2004 00:52 may have been monitored or recorded as: I'm back to dealing with the main issue of a badly formatted file being brought down from an archaic system and needing to be cleaned up before being passed to another user or a database table. I have the code I assume by saying you are back that you are talking ofyour thread from 12/17: get rid of whitesace around pipes??. below, which pulls the whole file in and parse it line by line. That problem is still that when the stuff is done parsing the file, the file still has a ton of white spaces left in it. did you try something like my @fields = split /\s*\|\s*/, $line; as suggested by James, Jeff and Randy? Why didnt it work - the problem looks still pretty much the same, does it? What I would like to do is when I first open the file (another piece of this massive script) is tell it to just run a sub program on each piece that does the same thing as the stuff below, unfortunately I am not sure of the way to do this. Frankly, after a while of looking at your code Im still not sure what you want do - that might be due to my ignorance, but you would really help me (and I guess others too) understand, if you could post some sample data before they go into your program and a line of how you expect thme to look like after they were processed by your code - I guess that would make it easier to figure out, where what goes how (or so). Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: (U) What are the best Perl books out there ... More than 1 is fin e ... list as many as you like
Hi, I like: Learning Perl by Randal Schwartz Tom Phoenix as a good introduction with tons of further references Programing Perl by Larry Wall, Tom Christiansen and Jon Orwant as the ultimate refernce and pillow Mastering Perl/Tk by Steve Lidie and Nancy Walsh for times when I dont have access to this mailing list and zentaras hints The Perl Cookbook by Tom Christiansen and Nathan Torkington for when I was to lasy to think for myself (or wanted to get depressed by how much better one could solve the problem Ive been working on in hunderts of lines) And even though I never read it in the linear way: Mastering regular expressions by Jeffrey Friedl Not to forget: perldoc perltoc or www.perldoc.com and The Hitchhickers Guide to the Galaxy and Last Chance to see by Douglas Adams. I guess others would recomend The Lord of the rings too. Good night:-) Wolf -- 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 all elements in an array
For Quality purpouses, Markham, Richard 's mail on Thursday 05 February 2004 04:27 may have been monitored or recorded as: How can I simply remove all elements in an array, given that the array is global and a procedure defines the elements to where the total number of elements in this array could be very well be less. I have tried @array = (); but this seems to affect the arrary in that it wont take any element assignments afterwards. well ---snip--- #!/usr/bin/perl use strict; use warnings; my @array=qw/1 2 3 4 5 6 a s d f g/; print Length for blank: , scalar @array,\n; print $_ foreach (@array); @array=(); print \nLength after blank: , scalar @array,\n; ---snap--- does it. @array=(); is the way to go: I guess your proble is somewhere else. Do I need to iterate through each element and blank the out? ...making easy thigs easy and hard things possible - heavans no! wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
For Quality purpouses, Lone Wolf 's mail on Thursday 05 February 2004 04:23 may have been monitored or recorded as: Hi Thank goodness I never said I had perfect code, because I would definitely be lying. no worries - I post code to get feedback. Thats the whole ideaof learning it. I attached 2 files, one the beginning data, the other the .sql file that I load into MySQL database. The files are about 3000 lines before and after so I cut out the first 30 lines and put them in the files to the list. Ok - then, again: Do not read these files into mem at once unless you really have to (which should be close to never). here is a script that uses your given data: ---snip--- #!/usr/bin/perl use strict; use warnings; my (@fields, $lng); opendir INDIR , ./sql or die Can't open dir with before files:$!; foreach my $infile (grep {!/^\./} readdir INDIR) { #read all the files in your home/sql dir #read only files that do not start with a . my ($i,$rec); open INFILE, ./sql//$infile or die Can't open $infile: $!; open OUTFILE, ./${infile}.out or die Can't open ${infile}.out at home: $!; while (INFILE) { $rec++; chomp; @fields = split /\s*\|\s*/, $_; $fields[0] =~ s/^\s+//; #there is probably a way to get rid of the trailing spaces in the first entry using split,I just couldnt think of any. $lng = @fields unless $lng; #set $lng for first record print The following record: $i has , scalar @fields, fields as compared to $lng fields in the first record! Skip. : $_\n and next unless $lng == @fields; #poor quality control of your input data: check if all reords have the same number of fields or skip and print record otherwise. $i++; print OUTFILE $i; print OUTFILE |$_ foreach (@fields); print OUTFILE |$fields[0]\n; #your trailing ID } close INFILE; close OUTFILE; print Read $rec records from ./sql/$infile and printed $i into ./ ${infile}.out\n; } closedir INDIR; ---snap--- A couple of hints: The script reads all files in the sql subdir of your home dir and produces the corrosponding filname.out in your homedir. the split splits as written by Jeff et al. I coulndt think of a better way to substtute the leading spaces for the first field. Anyone better suggestions? you end up with a final \n in each outfile. You rewrite it into a sub by substititing the line foreach my $infile (grep {!/^\./} readdir INDIR) { with sub whatever{ ... foreach my $infile (@_) { and call th sub with whatever (file1, file2, ...); of course you may want to change the open statements to, if you dont have your infiles in ./sql Hope that gets you started, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
For Quality purpouses, wolf blaum 's mail on Thursday 05 February 2004 06:07 may have been monitored or recorded as: The script reads all files in the sql subdir of your home dir and produces the corrosponding filname.out in your homedir. shame on me: of course it reads all the files in the sub dir sql of the CURRENT DIR, not the home dir. use ~/ if you want your homedir... Well, if been here a while... Something else i forgot: why do you need the count on the beginning of the line? I hope not as a unique (primary) key for the dbtable you feed that into.There should be an AUTO_INCREMENT in your DB for that. And talking about DBs: According to te 3rd rule of Normalisation as outlined by e.f.codd of ibm in the 1970s: (to that i was arround at this time...) An Entity is said to be in 3rd normal form if it is allready in 2nd normal form and no nonidentifying attributs are dependent on any other nonidentifying attributs. The repeat of a value like $fields[0] clearly violates this rule. See www.databasejournal.com/sqletc/article.php/1428511 on Db Design. Good night, wolf -- 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/Tk and portability
For Quality purpouses, Gary Stainburn 's mail on Friday 30 January 2004 16:26 may have been monitored or recorded as: Hi folks, Hi Gary, As I've never looked at Tk before I would appreciate people's opinions on it. Specifically, how easy is it to develop, and how portable is it between the two platforms? I havent read your privious thred, so I dont really know if this is helpful for you: most of the scripts I ever wrote that I wanted to have a GUI for were scripts that needed (sometimes complicated) config files. So what I did was writing qw/simle/ GUIs using Tk to produce these config files, that way keeping program logic and User Interface seperate (and easily exchangable). In that approach it is possible to do a little interactivity even when the real programm is running, but if you need to promt users for something ever second at runtime, thats probably to not a good idea. However, the GUIs are pretty reusable and for these simple tasks pretty easy to write. Any comments about deploying on a Windows platform would also be appreciated (I want to provide it as a download, so simple install would be good). -- The pairs of script/gui I wrote so far worked fine on SuSe Linux 8.0 up and Win32 (didnt try other OS). I once did a Win package for download using the tarma installer TI (www.tarma.com) which installed activestateperl if required and my script/GUI pair - TI is freeware that produces a Win Installer for you. Worked fine. If you only need to do a Win GUI, look at the GUI Loft, too. (www.banhof.se/ ~johanl/perl/Loft/) Thats a WYSIWYG GUI design tool, pretty delphi like, except that it doesent produce code but a design file which you can work with in you app, so you can click your GUI together and focus on the logic. Neat thing. As Joseph was pointing out, examples in the Tk docu are an endangerd species: Mastering Perl/Tk by Steve Lidie and Nacy Walsh is an extended zoo of these. Enjoy clicking around, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Running Perl CGI from Windows
For Quality purpouses, Jan Eden 's mail on Friday 30 January 2004 20:01 may have been monitored or recorded as: Hi all, Hi .. But accessing the script from a Windows machine gives me the prepared error message. From the log I can see that all parameter values end up in the $name variable, along with the names of the second and third parameter. So the value of $name is: John Doe [EMAIL PROTECTED] message=This is the message Note that the first parameter's name does not appear. What does your form action=. tag look like? Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Running Perl CGI from Windows
For Quality purpouses, Jan Eden 's mail on Friday 30 January 2004 20:17 may have been monitored or recorded as: Hi Jan Like this: form action=cgi-bin/mail_form.pl method=post enctype=text/plain accept-charset=iso-8859-1 ... /form Try enctype=application/x-www-form-urlencoded instead. I had the very same problem using the xitami webserver on WinOs. Dont ask me were that problem comes from - no clue:-) Hope that works, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: A little help please?
For Quality purpouses, Joel 's mail on Saturday 31 January 2004 00:26 may have been monitored or recorded as: Hi, I'm interested in learning to program perl, and I just got ActivePerl for Windows. I am running XP and have a few questions. First off, how do I run the interpreter under Windows, preferably without the XP command prompt? if you used the standard installer that ships with activeperl with the preselected options it will have set a) the path variable to the perl/bin directory b) the association of .pl files with the interpreter. (You may do both yourself under Systm Properties-Advanced-Environment Variables for a) and under Folder Options in the tools menue of the explore-File Types). Once .pl files are assoc. with perl, dubble click on script.pl will open a Command Prompt and feed your script to perl, which will subsequently run it. However, youll probably only see any output if you script doesnt terminate without interaction, eg., waits for your input as its last action or so (or takes some time). Thats not a problem if you call perl with your script manually from a cmd prompt (not the run thing under Win). Also, when I opened perl, it looked like the command prompt. Is the command prompt accesable through perl? I dont understand that question. Maybe thats the effect described above: your script is to quick for you to and once it ends it also terminates the promptwin (winOS does that, actually). Finally is the #!usr/bin/perl line necessary under XP? Nope - but usefull. it doesent do anything on Win (since the first line starting with #! isnt interpreted by command.com as it is by bash, sh or whatever shell on *NIX and perl ignores it as a comment. Put it keeps your scripts portable (eg, for the users of this list). Enjoy looking around, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Regarding Text Widget in Perl/Tk
For Quality purpouses, zentara 's mail on Friday 30 January 2004 16:22 may have been monitored or recorded as: Hi, neat trick! Great. However, I have a, well, couriosity? My script looks pretty much the same, except the print in dosomething (since it is acctually your script:-)) Here is a set of programs, that do what you want. ## #!/usr/bin/perl -w use strict; use Tk; my $mw = new MainWindow; my $listbox = $mw-Scrolled(Listbox, -scrollbars = osoe, -height = 5, -selectmode = multiple) -pack(-side = left); my $start = $mw-Button( -text = 'Start', -command = \start )-pack; $mw-Button( -text = 'Exit', -command = \exit )-pack; #start external command to pipe sub start { $start-configure(-state = 'disabled'); open(C, ./read-own-stdout-piper 21 |) or warn $!; $mw-fileevent( \*C, 'readable', \doSomething ); } sub doSomething { if ( eof(C) ) {# Child closed pipe close(C); # Close parent's part of pipe, # filevent is cancelled as well wait; # Avoid zombies return; } my $text = C;# Get text from child and put it into listbox print $text; #only diffeerence. chomp($text); $listbox-insert( 'end', 'Got: ' . $text ); $listbox-see('end'); } MainLoop; __END__ ## and the called script looks different (but prints to STDOUT and has a $|++ for flush. When I call the GUI from a command prompt opend under X I should see two parallel outputs, one in the terminal and one in the listbox, right. I do see these outputs on both, but the one in the listbox is way slower than the one to the console. However, the relation seams to be random (ie there is no, say constant 5 line adtvantage). I also tried the tie @array, Tk::Listbox, $listbox in start and only call $listbox-see('end') in dosomething with the result, that I get to see the whole output in the listbox at once and only when the callled script is finished. Any Idea? Thanks a lot, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: goto command
For Quality purpouses, Thomas Browner 's mail on Thursday 29 January 2004 18:46 may have been monitored or recorded as: Does perl have a goto command. For example if you tell scrip to do something and it returns a 1 then it should go to a block of code that does something else. Not talking about style (but in the TIMTOWTDI spirit): from perldoc -f goto: goto LABEL goto EXPR goto NAME The goto-LABEL form finds the statement labeled with LABEL and resumes execution there. It may not be used to go into any construct that requires initialization, such as a subroutine or a fore- ach loop. It also can't be used to go into a construct that is optimized away, or to get out of a block or subroutine given to sort. It can be used to go almost anywhere else within the dynamic scope, including out of subroutines, but it's usu- ally better to use some other construct such as last or die. The author of Perl has never felt the need to use this form of goto (in Perl, that is--C is another matter). (The difference being that C does not offer named loops combined with loop control. Perl does, and this replaces most structured uses of goto in other lan- guages.) hth, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Use and Require
For Quality purpouses, Mallik 's mail on Thursday 29 January 2004 18:57 may have been monitored or recorded as: Dear Perl Gurus, that must be someone else What is the difference between Use and Require. try perldoc -f use on your box (or www.perldoc.com): use Module VERSION LIST use Module VERSION use Module LIST use Module use VERSION Imports some semantics into the current package from the named module, generally by aliasing cer- tain subroutine or variable names into your pack- age. It is exactly equivalent to BEGIN { require Module; import Module LIST; } except that Module must be a bareword. VERSION may be either a numeric argument such as 5.006, which will be compared to $], or a literal of the form v5.6.1, which will be compared to $^V (aka $PERL_VERSION. A fatal error is produced if VERSION is greater than the version of the current Perl interpreter; Perl will not attempt to parse the rest of the file. Compare with require, which can do a similar check at run time. There is tons more infomation of how use/require are simliar/different. Enjoy. Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: New Perl User needs help with POST in perl
For Quality purpouses, PerlDiscuss - Perl Newsgroups and mailing lists 's mail on Thursday 29 January 2004 23:49 may have been monitored or recorded as: I have written my HTML code to where it uses POST to collect information. Where do I start to write a script that collects the data from the web site, places the input into a dbm file, then places a 1 next to it like an array? Some of the data in the file will have zeros, while the ones that are inputted in the site will have a 1. HI, try the CGI.pm modul (http://search.cpan.org). It takes care of all your IO stuff. Use it in OO fashion (like below) or even in function oriented fashion (like explaind at cpan). -snip--- #!/usr/bin/perl #input_getter.pl use strict; use warnings; use CGI qw /standard/; my $cgi = new CGI; #new CGI object my @params=$cgi-param; #get all params (that came via post or get...) print $cgi-header, #print a response $cgi-start_html('Results'), $cgi-h1('you entered:'), $cgi-start_ul; foreach (@params) { #I assume all you data come as #param1=value1param2=value2 format #no arrays returned (as for multiple select boxes and so) print $cgi-li($_ = ,$cgi-param($_)); } print $cgi-end_ul, $cgi-end_html; --snap-- returns to the caller --snip-- Content-Type: text/html; charset=ISO-8859-1 ?xml version=1.0 encoding=iso-8859-1? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; lang=en-US xml:lang=en-USheadtitleResults/title /headbodyh1you entered:/h1ulliemail = [EMAIL PROTECTED]/li/ul/ body/html --snap which looks pretty much like valid html. However, as browsers only return parameters, for which values were entered, dont do something like using the foreach loop above in modified form to eter you data in a db, unless you have checked that all the parameters you expect are acctually there (by either doig it server side in your script or using a little ugly javascript client side). Hope thats a start, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: array push
For Quality purpouses, Rob Dixon 's mail on Tuesday 27 January 2004 12:42 may have been monitored or recorded as: Didn't you mean to put spaces before the last three records? This will be the result of .. well - in Anthonys original mail there were spaces - i just copied that. Or did I totaly miss something. Maybe. I'm not sure where you're misunderstanding what I wrote. Anyway, I hope this helps. ok - I think we are talking about the same thing here. thx, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: array push
For Quality purpouses, Rob Dixon 's mail on Tuesday 27 January 2004 00:30 may have been monitored or recorded as: The right conclusion for the wrong reasons Wolf! The spaces are the result of interpolating the array into a string, and the presence of a newline on each array element is immaterial: my @arr = ('A', 'B', 'C', 'D'); print @arr\n; print @arr, \n; **OUTPUT A B C D ABCD Hi Rob, well, maybe Im totally wrong here, but getting these results : $last printed out TMR2,mpd_gw,50,w32-ix86,client TMR2,mpd_gw,50,w32-ix86,client TMR2,mpd_gw,50,w32-ix86,client TMR2,mpd_gw,50,w32-ix86,client @temparray printed out TMR2,mpd_gw,50,w32-ix86,client TMR2,mpd_gw,50,w32-ix86,client TMR2,mpd_gw,50,w32-ix86,client TMR2,mpd_gw,50,w32-ix86,client from this code: Code: if (something){ $last = $tmrname,$gateway_hash{$gateway},$version,$interp,$type\n; #print $last; push(@temparray, $last); } @temparray = sort @temparray; print @temparray; Anthony asked, where the spaces came from, expecting the output of $last and @temparray to be the same. Of course, you are right about the interpolation used before the print : i just meant to point out that the newlines AND the spaces in his print @temparray are a result of the quotes used with print, and his attachment of \n to $last before the push @temparray,$last - without making it to complicated. (Tim also hinted to $). Or did I totaly miss something. thx, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: array push
For Quality purpouses, Anthony J Segelhorst 's mail on Monday 26 January 2004 17:17 may have been monitored or recorded as: How come when I push a variable to an array it puts one whitespace before the variables on all the lines except the first one? I would except all the lines not to have the extra white space. .. print @temparray; Try print @temparay; since you have a \n at the end of your array (btw: do you really want that?) , your records are seperated by something when you print them. print puts a space in between the eleent as a convienience for people who dont have a \n at the end of their emelents. hth, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Slices
@arary[3...] but this doesn't work?. What about @array[3..$#array] PS: @arary = typo? Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: complex data file parsing
Hi, As far as your follow up question on the B lines, only line with a B in the beginning in set?, I'm not sure if I understand. If you mean that there will only be 1 line per order (set of lines A-T) with a B in the first position, you are correct. yes, thats what I meant. Sorry about my lazyness. Adittionally I get to correct all my embarassing typos... Also, as far as your assumption, The way I do it assumes that the first and only first line of each set beginns with an A (and falsly buts that A at the end of the privious record, but doesnt matter for the aim her, does it?), I'm not sure what you mean by this either. However, it sounds like you have it correct. Lines that indicate the beginning of an order block, will only ever start with an A in the first position. Well, what that $/=\nA does is, it changes the amount of data the while (FH) reads into $_ Usually that is a line - in your case, the change of $/ gets it to read a whole order into $_: from A, to T,. end of line here. Thats what you need. However, I cheat: it acctually reads from A,... to T, \nA, into $_, so even the (A,) belongs to the next record, it ends up in the privious one. Thats kind of wrong, given your record structure but does not matter for the purpous you described. See the print $_ in the code below. Finally, the final assumption, that The push assumes that there are always exactly 5 records between B and email and that this is the only line with a B in record (and comes before the lines with ADV_. I think that this is correct. well good:) I tested the script, and I was able to output e-mail addresses. However, using the data that I posted, it does not quite output exactly what I need. Based on this sample of order.csv and the script that you sent me (I added the line print @email to view the output): for (my $i=0; $i=$#fields; $i++){ if ($fields[$i] eq B) {$b_index=$i; next;} elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; last;} 1 print @email; ): What is going wrong? Am I trying to view the output incorrectly? The line 1 is still in the for loop. So you print all emails seen so far for every field the split gave you. Code with more debug in the right place: --- #! /usr/bin/perl use strict; use warnings; my @email; open (FH, complex.txt) or die $!; local $/ = \nA,; # make \nA, the record seperator while(FH){ # read the next record print This record holdes:\n$_ \n; my @fields = split ,|\n, $_; # split at , or \n my $b_index; # 0 for every new record for (my $i=0; $i=$#fields; $i++){ if ($fields[$i] eq B) {$b_index=$i; next;} elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; last;} } # end for print End of record.\n\n } # end while print @email; #last line in script - On my box that prints the 2 emails you wanted. I hope I didnt get something totally screwed. Let me know if that does it or not. Thx, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: can i do it with perl ?
I there, Hi, I need to write a web database application using perl, and i need a way that when the users logs into the system i download all the information regarding to the user to its local computer and make all the transaction locally. After that, when the user logs out of the system all the information and transaction that were made by that user are then updated to the database server. Can i do it with perl ?, which modules ?, thanks. Why does it have to be a web application? Or rather just a client/server thing? What Database? I didnt find a way to do the dishes yet, anything else I ever tried works in perl. Just give us some more info. Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: can i do it with perl ?
Give me a little bit of time with a soldering iron, some wire, and a laptop connected to your home network and your dishwasher and that can be rectified. :-D I new that was a gentle list! I just dont have a dishwasher :( But given the traffic here I happily dont get much time to use dishes at all. Have a nice weekend, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: From 5.6.1 to 5.8.2: how preserve installed modules?
Hi, i ont want to get involved in the religios questions: for the rest: use PPM or CPAN.pm? - How can I get PPM to tell me everything that's installed? ppm query * #gives you the list of installed modules ppm properties Mo::Dule #gives you a detailed discriptio of that installed module Can anyone say what I would break by upgrading to 5.8.2? Are there major CPAN modules known to become incompatible when moving to 5.8.2? Not from the top of my head. However, if you check http://aspn.activestate.com/ASPN/Modules/ and look for the ppm module status, youll find a nice table telling you which modules work in which version of activestate perl. There is a lot of modules that dont work with 5.8. yet (like Mail::POP3Client). Good luck, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: String concatenation qn
For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 2004 17:52 may have been monitored or recorded as: hi,. hi i would like to quickly append a string to a variable. open NEWFH, $filename.new or die new procmailrc err; where $filename has /tmp/xyz Anything really silly here?? Nothing I didnt do wrong at least a thousand times: open NEWFH, $filename..new or die new procmailrc err; will do it. perldoc perlop: Gory details of parsing quoted constructs When presented with something that might have several dif- ferent interpretations, Perl uses the DWIM (that's Do What I Mean) principle to pick the most probable inter- pretation. This strategy is so successful that Perl pro- grammers often do not suspect the ambivalence of what they write. But from time to time, Perl's notions differ sub- stantially from what the author honestly meant. - This is one of the latter cases. Wolf -- 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 to take command line argument and use it to run an upgrade script.
I'm a perl newby. me too:-) Right list, I assume. I'm looking on taking a command line argument from STDIN and use it for input to a script that upgrades software. Any examples would be greatly appreciated. @ARGV holds your command line arguments. call: scriptname.pl Universe 42 douglas 'Zappod Beblebrox' #! /usr/bin/perl use strict; use warnings; print You called me with , scalar @ARGV, Arguments.\n; if (@ARGV) { print Param to script: $_\n foreach (@ARGV); } Notice that there is a nice wa of processing command line args with the getopt:: modules from CPAN. Also take a look at perldoc perlvar for detailed info about @ARGV, ARGV and $ARGV. Hope that helps, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: complex data file parsing
hi, I know that each block always starts with and A in the first position of the first line and ends with a T in the last position of the last line. isnt it a T in the first position of the last row of the set? I know that the second line starts with a B, and the data in the 5th space on this line is the e-mail address, which is what I ultimately want. However,... only line with a B in the bigining in set? I am trying to get a list of email addresses for people who have ordered products that begin with ADV. These can appear in multiple I lines. Therefore you can never predict how many lines make up 1 order block. What about: #! /usr/bin/perl use strict; use warnings; my @email; open (FH, complex.txt) or die $!; local $/ = \nA,; # make \nA, the record seperator while(FH){ # read the next record my @fields = split ,|\n, $_; # split at , or \n my $b_index;# 0 for every new record for (my $i=0; $i=$#fields; $i++){ if ($fields[$i] eq B) {$b_index=$i; next;} elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; last;} } } works on the sample you provided. $/ (see perlvar) is the record seperator, usually \n. If really T would be the last char i the last row of the set, you could use T \n as $/ The way I do it assumes that the first and only first line of each set beginns with an A (and falsly buts that A at the end of the privious record, but doesnt matter for the aim her, does it?) The push assumes that there are always exactly 5 records between B and email and that this is the only line with a B in record (and comes before the lines with ADV_ lot of assumtions. Im sure there is better ways to do that - might be a strat, though. Online ordering is now available. Visit http://insidersadvantage.com for details. Uh, given from your question, I better dont,, eh? Good luck, Wolf -- 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 to take command line argument and use it to run an upgrade script.
My Compliments on a well done piece. OT: see, a logical problem I have with newsgroups is that you learn most (at least I do) by trying to explain things you think you understood to others - beginning explainers however make mistakes - Thats of course not what you want in a newsgroup, since there is the one asking, who is learning too, whom you dont want to confuse with slightly right answers. Nevertheless Im happy it seems this is a group were you can even learn how to explain (and what the group-iquette is anyway). Thanks for that, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Need help comparing lines in two files
This very green newbie would like to compare two files, let's say File1 and File2. I want to put the difference from File2 only, into a new file, File3. I had a very simliar problem about a week ago, which James answerd here: http://groups.google.com/groups?q=Perl+looping+(a+lot+of) +fileshl=enlr=ie=UTF-8selm=28A16704-4AD3-11D8-9A03-000A95BA45F8% 40grayproductions.netrnum=1 or try google groups perl looping through (a lot of) files The only really difference is that I didnt want to compare one FILE2 to FILE1 but 500. However, be carefull on your filesize: I settled reading one file into mem (as an array) and looping through the other ones using a while (FILE2) reading the 500 files line by line. For example: File1.txt oranges apples bananas File2.txt apples kiwi bananas The result I want for File3 is the new entry in File2, which is kiwi. (I don't care that oranges was in File1 and not File2.) I tried using a nested foreach loop structure, but I can't get that to work and I have a feeling using nested foreach's is not the way to go. why not? I'm guessing somehow I should use hashs, but I've never used a hash for anything and I don't really know how to use a hash. Can someone help ? do you need to associate the contens of the line with a filename ore something? if not, use an array. Here's my feeble attempt: my $file1; my $file2; my @file1 = qw(oranges apples bananas); my @file2 = qw(apples kiwi bananas); As Dan showed: FILE2: foreach $file2 (@file2){ foreach $file2 (@file2){ you may want foreach my $file1(@file1){ here #print $mastervob $tempvob \n; if ($file2 eq $file1) { last; # I would like to go up to the toplevel foreach here, but I don't know how to do it } # and I'm not sure this would even work. as Dan said: next FILE2; will do the job. else{ print $file2 \n; } } } This doesent do what I assume you want: when you place the print in the inner loop. Just look at the link above. Hope thats a start, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: IO File Problems
hi there, hi | servus, 2) now i have to merge this strings with strings from a file. in this file there are many configuration sections. the section i need looks like this: [WHITELIST] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] so i need to get all adresse under the [whitelist] tag into an array and merge them with my other array. i need to move the filepointer unter the tag - than cut the digit number and the = out - put the email adress in a array and I assume @emails to be your array. #!/usr/bin/perl use strict; use warnings; my @emails=get_db_emails; open (FH, whitelist.txt) or die Cant open whitelist.txt: $!; while (FH){ next unless (/\[WHITELIST\]/); my $inlist=1; while ($inlist){ chomp ($_=FH); if (/^\d+=(.*)/) {push @emails, $1;} else {$in_list=0;} } } Yes, this is very dirty and only works if the whitelist.txt file looks like you showed - however, it can hold multiple [WHITELIST] sections. A section is assumed to end on the first line found that doesent hold the digits=email pair. Note that you shouldnt try to verify email syntax yourself (unless you want to spend weeks implementing the rfc822 and related).There is a Email::Valid modul at CPAN that does not only check the syntaxx but also if there is a MX server in that domain accepting email. calc to the digit number of the last entry +1. I didnt get what you want here - sorry. sorry 4 my bad english but i am from austria :) Nevermind, great skiing over there! Send me a mail in german (or austrian:-) if you need further help. Hope thats a start, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
looping through (a lot of) files
Hi there, I do have one type A file, that holds about 25.000 A-ids, one per line. Furher I have 500 type B files in a dir that hold 10-500 B-ids each, one per line. All files are -T Now i want to generate 500 type C files, corrosponding to the b files: each B-id, that occours in a B-type file AND the A-type file should go into the corrosponding C-file. Each A id is unique in the A file, each B-id is unique in its file BUT NOT i all the Bfiles: each B id may occure in one or more B files. Im lookin for a fast and memory concious way to do that. I guess, there might be better ideas then foreach bfile in B-file-dir foreach b-id in Bfile foreach a-id in Afile print to Cfile and next Bfile if a_id eq b_id thank a lot, wolf -- 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/Writing Hash to Excel
Hi, I have successfully extracted the data I need and I am attempting to write the data into rows in excel. well, there is wonderful (as most of them:-) CPAN Module called: Spreadsheet::WriteExcel that allows you to write in excel files, create additional worksheets and that sort of stuff. There is also a module (alpha) called DBI::Excel which allows you to use the DBI Interface on Excel sheets quering in SQL if you like that better: however, at least up to my knowledge it doesent support multiple worksheets. My favourite method to export data to excel or something else is nevertheless using printf and \t to write tab delimited files which you might find importable basically everywhere. I would like to loop through the data starting with customer number and continue until I reach another customer number, at which time I would like to start a new row. I have included the sample data (results from extraction) as a attachment. I didnt find your privious thread so i might leave the calls of either way up to someone who knows that code. wolf ps: hope you arent a cowboys fan:-/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
wannabie asks Mail::POP3Client Mail::Audit
Hi, Im new (here|to perl) and would like to start of with that: My script should replace attachmends in mails: however, i cant find any atts. Script first: -- #! /usr/bin/perl use strict; use warnings; use Mail::POP3Client; use Mail::Audit qw(Attach); my $pop=new Mail::POP3Client(USER = you, PASSWORD = youpass, HOST = your.server); for (my $i=1; $i= $pop-Count();$i++) { my @mail = $pop-Retrieve($i); my $mailref = [EMAIL PROTECTED]; my $mail = Mail::Audit-new(data = $mailref); print From: , $mail-from,\nSubject: ,$mail-subject, \n; #try to find Content-type: multipart/mixed; boundary= in mail header #manually foreach (@$mailref){ /^(Content-type:)\s+/i and print $_\n; } #let Mail::Audit:Attachments try print Att-no: , $mail-num_attachments, \n; my $atts = $mail-attachments; foreach (@$atts){ print size: ,$_-size,\nfilename: ,$_-filename,\n; } } #for all mails in inbox $pop-Close(); --- Since I dont want the Mail::Audit object to use my local inbox but the pop retrieved data I pass the array ref to it. The problem: even though a print join (\n,[EMAIL PROTECTED]); shows me there are Content-type: multipart\mixed headers my first attempt to find them manually fails and gives me only the Content-type: text/plain or ..application/blabla lines from the mail body of multi part mails. Second attempt to identify atts via Mail::Audit::Attachment fails too. All mail headers of the retrieved messages do carry a MIME-version: 1.0 line as required by Mail::Audit::Attachment. All the other print froms and so work fine What am I doing wrong? Better solutions? Thanks a lot, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: wannabie asks Mail::POP3Client Mail::Audit
Follow-up: The problem: even though a print join (\n,[EMAIL PROTECTED]); shows me there are Content-type: multipart\mixed headers my first attempt to find them manually fails and gives me only the Content-type: text/plain or ..application/blabla lines from the mail body of multi part mails. ok, i solved that one: my $mail = Mail::Audit-new(data = $mailref); strangely eats the array up so I dont have anything for my manual attempt left. The strange thing: It only eats the header, the body is still there: couldnt find anything in the docu of Mail::Audit that mentions that. So droping the construction of that object (and its use) lets me identify the Content-type option in the header manually or by using the Mail::Header object, which parses the header and makes it accessible in standariezed form. However: Second attempt to identify atts via Mail::Audit::Attachment fails too. That still holds valid: I cant the heck use te Mail::Audit class as I would like to: seems like I cant use it at all... Whats wrong here? My code? My understanding? My carma? Thanks, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: printf
Am Montag, 22. Dezember 2003 20:17 schrieb Perl: i know what %9.1f would have done in this case. but how does %9.2g round off ? the FORMAT notation used by prinf, sprintf, ... can be found on http://www.perldoc.com/perl5.8.0/pod/func/sprintf.html which gives: %e a floating-point number, in scientific notation %f a floating-point number, in fixed decimal notation %g a floating-point number, in %e or %f notation Just in case: scientific notation is something like XeY which means X times 10 to the poxer of Y (power first!) HTH, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: RegEx Troubles
Given this in $_ pMost popular title searches:/pollia HREF=/title/tt0244365/Enterprise (2001)/a/li why would this regex not put digits in $1 ? $data2 =~ /popular title searches:\/pollia HREF=\\/title\/tt(\d*)\/\/ Hi, Snip--- $data2='pMost popular title searches:/pollia HREF=/title/tt0244365/Enterprise (2001)/a/li'; $data2 =~ /popular title searches:\/pollia HREF=\\/title\/tt(\d*)\/\/; print $1; endSnip--- prints 0244365 If that's what you are looking for. If you realy have the html in $_, why do you bind $data2 to the regex? That way you try to find [regex] in $data2. HTH, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response