[30387] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1630 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 10 18:14:24 2008

Date: Tue, 10 Jun 2008 15:14:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 10 Jun 2008     Volume: 11 Number: 1630

Today's topics:
    Re: Question on learning Perl <jurgenex@hotmail.com>
    Re: Question on learning Perl <danrumney@warpmail.net>
    Re: Question on learning Perl <danrumney@warpmail.net>
    Re: Question on learning Perl <jurgenex@hotmail.com>
    Re: Question on learning Perl <tzz@lifelogs.com>
    Re: Question on learning Perl <szrRE@szromanMO.comVE>
    Re: Question on learning Perl <szrRE@szromanMO.comVE>
    Re: System level file / directory comparion sln@netherlands.co
    Re: Time and again <someone@example.com>
    Re: Time and again <hjp-usenet2@hjp.at>
    Re: Time and again <jurgenex@hotmail.com>
    Re: Time and again <ben@morrow.me.uk>
    Re: Tk with Thread <slick.users@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 10 Jun 2008 16:39:00 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Question on learning Perl
Message-Id: <a7bt44hokoij2v9mlke3f9paogiic1469l@4ax.com>

grocery_stocker <cdalten@gmail.com> wrote:

Dear Grocery

>Anyhow, when you learned Perl, did you memorize most of the functions?
>Ie memorize what they do and the arguments that they take? Or did you
>just memorize the ones that you felt were relevant to you job? Is
>there some kind of trick to memorizing the functions?

Just don't. If you want to then create a cheat sheet with the functions
from 'perldoc perlfunc'. That will give you a very good idea which
function you are probably looking for. But for the actual detailed
functionality and parameter list just consult 'perldoc [func]'. It can't
be any easier, faster, and most important any more accurate than that.

jue


------------------------------

Date: Tue, 10 Jun 2008 12:49:11 -0400
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: Question on learning Perl
Message-Id: <484eb088$0$4283$4c368faf@roadrunner.com>

Andrew DeFaria wrote:
> grocery_stocker wrote:
>> I asked this in another forum and never got a response. Maybe the 
>> question was worded poorly.
>>
>> Anyhow, when you learned Perl, did you memorize most of the functions? 
>> Ie memorize what they do and the arguments that they take? Or did you 
>> just memorize the ones that you felt were relevant to you job? Is
>> there some kind of trick to memorizing the functions?
> When you first started using the language called English did you 
> memorize most of the words, their meanings, etc.?

I think that's a little simplistic. I can't remember the last time 
someone shouted "Syntax Error!" at me and failed to understand the 
entirety of what I was saying based on a misplaced punctuation mark.


------------------------------

Date: Tue, 10 Jun 2008 12:54:42 -0400
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: Question on learning Perl
Message-Id: <484eb1d3$0$4257$4c368faf@roadrunner.com>

grocery_stocker wrote:
> I asked this in another forum and never got a response. Maybe the
> question was worded poorly.
> 
> Anyhow, when you learned Perl, did you memorize most of the functions?
> Ie memorize what they do and the arguments that they take? Or did you
> just memorize the ones that you felt were relevant to you job? Is
> there some kind of trick to memorizing the functions?

Really, the only way to remember them is to use them.

You can learn a lot from reading books, FAQs and newsgroups, but the 
lessons will only really stuck when you start applying them.

Also, as the field in which you're programming changes, so will the 
functions that are at the forefront of your mind change. I am sure that 
there are some people out there who write scripts which present data to 
the command line and so can use printf in their sleep.
Others will know all of the File IO functions backwards and forwards.

However, every Perl coder will refer to perldoc and probably with great 
frequency.

Also, perldoc.perl.org is a great resource. In particular, this page:
   http://perldoc.perl.org/index-functions-by-cat.html
which lists functions by category


------------------------------

Date: Tue, 10 Jun 2008 17:26:47 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Question on learning Perl
Message-Id: <05et44pta5n8njqijoln7a80vucrh8c11f@4ax.com>

Dan Rumney <danrumney@warpmail.net> wrote:
>> When you first started using the language called English did you 
>> memorize most of the words, their meanings, etc.?

Oh yes, vey much so. Every week some 20-40 new words and the teacher
would check them at the beginning of each class.
 
