[24730] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6885 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 19 18:10:58 2004

Date: Thu, 19 Aug 2004 15:10: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           Thu, 19 Aug 2004     Volume: 10 Number: 6885

Today's topics:
    Re: File::Find question. <tadmc@augustmail.com>
    Re: File::Find question. (Steve P)
        How Should I Check for Directory existance in a server sunilkumar_1480@yahoo.com
        how to run dos command in perl <sms1@pctc.com>
    Re: how to run dos command in perl <jgibson@mail.arc.nasa.gov>
    Re: how to run dos command in perl <1usa@llenroc.ude.invalid>
    Re: How to upload a file from a local pc to  a web serv (srini)
    Re: My own handy Pocket Reference notes <abigail@abigail.nl>
    Re: Net::SFTP ssh_args => [ ] syntax question... (Icari)
        perl interpreter automatically exit windows so how I ca <end@dream.life>
    Re: perl interpreter automatically exit windows so how  <a@a.com>
    Re: perl interpreter automatically exit windows so how  <pinyaj@rpi.edu>
    Re: perl interpreter automatically exit windows so how  <1usa@llenroc.ude.invalid>
    Re: perl interpreter automatically exit windows so how  <postmaster@castleamber.com>
    Re: perl interpreter automatically exit windows so how  <mritty@gmail.com>
    Re: perl interpreter automatically exit windows so how  <shawn.corey@sympatico.ca>
    Re: perl interpreter automatically exit windows so how  (Greg Bacon)
        What is the best way to make a Tree Data Structure in o <SaveWorldFromAids@alexa.com>
    Re: What is the best way to make a Tree Data Structure  <postmaster@castleamber.com>
    Re: what's the best environment to exercise Perl? <spamtrap@dot-app.org>
    Re: what's the best environment to exercise Perl? <end@dream.life>
    Re: what's the best environment to exercise Perl? <end@dream.life>
    Re: what's the best environment to exercise Perl? <peter@semantico.com>
    Re: what's the best environment to exercise Perl? <matrix_calling@yahoo.dot.com>
    Re: what's the best environment to exercise Perl? <sbryce@scottbryce.com>
    Re: what's the best environment to exercise Perl? <postmaster@castleamber.com>
    Re: what's the best environment to exercise Perl? 510046470588-0001@t-online.de
    Re: what's the best environment to exercise Perl? <thundergnat@hotmail.com>
    Re: what's the best environment to exercise Perl? <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Aug 2004 09:43:34 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: File::Find question.
Message-Id: <slrnci9f4m.hvp.tadmc@magna.augustmail.com>

Steve P <nomad3d@msn.com> wrote:

> I need to only return the file
> names rather than the whole path and filename


> &print_html();

