how to parse the msqid_ds structure return from msgctl(ID, IPC_STAT, $msq_ds)
The docs state the following : == msgctl ID, CMD, ARG Calls the System V IPC function msgctl(2). You'll probably have to say use IPC::SysV; first to get the correct constant definitions. If CMD is IPC_STAT, then ARG must be a variable which will hold the returned msqid_ds structure. Returns like ioctl: the undefined value for error, 0 but true for zero, or the actual return value otherwise. See also perlipc/SysV IPC, IPC::SysV, and IPC::Semaphore documentation. == I have not found a way to dereference the msq_ds array returned as per http://cpansearch.bulknews.net/markup/IPC_SysV/SysV.pm. How is this msqid_ds structure parsed? Do you have a short example? Thanks, Eric _ Scanned by Sanmina-SCI eShield _ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Maybe off-topic. Detecting code used
I am processing a file using Unicode::Transform module to change the coding from UTF-8 to Unicode. Exist some way to detect the code used in one file (utf8, unicode) in order to select if some transform action is needed? TIA, ,_, (O,O) J. Alejandro Ceballos Z. [EMAIL PROTECTED] ( ) --- http://alejandro.ceballos.infomovil: (33) 3849-8936 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Split function help
Irfan J Sayed wrote: Hi, I have a following line/statement stored in variable $test deliver.Admin_Irfan_Project.20060413.212355 i want to split this line in . and store in array. I am using following code my @name = Split(/./, $test); split uses regular expressions to identify where to split the string. The expression you supplied, /./, would split on everything. In your particular case you could also split on /\W/. But this isn't a very good choice, just an example. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: truncate
Smith, Derek wrote: I want to use truncate to delete a matched line out a named.conf file on my DNS box. Here is my code As others have said, this will lop off the end of the file. Another option is to run perl -i and edit the file in place. while(){ print if /Acheck\-names/ } But under this example it would probably be easier and simpler to use the shell grep command. ;) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: golf
M. Kristall schreef: Ruud: [ while(local $_ = ARGV) ] With while(), the $_ is already local. not! Wouldn't using that 'local' explicitly, add another local-layer? my $i = 5; $_ = 'Hi there!!!'; while ($_ = $i--) { print } print 543210 my $i = 5; $_ = 'Hi there!!!'; while (local $_ = $i--) { print } print 54321Hi there!!! Right, I must've been mixing up with for: perl -e 'sub _{local $\=qq[\n];print qq[$_]}; $_=q[--];_;do{_;print for(1..5);_}for q[A]..q[C];_' -- A 12345A B 12345B C 12345C -- -- Affijn, Ruud http://www.xs4all.nl/~rvtol/Perl/japh.wav Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Split function help
Dear Irfan, i think for the code you can try the below, ($some_thing1,$some_thing2,$something_3)=split($test,.) Regards Mazhar On 4/25/06, Tom Allison [EMAIL PROTECTED] wrote: Irfan J Sayed wrote: Hi, I have a following line/statement stored in variable $test deliver.Admin_Irfan_Project.20060413.212355 i want to split this line in . and store in array. I am using following code my @name = Split(/./, $test); split uses regular expressions to identify where to split the string. The expression you supplied, /./, would split on everything. In your particular case you could also split on /\W/. But this isn't a very good choice, just an example. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Help in checking the OS type...
Hi Folks, I need to develop a script where in i need to first check the type of OS and then go about in finding the drives. I need your help in getting an idea of how to start about this... Thanks in Advance Regards Mazhar
Re: Help in checking the OS type...
Paul, It lists me out the operating system name thanks for the same. How can i go about getting the different drives/volumes created on the same... Regards Mazhar On 4/25/06, Paul D. Kraus [EMAIL PROTECTED] wrote: On 4/25/06, Mazhar [EMAIL PROTECTED] wrote: Hi Folks, I need to develop a script where in i need to first check the type of OS and then go about in finding the drives. [EMAIL PROTECTED]:~$ cat testperl.pl perl testperl.pl print OS:$^O\n; OS:linux *$^O* The name of the operating system under which this copy of Perl was built, as determined during the configuration process. The value is identical to $Config{'osname'}. http://www.perl.com/doc/manual/html/pod/perlvar.html HTH, Paul
Re: Split function help
Mazhar wrote: Dear Irfan, i think for the code you can try the below, ($some_thing1,$some_thing2,$something_3)=split($test,.) You have the split arguments reversed :) Also, don't use double quotes when there is nothing to interpolate. And space them out so its easier to read :) And use my() so its strict safe: my @things = split '.', $test; or with variables and () with the split: my($thing_a, $thing_b) = split('.', $test); HTH -- 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 in checking the OS type...
On 4/25/06, Mazhar [EMAIL PROTECTED] wrote: Paul, It lists me out the operating system name thanks for the same. How can i go about getting the different drives/volumes created on the same... Regards Mazhar I am not entirely sure what you are trying to do. Can you give me an example of what you want? Also try to bottom post it makes it easier for others in the future to follow the conversation. Paul
Python - NOT TROLLING
I am picking up python and messing around with it and I always come running back to perl :) At any rate I am curious what the more experienced programmers think of the language and its uses. Best tool for the best job seems to be the slogan. So my question is what do people use python for that perl doesn't also do just as well? Reg exp are a joke in python and every program I write uses them so I keep coming home. I was thinking about this last night over a beer(the only way to conteplate by the way :) ) and the only thing I could up with was for gui design or prototyping for C. However I learned a lot about code resuse that I never considered before trying python out that I have adopted 100% in my perl programming. If you are not using your own custom modules you are working to hard. I am not asking for info on why perl is better or worse just what situtations have you been in when perl didn't fit the bill and another scripting language did. PK
RegEx (m//) Flinstones
I need a RegEx (!!!with modify(m//)) what matches the words what ends with 'a'. = I have a test_file (for ex.:) = beforematchafter wilma and nana Mrs. Wilma Flinstone hommie barney wilmafred wilmafred flinstone mamafred == my_program.pl == #!/usr/bin/perl -w use strict; my $i=1; while () {# take one input line at time chomp; if (/(\b\w*a\b)/) { print $1 found in line $i\n; $i++; } else { $i++; } } == This program does not match 'nana' line 2 (only wilma) and it DOES atch 'wilmafred' line 5 and line 8 (I think it shouldn't)... And is the sign '' in \w ?? I thought that \w == [a-zA-Z0-9_] or it isn't??? == -- Thanks, Monomachus Don't worry, Be Happy -- 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 (m//) Flinstones
On Tue, 2006-25-04 at 17:36 +0400, Monomachus wrote: #!/usr/bin/perl -w use strict; my $i=1; while () { # take one input line at time chomp; if (/(\b\w*a\b)/) { This matches only the first occurrence. You will need a loop to match them all. print $1 found in line $i\n; $i++; } else { $i++; } } == This program does not match 'nana' line 2 (only wilma) and it DOES atch 'wilmafred' line 5 and line 8 (I think it shouldn't)... And is the sign '' in \w ?? I thought that \w == [a-zA-Z0-9_] or it isn't??? == #!/usr/bin/perl use strict; use warnings; my $i=1; while (DATA) { chomp; while (/(\w*a\b)/g) { print $1 found in line $i\n; } $i++; } __END__ beforematchafter wilma and nana Mrs. Wilma Flinstone hommie barney wilmafred wilmafred flinstone mamafred -- __END__ Just my 0.0002 million dollars worth, --- Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: RegEx (m//) Flinstones
On 4/25/06, Monomachus [EMAIL PROTECTED] wrote: I need a RegEx (!!!with modify(m//)) what matches the words what ends with 'a'. = I have a test_file (for ex.:) = beforematchafter wilma and nana Mrs. Wilma Flinstone hommie barney wilmafred wilmafred flinstone mamafred == my_program.pl == #!/usr/bin/perl -w use strict; my $i=1; while () {# take one input line at time chomp; if (/(\b\w*a\b)/) { print $1 found in line $i\n; $i++; } else { $i++; } } == This program does not match 'nana' line 2 (only wilma) and it DOES atch 'wilmafred' line 5 and line 8 (I think it shouldn't)... And is the sign '' in \w ?? I thought that \w == [a-zA-Z0-9_] or it isn't??? == It doesn't match 'nana' because you aren't using the 'g' modifier, so it exits after the first match and moves onto the next line. And you're only printing $1 in any case, so even it it matched more, you wouldn't know: if ( my @matches = /(\b\w*a\b)/g ) { print @matches found in line $.\n; } Also note the use of '$.' You don't need to keep track of line numbers. Perl does it for you. As for wilmafred, no, '' isn't in \w. the regex only captures 'wilma' in 'wilmafred'. Because '' isn't a \w character, there's a \b between the 'a' in wilma and the ''. if you want to make sure your \b is at a space or the end of the string, make sure you anchor it: #!/usr/bin/perl use strict; use warnings; while (DATA) {# take one input line at time chomp; if (my @matches = /\b(\w*a)\b(?:\s|\z)/g ) { print join(', ', @matches), found in line $.\n; } } __END__ beforematchafter wilma and nana Mrs. Wilma Flinstone hommie barney wilmafred wilmafred flinstone mamafred HTH, -- jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
perl help
Hi All, I am newbie of perl joined in this group last month.I could like to know how could i develop my perl programming and my opinion is only reading the materials , and other documents related to perl does not matters.Is there any other way that makes me better in perl like certifications or etc? Thanks Regards, Praveena -- 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 help
On Tue, 2006-25-04 at 21:09 -0700, Praveena Vittal wrote: Hi All, I am newbie of perl joined in this group last month.I could like to know how could i develop my perl programming and my opinion is only reading the materials , and other documents related to perl does not matters.Is there any other way that makes me better in perl like certifications or etc? Thanks Regards, Praveena Certificates do not make you a better programmer, practise does. I suggest you look at PerlMonks Tutorials http://perlmonks.org/?node=Tutorials They have an extensive list of tutorials. BTW, perl refers to the perl program that executes your scripts, Perl is the name of the language. -- __END__ Just my 0.0002 million dollars worth, --- Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Help in checking the OS type...
*Don't top post.* On 4/25/06, Mazhar [EMAIL PROTECTED] wrote: Paul, It lists me out the operating system name thanks for the same. How can i go about getting the different drives/volumes created on the same... Regards Mazhar On 4/25/06, Paul D. Kraus [EMAIL PROTECTED] wrote: On 4/25/06, Mazhar [EMAIL PROTECTED] wrote: Hi Folks, I need to develop a script where in i need to first check the type of OS and then go about in finding the drives. [EMAIL PROTECTED]:~$ cat testperl.pl perl testperl.pl print OS:$^O\n; OS:linux *$^O* The name of the operating system under which this copy of Perl was built, as determined during the configuration process. The value is identical to $Config{'osname'}. http://www.perl.com/doc/manual/html/pod/perlvar.html HTH, Paul File systems are system-specific. How you access them and find out information about them is an OS issue, not a perl issue. Most operating systems provide some version of the 'df' or 'du' system commands. Some don't. Most operating systems provide some version of and fstab file or /proc system. Some don't. If you don't knoe how to access filsystem information on your system, you need to find a good reference for your system. There are mailing lists devoted to most major OSes; there are also many good books. If you need information on a particular OS, let us know which one, and someone here can probably point you in the right direction. If you script needs to be portable, you'll need to lean about the commands and/or system calls for the differnt systems you intend to run the script on. Then insert some simple logic to do the right thing on a particular system, e.g.: if ( $^O =~ /some_os/ ) { # do something } elsif ( $^O =~ /some_os/ ) { # do something different } elsif ( $^O =~ /some_other_os/ ) { # do something completely different } And so on for each OS. You could also check out Sys::Filesystem. but then you already knew about that, because you took 30 seconds to do a simple CPAN seach for 'filesystem' before you came to this list, right? HTH, -- jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
How To Post (WAS: Help in checking the OS type...)
On Tue, 2006-25-04 at 13:38 -0400, Jay Savage wrote: *Don't top post.* *Prune your posts* Quote only what is important to your comments. Remove nested quotes (unless really, really important). Change the subject when you change the subject. -- __END__ Just my 0.0002 million dollars worth, --- Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
sort {} to work with undef values when its expecting an object
Hello List, I have a sort() issue that is a bit odd and any input wouls be most appreciated :) The code: use strict; use warnings; ... for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is defined its an object with a method called value() $a/$b-part('Name') returns an object that also has a method called value() or undefined if there is no Name part The sort works perfect for what I need, *except* when $a/$b-part('Name') does not return an object itself. Then it dies with Can't call method value() on undefined value. So how can I keep my sort() but avoid/work with the can't call method on undefined value error when $a/$b-part('Name') returns undef instead of an object? I've put them in valriables depending on defined()ness and done $name_a cmp $name_b Which is error free but also doesn't appear to sort it properly :( TIA! -- 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 Post (WAS: Help in checking the OS type...)
On 4/25/06, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote: On Tue, 2006-25-04 at 13:38 -0400, Jay Savage wrote: *Don't top post.* *Prune your posts* Quote only what is important to your comments. Remove nested quotes (unless really, really important). Change the subject when you change the subject. -- __END__ Just my 0.0002 million dollars worth, --- Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ And keep your .sig to 4 lines? ;) Seriously, though, go easy on the pruning. The rule of tumb is is that the message should include enough information that a person joining the thread can make sense of the response from the response itself. Unless the OP is particulalry verbose, the question is particularly complex, or your reposne is to a very specific issue in the post or previous comment, you'll want to be careful about pruning. Text is cheap: err on the side of pity for people who don't have threaded email clients. Best, --jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
Re: How To Post (WAS: Help in checking the OS type...)
On Tue, 2006-25-04 at 15:37 -0400, Jay Savage wrote: Seriously, though, go easy on the pruning. The rule of tumb is is that the message should include enough information that a person joining the thread can make sense of the response from the response itself. Unless the OP is particulalry verbose, the question is particularly complex, or your reposne is to a very specific issue in the post or previous comment, you'll want to be careful about pruning. Text is cheap: err on the side of pity for people who don't have threaded email clients. And spelling checkers are useflul. -- __END__ Just my 0.0002 million dollars worth, --- Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sort {} to work with undef values when its expecting an object
On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is defined its an object with a method called value() $a/$b-part('Name') returns an object that also has a method called value() or undefined if there is no Name part The sort works perfect for what I need, *except* when $a/$b-part('Name') does not return an object itself. Then it dies with Can't call method value() on undefined value. So how can I keep my sort() but avoid/work with the can't call method on undefined value error when $a/$b-part('Name') returns undef instead of an object? I've put them in valriables depending on defined()ness and done $name_a cmp $name_b Which is error free but also doesn't appear to sort it properly :( How does it not sort properly? We need some sample data for that. Generally, though, you have two options. One is to trap the error with eval or some other method. The other is to insert some logic to check that the methods are defined before you call them...and decide how you want to handle object that have no value. Perl is basically saying I can't sort it by value if it doesn't have a value. Either check for definedness in the sort, or verify the data before you sort it and set the bad data aside to deal with later. This is one of the quirks of dealing with methods. If a method isn't defined, it's more like an undefined subroutine call than an undefined variable, in that attempting to call a method on an object for which it's not defined is fatal. HTH, --jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
rm -rf in perl
Is there a definative way to recreate the gnu `rm -rf` in perl? I've seen a couple of modules that seem to implement something, and a bunch of variations using File::Find, but it just seems overly complicated.Since it's important I understand exactly what it's going to do (it's removing data here!) I'm hesitant to put any of them in use. And I guess the related question is, should I just shell out for this? Performance and portability aren't a concern here... Brian -- 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 Post (WAS: Help in checking the OS type...)
On 4/25/06, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote: On Tue, 2006-25-04 at 15:37 -0400, Jay Savage wrote: Seriously, though, go easy on the pruning. The rule of tumb is is that the message should include enough information that a person joining the thread can make sense of the response from the response itself. Unless the OP is particulalry verbose, the question is particularly complex, or your reposne is to a very specific issue in the post or previous comment, you'll want to be careful about pruning. Text is cheap: err on the side of pity for people who don't have threaded email clients. And spelling checkers are useflul. Nah, I like my tumb. -- j -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
RE: rm -rf in perl
Is there a definative way to recreate the gnu `rm -rf` in perl? I've seen a couple of modules that seem to implement something, and a bunch of variations using File::Find, but it just seems overly complicated.Since it's important I understand exactly what it's going to do (it's removing data here!) I'm hesitant to put any of them in use. And I guess the related question is, should I just shell out for this? Performance and portability aren't a concern here... Brian You could use rmtree. perldoc File::Path HTH richf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: sort {} to work with undef values when its expecting an object
Just a thought, but couldn't you put the logic in your grep statement? Something like this: grep {defined($_-value()) or defined($_-part('Name')-value())} @objects; -Original Message- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 25, 2006 12:22 PM To: beginners@perl.org Subject: sort {} to work with undef values when its expecting an object snip The code: use strict; use warnings; ... for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is defined its an object with a method called value() snip The sort works perfect for what I need, *except* when $a/$b-part('Name') does not return an object itself. Then it dies with Can't call method value() on undefined value. snip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: rm -rf in perl
On 25/04/06, RICHARD FERNANDEZ [EMAIL PROTECTED] wrote: Is there a definative way to recreate the gnu `rm -rf` in perl? You could use rmtree. perldoc File::Path Looks good, but then I saw this: NOTE: There are race conditions internal to the implementation of rmtree making it unsafe to use on directory trees which may be altered or moved while rmtree is running, and in particular on any directory trees with any path components or subdirectories potentially writable by untrusted users. eek - I'm running this on a shared folder, it's possible if unlikely I wonder if I'm using the wrong tool here and maybe a shell script is the right way to go... My next issue is the equiv of tar -cvjf and that's going to take a tar module and a compression module... I'm starting to think I'm coming at this the wrong way. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Problem while using Lingua::Wordnet...
Hi, list! Had anybody problems with using Lingua::Wordnet? I have.. I have following simple test script: test.pl: 001: use Lingua::Wordnet; 002: my $dict = new Lingua::Wordnet('lib/Lingua/dict'); Lingua::Wordnet object creation fails with following error: Unable to load lib/Lingua/dict/lingua_wordnet.index: at lib/Lingua/Wordnet.pm line 367. Wordnet.pm: ... 367:$self-{indexobj} = tie %{$self-{indexhash}}, 368: DB_File, $datapath/lingua_wordnet.index, 369: O_RDWR, 0666, $DB_BTREE or 370: die Unable to load $datapath/lingua_wordnet.index: $!; ... Note that $! was empty and there's no error description after colon. Any thoughts? Thanks in advance! -- Regards, Eugene Kosov -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Problem with using Lingua::Wordnet on Linux box
Hi, everybody! Has anybody had any problems with using Lingua::Wordnet on Linux? I have. I can't even open a dictionary. My script fails creating a Lingua::Wordnet object. [EMAIL PROTECTED] ~]$ cat test.pl #!/usr/bin/perl -w -Ilib use Lingua::Wordnet; Lingua::Wordnet-new('lib/Lingua/dict'); [EMAIL PROTECTED] ~]$ perl test.pl Unable to load lib/Lingua/dict/lingua_wordnet.index: at lib/Lingua/Wordnet.pm line 367. Wordnet.pm: ... 367:$self-{indexobj} = tie %{$self-{indexhash}}, 368: DB_File, $datapath/lingua_wordnet.index, 369: O_RDWR, 0666, $DB_BTREE or 370: die Unable to load $datapath/lingua_wordnet.index: $!; ... Note that there's no error description after colon ($! was empty). I don't know what's wrong, but the same thing works just fine on my FreeBSD box. Is it an OS issue? AFAIK (as I'm not an administrator) there's no any resource limitation. Any thoughts? Thanks in advance! Any help would be greatly appreciated. -- Regards Eugene Kosov -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Python - NOT TROLLING
On 4/25/06, Paul D. Kraus [EMAIL PROTECTED] wrote: I am picking up python and messing around with it and I always come running back to perl :) At any rate I am curious what the more experienced programmers think of the language and its uses. One thing that a lot of people like about Python is the encapsulation. I personally hate that feature... everyone says that Python is easy for programmers to read and understand, but if I have to do the following a bunch of times import pprint dump = pprint.PrettyPrinter(indent=4).pformat # ... dump(obj) # nothing useful dump(obj.__dict__) # more useful in order to see what's going on inside an object, that really makes me miss Data::Dumper and the sort of manual introspection Perl allows. That wasn't really what you asked for, I guess, but whatever :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: rm -rf in perl
Brian McKee wrote: On 25/04/06, RICHARD FERNANDEZ [EMAIL PROTECTED] wrote: Is there a definative way to recreate the gnu `rm -rf` in perl? You could use rmtree. perldoc File::Path Looks good, but then I saw this: NOTE: There are race conditions internal to the implementation of rmtree making it unsafe to use on directory trees which may be altered or moved while rmtree is running, and in particular on any directory trees with any path components or subdirectories potentially writable by untrusted users. try the pathrmdir() in File::Copy::Recursive althought technically any rm -rf (ven the shell itself) has a race condition since it could clean out directory, move on and then, someone adds a file between cleaning out the directory and its removal. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sort {} to work with undef values when its expecting an object
Timothy Johnson wrote: Just a thought, but couldn't you put the logic in your grep statement? Something like this: grep {defined($_-value()) or defined($_-part('Name')-value())} @objects; The only problem is then that the object woudl be completely skipped. I need all objects regardless of if their part call returns and object or undef :( Perhaps their is a logic I can do something like that, like 2 sort()s or a map() or ?? Thanks for the input! -Original Message- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 25, 2006 12:22 PM To: beginners@perl.org Subject: sort {} to work with undef values when its expecting an object snip The code: use strict; use warnings; ... for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is defined its an object with a method called value() snip The sort works perfect for what I need, *except* when $a/$b-part('Name') does not return an object itself. Then it dies with Can't call method value() on undefined value. snip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sort {} to work with undef values when its expecting an object
Jay Savage wrote: On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is defined its an object with a method called value() $a/$b-part('Name') returns an object that also has a method called value() or undefined if there is no Name part The sort works perfect for what I need, *except* when $a/$b-part('Name') does not return an object itself. Then it dies with Can't call method value() on undefined value. So how can I keep my sort() but avoid/work with the can't call method on undefined value error when $a/$b-part('Name') returns undef instead of an object? I've put them in valriables depending on defined()ness and done $name_a cmp $name_b Which is error free but also doesn't appear to sort it properly :( How does it not sort properly? We need some sample data for that. When using: $a-part('Name')-value() cmp $b-part('Name')-value-() in the sort funtion and all $a ans $b's part's have Names then it sorts properly. If I change it to $name_a cmp $name_b where $name_a and $name_n are set by a ternary check for definedness and set to the method call's value or some default value if itd undefined) it does not error out but not sort on $a or $b :) Generally, though, you have two options. One is to trap the error with eval or some other method. The other is to insert some logic to check I'll havew to try that, eval since the logci just isn;t working :) that the methods are defined before you call them...and decide how you want to handle object that have no value. Perl is basically saying I can't sort it by value if it doesn't have a value. Either check for definedness in the sort, or verify the data before you sort it and set the bad data aside to deal with later. This is one of the quirks of dealing with methods. If a method isn't defined, it's more like an undefined subroutine call than an undefined variable, in that attempting to call a method on an object for which it's not defined is fatal. HTH, --jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: rm -rf in perl
On Tue, 2006-25-04 at 16:41 -0500, JupiterHost.Net wrote: althought technically any rm -rf (ven the shell itself) has a race condition since it could clean out directory, move on and then, someone adds a file between cleaning out the directory and its removal. Sorry, there is no such race condition in UNIX but there might be in other OSes. When you open a file in UNIX, you are sitting on the i-node, not the directory. Even if its link count has dropped to zero, the file is still open and you are still writing to it (and using up disk space). It's only after the file is closed does it get deleted. Reading or writing to a file that has no directory entry is not a problem in UNIX. The i-node and the file's contents are not freed until every program using it has closed it. Of course, like I said, this may not be true for other OSes. If you are writing a portable script, you should keep this in mind. -- __END__ Just my 0.0002 million dollars worth, --- Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sort {} to work with undef values when its expecting an object
On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects But sometimes $a-part('Name') returns undef, so the sort fails. I need all objects regardless of if their part call returns and object or undef :( Perhaps their is a logic I can do something like that, like 2 sort()s or a map() or ?? It almost sounds like you're talking about a Schwartzian Transform. In fact, you could process your data in steps, as the Schwartzian Transform does. (Warning: Untested code follows.) First, you pick out the items you want: my @desired_data = grep { defined } @objects; Next, transform each data item into an array reference holding the original item and anything useful-to-know that you don't want to have to recompute inside the sort block. In this case, that's your method calls. I'm thinking something like this? my @transformed_data = map { my $part_name = $_-part('Name'); my $part_name_value = (defined $part_name) ? $part_name-value() : ;# empty string [ $_, $_-value(), $part_name_value ] } @desired_data; Now you can sort efficiently on the derived data: my @sorted_data = sort { $a-[1] cmp $b-[1]# value or $a-[2] cmp $b-[2]# part_name_value } @transformed_data; Finally, strip away the stuff you don't need anymore: my @result = map $_-[0], @sorted_data; And you've got your data in order. Is that anything like the order you wanted? In the tradition of the S.T., you should string the steps together without the intermediate arrays. But if you've followed along up to here, you can do that on your own. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
hashref slices
my $hashref; my @num=qw( 0 1 2 3 4 5 ); @hashref-[EMAIL PROTECTED] = ('one', 'two', 'three', 'four', 'five', 'six'); print join('\t', keys %{$hashref}), '\n; print join(\t, values %{$hashref}), '\n; How do I properly use hashref slices? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: hashref slices
Ryan Perry wrote: my $hashref; my @num=qw( 0 1 2 3 4 5 ); @hashref-[EMAIL PROTECTED] = ('one', 'two', 'three', 'four', 'five', 'six'); @{ $hashref [EMAIL PROTECTED] = ('one', 'two', 'three', 'four', 'five', 'six'); print join('\t', keys %{$hashref}), '\n; print join(\t, values %{$hashref}), '\n; How do I properly use hashref slices? perldoc perlreftut perldoc perlref perldoc perldsc perldoc perllol John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
501 Protocol scheme 'http' is not supported
Hi, I am trying to run this ++ require LWP::UserAgent; my $ua = LWP::UserAgent-new; my $response = $ua-get('http://search.cpan.org/'); if ($response-is_success) { print $response-content; # or whatever } else { die $response-status_line; } * I am getting 501 Protocol scheme 'http' is not supported at test.pl line 11. error. Please help. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: 501 Protocol scheme 'http' is not supported
On 4/26/06, nishanth ev [EMAIL PROTECTED] wrote: Hello, Its not the error with the perl script. Your program ran perfect on my machine. Please let me know if you ran it as a cgi script after adding the shebang and other modifications or simply ran as perl script. Simply as a perl script Most probably the error is with the perl module installation. Please change the url that you are trying to access and check. Itried again and got the same result. Regards Nishanth --- Sanchita Dahal [EMAIL PROTECTED] wrote: Hi, I am trying to run this ++ require LWP::UserAgent; my $ua = LWP::UserAgent-new; my $response = $ua-get('http://search.cpan.org/'); if ($response-is_success) { print $response-content; # or whatever } else { die $response-status_line; } * I am getting 501 Protocol scheme 'http' is not supported at test.pl line 11. error. Please help. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
match file name at end of a http url
If I want to use regular expression to extract the charactors after the last '/' in the url, but below regexpr doesn't work, what I do wrong? $url = 'http://website.com/path/file_name.img'; if (/\/.*$/) { print $url.is matched \n; } else { print failed; } -- perl -e 'print unpack(u,62V5N\FME;G\!EFQ`9VUA:6PN8V]M\[EMAIL PROTECTED] )' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: match file name at end of a http url
On 4/25/06, Ken Perl [EMAIL PROTECTED] wrote: If I want to use regular expression to extract the charactors after the last '/' in the url, but below regexpr doesn't work, what I do wrong? You're not using a module from CPAN. There's one on there that understands the rules about URLs. How about URI? http://search.cpan.org/~gaas/URI-1.35/URI.pm If you need to learn more about string handling, we can help with that, too. But handling URLs properly takes more than just a simple pattern match. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: 501 Protocol scheme 'http' is not supported
On 4/25/06, Sanchita Dahal [EMAIL PROTECTED] wrote: I am getting 501 Protocol scheme 'http' is not supported at test.pl line 11. error. Please help. It sounds as if LWP isn't properly installed. Can you get it to pass all the tests, and then re-install it? Good luck! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: match file name at end of a http url
Ken Perl wrote: If I want to use regular expression to extract the charactors after the last '/' in the url, but below regexpr doesn't work, what I do wrong? $url = 'http://website.com/path/file_name.img'; if (/\/.*$/) { print $url.is matched \n; } else { print failed; } -- perl -e 'print unpack(u,62V5N\FME;G\!EFQ`9VUA:6PN8V]M\[EMAIL PROTECTED] )' you probably want if( $url =~ /\/(.*$)/ ) then characters after last / are found in $1 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: match file name at end of a http url
On 4/25/06, John Ackley [EMAIL PROTECTED] wrote: if( $url =~ /\/(.*$)/ ) then characters after last / are found in $1 Unfortunately, characters after the first slash are in there, too. To process a URL requires more than a simple pattern match. Use a module from CPAN. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: match file name at end of a http url
Hello, I tried this and worked. Please let me know in case you find any bugs in this :) $url=http://dev.catalyst.perl.org/wiki/YetAnotherCatalystIntro;; if( $url =~ /\/([\w.]*$)/ ){ print $1; } else{ print No Match; } Regards Nishanth --- Tom Phoenix [EMAIL PROTECTED] wrote: On 4/25/06, John Ackley [EMAIL PROTECTED] wrote: if( $url =~ /\/(.*$)/ ) then characters after last / are found in $1 Unfortunately, characters after the first slash are in there, too. To process a URL requires more than a simple pattern match. Use a module from CPAN. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: match file name at end of a http url
On 4/25/06, nishanth ev [EMAIL PROTECTED] wrote: if( $url =~ /\/([\w.]*$)/ ){ print $1; } http://example.com/some-file.txt To process a URL requires more than a simple pattern match. Use a module from CPAN. Cheers! What I said. --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Help in checking the OS type...
On 4/25/06, Jay Savage [EMAIL PROTECTED] wrote: *Don't top post.* On 4/25/06, Mazhar [EMAIL PROTECTED] wrote: Paul, It lists me out the operating system name thanks for the same. How can i go about getting the different drives/volumes created on the same... Regards Mazhar On 4/25/06, Paul D. Kraus [EMAIL PROTECTED] wrote: On 4/25/06, Mazhar [EMAIL PROTECTED] wrote: Hi Folks, I need to develop a script where in i need to first check the type of OS and then go about in finding the drives. [EMAIL PROTECTED]:~$ cat testperl.pl perl testperl.pl print OS:$^O\n; OS:linux *$^O* The name of the operating system under which this copy of Perl was built, as determined during the configuration process. The value is identical to $Config{'osname'}. http://www.perl.com/doc/manual/html/pod/perlvar.html HTH, Paul File systems are system-specific. How you access them and find out information about them is an OS issue, not a perl issue. Most operating systems provide some version of the 'df' or 'du' system commands. Some don't. Most operating systems provide some version of and fstab file or /proc system. Some don't. If you don't knoe how to access filsystem information on your system, you need to find a good reference for your system. There are mailing lists devoted to most major OSes; there are also many good books. If you need information on a particular OS, let us know which one, and someone here can probably point you in the right direction. If you script needs to be portable, you'll need to lean about the commands and/or system calls for the differnt systems you intend to run the script on. Then insert some simple logic to do the right thing on a particular system, e.g.: if ( $^O =~ /some_os/ ) { # do something } elsif ( $^O =~ /some_os/ ) { # do something different } elsif ( $^O =~ /some_other_os/ ) { # do something completely different } And so on for each OS. You could also check out Sys::Filesystem. but then you already knew about that, because you took 30 seconds to do a simple CPAN seach for 'filesystem' before you came to this list, right? HTH, -- jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom! Thanks for the Response Jay. See currently if i have written ti script that will check the type of operating system. $Operate_sys=$^O; if ($Operate=WIN32) { Here i have to write the number of logical drives. Then the Total Space of each drive and the Free Space.. } if ($Operate=linux) { Here i have to write the number of volumes. Then the Total Space of each volume and the Free Space.. } I think the above will give you the details of what i am trying to do so. Thanks in Advance regards Mazhar
Re: perl help
On 4/26/06, Praveena Vittal [EMAIL PROTECTED] wrote: Hi All, I am newbie of perl joined in this group last month.I could like to know how could i develop my perl programming and my opinion is only reading the materials , and other documents related to perl does not matters.Is there any other way that makes me better in perl like certifications or etc? Thanks Regards, Praveena -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Hi For perl the learning is through practice and not by certifications. You can refer the materials of perl by visting www.perl.org and this site contains very structured way of tutorials. or you can even try if you have perl installed on a unix flavor machine. man perl man perlre man perlvar etc.. ALL THE BEST!!! Regards Mazhar
Re: match file name at end of a http url
if ($url =~ /\/([^\/]*)$/) { print $1; } On 26/04/06, Tom Phoenix [EMAIL PROTECTED] wrote: On 4/25/06, nishanth ev [EMAIL PROTECTED] wrote: if( $url =~ /\/([\w.]*$)/ ){ print $1; } http://example.com/some-file.txt To process a URL requires more than a simple pattern match. Use a module from CPAN. Cheers! What I said. --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: match file name at end of a http url
I don't know how to use URI::URI to solve my problem after reading the pod doc. since it is not easy to use regex, I am going to use split '/', $url to extract the last field. On 4/26/06, Tom Phoenix [EMAIL PROTECTED] wrote: On 4/25/06, nishanth ev [EMAIL PROTECTED] wrote: if( $url =~ /\/([\w.]*$)/ ){ print $1; } http://example.com/some-file.txt To process a URL requires more than a simple pattern match. Use a module from CPAN. Cheers! What I said. --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- perl -e 'print unpack(u,62V5N\FME;G\!EFQ`9VUA:6PN8V]M\[EMAIL PROTECTED] )' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response