>I think that's a little simplistic. I can't remember the last time 
>someone shouted "Syntax Error!" at me and failed to understand the 
>entirety of what I was saying based on a misplaced punctuation mark.

Well, compilers are the ultimate nit-pickers ;-)

jue


------------------------------

Date: Tue, 10 Jun 2008 13:26:48 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Question on learning Perl
Message-Id: <86zlptqh7b.fsf@lifelogs.com>

On Tue, 10 Jun 2008 05:45:09 -0700 (PDT) grocery_stocker <cdalten@gmail.com> wrote: 

gs> Anyhow, when you learned Perl, did you memorize most of the functions?
gs> Ie memorize what they do and the arguments that they take? Or did you
gs> just memorize the ones that you felt were relevant to you job? Is
gs> there some kind of trick to memorizing the functions?

I've had to learn 4 human languages in addition to many programming
languages.  The process is the same: instead of memorization and dry
learning, immerse yourself in the language and don't use anything else
until you feel the rhythm, syntax, and grammar easily.  For programming
languages, it takes between 1 and 8 weeks depending on your experience
and the language itself.  Human languages take longer, 3 months - 12
months because they are so much more complex and nuanced, but it's the
same principle.

Ted


------------------------------

Date: Tue, 10 Jun 2008 13:11:28 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Question on learning Perl
Message-Id: <g2mn5p04vp@news4.newsguy.com>

Frank Seitz wrote:
> grocery_stocker wrote:
>> I asked this in another forum and never got a response. Maybe the
>> question was worded poorly.
>>
>> Anyhow, when you learned Perl, did you memorize most of the
>> functions? Ie memorize what they do and the arguments that they
>> take? Or did you just memorize the ones that you felt were relevant
>> to you job? Is there some kind of trick to memorizing the functions?
>
> I use the following litte book which I always have on my desktop:
>
> "Perl Pocket Reference", O'Reilly, Johan Vromans, $9.95

That's the little book, in all it's incarnations, that has never left my 
side. :-)

BTW, will there be one for 5.10 coming out? I haven't been able to find 
anything about it last time I looked.

-- 
szr 




------------------------------

Date: Tue, 10 Jun 2008 13:13:25 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Question on learning Perl
Message-Id: <g2mn960527@news4.newsguy.com>

Charlton Wilbur wrote:
>>>>>> "gs" == grocery stocker <cdalten@gmail.com> writes:
>
>    gs> Anyhow, when you learned Perl, did you memorize most of the
>    gs> functions?  Ie memorize what they do and the arguments that
>    they gs> take? Or did you just memorize the ones that you felt were
>    gs> relevant to you job? Is there some kind of trick to memorizing
>    gs> the functions?
>
> I didn't set out to memorize anything.  When I needed to do
> something, I looked through the FAQ and perldoc perlfunc to see what
> might help me do it.  After a couple months, I stopped needing to
> look things up very often; I still look through perldoc perlfunc from
> time to time, and I read the FAQs as they're posted here.

