RE: Question on the Camel book

2006-09-22 Thread Thomas Bätzler
Hi, flotsan [EMAIL PROTECTED] asked: I am reading the Perl Camel book - Programming Perl 3rd Ed and having a bit of trouble to understand some of the ideas presented in section 2.11.2. Specifically it is told the following two statements are different: 1) if ($_ = STDIN) { print; }

Re: Question on the Camel book

2006-09-22 Thread John W. Krahn
flotsan wrote: Hey guys, Hello, I am reading the Perl Camel book - Programming Perl 3rd Ed and having a bit of trouble to understand some of the ideas presented in section 2.11.2. Specifically it is told the following two statements are different: 1) if ($_ = STDIN) { print; }

Re: Question on the Camel book

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John W. Krahn wrote: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. John Should running the above from the command line make a difference? I ran them both entering 0

Re: Question on the Camel book

2006-09-22 Thread Dr.Ruud
flotsan schreef: it is told the following two statements are different: 1) if ($_ = STDIN) { print; } # suboptimal: doesn't test defined 2) if (defined($_ = STDIN)) { print; } # best But as I see it, these two do the same thing perl -le ' print defined($_) ? \$_\ : undefined

Re: Question on the Camel book

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dr.Ruud wrote: flotsan schreef: it is told the following two statements are different: 1) if ($_ = STDIN) { print; } # suboptimal: doesn't test defined 2) if (defined($_ = STDIN)) { print; } # best But as I see it, these two do the same

problem with stat?

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm trying to figure out how to use stat. I have the following code: #!/usr/bin/perl -w use strict; my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mathew Snyder wrote: I'm trying to figure out how to use stat. I have the following code: #!/usr/bin/perl -w use strict; my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my

Proper output

2006-09-22 Thread Sayed, Irfan \(Irfan\)
Hi All, I am not getting the proper output in @vob_rep Array. Following is my code # Perl script to change the replica name use strict; use warnings; my $fname = /tmp/vob_list1; open FILE,,$fname or die $!; my $fname1 = /tmp/repl_list1; open FILE1,,$fname1 or die $!; my $CT =

Re: about perltoot

2006-09-22 Thread Mumia W.
On 09/21/2006 07:08 PM, chen li wrote: Hi all, I read some sections in perltoot. In section Autoloaded Data Methods I see some line codes as following: package Person; use Carp; our $AUTOLOAD; # it's a package global my %fields = ( name= undef,

RE: Date and Time Functions

2006-09-22 Thread Lee Goddard
Xavier Mas i Ramón [mailto:[EMAIL PROTECTED] : A Dijous 21 Setembre 2006 01:38, [EMAIL PROTECTED] va escriure: I am looking for some simple perl functions that will return the current date and time in string format. The purpose is to create a file with part of the name being the date and

Re: problem with stat?

2006-09-22 Thread John W. Krahn
Mathew Snyder wrote: I'm trying to figure out how to use stat. I have the following code: You should really figure out how to use readdir perldoc -f readdir #!/usr/bin/perl -w use strict; my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Updated my code to look like this: #!/usr/bin/perl -w use strict; my %filenames; my $file_count = 0; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){ next if ($file

Re: Proper output

2006-09-22 Thread John W. Krahn
Sayed, Irfan (Irfan) wrote: Hi All, Hello, I am not getting the proper output in @vob_rep Array. What is it doing that you don't want it to do? What is it not doing? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: Question on the Camel book

2006-09-22 Thread John W. Krahn
Mathew Snyder wrote: John W. Krahn wrote: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. Should running the above from the command line make a difference? I ran them both entering 0 each time and I got 0 back. This is

Re: Question on the Camel book

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John W. Krahn wrote: Mathew Snyder wrote: John W. Krahn wrote: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. Should running the above from the command line make a

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: #!/usr/bin/perl -w use strict; I would change that to: #!/usr/bin/perl -w use warnings ; use strict ; my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){ push

Re: Question on the Camel book

2006-09-22 Thread flotsan
Thanks... Now I see the one with defined test deals better with those possible false false inputs:-) flotsan John W. Krahn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Mathew Snyder wrote: John W. Krahn wrote: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of

Re: Question on the Camel book

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: John W. Krahn: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. Should running the above from the command line make a difference? I ran them both entering 0 each time and I got 0 back. This is

