[26118] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8313 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 11 03:05:26 2005

Date: Thu, 11 Aug 2005 00:05:05 -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, 11 Aug 2005     Volume: 10 Number: 8313

Today's topics:
    Re: desc $table in DBI Oracle <sdn.girths00869@zoemail.net>
    Re: Efficiently search in large files? (Robert Maas, see http://tinyurl.com/uh3t)
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
        FAQ . <comdog@panix.com>
    Re: FAQ . <darkon.tdo@gmail.com>
    Re: FAQ . <josef.moellers@fujitsu-siemens.com>
        Language question -- check for invalid hash key? <malchore@comcast.net>
    Re: Language question -- check for invalid hash key? <someone@example.com>
    Re: OT how to fill out a form and submit?? <noreply@gunnar.cc>
        Perl Solaris/Linux LASTLOG <drew@drew.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 11 Aug 2005 01:08:24 -0500
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: desc $table in DBI Oracle
Message-Id: <Xns96AF160A97B75sdn.comcast@216.196.97.136>

xhoster@gmail.com wrote in news:20050801114637.177$AO@newsreader.com:

> ngoc <ngoc@yahoo.com> wrote:
>> Hi
>> I use  "my $header_sql = qq { desc $table };". It does not work.
>> But "select column_name from all_tab_columns where table_name =
>> \'$table\'" work.
>> My problem is "desc $table" matching which "select * from $table"
>> than
>> select column_name ...........
>> (I mean data and column name order matching).
>> Thanks
> 
> I believe, but am not certain, that "desc" is not valid Oracle SQL
> syntax. Rather, it is a command to the oracle tool SQLPLUS.  So when
> you are using SQLPLUS, it intercepts the desc command and processes it
> itself.  Since perl is connecting directly to Oracle, not via SQLPLUS,
> then the command does not work from Perl.
> 
> Xho
> 

You are correct, Xho.

-- 
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`


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

Date: Wed, 10 Aug 2005 18:41:29 -0700
From: rem642b@Yahoo.Com (Robert Maas, see http://tinyurl.com/uh3t)
Subject: Re: Efficiently search in large files?
Message-Id: <REM-2005aug10-005@Yahoo.Com>

(I tried to post a followup several weeks ago, but my article never
 appeared, so I tried re-posting from my backup copy an hour or so
 ago but again it hasn't appeared, so I'm switching newsgroup now
 for a third try:)
> Newsgroups: perl.beginners
> Subject: Efficiently search in large files?
> References: <A1FE021ABD24D411BE2D0050DA450B920199409A@MERKUR>
> Message-ID: <BAY104-F42998BBB5E496210209DADDE90@phx.gbl>
> From: ayajiang@hotmail.com (Nan Jiang)
> I'm developing a simple search engine under cgi-bin of a webserver.
> The problem is my database is a single 2GB xml file, when I use
> XML:Twig to maintain searching in the file, it usually takes a v.long
> time to process

I don't know about XML:Twig, from your wording I assume it parses the
entire XML file, or most of it up to the point of a match, each time it
needs to satisfy a query, right? I suggest an alternate approach: Look
carefully at the structure of your XML data, and see if it can be
mapped to a set of tables in a relational database. Then write a
program to do that mapping, then from that point forward execute
queries against the database instead of against the raw XML file. Is
this idea practical for your situation?

If that's not practical, the alternative is to compile an index of any
terms you might later want to search for, with each result set being a
list of pointers into the huge XML file. Then you can execute searches
against your index, and then use random access to directly fetch the
relevant data from the XML file. If records to be fetched are very
small, then it might be better to simply copy all the data into the
index so you can avoid the extra step of accessing the XML file.

Is the XML file something that might change from day to day, or
something relatively stable?


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

Date: 11 Aug 2005 04:25:34 GMT
From: <jari.aalto <AT> poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1123734263@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto A T poboxes com

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            and XEmacs port

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/
        http://math.berkeley.edu/~ilya/software/emacs/
        by Ilya Zakharevich

        CPerl is major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr <AT> ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: Thu, 11 Aug 2005 04:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ .
Message-Id: <ddeill$ijt$1@reader2.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

 .: 



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Thu, 11 Aug 2005 04:08:54 -0000
From: darkon <darkon.tdo@gmail.com>
Subject: Re: FAQ .
Message-Id: <Xns96AF18018660darkon@216.168.3.30>

PerlFAQ Server <comdog@panix.com> wrote:

> This message is one of several periodic postings to
> comp.lang.perl.misc intended to make it easier for perl
> programmers to find answers to common questions. The core of
> this message represents an excerpt from the documentation
> provided with Perl. 
> 
> -----------------------------------------------------------------
> 
> .: 
> 
> 
> 
> -----------------------------------------------------------------

What is this, zen FAQ?


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

Date: Thu, 11 Aug 2005 08:37:59 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: FAQ .
Message-Id: <dderjp$luo$1@nntp.fujitsu-siemens.com>

darkon wrote:
> PerlFAQ Server <comdog@panix.com> wrote:
>=20
>=20
>>This message is one of several periodic postings to
>>comp.lang.perl.misc intended to make it easier for perl
>>programmers to find answers to common questions. The core of
>>this message represents an excerpt from the documentation
>>provided with Perl.=20
>>
>>-----------------------------------------------------------------
>>
>>.:=20
>>
>>
>>
>>-----------------------------------------------------------------
>=20
>=20
> What is this, zen FAQ?

No, it's the default case!

SCNR,

Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Wed, 10 Aug 2005 21:12:54 -0500
From: "Richard G." <malchore@comcast.net>
Subject: Language question -- check for invalid hash key?
Message-Id: <RP-dnZ2dnZ0oVAf2nZ2dndUvZ9-dnZ2dRVn-yZ2dnZ0@comcast.com>

Hi.

Kinda new to Perl.  I've read the Programming Perl book (2nd ed, not
newest.)  I have a script I recently wrote that stores key/data pairs in a
hash for use as a look-up table during script execution.  The script reads a
large data file, extracts string fragments from each line, chops the last
character from a string and uses that character as the key to lookup
information in my hash.  Basicaly, it looks like this:

my %Hash_Table = (
A => "Data for A",
B => "Data for B",
C => "Data for C"
);

$String _Fragment = substr ($Long_String, $x, $y);
$Key_Char = chop $String_Fragment;
$Data_Info = $Hash_Table{$Key_Char};

Trouble is I can't guarentee the character I chop from String_Fragment will
be a valid Key in the hash.  I don't mind if I run across an invalid key,
but how can I gracefully first check if it's a valid key before I attempt to
access the data in the hash?  The perl book I have doesn't explain the
result if you use in invalid Key in a hash variable.

The reason I ask is because I capture all STDOUT and STDERR to files, and I
run perl with the -w flag so I can capture all warning messages.  Well, with
the -w flag, perl complains I'm assigning an unitialized value to a
variable.

The solution I figured was to wrap the hash access in a conditional if
statement:

$Data_Info = $Hash_Table{$Key_Char} if ($Hash_Table{$Key_Char});

This works, in that it wont kick a warning message if I use an invalid key.
I was just curious if there's a better way, and to do the verification and
assignment all in one statment without needing to access the keypair twice?
What I did feels sorta ameturish.  If there's something more elegent (or
more complex for job security) I'm curious what it is.




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

Date: Thu, 11 Aug 2005 03:09:39 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Language question -- check for invalid hash key?
Message-Id: <TjzKe.174051$9A2.52022@edtnps89>

Richard G. wrote:
> 
> Kinda new to Perl.  I've read the Programming Perl book (2nd ed, not
> newest.)  I have a script I recently wrote that stores key/data pairs in a
> hash for use as a look-up table during script execution.  The script reads a
> large data file, extracts string fragments from each line, chops the last
> character from a string and uses that character as the key to lookup
> information in my hash.  Basicaly, it looks like this:
> 
> my %Hash_Table = (
> A => "Data for A",
> B => "Data for B",
> C => "Data for C"
> );
> 
> $String _Fragment = substr ($Long_String, $x, $y);
> $Key_Char = chop $String_Fragment;

Why not use unpack() and get both values in one statement?

> $Data_Info = $Hash_Table{$Key_Char};
> 
> Trouble is I can't guarentee the character I chop from String_Fragment will
> be a valid Key in the hash.  I don't mind if I run across an invalid key,
> but how can I gracefully first check if it's a valid key before I attempt to
> access the data in the hash?

perldoc -f exists

> The perl book I have doesn't explain the
> result if you use in invalid Key in a hash variable.

Look for the word "autovivification".



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 11 Aug 2005 00:29:38 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: OT how to fill out a form and submit??
Message-Id: <3lvdeoF14eqbmU1@individual.net>

Travis wrote:
> I want to write a perl script to fill out a form and submit it.
> Is this how it is done?
> 
> print
> "Location:http://www.somewhere.com/wwwboard/cgi-bin/wwwboard/wwwboard.pl?nam
> e=cindy&subject=new&body=something";

A form is one way to pass data to a script. What you are trying to do 
above is passing data to wwwboard.pl via a query string appended to the 
URL of a redirect request, and thus not make use of any form.

> Assuming that works..

It should, provided that the script is designed to accept GET requests.

> How do I get it to continue the script instead of ending
> after the print location?

If you have that need, you probably want to make use of the libwww-perl 
'family' of Perl modules, e.g. LWP::UserAgent.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 10 Aug 2005 23:12:56 -0400
From: drew <drew@drew.net>
Subject: Perl Solaris/Linux LASTLOG
Message-Id: <H8GdnZ2dnZ3WvEXtnZ2dnepdZ9-dnZ2dRVn-0p2dnZ0@comcast.com>

i have to process a large amount of data and i cannot perform this on 
the invidual servers for either security sake or the way we have been setup.


here is the script from the  PERL COOKBOOK  to show the closest approach

#!/usr/bin/perl
# laston - find out when given user last logged on
use User::pwent;
use IO::Seekable qw(SEEK_SET);

open (LASTLOG, "/var/log/lastlog") or die "can't open /usr/adm/lastlog: $!";

$typedef = 'L A12 A16';  # linux fmt; sunos is "L A8 A16"
$sizeof  = length(pack($typedef, ()));

for $user (@ARGV) {
     $U = ($user =~ /^\d+$/) ? getpwuid($user) : getpwnam($user);
     unless ($U) { warn "no such uid $user\n"; next; }
     seek(LASTLOG, $U->uid * $sizeof, SEEK_SET) or die "seek failed: $!";
     read(LASTLOG, $buffer, $sizeof) == $sizeof or next;
     ($time, $line, $host) = unpack($typedef, $buffer);
     printf "%-8s UID %5d %s%s%s\n", $U->name, $U->uid,
           $time ? ("at " . localtime($time)) : "never logged in",
           $line && " on $line",
           $host && " from $host";
}






i have geathered all the passwd files/lastlog file for each server

how do i get getpwuid / getpwnam to work on the the password file that 
i gathered and then work on the lastlog of the associated server?

all pointers will be appreciated and thanks.
prasanth


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

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 8313
***************************************


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