I too always go back to the references, though I find after having used 
Perl for so long many things I can just bring up from memory, but never 
underestimate the importance of a good quick reference (like the Perl 
Pocket Reference from O'Reilly.)

-- 
szr 




------------------------------

Date: Tue, 10 Jun 2008 14:23:22 -0700
From: sln@netherlands.co
Subject: Re: System level file / directory comparion
Message-Id: <b4rt441pgvteuhbeiofo2h5tbt93b4gt90@4ax.com>

On Mon, 9 Jun 2008 21:09:07 -0700 (PDT), syang8 <syang8@gmail.com> wrote:

>I just want to check the pathes. Here is actual work I need to do:
>
>I have a project root directory called projRoot, which includes some
>subdirectorys called subDir1, subDir2 ... , and the subdirectories
>include more sub-sub-directories.  A string $a, whose value is the
>path of the directory I should deal with, is passed to my program. The
>value of $a may be the an absolute path or the relative path to my
>current working directory.
>
>I want to check if $a is a subdirectory of projRoot.
>
>-steve
>

It sounds like your very confused here.
Your a program (or sub) that is passed an absolute or relative path.
It sounds like you have a constant projRoot that you know of.
You wan't to compare the two, but you don't know what your current
directory is.

So why do you care what the current working directory is anyway?
What has that got to do with it? How do you know that $a is related
to the current working directory?

Unless it's guaranteed, chiselled in stone, never assume that current working
directory has anything to do with a comparison of two paths!

Resolve $a to its absolute path ($A), projRoot to its absolute path ($projRoot),
then do a regular expression on it:

if ($A =~ /^$projRoot\//i) { ... }

Damn the torpedo's, full speed ahead.

>On Jun 9, 8:19 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>> Quoth syang8 <sya...@gmail.com>:
>>
>> > Is there any command in perl that I can check if two files are the
>> > same one?
>>
>> > For example, if there some file test  at the directory: /usr/var/test,
>> > and two strings $a = "./test" and $b ="../var/test". Is there any
>> > function that returns true if I compare $a and $b?
>>
>> If you want to test the actual filesystem, use the device and inode
>> values from stat (assuming a Unix system: they tend to be meaningless on
>> other systems). If you just want to check the paths, use Cwd::abs_path.
>>
>> Ben
>>
>> --
>> For the last month, a large number of PSNs in the Arpa[Inter-]net have been
>> reporting symptoms of congestion ... These reports have been accompanied by an
>> increasing number of user complaints ... As of June,... the Arpanet contained
>> 47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * b...@morrow.me.uk



------------------------------

Date: Tue, 10 Jun 2008 18:03:46 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Time and again
Message-Id: <6mz3k.677$sg6.66@edtnps91>

markdibley wrote:
> 
> I keep searching and searching and can never find the function I am
> looking for.
> 
> print scalar localtime();

Which is short for:

print scalar localtime( time() );

> gives
> Tue Jun 10 11:28:55 2008
> 
> I write that to a file and later I read it in and want to convert it
> into a timestamp that I can sort on.

Just remove the "scalar localtime()" part of the expression:

print time();


Then later you can sort it correctly "sort {$a <=> $b}" or display it in 
whatever format you want using localtime() or gmtime() or 
POSIX::strftime() or etc.



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


------------------------------

Date: Tue, 10 Jun 2008 22:49:35 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Time and again
Message-Id: <slrng4tq70.a6t.hjp-usenet2@hrunkner.hjp.at>

On 2008-06-10 11:30, Jürgen Exner <jurgenex@hotmail.com> wrote:
> markdibley <markdibley@gmail.com> wrote:
>>print scalar localtime();
>>gives
>>Tue Jun 10 11:28:55 2008
>>
>>I write that to a file and later I read it in 
>
> Why are you dumping the data into a file and then reading it back in?

That's what files are for. Why would you write something into a file if
you didn't plan to read it at some time?

	hp


------------------------------

Date: Tue, 10 Jun 2008 21:22:48 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Time and again
Message-Id: <enrt445iclinm4st27ug762a6gheale83j@4ax.com>

"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2008-06-10 11:30, Jürgen Exner <jurgenex@hotmail.com> wrote:
>> markdibley <markdibley@gmail.com> wrote:
>>>I write that to a file and later I read it in 
>>
>> Why are you dumping the data into a file and then reading it back in?
>
>That's what files are for. Why would you write something into a file if
>you didn't plan to read it at some time?

Well, why would you write something to a file and then read it back into
the program if you already have the information in the program to begin
with?

It all depends on what the OP meant with "later". I have seen code like
	
	system ("myprog > temp.txt");
	open (TMP, '<', 'temp.txt');
	@result = <TMP>;

Here the programmer writes information to a file and later reads it back
into the program, but unless there are very special circumstances
probably nobody would call this good code.

The OP already clarified that this is not what he was doing but that he
was dealing with log files. But that detail was missing in the original
post.

jue


------------------------------

Date: Tue, 10 Jun 2008 22:53:00 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Time and again
Message-Id: <sm93i5-c9s1.ln1@osiris.mauzo.dyndns.org>


Quoth Jürgen Exner <jurgenex@hotmail.com>:
> 
> It all depends on what the OP meant with "later". I have seen code like
> 	
> 	system ("myprog > temp.txt");
> 	open (TMP, '<', 'temp.txt');
> 	@result = <TMP>;

I've done this in the past. It was the only way I could find at the time
to get the output of an external process under Win98...

> Here the programmer writes information to a file and later reads it back
> into the program, but unless there are very special circumstances
> probably nobody would call this good code.

 ...I guess those probably count as 'very special circumstances' :).

Ben

-- 
I touch the fire and it freezes me,                      [ben@morrow.me.uk]
I look into it and it's black.
Why can't I feel? My skin should crack and peel---
I want the fire back...                     BtVS, 'Once More With Feeling'


------------------------------

Date: Tue, 10 Jun 2008 13:30:58 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Re: Tk with Thread
Message-Id: <f41779b3-db6f-4103-a9f9-89f82908388d@d77g2000hsb.googlegroups.com>

How would I go fixing my code below to make it work?

I am just frustrate that I can't get it to work and not any example
toward to this issue. Thanks.

use strict;
use warnings;
use Tk;
use threads;
#use Win32::OLE;
#use Win32::OLE::Const 'Microsoft Excel';

my $thr;

my $mainWindow = MainWindow->new;
my $textBox = $mainWindow->Scrolled("Text", -width=>80, -height=>7,
      -scrollbars=>"ose", -wrap=>"word")->pack();

my $goBut = $mainWindow->Button(-foreground=>"blue", -text=>"Click",
                   -command=>sub {
				   $thr = threads->new(\&excecute);
				   #&excecute;
				   } )->pack();

my $stopBut = $mainWindow->Button(-foreground=>"red", -text=>"Exit",
                   -command=>sub{
				   if(defined($thr)){ $thr->detach; }
				   exit;
				   })->pack();

MainLoop;


sub excecute
{
	$goBut->configure(-state=>"disabled");
	$textBox->configure(-state=>"normal");
	open(FILE,"C:/file.txt") or die "Can't open file.\n";
	while(<FILE>)
	{
		my $message = $_;
		$textBox->insert('end', $message);
	}
	close(FILE);

	$textBox->configure(-state=>"disabled");
	$textBox->see('end');

	use Win32::OLE;
	use Win32::OLE::Const 'Microsoft Excel';

	my ($Excel,$Workbook,$fileOutput,$CurrentSheet,$Range);
	$fileOutput = "C:/test.xls";

	$Excel = Win32::OLE->new('Excel.Application', 'Quit') || die "Can't
create Excel object. \n";
	$Excel->{'Visible'} 			= 1;	#0 is hidden, 1 is visible
	$Excel->{DisplayAlerts} 		= 0;	#0 is hide alerts
	$Excel->{SheetsInNewWorkbook} 	= 1;
	$Workbook = $Excel->Workbooks->Add();

	$Workbook->SaveAs($fileOutput) or die "Can't save Excel.\n";
	$CurrentSheet = $Workbook->Worksheets(1);
	$CurrentSheet->Select;

	for (my $i=1; $i<=2000; $i++)
	{
		$Range = $CurrentSheet->Range("A$i");
		$Range->{Value} = $i;
		sleep(0.01);
	}

	$Workbook->Save();
	$Workbook->Close();
	$Excel->Quit();
	Win32::OLE->FreeUnusedLibraries();
	$goBut->configure(-state=>"normal");
	return;
}

On Jun 10, 7:55 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth zentara <zent...@highstream.net>:
>
> > On Mon, 9 Jun 2008 08:22:12 -0700 (PDT), Slickuser
> > <slick.us...@gmail.com> wrote:
>
> > >When I move the use OLE to where I want to use it. Here's the error I
> > >get.
>
> > >Free to wrong pool 2db6e00 not 222dc8 during global destruction.
>
> > That is definitely an error caused by threads getting confused.
> > Try putting your
> > use Win32::OLE;
> > use Win32::OLE::Const 'Microsoft Excel';
>
> > in the new_thread sub.  The other subs are part of the main code.
>
> This won't change anything. Use statements are executed at compile-time,
> before any threads have been created.
>
> If you *really* need to use a module in a particular thread, you need to
> 'require' it and call ->import manually. This is almost certainly not
> necessary in this case, though.
>
> > Also, try to make new_thread self-contained, don't use a separate
> > &test. Additionally, you are trying to access the Tk widget from thread
> > code in &test..... this cannot be done.
>
> This is much more likely to be the problem.
>
> Ben
>
> --
> Like all men in Babylon I have been a proconsul; like all, a slave ... During
> one lunar year, I have been declared invisible; I shrieked and was not heard,
> I stole my bread and was not decapitated.
> ~ b...@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1630
***************************************


home help back first fref pref prev next nref lref last post