questions from Learning Perl

2008-04-06 Thread itshardtogetone
Hi, I am doing some homework from the book Learning Perl chapter 4 excercise 1, Looking at the script below, I wonder why line 6 (print "Enter some numbers on separate line: ";) is not printed immediately after the previous print. Thanks use strict; use warnings; my @fred = qw/1 3 5 7 9/; my $fr

Re: redirect Find::File to /dev/null

2008-04-06 Thread protoplasm
On Apr 5, 7:20 am, [EMAIL PROTECTED] (John W. Krahn) wrote: > > WARNINGS > If you run your program with the "-w" switch, or if you use the > "warnings" pragma, File::Find will report warnings for several > weird situations. You can disable these warnings by putting the >

Re: using regex, how to erase off all blank spaces

2008-04-06 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > use strict; > use warnings; > > open (MYDATAS , " my @datas = ; > close MYDATAS; > > foreach (@datas){ > s/^\s*$//; > } > > open (WRITEDATAS, ">testing.txt") || die $!; > print WRITEDATAS @datas; > close WRITEDATAS; That looks a lot like Perl 4. Study this: #!/usr

Re: questions from Learning Perl

2008-04-06 Thread Chas. Owens
On Sun, Apr 6, 2008 at 5:36 AM, <[EMAIL PROTECTED]> wrote: snip > my $user_total = &total(); snip First off, don't call functions with &*. The problem here is that you are evaluating in list context. That means it will read from STDIN until it is closed. To close a STDIN on UNIX use control-

Re: questions from Learning Perl

2008-04-06 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: I am doing some homework from the book Learning Perl chapter 4 excercise 1, Looking at the script below, I wonder why line 6 (print "Enter some numbers on separate line: ";) is not printed immediately after the previous print. I don't understand what you mean. However

Perl Serialize object as string

2008-04-06 Thread anthony brooke
Hello everyone, I need to serialize an perl object to STRING TEXT, not scalar or file. The Storable module allow serialization to file and scalar variable, but this is not possible for passing between the perl and prolog program, that's why I need it to be string. I tried out the FreezeThaw modu

Re: Perl Serialize object as string

2008-04-06 Thread Chas. Owens
On Sun, Apr 6, 2008 at 1:52 PM, anthony brooke <[EMAIL PROTECTED]> wrote: > Hello everyone, I need to serialize an perl object to STRING TEXT, > not scalar or file. The Storable module allow serialization to file and > scalar variable, but this is not possible for passing between the perl > and pro

Re: Perl Serialize object as string

2008-04-06 Thread anthony brooke
Thanks for the reply, I always thought that Dumper is used for debugging purposes, I will look at it deeper. Btw, what you mean by cyclic data ? - Original Message From: Chas. Owens <[EMAIL PROTECTED]> To: anthony brooke <[EMAIL PROTECTED]> Cc: beginner perl mailling list Sent: Monday

Re: redirect Find::File to /dev/null

2008-04-06 Thread John W. Krahn
protoplasm wrote: On Apr 5, 7:20 am, [EMAIL PROTECTED] (John W. Krahn) wrote: WARNINGS If you run your program with the "-w" switch, or if you use the "warnings" pragma, File::Find will report warnings for several weird situations. You can disable these warnings by puttin

Re: Perl Serialize object as string

2008-04-06 Thread Chas. Owens
On Sun, Apr 6, 2008 at 2:33 PM, anthony brooke <[EMAIL PROTECTED]> wrote: > Thanks for the reply, I always thought that Dumper is used for debugging > purposes, I will look at it deeper. Btw, what you mean by cyclic data ? snip Data::Dumper is often used to display the contents of a data structur

Re: Perl Serialize object as string

2008-04-06 Thread Dr.Ruud
anthony brooke schreef: > I need to serialize an perl object to STRING TEXT, > not scalar Printing (the value of) a scalar, gives you a string. See `perldoc -f sprintf`. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [E

Re: Perl Serialize object as string

2008-04-06 Thread Chas. Owens
On Sun, Apr 6, 2008 at 6:17 PM, Dr.Ruud <[EMAIL PROTECTED]> wrote: snip > > I need to serialize an perl object to STRING TEXT, > > not scalar > > Printing (the value of) a scalar, gives you a string. > See `perldoc -f sprintf`. snip Unfortunately the freeze subroutine from Storable outputs a b

Arbitrary mathematical relations, not just hashes

2008-04-06 Thread Kelly Jones
Many programming languages (including Perl, Ruby, and PHP) support hashes: $color['apple'] = 'red'; $color['ruby'] = 'red'; $type['apple'] = 'fruit'; $type['ruby'] = 'gem'; This quickly lets me find the color or type of a given item. In this sense, color() and type() are like mathematical funct

Re: [PHP] Arbitrary mathematical relations, not just hashes

2008-04-06 Thread Casey
On Sun, Apr 6, 2008 at 4:52 PM, Kelly Jones <[EMAIL PROTECTED]> wrote: > Many programming languages (including Perl, Ruby, and PHP) support hashes: > > $color['apple'] = 'red'; > $color['ruby'] = 'red'; > > $type['apple'] = 'fruit'; > $type['ruby'] = 'gem'; > > This quickly lets me find the co

Re: how to look back past hour

2008-04-06 Thread Richard Lee
Thomas Bätzler wrote: Richard Lee <[EMAIL PROTECTED]> asked: What is the best way to indicate past hour from current time without using a module? [...] #!/usr/bin/perl -w use strict; printf "%d:%02d to %d:%02d\n", (localtime time - 3600 )[2,1], (localtime time)[2,1]; __END__

opening a big file

2008-04-06 Thread Richard Lee
I am trying to open a big file and go through line by line while limiting the resource on the system. What is the best way to do it? Does below read the entire file and store them in memory(not good if that's the case).. open(SOURCE, "/tmp/file") || die "not there: $!\n"; while () { ## do som

Re: opening a big file

2008-04-06 Thread Richard Lee
Richard Lee wrote: I am trying to open a big file and go through line by line while limiting the resource on the system. What is the best way to do it? Does below read the entire file and store them in memory(not good if that's the case).. open(SOURCE, "/tmp/file") || die "not there: $!\n";

Re: Arbitrary mathematical relations, not just hashes

2008-04-06 Thread Mr. Shawn H. Corey
On Sun, 2008-04-06 at 16:52 -0700, Kelly Jones wrote: > Many programming languages (including Perl, Ruby, and PHP) support hashes: > > $color['apple'] = 'red'; > $color['ruby'] = 'red'; > > $type['apple'] = 'fruit'; > $type['ruby'] = 'gem'; > > This quickly lets me find the color or type of a gi

Re: opening a big file

2008-04-06 Thread Chas. Owens
On Sun, Apr 6, 2008 at 10:36 PM, Richard Lee <[EMAIL PROTECTED]> wrote: > I am trying to open a big file and go through line by line while limiting > the resource on the system. > What is the best way to do it? > > Does below read the entire file and store them in memory(not good if that's > the

Re: opening a big file

2008-04-06 Thread Mr. Shawn H. Corey
On Sun, 2008-04-06 at 22:36 -0400, Richard Lee wrote: > I am trying to open a big file and go through line by line while > limiting the resource on the system. > What is the best way to do it? > > Does below read the entire file and store them in memory(not good if > that's the case).. > > open

yesterday's time

2008-04-06 Thread Richard Lee
I just read FAQ on finding out yesterday's time. I see that one of the easy way to find out is my $date = scalar localtime( ( time() - ( 24 * 60 * 60 ) ) ); print "$date\n"; and it works fine for me I also see lot of modules that will make life easier for beginners.. but since I was learning

Re: String To Hash Conversion

2008-04-06 Thread Prabu Ayyappan
- Original Message From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> To: beginners@perl.org Sent: Saturday, April 5, 2008 11:22:41 PM Subject: Re: String To Hash Conversion Prabu Ayyappan wrote: > I want to convert a string into a Hash data structure > > For Example > > String: > "[['aaa