Re: Question on the Camel book

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: Dr.Ruud: flotsan: it is told the following two statements are different: 1) if ($_ = STDIN) { print; } # suboptimal: doesn't test defined 2) if (defined($_ = STDIN)) { print; } # best But as I see it, these two do the same thing perl -le ' print

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Dr.Ruud schreef: Mathew Snyder: #!/usr/bin/perl -w use strict; I would change that to: #!/usr/bin/perl -w use warnings ; use strict ; Oops, the whole point of that was to remove the -w. See `perldoc perllexwarn`. -- Affijn, Ruud (now you'll remember even better) Gewoon is een

Re: problem with stat?

2006-09-22 Thread Mumia W.
On 09/22/2006 02:58 AM, Mathew Snyder wrote: [...] my $mod_time = (stat($file))[9]; [...] If $file is not in the current directory, this won't work. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John W. Krahn wrote: #!/usr/bin/perl -w use strict; my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){ push @filenames, $file; } Why not

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: foreach my $file (sort(readdir DH)){ next if ($file =~ /^.%|^..$/); my $mod_time = (stat($file))[9]; $filenames{$file} = $mod_time; } No need to sort before you put things in a hash: hashes don't keep order. Try this: my %file_modtime =

Re: Question on the Camel book

2006-09-22 Thread John W. Krahn
Dr.Ruud wrote: Mathew Snyder schreef: John W. Krahn: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. Should running the above from the command line make a difference? I ran them both entering 0 each time and I got 0 back.

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dr.Ruud wrote: Mathew Snyder schreef: foreach my $file (sort(readdir DH)){ next if ($file =~ /^.%|^..$/); my $mod_time = (stat($file))[9]; $filenames{$file} = $mod_time; } No need to sort before you put things in a

Re: problem with stat?

2006-09-22 Thread John W. Krahn
Mathew Snyder wrote: John W. Krahn wrote: my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){ push @filenames, $file; } Why not just: my @filenames = sort readdir DH; Being new to Perl I want to

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: John W. Krahn: Mathew: #!/usr/bin/perl -w use strict; my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){ push @filenames, $file; } Why not just: my @filenames

URL need not do enciding

2006-09-22 Thread Anish Kumar K.
Hi I have a String which I am forming inside a variable. Say my $urlString=http://www.yahoo.com/mail?username=anishkumar_kuserid=1234.0companyname=abc;. I am printing this string in a browser through CGI. In that case I am getting the URL with encoded characters for = say now it looks like

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John W. Krahn wrote: Mathew Snyder wrote: John W. Krahn wrote: my @filenames; my $processDir = /usr/bin; opendir DH, $processDir or die cannot open $processDir: $!; foreach my $file (sort(readdir DH)){ push @filenames, $file; } Why

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Dr.Ruud schreef: Mathew Snyder: foreach my $file (sort(readdir DH)){ push @filenames, $file; } You sort too early. Ignore that. Just use John's alternative: my @filenames = sort readdir DH; or make that my @filenames = sort grep -f, readdir DH; Globs are sorted nowadays, I

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: I [...] removed the initialization to 0 for 'my $file_count' since it doesn't need to be set to an initial value anyway. There was nothing wrong with that initialization, but it is OK too to leave it out. But: you don't really need that $file_count, do you? The length

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
Dr.Ruud wrote: Dr.Ruud schreef: Mathew Snyder: foreach my $file (sort(readdir DH)){ push @filenames, $file; } You sort too early. Ignore that. Just use John's alternative: my @filenames = sort readdir DH; or make that my @filenames = sort grep -f, readdir DH; I

Re: Question on the Camel book

2006-09-22 Thread Dr.Ruud
John W. Krahn schreef: Dr.Ruud: Mathew Snyder: John W. Krahn: Yes, Perl has five false values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. Should running the above from the command line make a difference? I ran them both entering 0 each time and

Re: URL need not do enciding

2006-09-22 Thread John W. Krahn
Anish Kumar K. wrote: Hi Hello, I have a String which I am forming inside a variable. Say my $urlString=http://www.yahoo.com/mail?username=anishkumar_kuserid=1234.0companyname=abc;. I am printing this string in a browser through CGI. In that case I am getting the URL with encoded

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
Dr.Ruud wrote: Dr.Ruud schreef: Mathew Snyder: foreach my $file (sort(readdir DH)){ push @filenames, $file; } You sort too early. Ignore that. Just use John's alternative: my @filenames = sort readdir DH; or make that my @filenames = sort grep -f, readdir DH; Did

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: Dr.Ruud: my @filenames = sort grep -f, readdir DH; I tried this line using $dh. Nothing was getting placed in the array. Would that be because everything in /usr/bin is an executable file? Aaargh no, I am making the same mistake as you did: not prepending the