> sub print_html {


Why are you specifying to circumvent prototypes when the functions
do not even _have_ prototypes?

See how to call subroutines in "perldoc perlsub", then call w/o the ampersand:

   print_html();


> sub wanted {
>      /^.*\.rfu\z/s &&


Think about where the string is that you are pattern matching against.

What is the name of the variable containing the string to be searched?


>    print OUT ("$name\n<BR>");
                 ^^^^^


Use that variable name here instead of the one you have.  :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 19 Aug 2004 12:18:42 -0700
From: nomad3d@msn.com (Steve P)
Subject: Re: File::Find question.
Message-Id: <af2809b.0408191118.179753ec@posting.google.com>

> 
> 
> Did you try reading the docs for File::Find?
> 
>      For example, when examining the file /some/path/foo.ext you
>      will have:
> 
>          $File::Find::dir  = /some/path/
>          $_                = foo.ext
>          $File::Find::name = /some/path/foo.ext
> 
> Just use $_ instead of $File::Find::name inside the wanted function.
> (find2perl is doing the odd bit of making just $name represent
> $File::Find::name - just replace $name with $_)
> 
> Paul Lalli

Ah yes. I did read the docs on it, but for some reason, that little
part escaped me. Thank you for pointing that out. :)

Regards, 
Steve Powell


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

Date: 19 Aug 2004 15:00:54 -0700
From: sunilkumar_1480@yahoo.com
Subject: How Should I Check for Directory existance in a server
Message-Id: <d672b808.0408191400.638d950a@posting.google.com>

I have to create a directory in a FTP server but before I create i
should check for the existance of the directory. If the directory does
exist then I should not create the directory. The following is the
code which I have written and I am unsuccessful with reading a
directory in a server

my $dir_name = $ARGV[0];
my $basepath = "c:\\Inetpub\\wwwroot\\$dir_name\\test";
my $count = 0;
my $server="casr.com";
my $user="slb";
my $password="bigfiles";
my $dir="iDistrict/incoming/baselines/TestReports/";
my $success="true";
my $filetran="true";
my $reason;
my $test="true";
my @file_list;
my $ret;
my $ftp=Net::FTP->new($server) or $success="false";
$ftp->login($user, $password) or $success="false";
$ftp->pasv() or $success="false";
$ftp->binary() or $success="false";
$ftp->cwd($dir) or $success='false';
print $ftp->cwd($dir);
# I am unable to open the directory that exists in the server which I
have
# mentioned with $dir name.
opendir(SRC, $dir);
my @dir_files = readdir(SRC);
foreach my $file (@dir_files)
{
  if($file eq $dir_name)
  {
      $ret = 0;
      closedir(SRC);
      last;
   }
}

if($ret ne 0)
{
  $ftp->mkdir($folder_name) or $success='false';
}
$ftp->cwd($dir."/".$folder_name) or $success='false';


Can anybody help me how to read the contents of a directory in the
server.


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

Date: Thu, 19 Aug 2004 13:29:30 -0700
From: "jenson" <sms1@pctc.com>
Subject: how to run dos command in perl
Message-Id: <L48Vc.1478$KF.11582@tor-nn1.netcom.ca>

I want to return the output and a dos command to a scalar variable and
display it.

The following code did not work. I think I made a mistake in using the `
sign. Please advise what needs to be changed to make the following code work
in window xp.

Any help is much appreciated.

open (DATE, `echo %date%`);
$theDate = <DATE>;
close(DATE);
print "This is $theDate \n";




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

Date: Thu, 19 Aug 2004 13:42:40 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: how to run dos command in perl
Message-Id: <190820041342402820%jgibson@mail.arc.nasa.gov>

In article <L48Vc.1478$KF.11582@tor-nn1.netcom.ca>, jenson
<sms1@pctc.com> wrote:

> I want to return the output and a dos command to a scalar variable and
> display it.
> 
> The following code did not work. I think I made a mistake in using the `
> sign. Please advise what needs to be changed to make the following code work
> in window xp.
> 
> Any help is much appreciated.
> 
> open (DATE, `echo %date%`);

This statement executes 'echo %date%' as a shell command and uses the
output as a file name to open. I am not using Windows XP, so I don't
know what 'echo %date%' returns, but I am pretty sure you don't want to
open a file of that name. 


> $theDate = <DATE>;
> close(DATE);
> print "This is $theDate \n";


Try this:

   $theDate = `echo %date%`;

Other advice:

1. Your description "doesn't work" is too vague for people to help you.
Please try to be more descriptive of what your program is doing and
what you think it should be doing that it is not.

2. Always post a minimal, complete program demonstrating the problem
you are experiencing.

3. Always put 'use strict;' at the top of your program.

4. Always, some would go so far as to say 'yes, alway', check the
return from on open.

Guidelines for posts to this newsgroup are posted frequently, Please
follow them.

Thanks.


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

Date: 19 Aug 2004 21:06:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: how to run dos command in perl
Message-Id: <Xns954AAE10462A8asu1cornelledu@132.236.56.8>

"jenson" <sms1@pctc.com> wrote in
news:L48Vc.1478$KF.11582@tor-nn1.netcom.ca: 

> I want to return the output and a dos command to a scalar variable and
> display it.
> 
> The following code did not work. I think I made a mistake in using the
> ` sign. Please advise what needs to be changed to make the following
> code work in window xp.
> 
> Any help is much appreciated.
> 
> open (DATE, `echo %date%`);
> $theDate = <DATE>;
> close(DATE);
> print "This is $theDate \n";

Let's see. 

First:

echo is an internal command implemented in cmd.exe. Unless you have 
installed cygwin or something like that, the line above will not do what 
you want it to do.

C:\Home> type ttt.pl
use strict;
use warnings;

unless(defined (my $temp = `echo %temp%`)) {
    print "Command failed\n";
}

C:\Home> ttt
Command failed: Bad file descriptor at C:\Home\asu1\ttt.pl line 7.

On the other hand:

C:\Home> type ttt.pl
use strict;
use warnings;

if(defined (my $temp = `cmd.exe /c echo \%temp\%`)) {
    print "TEMP = $temp\n";
} else {
    die "Command failed: $!";
}

C:\Home> ttt
TEMP = C:\DOCUME~1\user\LOCALS~1\Temp

Second, do you have a program that sets the environment variable DATE 
which then points to a file by that name or something. I am having 
trouble making any sense of the four lines of code you posted.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: 19 Aug 2004 14:43:37 -0700
From: schimata2@yahoo.com (srini)
Subject: Re: How to upload a file from a local pc to  a web server from a html page????
Message-Id: <5fc50f33.0408191343.4fc7f98@posting.google.com>

OK.. Iam tired of two two things:
1. to look around in this group for a way to upload a file to the web
server
2. to hear the useless and sarcastic answers from some people.

Can some gentlemen pl. tell me how the following code would be
successful?

HTML part:
---------------
<tr><td colspan="2"> <FONT color=black>Attachment (if any):</FONT><BR>
 <INPUT  type="file" size=50 name="attachedfile" ALLOW="text/*">
</td></tr>
--------------


Perl code:
-----------------------------------------------
$attachedFile = $query -> param ("attachedfile");     
$attachedFile=~ s/.*[\/\\](.*)/$1/;
 
$upload_filehandle = $query->upload("attachedfile");
 
$uploaddir = "C:\\Temp\\";  #### on web server..

$temp = $uploaddir . $attachedFile;
    
open UPLOADFILE, ">$temp";
while (<$upload_filehandle>)
 {
   print UPLOADFILE;
 }
close UPLOADFILE;
print "$temp";
 
------------------------------------------------ 

The above code gives me a zero sized file on the web server (in
C:\ViewStore folder). How can the above code be modified to get the
correct file from the local PS to the web server???

Thanks in advance..
Srini 


Brian McCauley <nobull@mail.com> wrote in message news:<cg1lg7$tki$1@slavica.ukpost.com>...
> srini wrote:
> 
> > $upload_filehandle = $query->upload("attachedfile");
> >  
> > $uploaddir = "C:\\Temp";  #### on web server..
> > 
> > $temp = $uploaddir . $attachedFile;
> >     
> > open UPLOADFILE, ">$temp";
> > close UPLOADFILE;
> > print "$temp";
> > 
> > Now I want to capture the file attachment from a user's desktop and
> > upload it into a temp variable on the web server. It is giving me zero
> > byte sized file in the $temp variable.
> 
> You getting the CGI upload filehandle then not doing anything with it.
> 
> You are opening a file for output withouy checking for success.
> 
> You are not writing anything to that file.
> 
> You concatenate a directory name and a filename to make a full path name 
> and forgetting to put a directory separator character in.
> 
>  > What am I doing wroing here?
> 
> It would appear you are forgetting the rule:
> 
> "You can't just make shit up and expect the computer to know what you mean".
> 
> > Can some boby kindly tell me how my perl code should be modified so
> > that I can store the $attachedFile from the user's desktop into $temp
> > variable on the web server?
> 
> If you want to save the stuff to a file you should read stuff from the 
> filehandle $upload_filehandle and write it to the other one.
> 
> But although your code appears to be writing a file you say you actually 
> want the content of the uploaded in a variable.
> 
> You need to get clear in your mind what you are trying to do.
> 
> If you want to slurp $upload_filehandle into a variable then do so. 
> (See FAQ).
> 
> You should put directory separators between directory names and filenames.
> 
> You should always, yes always, check the success of open.


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

Date: 19 Aug 2004 20:08:51 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <slrncia26j.q3p.abigail@alexandra.abigail.nl>

Dave Weaver (zen13097@zen.co.uk) wrote on MMMMVI September MCMXCIII in
<URL:news:41245c68$0$209$db0fefd9@news.zen.co.uk>:
`'  On 18 Aug 2004 07:27:05 GMT, Abigail <abigail@abigail.nl> wrote:
`' >  Randal L. Schwartz (merlyn@stonehenge.com) wrote on  September MCMXCIII
`'                                                      ^^^^^
`'  
`'  I get the whole Sept'93 reference, but surely there's something wrong
`'  there?


Yeah, I was using some CPAN module to do decimal to Roman conversion,
but it turns out that it can't deal with numbers greater than 3999.



Abigail
-- 
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'


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

Date: 19 Aug 2004 12:00:04 -0700
From: icari.eccles@gmail.com (Icari)
Subject: Re: Net::SFTP ssh_args => [ ] syntax question...
Message-Id: <e0097116.0408191100.7875c3f2@posting.google.com>

"David K. Wall" <dwall@fastmail.fm> wrote in message news:<Xns954A6923E8A64dkwwashere@216.168.3.30>...
> 
> I'm not sure I understand the question, plus you mention Net::SSH 
> when Net::SFTP uses Net::SSH::Perl instead of Net::SSH. But, yes, you 
> can put a hash inside the anonymous array following 'ssh_args', e.g.;
> 
> my %params = ( port => 22 );
> my %args = (ssh_args => [%params]);
> 
> But that's a rather long-winded way of doing it, and in my opinion 
> it's a bit obfuscated. More plainly: yecch! :-)
> The docs for Net::SFTP also refer you to Net::SSH::Perl....
> It seems you read the docs for Net::SFTP and Net::SSH::Perl, because 
> the code below defines the ssh port just as the docs recommend. But 
> ssh_args is not really associated with a hash, but a scalar: a 
> reference to an anonymous array. You might benefit from reading 
> perlreftut and perlref. In particular, see "Make Rule 2" in 
> perlreftut.
> 
> > my %args = (user => "$user", password => "$pass", ssh_args =>
> > [port => 22]);
> 
> $user and $pass don't need to have quotes around them, though. See 
> 'perldoc -q quoting' for why this is generally a bad idea.
>  
> The docs call for a reference to a list of named arguments; [] is the 
> most convenient way to write this. If you also wanted to turn on 
> compression, here's one way to write it:
> 
> my $sftp = Net::SFTP->new( $host,     
>     user     => $user, 
>     password => $pass, 
>     ssh_args => [port => 22, compression => 1]
> );
> 
> Caveat: I've never used Net::SFTP, the above code is untested and 
> based purely on a quick reading of the docs.

Oops, I actually did mean Net::SSH::Perl.  I read the man pages for
both SFTP and SSH-Perl modules, but was a bit confused with the syntax
usage when I saw the ssh_args => [ ] line in the example file.  I just
tested this out and it worked, I won't need to worry about making sure
/etc/services had ssh port defined when I port my script to another
system.  Thanks for your help :). I was just recently placed on a
project to provide some scripts and just started to learn perl while I
was creating my code (I have not been coding for a long time) so I'm
still learning. I'll refer to the perlreftut and perlref for more
information, thanks again for all the tips!

Icari.


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

Date: Fri, 20 Aug 2004 00:57:41 +0800
From: Alont <end@dream.life>
Subject: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <4126dabd.127559140@130.133.1.4>

in my WINDOWS XP, I can open *.pl file and perl interpreter
automatically start and execute *.pl file but it automatically exit
too, so I can't saw the result of script, how to set perl interpreter
stay on the command line?
the guide haven't tell me the answer:
Win95/NT 
The Win95/NT installation, when using the ActiveState installer for
Perl, will modify the Registry to associate the .pl extension with the
perl interpreter. If you install Perl by other means (including
building from the sources), you may have to modify the Registry
yourself. Note that this means you can no longer tell the difference
between an executable Perl program and a Perl library file.

      Your fault as a Government is My failure as a citizen


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

Date: Thu, 19 Aug 2004 17:45:38 GMT
From: "Gibbering Poster" <a@a.com>
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <6H5Vc.5862$Nh5.331@newssvr27.news.prodigy.com>


"Alont" <end@dream.life> wrote in message
news:4126dabd.127559140@130.133.1.4...
> in my WINDOWS XP, I can open *.pl file and perl interpreter
> automatically start and execute *.pl file but it automatically exit
> too, so I can't saw the result of script, how to set perl interpreter
> stay on the command line?

You could always put '<>' at the end of your script...




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

Date: Thu, 19 Aug 2004 15:00:04 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <Pine.SGI.3.96.1040819145946.1358098A-100000@vcmr-64.server.rpi.edu>

On Thu, 19 Aug 2004, Greg Bacon wrote:

>I like to use something similar to the following:
>
>    END { system "pause" unless $ENV{PROMPT} }
>
>That way, I don't see the pause in a command window.
>
>I'd like to know of a workaround that would cause the window to
>linger when there are syntax errors, a use fails, etc.

Easy:  make that END { ... } the first line of your code.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
RPI Corporation Secretary   %  have long ago been overpaid?
http://japhy.perlmonk.org/  %  
http://www.perlmonks.org/   %    -- Meister Eckhart




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

Date: 19 Aug 2004 19:21:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <Xns954A9C4499585asu1cornelledu@132.236.56.8>

Alont <end@dream.life> wrote in news:4126dabd.127559140@130.133.1.4:

> in my WINDOWS XP, I can open *.pl file and perl interpreter
> automatically start and execute *.pl file but it automatically exit
> too, so I can't saw the result of script, how to set perl interpreter
> stay on the command line?
> the guide haven't tell me the answer:

Learn how to use Windows XP, why don't you?

Download the "Command Prompt Here" powertoy from Microsoft (google for it). 
Then, you can open a cmd shell window anywhere you want in explorer. Run 
you Perl scripts from the command line instead of double clicking on them 
unless the scripts are designed to interact with you using a GUI. This goes 
for all programs, not just for Perl scripts.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: 19 Aug 2004 19:33:23 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <Xns954A94132B369castleamber@130.133.1.4>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns954A9C4499585asu1cornelledu@132.236.56.8: 

> Alont <end@dream.life> wrote in news:4126dabd.127559140@130.133.1.4:
> 
>> in my WINDOWS XP, I can open *.pl file and perl interpreter
>> automatically start and execute *.pl file but it automatically exit
>> too, so I can't saw the result of script, how to set perl interpreter
>> stay on the command line?
>> the guide haven't tell me the answer:
> 
> Learn how to use Windows XP, why don't you?
> 
> Download the "Command Prompt Here" powertoy from Microsoft (google for
> it). Then, you can open a cmd shell window anywhere you want in
> explorer. Run you Perl scripts from the command line instead of double
> clicking on them unless the scripts are designed to interact with you
> using a GUI.

Or just run and do their work and no interacting nor reporting is required.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: Thu, 19 Aug 2004 13:10:24 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <20040819130925.T2996@barbara.cs.rpi.edu>

On Fri, 20 Aug 2004, Alont wrote:

>
> in my WINDOWS XP, I can open *.pl file and perl interpreter
> automatically start and execute *.pl file but it automatically exit
> too, so I can't saw the result of script, how to set perl interpreter
> stay on the command line?
> the guide haven't tell me the answer:
> Win95/NT
> The Win95/NT installation, when using the ActiveState installer for
> Perl, will modify the Registry to associate the .pl extension with the
> perl interpreter. If you install Perl by other means (including
> building from the sources), you may have to modify the Registry
> yourself. Note that this means you can no longer tell the difference
> between an executable Perl program and a Perl library file.


Maybe, just maybe, you should wait a few minutes before asking the same
question again.  Usenet is not instantaneous.  This question has been
answered, with a couple different answers, in the original thread.

Paul Lalli


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

Date: Thu, 19 Aug 2004 13:32:59 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <Jt5Vc.22841$ZI1.903379@news20.bellglobal.com>

Try adding this to your script:

END{<STDIN>}

This way the results don't disappear until you press ENTER.

Alont wrote:
> in my WINDOWS XP, I can open *.pl file and perl interpreter
> automatically start and execute *.pl file but it automatically exit
> too, so I can't saw the result of script, how to set perl interpreter
> stay on the command line?
> the guide haven't tell me the answer:
> Win95/NT 
> The Win95/NT installation, when using the ActiveState installer for
> Perl, will modify the Registry to associate the .pl extension with the
> perl interpreter. If you install Perl by other means (including
> building from the sources), you may have to modify the Registry
> yourself. Note that this means you can no longer tell the difference
> between an executable Perl program and a Perl library file.
> 
>       Your fault as a Government is My failure as a citizen



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

Date: Thu, 19 Aug 2004 18:43:37 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: perl interpreter automatically exit windows so how I can saw the result of script?
Message-Id: <10i9t6pn4cgmk87@corp.supernews.com>

In article <Jt5Vc.22841$ZI1.903379@news20.bellglobal.com>,
    Shawn Corey  <shawn.corey@sympatico.ca> wrote:

: Try adding this to your script:
: 
: END{<STDIN>}
: 
: This way the results don't disappear until you press ENTER.

I like to use something similar to the following:

    END { system "pause" unless $ENV{PROMPT} }

That way, I don't see the pause in a command window.

I'd like to know of a workaround that would cause the window to
linger when there are syntax errors, a use fails, etc.

Greg
-- 
Sometimes it is said that man cannot be trusted with the government of
himself.  Can he, then, be trusted with the government of others?
    -- Thomas Jefferson


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

Date: Thu, 19 Aug 2004 17:49:51 GMT
From: "http://links.i6networks.com" <SaveWorldFromAids@alexa.com>
Subject: What is the best way to make a Tree Data Structure in one text file?
Message-Id: <3L5Vc.832$NRf.30@news04.bloor.is.net.cable.rogers.com>

I want to write a tree and read the tree from one text file by Perl's
regular expression.

What is the best way to do it in term of speed.

I want to be able to select sub note and search all note and search with a
sub note.

It is really like a Forum, but saves everything in one text file.

Here is some of my ideas:

design 1:

parentname1:childname1:childdata1
parentname1:childname2:childdata2


design2:
parentname
childname1:childdata1
childname2:childdata2

design2 saves space, but design2 also requries everything is in order.
design1 allow me just appent lines to the file.

Any other better designs?




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

Date: 19 Aug 2004 18:44:10 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: What is the best way to make a Tree Data Structure in one text file?
Message-Id: <Xns954A8BBB278E0castleamber@130.133.1.4>

"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote in
news:3L5Vc.832$NRf.30@news04.bloor.is.net.cable.rogers.com: 

> I want to write a tree and read the tree from one text file by Perl's
> regular expression.
> 
> What is the best way to do it in term of speed.

dump a hash of hashes to a file and read it back

> I want to be able to select sub note and search all note and search
> with a sub note.

In your file, or after reading the data into memory?

> It is really like a Forum, but saves everything in one text file.

XML? Altough for a Forum I would recommend a database.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: Thu, 19 Aug 2004 11:31:26 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <VJSdncuskvVTWrncRVn-gg@adelphia.com>

Alont wrote:

> what's the best convenient environment to exercise Perl?

A computer. Seriously! Perl runs on damn near everything. ;-)

> my platform is windows xp

That will do.

For a neatly-packaged, easily-installed Perl for Windows:
     <http://activestate.com/>

For some links, dead trees, etc. to help get you started:
     <http://learn.perl.org>

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 20 Aug 2004 00:29:27 +0800
From: Alont <end@dream.life>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <4124d3db.125797609@130.133.1.4>

write perl program in a editor and then save it as a *.pl file, and
then execute it? but the perl.exe will automatically exit when perl
script is end, and I can't see the result of my script,
the "environment" I asked is there have an editor who could execute
perl immediately(through a HotKey or a menu)

at Thu, 19 Aug 2004 11:31:26 -0400
Sherm Pendley <spamtrap@dot-app.org>×íõ¸õ¸µÄÄØà«µÀ:--
>Alont wrote:
>
>> what's the best convenient environment to exercise Perl?
>
>A computer. Seriously! Perl runs on damn near everything. ;-)
>
>> my platform is windows xp
>
>That will do.
>
>For a neatly-packaged, easily-installed Perl for Windows:
>     <http://activestate.com/>
>
>For some links, dead trees, etc. to help get you started:
>     <http://learn.perl.org>
>
>sherm--


      Your fault as a Government is My failure as a citizen


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

Date: Fri, 20 Aug 2004 00:30:15 +0800
From: Alont <end@dream.life>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <4125d57e.126216000@130.133.1.4>

what a good site, thank you :-)

at Thu, 19 Aug 2004 11:31:26 -0400
Sherm Pendley <spamtrap@dot-app.org>×íõ¸õ¸µÄÄØà«µÀ:--
>For some links, dead trees, etc. to help get you started:
>     <http://learn.perl.org>
>
>sherm--


      Your fault as a Government is My failure as a citizen


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

Date: Thu, 19 Aug 2004 17:41:10 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <4124d829$0$8717$afc38c87@news.easynet.co.uk>

Open two command shells. In one type vi fred.pl (or whatever your favourite
editor is) and in the other you can type perl fred.pl to run the program. The
results will be left on-screen in the second window after the program runs.

Honest that is all you need, the syntax highlighting in vi is particularly
useful as is a tool called perltidy. Perl programmers rarely use IDEs (unless
you count emacs :-) ) and as a result there exist very few IDEs for Perl.

No Perl programmer I have ever known uses an IDE.


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

Date: Thu, 19 Aug 2004 22:19:57 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <IZ4Vc.54$rM6.148@news.oracle.com>

Alont wrote:

> write perl program in a editor and then save it as a *.pl file, and
> then execute it? but the perl.exe will automatically exit when perl
> script is end, and I can't see the result of my script,
> the "environment" I asked is there have an editor who could execute
> perl immediately(through a HotKey or a menu)
> 

Try vim (http://www.vim.org). It should do what you seem to want it to do.

--

Abhinav
[Cancelled earlier message with incorrect web site]


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

Date: Thu, 19 Aug 2004 10:56:09 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <10i9mt58boedr8c@corp.supernews.com>

Peter Hickman wrote:
> Open two command shells. In one type vi fred.pl (or whatever your favourite
> editor is) and in the other you can type perl fred.pl to run the program. The
> results will be left on-screen in the second window after the program runs.

Or use your favorite Windows editor, open a command window and type perl 
fred.pl > results.txt to run the program. Open results.txt in your text 
editor to see the results.



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

Date: 19 Aug 2004 17:23:16 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <Xns954A7E038A37Acastleamber@130.133.1.4>

Alont <end@dream.life> wrote in news:4124d3db.125797609@130.133.1.4:

> write perl program in a editor and then save it as a *.pl file, and
> then execute it? but the perl.exe will automatically exit when perl
> script is end, and I can't see the result of my script,
> the "environment" I asked is there have an editor who could execute
> perl immediately(through a HotKey or a menu)

Use cmd.exe as a "DOS" box.

Windows key + R, type cmd.exe in the box. I made shortcuts in dirs, you can 
also use the command prompt here hack (Google for it).

I use Textpad to edit Perl files, it does syntax highlighting. You can 
invoke your script, and capture the output etc.

And stop top posting.


-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: 19 Aug 2004 17:16:27 +0200
From: 510046470588-0001@t-online.de
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <87pt5n6tv8.fsf@debian.i-did-not-set--mail-host-address--so-shoot-me>

Alont <end@dream.life> writes:
> what's the best convenient environment to exercise Perl?

the GNU Emacs, of course

Klaus Schilling


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

Date: Thu, 19 Aug 2004 15:11:53 -0400
From: thundergnat <thundergnat@hotmail.com>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <4124fb79$0$21740$61fed72c@news.rcn.com>

Alont wrote:

> write perl program in a editor and then save it as a *.pl file, and
> then execute it? but the perl.exe will automatically exit when perl
> script is end, and I can't see the result of my script,
> the "environment" I asked is there have an editor who could execute
> perl immediately(through a HotKey or a menu)
> 

There is a mini perl IDE/editor available on CPAN;

http://www.cpan.org/authors/id/T/TP/TPARVIAI/t-pad-4.04.pl

Has syntax highlighting, in editor execution and some other
interesting stuff. Perhaps most interesting, it is written
in perl.


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

Date: 19 Aug 2004 19:27:12 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <Xns954A9D338FA3asu1cornelledu@132.236.56.8>

Alont <end@dream.life> wrote in news:4125d57e.126216000@130.133.1.4:

> at Thu, 19 Aug 2004 11:31:26 -0400 Sherm Pendley <spamtrap@dot-app.org>
> ×íõ¸õ¸µÄÄØà«µÀ:--
>>For some links, dead trees, etc. to help get you started:
>>     <http://learn.perl.org>

> what a good site, thank you :-)

You can show your gratitude by reading the posting quidelines and avoiding 
top-posting.
-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

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 V10 Issue 6885
***************************************


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