[17818] in Perl-Users-Digest
Perl-Users Digest, Issue: 5238 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 4 19:16:38 2001
Date: Thu, 4 Jan 2001 16:16:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978653776-v9-i5238@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 4 Jan 2001 Volume: 9 Number: 5238
Today's topics:
oracle dbstart dbstop script for NT & unix ? <ronr@my-deja.com>
Re: oracle dbstart dbstop script for NT & unix ? mountain_arts@my-deja.com
OT: apology <adam.walton@btconnect.com>
Re: OT: apology (Tad McClellan)
Palindrome Program <rrocky@bigfoot.com>
Re: Palindrome Program <rrocky@bigfoot.com>
Re: Palindrome Program <joe+usenet@sunstarsys.com>
Re: Palindrome Program <rrocky@bigfoot.com>
Re: Palindrome Program <iltzu@sci.invalid>
Re: Palindrome Program (Tad McClellan)
Re: Palindrome Program <rrocky@bigfoot.com>
Re: Palindrome Program <joe+usenet@sunstarsys.com>
parent uses child method (OOP) ? <prlawrence@lehigh.edu>
Re: parent uses child method (OOP) ? (Tad McClellan)
Perl and File Structures <steve@reedelectronics.com>
Re: Perl and File Structures (Garry Williams)
Re: Perl and File Structures <nospam@nospam.com>
Re: Perl and File Structures <steve@reedelectronics.com>
Re: Perl and File Structures (Garry Williams)
Re: Perl and File Structures <bwalton@rochester.rr.com>
Re: Perl and File Structures <steve@reedelectronics.com>
Re: Perl and File Structures <jhelman@wsb.com>
Re: Perl and File Structures <sunymoon@geocities.com>
Re: Perl and File Structures (Garry Williams)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Jan 2001 13:21:59 GMT
From: Ronald J.H. Rood <ronr@my-deja.com>
Subject: oracle dbstart dbstop script for NT & unix ?
Message-Id: <92v91j$va6$1@nnrp1.deja.com>
Hi,
a client wants to have oracle databases on NT. He also wants a script
that can start and stop the database[s] if needed. On unix this is no
problem but on NT .... Does anybody have something nice to do this ?
Maybe a nice perl script can be made that is platform independend.
--
Ronald
http://ronr.nl/unix-dba
The best way to accellerate a computer 'running' windows is by
gravitation
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 03 Jan 2001 19:30:53 GMT
From: mountain_arts@my-deja.com
Subject: Re: oracle dbstart dbstop script for NT & unix ?
Message-Id: <92vuld$jb2$1@nnrp1.deja.com>
In article <92v91j$va6$1@nnrp1.deja.com>,
Ronald J.H. Rood <ronr@my-deja.com> wrote:
> Hi,
>
> a client wants to have oracle databases on NT. He also wants a script
> that can start and stop the database[s] if needed. On unix this is no
> problem but on NT .... Does anybody have something nice to do this ?
>
> Maybe a nice perl script can be made that is platform independend.
>
> --
> Ronald
> http://ronr.nl/unix-dba
> The best way to accellerate a computer 'running' windows is by
> gravitation
>
> Sent via Deja.com
> http://www.deja.com/
>
Here is an example of how I do this
Let me know what you think.
#!/usr/local/bin/perl
use Net::Telnet ();
main ( );
sub main {
log_write ("Stoping oracle for train \n");
log_on_to_host_name ( "my_host_name" );
shut_down_oracle_for_instance ( "instance_name");
log_off_my_host_name ( );
}
sub log_on_to_host_name {
my ( $host );
$host = shift @_;
log_write ("logon to $host\n");
$tn = new Net::Telnet (Timeout => 1000,
Errmode => 'return',
Prompt => '/root:common>/');
$tn->open( $host );
$tn->login("root", "secret_name");
@rv = $tn->cmd("hostname");
log_write ("logged on to $rv[0] \n");
}
sub shut_down_oracle_for_instance {
my ( $instance, @rv, $cmnd ) ;
$instance = shift @_;
$set_sid = "export ORACLE_SID=$instance";
@rv = $tn->prompt("/oracle/");
@rv = $tn->cmd("su - oracle");
@rv = $tn->cmd( $set_sid );
@rv = $tn->prompt("/SVRMGR>/");
@rv = $tn->cmd( "svrmgrl" );
@rv = $tn->cmd( "connect internal");
@match = grep /Connected\./ , @rv;
if ( $#match >= 0 ) {
@rv = $tn->cmd( 'select * from v$database;');
$upcase = uc $instance;
$upcase =~ s/1//;
@match = grep /$upcase/ , @rv;
log_write ("connected to $match[0]\n");
@rv = $tn->cmd( "shutdown immediate" );
foreach ( @rv ) {
log_write ( $_ );
}
log_write ("$instance shutdown\n");
}
else {
log_write ("cannot connect to instance\n");
}
@rv = $tn->prompt("/oracle/");
@rv = $tn->cmd( "exit" );
}
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 2 Jan 2001 01:38:30 -0000
From: "Adam T Walton" <adam.walton@btconnect.com>
Subject: OT: apology
Message-Id: <pga46.7443$nu5.54874@NewsReader>
Henceforth, I make an assertion to familiarise myself with the perldocs and
relevant FAQ's, rather than posting here 'blindly'. Still, perldocs doesn't
contain anything about generating high contrast foreground / background
colors... so, surely, the question was valid all along? Anyway, thanks to
Martien / El Nadie / Bart / etc I now have a sub that does exactly what I
was looking for... Thanks for your help.
I feel suitably ashamed and admonished for kick-starting this fuss in the
first place [thanks to Tad for giving me a 'stern' insight into the way
things are run around here :) ] I'll go back to lurking and trying to fine
tune my perl and my whit until they are as acerbic, pithy and to the point
as Abigail's.
Sorry
Adam
------------------------------
Date: Mon, 1 Jan 2001 22:26:07 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: OT: apology
Message-Id: <slrn952iif.df4.tadmc@magna.metronet.com>
Adam T Walton <adam.walton@btconnect.com> wrote:
>Henceforth, I make an assertion to familiarise myself with the perldocs and
>relevant FAQ's, rather than posting here 'blindly'.
Too bad the blow job stuff has already been said.
>Still, perldocs doesn't
>contain anything about generating high contrast foreground / background
>colors... so, surely, the question was valid all along?
The First Test of On-Topicness, adjusted to your situation:
Would how you "generate high contrast" be fundamentally different
if you were coding in C or Java or Visual Basic instead of Perl?
if not, then it does not matter what language you use to code
it up, and so does not belong in any language newsgroup.
A web or artistic newsgroup might provide an algorithm.
Once you know what you want to do, you code it up in Perl. If
it "doesn't work", then it would be on-topic to ask how to
code up the algorithm in Perl. Deciding on an algorithm is
certainly not on-topic here.
If it is about Perl, then ask it here.
If it is about some application area that you are using Perl in,
then ask in a newsgroup related to the application area (WWW for
this particular subject, I guess).
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 02 Jan 2001 11:25:49 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Palindrome Program
Message-Id: <3A522B3D.8C4AF4B7@bigfoot.com>
Hi,
I am a PERL Newbie.
I found this program on someone's webpage which finds a palindrome
1 #!/usr/local/bin/perl
2 $alary = @work = <STDIN>;
3 for (@work) {
4 chomp if $alary;
5 chop unless $alary;
6 tr/a-z/A-Z/;
7 s[ \W +] {}oxg ;
8 $ynergy = #1; $$ = "winner"; $_ = "loser";
9 join $tock_option,
10 reverse split //;
11 print "$$\n" if ($$ eq $ynergy);
12 print "$_\n" if ($_ eq $ynergy);
13 }
I am trying to understand the program
This is what I figured out.
Line 2 - reads all lines from Std Input. It goes into an array of
strings called work. the variable "alary" holds the no of strings
Line 3 - iterates through all the lines
Line 4-5 - chomp/chop the lines
Line 6 - transliterates everything to upper case
Line 7 - Can't understand.
Line 8 - Can't understand .
What does "$ynergy = #1" mean ?
Line 9-10 Again can't understand.
Can anyone help ?
Also do all the funny variable names have some significance ?
--
Rocky
RSC - http://www.slack.net/~shiva/rsc.html
------------------------------
Date: Tue, 02 Jan 2001 11:48:33 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Re: Palindrome Program
Message-Id: <3A523091.77DB7B8B@bigfoot.com>
Rocky Raccoon wrote:
>
> Hi,
> I am a PERL Newbie.
> I found this program on someone's webpage which finds a palindrome
> 1 #!/usr/local/bin/perl
> 2 $alary = @work = <STDIN>;
> 3 for (@work) {
> 4 chomp if $alary;
> 5 chop unless $alary;
> 6 tr/a-z/A-Z/;
> 7 s[ \W +] {}oxg ;
> 8 $ynergy = #1; $$ = "winner"; $_ = "loser";
> 9 join $tock_option,
> 10 reverse split //;
> 11 print "$$\n" if ($$ eq $ynergy);
> 12 print "$_\n" if ($_ eq $ynergy);
> 13 }
>
> I am trying to understand the program
> This is what I figured out.
> Line 2 - reads all lines from Std Input. It goes into an array of
> strings called work. the variable "alary" holds the no of strings
> Line 3 - iterates through all the lines
> Line 4-5 - chomp/chop the lines
> Line 6 - transliterates everything to upper case
> Line 7 - Can't understand.
> Line 8 - Can't understand .
> What does "$ynergy = #1" mean ?
> Line 9-10 Again can't understand.
>
> Can anyone help ?
>
> Also do all the funny variable names have some significance ?
I figured it out.
It's actually
$ynergy = join $tock_option, reverse split //;
However what's
s[ \W +] {}oxg;
--
Rocky
RSC - http://www.slack.net/~shiva/rsc.html
------------------------------
Date: 02 Jan 2001 15:06:11 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Palindrome Program
Message-Id: <m3u27hyb0s.fsf@mumonkan.sunstarsys.com>
Rocky Raccoon <rrocky@bigfoot.com> writes:
> Hi,
> I am a PERL Newbie.
No you're not - you are a Perl/perl newbie :)
> I found this program on someone's webpage which finds a palindrome
> 1 #!/usr/local/bin/perl
> 2 $alary = @work = <STDIN>;
> 3 for (@work) {
> 4 chomp if $alary;
> 5 chop unless $alary;
> 6 tr/a-z/A-Z/;
> 7 s[ \W +] {}oxg ;
> 8 $ynergy = #1; $$ = "winner"; $_ = "loser";
> 9 join $tock_option,
> 10 reverse split //;
> 11 print "$$\n" if ($$ eq $ynergy);
> 12 print "$_\n" if ($_ eq $ynergy);
> 13 }
>
> I am trying to understand the program
> This is what I figured out.
> Line 2 - reads all lines from Std Input. It goes into an array of
> strings called work. the variable "alary" holds the no of strings
> Line 3 - iterates through all the lines
> Line 4-5 - chomp/chop the lines
good- but only one of them (lines 4 or 5)
will ever be effective. Can you see which,
and why?
> Line 6 - transliterates everything to upper case
> Line 7 - Can't understand.
> Line 8 - Can't understand .
> What does "$ynergy = #1" mean ?
> Line 9-10 Again can't understand.
>
> Can anyone help ?
Here's a few tips:
line 7 uses alternate quoting styles for each
portion of the substitution; and of the flags
used, only the "gx" flags are relevant. It
could have been written
s/\W//g;
line 8 is really a multiline statement that
spans lines 8-10. $tock_option = '' here,
and these are the key lines in understanding
the program.
for line 11, see
% man perlvar
($$ eq $ynergy) is most likely always false.
line 12 is the palindrome test.
> Also do all the funny variable names have some significance ?
I think it's meant to be amusing, but it's certainly not
helpful in making it clear what the code is supposed to do.
That's probably the point, though :)
btw: with a good programming text editor, you will
have a much easier time figuring out crazy code
like this. emacs has a highlighting mode (font-lock)
under cperl that makes it easy to figure out.
That's probably cheating, but that's what I did :)
HTH
--
Joe Schaefer
------------------------------
Date: Tue, 02 Jan 2001 12:17:52 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Re: Palindrome Program
Message-Id: <3A523770.99EA1CCB@bigfoot.com>
Joe Schaefer wrote:
> > I found this program on someone's webpage which finds a palindrome
> > 1 #!/usr/local/bin/perl
> > 2 $alary = @work = <STDIN>;
> > 3 for (@work) {
> > 4 chomp if $alary;
> > 5 chop unless $alary;
> > 6 tr/a-z/A-Z/;
> > 7 s[ \W +] {}oxg ;
> > 8 $ynergy = #1; $$ = "winner"; $_ = "loser";
> > 9 join $tock_option,
> > 10 reverse split //;
> > 11 print "$$\n" if ($$ eq $ynergy);
> > 12 print "$_\n" if ($_ eq $ynergy);
> > 13 }
> >
> good- but only one of them (lines 4 or 5)
> will ever be effective. Can you see which,
> and why?
if the file is empty then alary will be 0.
So chop will happen. Other wise chomp will happen.
>
> > Line 6 - transliterates everything to upper case
> > Line 7 - Can't understand.
> > Line 8 - Can't understand .
> > What does "$ynergy = #1" mean ?
> > Line 9-10 Again can't understand.
> >
> > Can anyone help ?
>
> Here's a few tips:
>
> line 7 uses alternate quoting styles for each
> portion of the substitution; and of the flags
> used, only the "gx" flags are relevant. It
> could have been written
>
> s/\W//g;
What is the 'x' flag ?
>
> line 8 is really a multiline statement that
> spans lines 8-10. $tock_option = '' here,
> and these are the key lines in understanding
> the program.
So the chap has written "join $tock_option, reverse split //;"
instead of
join ' ', reverse split //;
just to obfuscate it.
>
> for line 11, see
>
> % man perlvar
>
> ($$ eq $ynergy) is most likely always false.
>
> line 12 is the palindrome test.
What's $$ ?
--
Rocky
RSC - http://www.slack.net/~shiva/rsc.html
------------------------------
Date: 2 Jan 2001 20:38:54 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Palindrome Program
Message-Id: <978466892.7906@itz.pp.sci.fi>
In article <3A522B3D.8C4AF4B7@bigfoot.com>, Rocky Raccoon wrote:
>
>1 #!/usr/local/bin/perl
>2 $alary = @work = <STDIN>;
>3 for (@work) {
>4 chomp if $alary;
>5 chop unless $alary;
>6 tr/a-z/A-Z/;
>7 s[ \W +] {}oxg ;
>8 $ynergy = #1; $$ = "winner"; $_ = "loser";
>9 join $tock_option,
>10 reverse split //;
>11 print "$$\n" if ($$ eq $ynergy);
>12 print "$_\n" if ($_ eq $ynergy);
>13 }
>
>I am trying to understand the program
>
>Also do all the funny variable names have some significance ?
Not really. Only $_ and $$ are special.
Let's start by feeding it through B::Deparse to de-obfuscate it:
$alary = @work = <STDIN>;
foreach $_ (@work) {
chomp $_ if $alary;
chop $_ unless $alary;
tr/a-z/A-Z/;
s/ \W +//gox;
$ynergy = join($tock_option, reverse(split(//, $_, 0)));
print "$$\n" if $$ eq $ynergy;
print "$_\n" if $_ eq $ynergy;
}
Now let's remove conditions that can never happen (well, $$ could
equal $ynergy, but it's bloody unlikely):
$alary = @work = <STDIN>;
foreach $_ (@work) {
chomp $_;
tr/a-z/A-Z/;
s/ \W +//gox;
$ynergy = join($tock_option, reverse(split(//, $_, 0)));
print "$_\n" if $_ eq $ynergy;
}
..and some unnecessary variables and substitution modifiers:
foreach (<STDIN>) {
chomp;
tr/a-z/A-Z/;
s/\W+//g;
$ynergy = join "", reverse split //;
print "$_\n" if $_ eq $ynergy;
}
But hey.. the join() and the split() are useless, since reverse()
works character by character in scalar context anyway. And we don't
really need $ynergy to hold the reversed string:
foreach (<STDIN>) {
chomp;
tr/a-z/A-Z/;
s/\W+//g;
print "$_\n" if $_ eq reverse $_;
}
There. Can you see what it's doing now?
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Tue, 2 Jan 2001 13:53:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Palindrome Program
Message-Id: <slrn9548u4.fp1.tadmc@magna.metronet.com>
Rocky Raccoon <rrocky@bigfoot.com> wrote:
>What is the 'x' flag ?
Perl's operators (including the pattern match operator) are described in:
perldoc perlop
>What's $$ ?
Perl's variables are described in:
perldoc perlvar
Become empowered! Use the docs that shipped with the software
that you are using, and answer questions yourself in less
time than it takes to ask thousands of other people to look
it up for you.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 02 Jan 2001 12:53:50 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Re: Palindrome Program
Message-Id: <3A523FDD.70AE9189@bigfoot.com>
Tad McClellan wrote:
> Perl's operators (including the pattern match operator) are described in:
>
> perldoc perlop
>
> >What's $$ ?
>
> Perl's variables are described in:
>
> perldoc perlvar
>
Thank you.
Found both the stuff.
I was trying to do
man instead of perldoc unsuccessfully.
--
Rocky
RSC - http://www.slack.net/~shiva/rsc.html
------------------------------
Date: 02 Jan 2001 15:55:47 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Palindrome Program
Message-Id: <m3pui5y8q4.fsf@mumonkan.sunstarsys.com>
Rocky Raccoon <rrocky@bigfoot.com> writes:
> Joe Schaefer wrote:
> > > I found this program on someone's webpage which finds a palindrome
> > > 1 #!/usr/local/bin/perl
> > > 2 $alary = @work = <STDIN>;
> > > 3 for (@work) {
> > > 4 chomp if $alary;
> > > 5 chop unless $alary;
> > > 6 tr/a-z/A-Z/;
> > > 7 s[ \W +] {}oxg ;
> > > 8 $ynergy = #1; $$ = "winner"; $_ = "loser";
> > > 9 join $tock_option,
> > > 10 reverse split //;
> > > 11 print "$$\n" if ($$ eq $ynergy);
> > > 12 print "$_\n" if ($_ eq $ynergy);
> > > 13 }
> > >
> > good- but only one of them (lines 4 or 5)
> > will ever be effective. Can you see which,
> > and why?
>
> if the file is empty then alary will be 0.
> So chop will happen. Other wise chomp will happen.
Almost. When the "file" is empty, what about line 3?
> > Here's a few tips:
> >
> > line 7 uses alternate quoting styles for each
> > portion of the substitution; and of the flags
> > used, only the "gx" flags are relevant. It
> > could have been written
> >
> > s/\W//g;
>
> What is the 'x' flag ?
It has to do with ignoring space characters in regexps.
That can make them more readable, but not in this case.
See
% man perlre
for the details.
> > % man perlvar
> >
> > ($$ eq $ynergy) is most likely always false.
> >
> > line 12 is the palindrome test.
>
> What's $$ ?
It's time to crack into Perl's documentation
to learn more. That means reading the manpages,
or the ActiveState documentation that has most
everything in html form. If you're on a *nix
box, type
% man perl
to see a list of all the relevant perl
doecumentation. Also, perl comes bundled with
it's own documentation locator, perldoc:
% man perldoc
perldoc is quite useful for locating FAQs
on your computer. It permits keyword sarches
of the FAQ questions (not answers, though).
For example, try
% perldoc -q perl
to read the FAQs about Perl/perl itself.
If you're not on a *nix-like OS, I'm not sure
exactly how "perldoc" and "man" work for you, but
in principal it should be similar to the *nix
commands.
HTH
--
Joe Schaefer
------------------------------
Date: Tue, 2 Jan 2001 14:44:48 -0600
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: parent uses child method (OOP) ?
Message-Id: <92tek2$g1o@fidoii.CC.Lehigh.EDU>
Hello,
I have need for a parent module to sometimes use a method from whatever
child invokes it. Here is a three-file sample that works, but raises a
question:
---------------------------------------------
package Test02;
sub print_value {
my $self = shift;
print $self->get_value(shift), "\n";
}
1;
---------------------------------------------
package Test01;
use base (Test02);
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {
key01 => 'value01',
};
return bless $self, $class;
}
sub get_value {
my $self = shift;
return $self->{shift()};
}
1;
---------------------------------------------
#!/usr/local/bin/perl -w
use diagnostics;
use strict;
use Test01;
my $obj = Test01->new;
$obj->print_value('key01');
---------------------------------------------
Question: How can I test from Test02 to be sure the requisite child method
is available before attempting to use it?
Thanks,
All comments welcome,
Phil R Lawrence
------------------------------
Date: Tue, 2 Jan 2001 15:14:05 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: parent uses child method (OOP) ?
Message-Id: <slrn954dkd.ftp.tadmc@magna.metronet.com>
Phil R Lawrence <prlawrence@lehigh.edu> wrote:
>Question: How can I test from Test02 to be sure the requisite child method
>is available before attempting to use it?
perldoc perlobj
---------------------------
=item can(METHOD)
C<can> checks to see if its object has a method called C<METHOD>,
if it does then a reference to the sub is returned, if it does not then
I<undef> is returned.
---------------------------
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 31 Dec 2000 13:45:27 -0500
From: "Steve Reed" <steve@reedelectronics.com>
Subject: Perl and File Structures
Message-Id: <92nuuc0caf@enews1.newsguy.com>
OK, I've come to the realization that it's time to visit the well of
information in this newsgroup and ask for some guidance.
I'm in the midst of writing a Perl application that reads and writes
information via Telnet from a network device. In my C programming days, I
would (after determining the exact information I want to store) create a
structure for the data and then simply read and write from the structure. I
understand that in Perl I could use an array or hash and write the data in
the form of text strings out to a file, but that presents a couple of
problems I'd rather avoid. One, I don't want the data being stored to be
able to be easily seen by simply reading the text file and, two, I don't
want the file to be configurable by hand by simply adding and deleting
lines.
Does Perl, or some add-on module, offer the ability to create file
"structures" where data can be easily stored and retrieved, and the data is
not stored in a way that can be easily modified with a text editor? I want
to be able to read and write from a data file in a snap - quickly reading
and/or changing certain values (such as IP address information).
Thanks in advance,
Steve
--
----------------------------------------------------------------------------
------------------------
Satellite Freedom for business-class broadband Satellite Internet
http://www.satellitefreedom.com
Toll Free: 1-877-546-6840
----------------------------------------------------------------------------
------------------------
------------------------------
Date: Sun, 31 Dec 2000 19:40:23 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Perl and File Structures
Message-Id: <HYL36.131$Dm5.6892@eagle.america.net>
On Sun, 31 Dec 2000 13:45:27 -0500, Steve Reed
<steve@reedelectronics.com> wrote:
>Does Perl, or some add-on module, offer the ability to create file
^^^^^^^^^^^^^^^^^^
>"structures" where data can be easily stored and retrieved, and the data is
>not stored in a way that can be easily modified with a text editor? I want
>to be able to read and write from a data file in a snap - quickly reading
>and/or changing certain values (such as IP address information).
Check CPAN for the Storable module.
--
Garry Williams
------------------------------
Date: 31 Dec 2000 22:20:46 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Perl and File Structures
Message-Id: <92obfu$7rs$0@216.155.33.14>
In article <92nuuc0caf@enews1.newsguy.com>, "Steve Reed"
<steve@reedelectronics.com> wrote:
| OK, I've come to the realization that it's time to visit the well of
| information in this newsgroup and ask for some guidance.
|
| I'm in the midst of writing a Perl application that reads and writes
| information via Telnet from a network device. In my C programming
| days, I would (after determining the exact information I want to
| store) create a structure for the data and then simply read and
| write from the structure. I understand that in Perl I could use an
| array or hash and write the data in the form of text strings out to
| a file, but that presents a couple of problems I'd rather avoid.
| One, I don't want the data being stored to be able to be easily seen
| by simply reading the text file and, two, I don't want the file to
| be configurable by hand by simply adding and deleting lines.
|
| Does Perl, or some add-on module, offer the ability to create file
| "structures" where data can be easily stored and retrieved, and the
| data is not stored in a way that can be easily modified with a text
| editor? I want to be able to read and write from a data file in a
| snap - quickly reading and/or changing certain values (such as IP
| address information).
There's several modules you can look into that I've been recently
playing with myself..
Storable has a fairly short learning curve, but may be too simplistic
for your needs.
DBI, (and the accompanying Text::CSV_XS, SQL::Statement, DBD::File,
DBD::CSV, and other DBD modules (like mySQL and mSQL)) may fit the bill
more succinctly, but have a much sharper learning curve. (for which I
would recommend the O'Reilly "Learning the Perl DBI" as a good place to
start (mentions Storable as well)
Then again, these could be complete overkill for what you need. That
decision I leave up to you, and the recommendations of the other
denizens of comp.lang.perl.misc.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sun, 31 Dec 2000 16:36:00 -0500
From: "Steve Reed" <steve@reedelectronics.com>
Subject: Re: Perl and File Structures
Message-Id: <92o8rg0da6@enews2.newsguy.com>
Thanks for the tip - I found the Storable package and installed it. It
looks like what I need but the documentation bites (I'm sure the guy who
wrote it understands it, tho).
If anyone knows of any well-documented examples of how to use the Storable
module I'd very much appreciate it.
Many thanks,
Steve
--
----------------------------------------------------------------------------
------------------------
Satellite Freedom for business-class broadband Satellite Internet
http://www.satellitefreedom.com
Toll Free: 1-877-546-6840
----------------------------------------------------------------------------
------------------------
"Garry Williams" <garry@zvolve.com> wrote in message
news:HYL36.131$Dm5.6892@eagle.america.net...
> On Sun, 31 Dec 2000 13:45:27 -0500, Steve Reed
> <steve@reedelectronics.com> wrote:
>
> >Does Perl, or some add-on module, offer the ability to create file
> ^^^^^^^^^^^^^^^^^^
> >"structures" where data can be easily stored and retrieved, and the data
is
> >not stored in a way that can be easily modified with a text editor? I
want
> >to be able to read and write from a data file in a snap - quickly reading
> >and/or changing certain values (such as IP address information).
>
> Check CPAN for the Storable module.
>
> --
> Garry Williams
------------------------------
Date: Sun, 31 Dec 2000 22:44:32 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Perl and File Structures
Message-Id: <kFO36.173$Dm5.8914@eagle.america.net>
[ Re-ordered the flow of time ]
[ Fixed broken line wrapping ]
On Sun, 31 Dec 2000 16:36:00 -0500, Steve Reed
<steve@reedelectronics.com> wrote:
>"Garry Williams" <garry@zvolve.com> wrote in message
>news:HYL36.131$Dm5.6892@eagle.america.net...
>> On Sun, 31 Dec 2000 13:45:27 -0500, Steve Reed
>> <steve@reedelectronics.com> wrote:
>>
>> >Does Perl, or some add-on module, offer the ability to create file
>> ^^^^^^^^^^^^^^^^^^
>> >"structures" where data can be easily stored and retrieved, and
>> >the data is not stored in a way that can be easily modified with a
>> >text editor? I want to be able to read and write from a data file
>> >in a snap - quickly reading and/or changing certain values (such
>> >as IP address information).
>>
>> Check CPAN for the Storable module.
>>
>Thanks for the tip - I found the Storable package and installed it. It
>looks like what I need but the documentation bites (I'm sure the guy who
>wrote it understands it, tho).
>
>If anyone knows of any well-documented examples of how to use the
>Storable module I'd very much appreciate it.
Did you try the example in the Storable manual page? What happened?
What part did you not understand?
--
Garry Williams
------------------------------
Date: Mon, 01 Jan 2001 00:24:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl and File Structures
Message-Id: <3A4FCEAA.921C03AB@rochester.rr.com>
Steve Reed wrote:
>
> Thanks for the tip - I found the Storable package and installed it. It
> looks like what I need but the documentation bites (I'm sure the guy who
> wrote it understands it, tho).
>
> If anyone knows of any well-documented examples of how to use the Storable
> module I'd very much appreciate it.
...
> Steve
...
I don't think that's really being fair to the docs for Storable. I find
them well-written, complete, and with appropriate examples. If you want
more info, try recipies 11.12 and 11.13 in Perl Cookbook and Chapter 10
(Persistence) of Advanced Perl Programming.
--
Bob Walton
------------------------------
Date: Sun, 31 Dec 2000 20:49:40 -0500
From: "Steve Reed" <steve@reedelectronics.com>
Subject: Re: Perl and File Structures
Message-Id: <92onpr015h8@enews1.newsguy.com>
Hmmm...I'm obviously not looking in the right place for the full
documentation - I was looking at what documentation I could find at the
CPAN.ORG site. Running Windows here. Where would the manual pages be
located from the Storable install? (yeah, yeah, another dumb newbie
question).
Happy New Year,
Steve
--
----------------------------------------------------------------------------
------------------------
Satellite Freedom for business-class broadband Satellite Internet
http://www.satellitefreedom.com
Toll Free: 1-877-546-6840
----------------------------------------------------------------------------
------------------------
"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:3A4FCEAA.921C03AB@rochester.rr.com...
> Steve Reed wrote:
> >
> > Thanks for the tip - I found the Storable package and installed it. It
> > looks like what I need but the documentation bites (I'm sure the guy who
> > wrote it understands it, tho).
> >
> > If anyone knows of any well-documented examples of how to use the
Storable
> > module I'd very much appreciate it.
> ...
> > Steve
> ...
> I don't think that's really being fair to the docs for Storable. I find
> them well-written, complete, and with appropriate examples. If you want
> more info, try recipies 11.12 and 11.13 in Perl Cookbook and Chapter 10
> (Persistence) of Advanced Perl Programming.
> --
> Bob Walton
------------------------------
Date: Mon, 01 Jan 2001 03:06:05 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Perl and File Structures
Message-Id: <8osv4tghgv5olvp530o5bhvdfojjr07egr@4ax.com>
On Sun, 31 Dec 2000 20:49:40 -0500, "Steve Reed"
<steve@reedelectronics.com> wrote:
>Hmmm...I'm obviously not looking in the right place for the full
>documentation - I was looking at what documentation I could find at the
>CPAN.ORG site. Running Windows here. Where would the manual pages be
>located from the Storable install? (yeah, yeah, another dumb newbie
>question).
Assuming you're running Activestate (and build 6xx since the 5xx
builds did some weird things with the docs), go to the Start Menu ->
Programs -> ActivePerl -> Documentation.
This will load an HTML page in your default browser. Then scan down
the list in the left frame (it'll be near the bottom, as Storable is
rather late in the alphabet).
Alternatively, should you have installed Perl in C:\Perl, then the
following link should work (adjust as necessary)...
file:///c%7C/perl/html/site/lib/Storable.html
Hope this helps, and Happy New Year to you,
JH
------------------------------
Date: Mon, 01 Jan 2001 19:43:00 GMT
From: "Sean" <sunymoon@geocities.com>
Subject: Re: Perl and File Structures
Message-Id: <85546.113786$7I.11523928@typhoon.nyroc.rr.com>
I do not have the "Storable" module, but, you may want to try:
C:\>perldoc Storable
Assuming ?:\perl\bin is in your PATH= -- it should be, by default.
--
Sean S. -:- ICQ: 1826323
(Email: sunymoon <AT> GeoCities >DOT< com )
Steve Reed wrote in message <92onpr015h8@enews1.newsguy.com>...
>Hmmm...I'm obviously not looking in the right place for the full
>documentation - I was looking at what documentation I could find at the
>CPAN.ORG site. Running Windows here. Where would the manual pages be
>located from the Storable install? (yeah, yeah, another dumb newbie
>question).
>
>Happy New Year,
>
>Steve
>
>--
>---------------------------------------------------------------------------
-
>------------------------
>Satellite Freedom for business-class broadband Satellite Internet
>http://www.satellitefreedom.com
>Toll Free: 1-877-546-6840
>---------------------------------------------------------------------------
-
>------------------------
>"Bob Walton" <bwalton@rochester.rr.com> wrote in message
>news:3A4FCEAA.921C03AB@rochester.rr.com...
>> Steve Reed wrote:
>> >
>> > Thanks for the tip - I found the Storable package and installed it. It
>> > looks like what I need but the documentation bites (I'm sure the guy
who
>> > wrote it understands it, tho).
>> >
>> > If anyone knows of any well-documented examples of how to use the
>Storable
>> > module I'd very much appreciate it.
>> ...
>> > Steve
>> ...
>> I don't think that's really being fair to the docs for Storable. I find
>> them well-written, complete, and with appropriate examples. If you want
>> more info, try recipies 11.12 and 11.13 in Perl Cookbook and Chapter 10
>> (Persistence) of Advanced Perl Programming.
>> --
>> Bob Walton
>
>
------------------------------
Date: Mon, 01 Jan 2001 20:41:38 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Perl and File Structures
Message-Id: <6Y546.351$Dm5.17187@eagle.america.net>
On Sun, 31 Dec 2000 20:49:40 -0500, Steve Reed
<steve@reedelectronics.com> wrote [upside-down]:
>Hmmm...I'm obviously not looking in the right place for the full
>documentation - I was looking at what documentation I could find at
>the CPAN.ORG site. Running Windows here. Where would the manual
>pages be located from the Storable install? (yeah, yeah, another dumb
>newbie question).
In the same place as all of the other manual pages for perl are.
On your computer.
Under the `Online (sic) Documentaion' shortcut in the ActivePerl
folder. This is probably accessible from your `Start' menu.
--
Garry Williams
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 5238
**************************************