Re: problem with stat?

2006-09-22 Thread Mathew Snyder
Dr.Ruud wrote: Mathew Snyder schreef: Dr.Ruud: my @filenames = sort grep -f, readdir DH; I tried this line using $dh. Nothing was getting placed in the array. Would that be because everything in /usr/bin is an executable file? Aaargh no, I am making the same mistake as you did: not

Re: problem with stat?

2006-09-22 Thread John W. Krahn
Dr.Ruud wrote: Dr.Ruud schreef: Mathew Snyder: foreach my $file (sort(readdir DH)){ push @filenames, $file; } You sort too early. Ignore that. Just use John's alternative: my @filenames = sort readdir DH; or make that my @filenames = sort grep -f, readdir DH; Please

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: Did a bit o' Googling and found how to use the 'not' operator and now have this line that eliminates the . and .. while still populating the array in as few lines as possible: @filenames = sort grep { !/^\.$|^\.\.$/ } readdir $dh; Yes, but that still doesn't filter

RE: problem with stat?

2006-09-22 Thread Thomas Bätzler
Mathew Snyder [EMAIL PROTECTED] wrote: Did a bit o' Googling and found how to use the 'not' operator and now have this line that eliminates the . and .. while still populating the array in as few lines as possible: @filenames = sort grep { !/^\.$|^\.\.$/ } readdir $dh; You can optimise

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Mathew Snyder schreef: Dr.Ruud: my @filenames = grep -f $dir/$_, sort readdir DH; Interesting. The above line returns 1648 items while the following @filenames = sort grep { !/^\.$|^\.\.$/ } readdir $dh; returns 1650. That would mean that there are 2 other no-plain-files inside your

RE: URL need not do enciding

2006-09-22 Thread Lee Goddard
I have a String which I am forming inside a variable. Say my $urlString=http://www.yahoo.com/mail?username=anishkumar_kus erid=1234.0companyname=abc. I am printing this string in a browser through CGI. In that case I am getting the URL with encoded characters for = say now it looks

Re: problem with stat?

2006-09-22 Thread John W. Krahn
Dr.Ruud wrote: The '.' and '..' are directories, not plain files. Some file systems do not have the directories '.' and '..' so they *could* just be plain files. You can write !/^\.$|^\.\.$/ as !/^\.\.?$/ so also as !/^[.][.]?$/ Until Perl 5.8.10 comes along literals

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
John W. Krahn schreef: Dr.Ruud: The '.' and '..' are directories, not plain files. Some file systems do not have the directories '.' and '..' so they *could* just be plain files. Right, and that is one of the reasons why I keep bringing -f() up. I am also testing with a file called |ls -a

Re: problem with stat?

2006-09-22 Thread Dr.Ruud
Thomas Bätzler schreef: [ !/^\.$|^\.\.$/ and !/^\.\.?$/ ] I'm assuming that this regex would be faster, too, since it does not contain an alternation. That is hard to say without actual benchmarking: the regex-optimizer gets better with every new version of perl. Check also the re=debug

Re: about perltoot

2006-09-22 Thread chen li
--- Mumia W. [EMAIL PROTECTED] wrote: On 09/21/2006 07:08 PM, chen li wrote: Hi all, I read some sections in perltoot. In section Autoloaded Data Methods I see some line codes as following: package Person; use Carp; our $AUTOLOAD; # it's a package global

AUTOLOAD in perltoot

2006-09-22 Thread chen li
Hi all, I copy some codes from perltoot and write some lines to see how AUTOLOAD works. test.pl #!C:/Perl/bin/perl.exe use strict; use warnings; use Data::Dumper; use Person; my $obj=Person-new(); print $obj-name(); print Dumper $obj; # Person.pm in the

Re: RANSAC method code for perl?

