Re: Unicode class for ø
Mr. Shawn H. Corey пишет: On Thu, 2008-10-02 at 17:09 +0300, Vyacheslav Karamov wrote: Vyacheslav Karamov пишет: Hi All! I making regular expression for mathching authors in some text (English, French or German). Which character class lower-case letters containing latin letters like ø? For example Colding-Jørgensen Sorry, I need an upper-case too. POSIX has a class of characters that respond to locale. use POSIX; /[[:alpha:]]+/; See: perldoc POSIX perldoc perllocale perldoc locale use POSIX + [:alpha:] doesn't work -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Unicode class for ø
Vyacheslav Karamov пишет: Mr. Shawn H. Corey пишет: On Thu, 2008-10-02 at 17:09 +0300, Vyacheslav Karamov wrote: Vyacheslav Karamov пишет: Hi All! I making regular expression for mathching authors in some text (English, French or German). Which character class lower-case letters containing latin letters like ø? For example Colding-Jørgensen Sorry, I need an upper-case too. POSIX has a class of characters that respond to locale. use POSIX; /[[:alpha:]]+/; See: perldoc POSIX perldoc perllocale perldoc locale use POSIX + [:alpha:] doesn't work Solution: just add use utf8; (without quotes) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Regexp: Correct braces
Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regexp: Correct braces
Rob Coops пишет: Try this: (?:Some text not captured) The ?: at the beginning tels perl that even though you want it to see thsi whole group you would not like perl to capture the string. Look up perlre (http://perldoc.perl.org/perlre.html) for some more information on this particulair topic it will lead you to the other pages that hold more information about more fun things you can do with regex's. Regards, Rob On Fri, Oct 3, 2008 at 10:52 AM, Vyacheslav Karamov [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong I was misunderstood. I need to capture something in braces (with braces or not. Its not important), but I need to capture if opening brace correspond closing one. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regexp: Correct braces
On Fri, Oct 3, 2008 at 11:15 AM, Vyacheslav Karamov [EMAIL PROTECTED]wrote: Rob Coops пишет: Try this: (?:Some text not captured) The ?: at the beginning tels perl that even though you want it to see thsi whole group you would not like perl to capture the string. Look up perlre (http://perldoc.perl.org/perlre.html) for some more information on this particulair topic it will lead you to the other pages that hold more information about more fun things you can do with regex's. Regards, Rob On Fri, Oct 3, 2008 at 10:52 AM, Vyacheslav Karamov [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong I was misunderstood. I need to capture something in braces (with braces or not. Its not important), but I need to capture if opening brace correspond closing one. Ah, ok thats a different story in that case I would go for somethign along these lines: m/((.*?\)|\[.*?\])/ That should get you a match of (as little stuff as possible in the middle) or [as little stuff as possible in the middle] so only your first fwo lines should match the other two should not, the only thing that might trip you up is a line with multiple braces like [)](] will still be seen as matching if you want to exclude those you could do somehting along the lines of: m/((^\(.*?\])|(^\[.*?\)))/ which should also match the two top lines but will not match [)](] at least I believe it should not I have not tested it as I am being kept quite busy today (delivery deadline today)
Re: Regexp: Correct braces
Vyacheslav Karamov wrote: Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong HTH, Rob use strict; use warnings; while (DATA) { while ( / ( \[[^])]+\] | \([^])]+\) ) /xg ) { print $1, \n; } } __DATA__ [correct] - correct (also correct) - also correct [wrong) - wrong (also wrong] - also wrong -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regexp: Correct braces
On Fri, 2008-10-03 at 11:52 +0300, Vyacheslav Karamov wrote: Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong #!/usr/bin/perl use strict; use warnings; while( ){ chomp; while( /\((.*?)\)|\[(.*?)\]/g ){ my $result = $1; $result = $2 unless defined $result; print $result\n; } } __END__ Note that if these structures can be nested, you will have to use a FSA with a push-down stack. -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regexp: Correct braces
Mr. Shawn H. Corey wrote: On Fri, 2008-10-03 at 11:52 +0300, Vyacheslav Karamov wrote: Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong #!/usr/bin/perl use strict; use warnings; while( ){ chomp; while( /\((.*?)\)|\[(.*?)\]/g ){ my $result = $1; $result = $2 unless defined $result; print $result\n; } } __END__ Note that if these structures can be nested, you will have to use a FSA with a push-down stack. That will match a line like [wrong) and (wrong] Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: after upgrade: glibc detected *** /usr/bin/perl: double free or corruption
Peter Daum wrote: I recently upgraded a system (as far as perl is concerned from 5.8.8 to 5.10.0). Afterwards I ran into a mysterious problem. I could eventually find a workaround, but still don't really understand, what is going on. After the upgrade, a perl program wouldn't run anymore - it crashed with a message:*** glibc detected *** /usr/bin/perl: double free or corruption (fasttop): ... and a memory map suggesting some problem on the heap. The crash can be reproduced by the following code: use Net::LDAP; my $self=Net::LDAP-new(127.0.0.1); ($self-{prog_name}= $0) =~ s|^.*/([^/]+)$|$1|; # when I put an intermediate variable into the statement: $self-{prog_name}= (my $_p= $0) =~ s|^.*/([^/]+)$|$1|; the program works again. Technically, my problem is solved, but maybe somebody here can shed some light on some questions: - I tried to run the program under the debugger hoping to find, where exactly the error occurs - unfortunately the same program suddenly worked just fine, so I ended up putting print statements into the code until I eventually found the problematic line. Why can't the crash be reproduced under the debugger? Would there be an easier way to find the problem? - Generally, I still don't understand what's wrong with the original program code.I didn't try it but I don't think it is anything specific to Net::LDAP. However, when $self is just some hash reverence (my $self={}), the code also works without any problem. Actually, it seems like the problem is indeed specific to Net::LDAP; furthermore, the crash only occurs, if there is a LDAP server running at the specified address. I still would love to know where exactly the problem is. Is there a bug somewhere in Perl or in Net::LDAP? Am I doing something wrong? (well, some might argue that it's a bad to rely on Net::LDAP::new returning a hash reference and isn't using a key named prog_name ...) Regards, Peter Daum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regexp: Correct braces
On Fri, 2008-10-03 at 12:38 +0100, Rob Dixon wrote: Mr. Shawn H. Corey wrote: Note that if these structures can be nested, you will have to use a FSA with a push-down stack. That will match a line like [wrong) and (wrong] Rob Note that if these structures can be nested, you will have to use a FSA with a push-down stack. -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Accessing hash of arrays?
I have a script for archiving email messages on IMAP (whole code is available at http://mcepl.fedorapeople.org/tmp/archiveIMAP.pl). I go through all messages in one source folder and put all of those which I want to archive to hash indexed by the target folder: ... $targetFolder = getTargetFolder($folder,$msgYear); push ( @{ $targetedMessages{$folder} } , $msg); ... and then just go through the hash and actually move all messages which should go to one target folder: foreach my $tFolder (keys %targetedMessages) { if (!($imap-exists($tFolder))) { $imap-create($tFolder) or die Could not create $tFolder: [EMAIL PROTECTED]; } $imap-move($tFolder,[EMAIL PROTECTED]); } EPIC complains about the @-sign in the last line of this snippet -- that I should use $-sign when trying to slice the array. But I am not trying to slice an array (at least I hope). Just following perldsc(1) I am trying to get whole array and use it as a parameter of the method move. Who's wrong? Me or EPIC? Thanks for any advice, Matěj Cepl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Beginners' books for Perl newbies using Windows?
Raymond == Raymond Wan [EMAIL PROTECTED] writes: Raymond In academia, it is common to blame the student, but up to a point, it Raymond might be worth asking if the teacher can teaching things Raymond differently...especially if enough students complain. As someone who has built a solid reputation creating quality training materials in this area, allow me to elaborate. I've seen a lot of ineffective training materials in my life. Many times, instructors don't understand that the point of all training is state change. Students start some place, and want to end up in a different place. It's not enough to simply throw facts at a student and have them try to sort out the framework in which to hold those facts (which is what my junior high History teacher thought teaching history meant, and why I still have a distaste for that to this day, but I digress). As an instructor, I need to figure out what incremental change in frameworks *and* facts are needed at each step. And for efficient learning, I also need to linearize the knowledge... each new item buildling closer to the final desired state. One of the reasons Learning Perl is so effective is that I specifically designed the starting and ending point of the reader, and then figured out the absolute minimum steps to get there, and *left everything else out*. I consider the selection of what we left out to be a lot more important than what we put in. :) People often ask what about this and why isn't that in there, and I generally reply because the course wouldn't fit in a week then... we'd have to take something else out, and we wouldn't reach the desired goal. The other thing that makes Learning Perl successful is that I take it *personally* when someone in my classroom didn't achieve satisfaction in the stated results of the course. I investigate each case. In some cases, it's because the person didn't meet the starting point of the course and tried to slide by... that's not anything I can do except make the pre-reqs clearer the next time. But if there was some break in the chain of new-things-building-on-old, I make sure that another way to teach that step gets incorporated in the next courseware update, and then back into the books when we update the books. In my view, there are no stupid students. Only misstated pre-reqs, misaligned goals, or *bad* instructors. No excuse for any of those. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Bug Or Feature?
Here's my problem (well, a shortened example=) #hashes.pl use strict; use warnings; use Data::Dumper; my %a=(a=1, b=2, c=3); print Dumper \%a; print \n.(- x 10).\n; my $c=$a{d}-[0]; print Dumper \%a; $ perl hashes.pl $VAR1 = { 'c' = 3, 'a' = 1, 'b' = 2 }; -- $VAR1 = { 'c' = 3, 'a' = 1, 'b' = 2, 'd' = [] }; Now, while I'd expect a warning on the line of my $c=$a{d}-[0]; (like, dunno, you're trying to dereference undef?) I'd never think a field is added to the hash... I'm confused.. Is this expected behaviour? Changing a right-hand operand (without calling a sub)? cheers paolino -- Paolo Gianrossi Softeco Sismat S.p.A. - RD Division via De Marini 1, 16149 Genova Tel: +39 010 6026 332 - Fax: +39 010 6026 350 E-Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Accessing hash of arrays?
On Fri, 2008-10-03 at 16:03 +0200, Matej Cepl wrote: I have a script for archiving email messages on IMAP (whole code is available at http://mcepl.fedorapeople.org/tmp/archiveIMAP.pl). I go through all messages in one source folder and put all of those which I want to archive to hash indexed by the target folder: ... $targetFolder = getTargetFolder($folder,$msgYear); push ( @{ $targetedMessages{$folder} } , $msg); ... and then just go through the hash and actually move all messages which should go to one target folder: foreach my $tFolder (keys %targetedMessages) { if (!($imap-exists($tFolder))) { $imap-create($tFolder) or die Could not create $tFolder: [EMAIL PROTECTED]; } $imap-move($tFolder,[EMAIL PROTECTED]); $imap-move($tFolder,$targetedMessages{$tFolder}); # $targetedMessages{$tFolder} already is a reference } EPIC complains about the @-sign in the last line of this snippet -- that I should use $-sign when trying to slice the array. But I am not trying to slice an array (at least I hope). Just following perldsc(1) I am trying to get whole array and use it as a parameter of the method move. Who's wrong? Me or EPIC? Thanks for any advice, Matěj Cepl -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bug Or Feature?
On Fri, 2008-10-03 at 18:21 +0200, Paolo Gianrossi wrote: Here's my problem (well, a shortened example=) #hashes.pl use strict; use warnings; use Data::Dumper; my %a=(a=1, b=2, c=3); print Dumper \%a; print \n.(- x 10).\n; my $c=$a{d}-[0]; print Dumper \%a; $ perl hashes.pl $VAR1 = { 'c' = 3, 'a' = 1, 'b' = 2 }; -- $VAR1 = { 'c' = 3, 'a' = 1, 'b' = 2, 'd' = [] }; Now, while I'd expect a warning on the line of my $c=$a{d}-[0]; (like, dunno, you're trying to dereference undef?) I'd never think a field is added to the hash... I'm confused.. Is this expected behaviour? Changing a right-hand operand (without calling a sub)? Perl does this even if you're just testing. I don't know why. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; $Data::Dumper::Maxdepth = 0; my $var = {}; if( exists $var-{foo}{bar}[5] ){ print foobar\n; } print Dumper $var; __END__ -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Accessing hash of arrays?
On Oct 3, 10:03 am, [EMAIL PROTECTED] (Matej Cepl) wrote: I have a script for archiving email messages on IMAP (whole code is available athttp://mcepl.fedorapeople.org/tmp/archiveIMAP.pl). I go through all messages in one source folder and put all of those which I want to archive to hash indexed by the target folder: ... $targetFolder = getTargetFolder($folder,$msgYear); push ( @{ $targetedMessages{$folder} } , $msg); ... and then just go through the hash and actually move all messages which should go to one target folder: foreach my $tFolder (keys %targetedMessages) { if (!($imap-exists($tFolder))) { $imap-create($tFolder) or die Could not create $tFolder: [EMAIL PROTECTED]; } $imap-move($tFolder,[EMAIL PROTECTED]); } EPIC complains about the @-sign in the last line of this snippet -- that I should use $-sign when trying to slice the array. But I am not trying to slice an array (at least I hope). Just following perldsc(1) I am trying to get whole array and use it as a parameter of the method move. Who's wrong? Me or EPIC? You. %targetedMessages is a hash $targetedMessages{$tFolder} is an element of that hash, that happens to be a reference to an array. @{$targetedMessaages{$tFolder}} would be the array that $targetedMessages{$tFolder} references. if you were to put a slash in front of that, you'd have yet another reference to this same array. But of course there is no need to do that, as $targetedMessages{$tFolder} is already a reference to the array. @targetedMessages{$tFolder} is a one-element slices of the hash %targetedMessages. It is the list containing ( $targetedMessages{$tFolder} ). Since you can't take a reference to a slice, the \ instead does the same thing it does to any other list - returns a list of references to the list elements. You are therefore getting back a reference to $targetedMessages{$tFolder}, which is itself already a reference. And you are trying to pass that array-reference-reference as a parameter. If you want to pass a reference to the array, use $targetdMessages{$tFolder} If you want to dereference the reference and pass the array elements, use @{$targetdMessages{$tFolder}} Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bug Or Feature?
Paolo Gianrossi wrote: Here's my problem (well, a shortened example=) #hashes.pl use strict; use warnings; use Data::Dumper; my %a=(a=1, b=2, c=3); print Dumper \%a; print \n.(- x 10).\n; my $c=$a{d}-[0]; print Dumper \%a; $ perl hashes.pl $VAR1 = { 'c' = 3, 'a' = 1, 'b' = 2 }; -- $VAR1 = { 'c' = 3, 'a' = 1, 'b' = 2, 'd' = [] }; Now, while I'd expect a warning on the line of my $c=$a{d}-[0]; (like, dunno, you're trying to dereference undef?) I'd never think a field is added to the hash... I'm confused.. Is this expected behaviour? Changing a right-hand operand (without calling a sub)? It is called 'autovivication'. If you try to use the value of a non-existent hash or array element as if it was a reference to a hash or array then an anonymous hash or array will be created for you. Take a look at perldoc perlglossary and look at 'autovivification'. Your example is not a very useful one. It is most often seen as push @{$a{d}}, $newdata; or something similar. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Extract fields from a HTML source
Hi, I used LWP to GET a source document. The document is styled HTML with a form. I'm after the field value data. The question is what should I do with to work with this document source? Life would be easier if the source were XML but I was wondering is there is a way or module for dealing with in this form. my $res = $ua-request($req); if ($res-is_success) { print $res-decoded_content; ... TIA, Dp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Extract fields from a HTML source
Dermot wrote: Hi, I used LWP to GET a source document. The document is styled HTML with a form. I'm after the field value data. The question is what should I do with to work with this document source? Life would be easier if the source were XML but I was wondering is there is a way or module for dealing with in this form. my $res = $ua-request($req); if ($res-is_success) { print $res-decoded_content; ... Take a look at HTML::TreeBuilder Dermot. It may be a steep learning curve, but it's the nicest module I know for your purpose. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: join operator for arrays question
John W. Krahn schreef: BTW $$_[0] is usually written as $_-[0]. I think it is a pity that O::Deparse() doesn't do this: $ perl -MO=Deparse -e '$$_[0] = 1' $$_[0] = 1; -e syntax OK $ perl -MO=Deparse -e '$_-[0] = 1' $$_[0] = 1; -e syntax OK -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regexp: Correct braces
Vyacheslav Karamov schreef: Hi All! I need to capture something in braces using regular expressions. But I don't need to capture wrong data: [Some text] - correct (Some text) - also correct [Some text) - wrong (Some text] - also wrong http://search.cpan.org look for Regexp::Common, more specifically Regexp::Common::balanced. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Unicode class for ø
Vyacheslav Karamov schreef: just add use utf8; (without quotes) Did you read the documentation? The utf8 pragma is about the encoding of your script itself. So I assume you have non-ASCII characters in your script, and your editor saves the script encoded in UTF-8. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bug Or Feature?
On Fri, 2008-10-03 at 20:11 +0200, Dr.Ruud wrote: Mr. Shawn H. Corey schreef: [autovivication] Perl does this even if you're just testing. I don't know why. [...] if( exists $var-{foo}{bar}[5] ){ print foobar\n; } print Dumper $var; just testing? exists() just doesn't shortcut. So to test $var-{foo}{bar}[5] you just need to have $var-{foo}{bar}, etc. One would think that exists( $var-{foo}{bar}[5] ) would be a short-cut for ( exists( $var-{foo} ) exists( $var-{foo}{bar} ) exists( $var-{foo}{bar}[5] ) but apparently not :( -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bug Or Feature?
Mr. Shawn H. Corey schreef: [autovivication] Perl does this even if you're just testing. I don't know why. [...] if( exists $var-{foo}{bar}[5] ){ print foobar\n; } print Dumper $var; just testing? exists() just doesn't shortcut. So to test $var-{foo}{bar}[5] you just need to have $var-{foo}{bar}, etc. Just Google on autovivication. Just some examples: http://en.wikipedia.org/wiki/Autovivification http://www.sysarch.com/Perl/autoviv.txt Or just step through your code with perl -d. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bug Or Feature?
Mr. Shawn H. Corey schreef: One would think that exists( $var-{foo}{bar}[5] ) would be a short-cut for ( exists( $var-{foo} ) exists( $var-{foo}{bar} ) exists( $var-{foo}{bar}[5] ) but apparently not :( exists() just doesn't shortcut :) It is about lvalue context too, see exists documentation: This surprising autovivification in what does not at first--or even second--glance appear to be an lvalue context may be fixed in a future release. (5.8.x) There is no pragma to shut it off. I think it is possible to create a source filter to make exists() do what you want. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bug Or Feature?
Dr.Ruud schreef: I think it is possible to create a source filter to make exists() do what you want. I forgot to mention this classic by Uri: http://www.perlarchive.com/___TLC/7026.shtml which has a deep_exists(). -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Binary File Editing - Help!
Hello All, I am having a problem that should be very simple. I cannot figure this out for the life of me. I have a business need where I need to change a literal in a zip file from one string to another. Specifically, I need to change a filename embedded in the zip file (the one that would be extracted) with something else. Because the process is owned by another group and how things are configured here (running multiple runs simulatenously), I am stuck with trying to come up with a creative solution. Here is what I have: #--- start $ cat runme export WORKFILE=13646 export REALFILE=TRANS cat outfile.zip | perl -e ' use strict; use warnings; my $sw = 0; my $rc = 0; my $line = ; open(OUT, temp.zip) or die; while ($line = ) { if (! $sw) { $rc = $line =~ s/$ENV{WORKFILE}/ENV{REAL}/; print STDERR rc = $rc\n; print OUT $line; $sw++; } else { print OUT $line; } } close(OUT); ' $ runme rc = $ unzip -t temp.zip Archive: temp.zip testing: 13646OK No errors detected in compressed data of temp.zip. $ #--- end I don't understand why my $rc line is null either. The obvious solution is to change the input filename before the file gets zipped, but as mentioned, this is done by another group. Any help would be appreciated. Thanks so much, Jeff
Re: Accessing hash of arrays?
On 2008-10-03, 16:57 GMT, Paul Lalli wrote: %targetedMessages is a hash $targetedMessages{$tFolder} is an element of that hash, that happens to be a reference to an array. Of course, silly me, thanks! Matěj -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Beginners' books for Perl newbies using Windows?
From: [EMAIL PROTECTED] (Randal L. Schwartz) In my view, there are no stupid students. Only misstated pre-reqs, misaligned goals, or *bad* instructors. No excuse for any of those. Not being too stupid might be considered a pre-req. Though usualy it's not stated this way, but rather as must already understand XY :-) Anyway thanks for a very well written and thought out post! I wish all teachers/instructors were like this. 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/
Re: Beginners' books for Perl newbies using Windows?
Hi Randal, Randal L. Schwartz wrote: Raymond == Raymond Wan [EMAIL PROTECTED] writes: Raymond In academia, it is common to blame the student, but up to a point, it Raymond might be worth asking if the teacher can teaching things Raymond differently...especially if enough students complain. In my view, there are no stupid students. Only misstated pre-reqs, misaligned goals, or *bad* instructors. No excuse for any of those. Insightful reply, indeed -- thanks! Oddly enough, I had a history teacher in high school who thought teaching history was throwing the book at you and letting you read silently in class. Agreed -- bad instructors are very common. Some do it because it's their job and they aren't giving that up [junior/high school], while in other cases, the professor might excel in research and, likewise, have to teach as part of their job [university]. You /would/ find stupid students if they were forced to take the class (or, likewise, forced to read Learning Perl). That is, they don't really want to do it...but something forced them. Stupid would be too strong...more like unmotivated... I don't think you would see that with book (i.e., someone forced to buy and read a book). But in school...a lot of unmotivated people, potentially...and maybe on both sides of the teacher's desk. Ray -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/