2006-09-22 Thread Saurabh Singhvi
Hi Fred, Right now, something else has taken first priority, so I will be writing this code later on. I'll post here and on CPAN :) regards Saurabh On 9/22/06, hOURS [EMAIL PROTECTED] wrote: Hello Saurabh, Did you ever find this? Because I'd be interested as well. Thanks, Fred Kittelmann

Re: problem with stat?

2006-09-22 Thread Mathew
Dr.Ruud wrote: Thomas Bätzler schreef: [ !/^\.$|^\.\.$/ and !/^\.\.?$/ ] I'm assuming that this regex would be faster, too, since it does not contain an alternation. That is hard to say without actual benchmarking: the regex-optimizer gets better with every new version of perl. But

Re: problem with stat?

2006-09-22 Thread Mathew
John W. Krahn wrote: Dr.Ruud wrote: The '.' and '..' are directories, not plain files. Some file systems do not have the directories '.' and '..' so they *could* just be plain files. You can write !/^\.$|^\.\.$/ as !/^\.\.?$/ so also as !/^[.][.]?$/ Until Perl 5.8.10

Re: about perltoot

2006-09-22 Thread Mumia W.
On 09/22/2006 07:50 AM, chen li wrote: --- Mumia W. [EMAIL PROTECTED] wrote: That redundancy allows you to use inheritance. If you have a class Employee, with an expanded set of fields, this method makes it possible to add the fields without having to modify each method that uses them.

Re: AUTOLOAD in perltoot

2006-09-22 Thread Mumia W.
On 09/22/2006 08:30 AM, chen li wrote: Hi all, I copy some codes from perltoot and write some lines to see how AUTOLOAD works. test.pl #!C:/Perl/bin/perl.exe use strict; use warnings; use Data::Dumper; use Person; my $obj=Person-new(); print $obj-name();

cmdline program to access s.m.a.r.t. data

2006-09-22 Thread reader
Anyone know from experience of a commandline oriented program that can access S.M.A.R.T. data? In particular hard drive temperature. This would be a monitor tool for windowsxp machines. There appears to be a number of Temperature monitoring tools on the internet but what I'm looking for is one

Re: problem with stat?

2006-09-22 Thread John W. Krahn
Mathew wrote: John W. Krahn wrote: Dr.Ruud wrote: You can write !/^\.$|^\.\.$/ as !/^\.\.?$/ so also as !/^[.][.]?$/ Until Perl 5.8.10 comes along literals are more efficient than character classes so the first one would be better. I had tried this /^[.]$|^[..]$/ but had been

Re: cmdline program to access s.m.a.r.t. data

2006-09-22 Thread Corey Hickey
[EMAIL PROTECTED] wrote: Anyone know from experience of a commandline oriented program that can access S.M.A.R.T. data? In particular hard drive temperature. This would be a monitor tool for windowsxp machines. I've never tried it on anything other than Linux, but smartmontools lists

getting columns of 2D array

2006-09-22 Thread Aditi Gupta
Hello Everybody, We can get rows of a 2D array as $aref = $AoA[$i]; print @$aref; #will print row 'i' as an array How can I print column 'i' as an array using references? Is there any other way which doesn't require two 'for loops' to print the columns? Thanks in advance, Aditi -- To

Re: cmdline program to access s.m.a.r.t. data

2006-09-22 Thread joseph
Corey Hickey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Anyone know from experience of a commandline oriented program that can access S.M.A.R.T. data? In particular hard drive temperature. This would be a monitor tool for windowsxp machines. I've

Re: getting columns of 2D array

2006-09-22 Thread John W. Krahn
Aditi Gupta wrote: Hello Everybody, Hello, We can get rows of a 2D array as $aref = $AoA[$i]; print @$aref; #will print row 'i' as an array How can I print column 'i' as an array using references? Is there any other way which doesn't require two 'for loops' to print the columns? print

Re: getting columns of 2D array

2006-09-22 Thread Bryan R Harris
Aditi Gupta wrote: Hello Everybody, Hello, We can get rows of a 2D array as $aref = $AoA[$i]; print @$aref; #will print row 'i' as an array How can I print column 'i' as an array using references? Is there any other way which doesn't require two 'for loops' to print the columns?

Re: cmdline program to access s.m.a.r.t. data

2006-09-22 Thread reader
joseph [EMAIL PROTECTED] writes: Corey Hickey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Anyone know from experience of a commandline oriented program that can access S.M.A.R.T. data? In particular hard drive temperature. This would be a monitor