[22275] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4496 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 31 14:05:55 2003

Date: Fri, 31 Jan 2003 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 31 Jan 2003     Volume: 10 Number: 4496

Today's topics:
    Re: Attitude to Perl in academia (Sara)
    Re: Attitude to Perl in academia <uri@stemsystems.com>
    Re: Attitude to Perl in academia Andrew Lee
    Re: Comparing files with difference percentage (Malcolm Dew-Jones)
        Crossposting (was: Fetchrow Question) <nobull@mail.com>
    Re: dereferencing anonymous arrayref: doesn't work? (Tor Fuglerud)
    Re: Email attachment with IO::Socket <mememe@meme.com>
    Re: Email attachment with IO::Socket Andrew Lee
    Re: Help With Nested Hash/Array Requested <goldbb2@earthlink.net>
    Re: inconsistent handling of undefined values? <ra.jones@NO_UCE*cwcom.net>
        Makefile viewer <thens@nospam.com>
    Re: Multi-line (with \n's) regex search (h\)
    Re: newbie EASY problem :-) <n_joeller@sharblbaziilyar.com>
    Re: newbie EASY problem :-) <n_joeller@sharblbaziilyar.com>
    Re: newbie EASY problem :-) (Tad McClellan)
    Re: Oracle DBD <rereidy@indra.com>
    Re: Oracle DBD <jpagnew@vcu.edu>
    Re: Oracle DBD Andrew Lee
    Re: perl data structure question (bad_knee)
        Regex help (Michael Robbins)
    Re: Regex help <nobull@mail.com>
    Re: regular expression / matching (Anno Siegel)
        RFC Date <thisis@bogus.com>
    Re: RFC Date <thisis@bogus.com>
    Re: RFC Date <mbudash@sonic.net>
    Re: Sorting A Referenced Hash of a Hash (Tor Fuglerud)
        Web server permissions problem for Quota::query?? (Andrew McCall)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 31 Jan 2003 08:17:51 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Attitude to Perl in academia
Message-Id: <776e0325.0301310817.1e5a5363@posting.google.com>

rat_tank@yahoo.com (Rat Tank) wrote in message news:<ae14ba57.0301300939.2d47cb01@posting.google.com>...
  <snip>
>     Its type system is not entirely sound. Inference upon the typing
> rules (which aren't formally stated anywhere; I had to derive them
> from the sourcecode) can lead to propositional contradictions.
 
I think you may have mis-stated this point. If what you mean is that
the language "isn't strongly typed", then yes, that's probably true. I
suppose in a classrom context where "declarations" or "date
representation & storage" is being taught, that ascpect could be
undesirable.


>     It is most certainly _not_ Turing complete (trivially provable);
> hence not all algorithms can be implemented in it that you could with
> a Turing complete language like Java or C(++).

I disagree. Please present a turing machine that cannot be represented
in Perl? I'm not sure that evemn makes sense. Perl has the logical
constructs and control features to be in any state that a turing
machine can repsesent.


>     Perl's reference counting system of garbage collection can
> sometimes result in memory leaks, as opposed to the more thorough
> graph traversal employed in other languages.

I'm not aware of more susceptibility in Perl to memory leaks than
other languages or shells. In fact, I suspect its less susceptible
since the rules of storage and scoping, being interpreted, are
simpler.

>     Despite all this, it's frustrating that I can't get course credit
> for the various projects I've done in my own time (that would be
> perfectly acceptable as coursework if implemented in other languages).
> I know that academia is not quite the 'real world', but I'd have hoped
> that could be offset by just how damn useful Perl is (and I've
> demonstrated this to my profs on more than one occasion). What do you
> think?
>  
> RT

I suspect Perl may be a relatively poor "teaching language". It's not
wordy, and uses too many symbols and gliphs to make it readily
presentable on a viewgraph. Indentation rules are loosely enforced
(see note), and Perl is concise and succint. If you want to teach a
class in looping for example, even though you COULD do it in Perl with
a "for" or "while", experienced programmers tend to go for "grep" and
"map" which syntactically are less evident to be looping constructs.

Perl has MANY WAYS to do one thing. That may not be desirable from the
professor's viewpoint, who would have to understand ALL of them. In
the more pedestrian languages you mention, there are fewer options,
consequently fewer solutions to ponder when grading. That may be
desirable?

Think about it- the prof wants to determine how well a student grasps
"iterative processes". The student turns in a one-line "grep" as the
solution to a problem in that area. Well, does he understand
iteration, or grep? In java and c and others, although there may be
libraries to do it, the student is likely to turn in a classical
looping block, making the prof's job easier perhaps.

I also finished my Masters In Computer Science without a single line
of Perl in the acedemic program. I think in many cases it would have
been acceptable to use it, but out of ignorance I fell back on c++ or
c. My grades were OK in those projects, but I probably could have
saved 50-80% of the programming time had I known Perl then.

I suspect that in many colleges, Perl IS popular and in fact
preferred. When I was in school I noted wide variation
school-to-school in what were considered "popular languages". Often it
depended on local hardware, or the sysadmin's whims, and sometimes
less on direction from the department. You know those unix sysadmins
are going to only install their favorites!

Don't assume that because your school doesn't favor Perl, that many
others don't as well. It's likely to be very popular in schools where
students have a choice, simply because solutions can be had very
quickly, leaving more time for dating and beer, the real essentials of
college life. Come to think of it- its Beer-Thirty now I'm outta here!



Gx


Note- that's One of Python's nicest attributes- indentation MEANS
SOMETHING. As long as its there, why not give it meaning? That was an
inspired idea, Guido. We all indent- making the code pretty. Well it
wold be even prettier if instead of braces (or in addition to..), the
indentation defined the blocks?  Steal it Larry!!


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

Date: Fri, 31 Jan 2003 16:30:30 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Attitude to Perl in academia
Message-Id: <x7n0lhz3h6.fsf@mail.sysarch.com>

>>>>> "RT" == Rat Tank <rat_tank@yahoo.com> writes:

  RT> Uri Guttman <uri@stemsystems.com> wrote in message news:<x73cna33lm.fsf@mail.sysarch.com>...
  >> >>>>> "RT" == Rat Tank <rat_tank@yahoo.com> writes:
  >> 
  >> huh? perl has no typing system as do most other languages. so how can
  >> you dreive one?
  RT>     Actually, I think you'll find that Perl does have a typing system,
  RT> but it's of the form of languages like ML or Smalltalk; it's an
  RT> implicit typing system. The programmer may well not know the exact
  RT> type, but the underlying compiler does have a concept of the type of
  RT> each symbol, and infers it automatically at runtime from context.
  RT> Because the type is hidden, that makes it even more severe that the
  RT> Perl typer has PROVABLE BUGS. Such un-typesafeness can result in
  RT> garbage casts, and worse yet, regular buffer overflows.

you are blathering. perl does not do any compiler work at runtime
(unless you call eval). there is compile time and there is runtime. perl
variables can hold any form of a scalar value. the compiler has no way
to change that at any time. as for the claim about the perl typer and
its 'bugs', i never heard of a perl typer. the type of a value isn't
hidden and it can be easily found with a module but it is almost never
needed by the coder. perl (correctly) handles conversions and without
buffer overruns. i don't know where you are getting this misinformation
from.

  >> that is total crap. i don't know where you learned about state and
  >> turing machines but it is hard to find a common programming language
  >> that isn't turing complete. all you need is a single array, a few state
  >> variables and some simple boolean logic.
  RT>     I don't think you quite understand the subtle concept of Turing
  RT> completeness. Perhaps you'd care to post a simple program (in Perl)
  RT> that simulates a Turing machine (plus the other requirements for
  RT> Turing completeness). I think you'll find that Perl doesn't implement
  RT> the recursive structures required.

huh? you are bonkers. the stupidest basic is turing complete.  and
please don't insult my knowledge of turing stuff. ever heard of the book
'computation: finite and infinite state machines' by marvin minsky? try
reading it sometime to actually learn about turing machines. in there he
shows the smallest universal turing machine (which minsky discovered)
and it only has about 4 variables and 6 states plus the infinite tape. i
think perl can handle that level of complexity.

  >> that is a known thing and can be handled if you know how to deal with
  >> circular refs. and if you emply them, you should know how to destroy them.
  RT>     The point of garbage collection is that one shouldn't have to
  RT> destroy things manually. This isn't a rare occurence either; Perl
  RT> regularly uses circular refs in such common structures as hashes and
  RT> arrays, and memory leaks are therefore quite frequent.

perl itself never uses circular references. perl programs may use them
but by far the majority of them don't. circular references are not a
common design requirement and if you think they are, you must be in a
tangled hierarchy yourself.

i am only writing this to make sure others who read this thread don't
fall for your line of hooey. i don't care what you think about perl
(which is way off base) but i do care what others will read.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Fri, 31 Jan 2003 12:53:01 -0500
From: Andrew Lee
Subject: Re: Attitude to Perl in academia
Message-Id: <pidl3vcr8aau5kb523b73dqademf2srs97@4ax.com>

On 30 Jan 2003 22:38:35 GMT, randy@theoryx5.uwinnipeg.ca (Randy Kobes)
wrote:

>On Thu, 30 Jan 2003 14:33:10 -0500, Andrew Lee <AndrewLee> wrote:
>
>[ ... ]
>> Wanna see what academics do?  Look at Lotus Notes  :-)
>
>Or read biographies of Alan Turing and Alonzo Church ...

Don't forget von Neuman, Dijkstra, Hamming, Knuth, Shannon ...

But those guys are brilliant ... not your run-of-the-mill CS Prof who
flunked out of a math program .... :-) 



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

Date: 31 Jan 2003 10:06:41 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Comparing files with difference percentage
Message-Id: <3e3abb31@news.victoria.tc.ca>

Vinicio Tavares (vtmcs@terra.com.br) wrote:
: I have 2 ascii files: text1.txt and text2.txt.

:     Text1.txt                 Text2.txt
: -----------------       --------------------
: a                       a
: b                       c
: c                       c
: d                       d
: e                       e

:   I want to compare the files returning the difference percentage. How
: could I do this?

:    In the example above it would return '20%'. As 1 of 5 chars doesn't
: match.

Did you check out the diff module?  I don't know it's precise name, but I
hear it's on CPAN and works like the diff command.

I think I would use that as the basis for any comparisons of this sort.



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

Date: 31 Jan 2003 17:39:51 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Crossposting (was: Fetchrow Question)
Message-Id: <u9hebp1amw.fsf_-_@wcl-l.bham.ac.uk>

"Smiley" <smiley@uvgotemail.com> writes:

> "Tintin" <me@privacy.net> wrote in message
> news:b1c62f$11e6cu$1@ID-172104.news.dfncis.de...
> >
> > "Smiley" <smiley@uvgotemail.com> wrote in message
> > news:v3iv5ob6sa0u36@corp.supernews.com...
> > [snip of repeated question in alt.perl and possibly other groups]
> >
> > Please read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
> >
> 
> Thank you, but I do know how to crosspost.  Something went wrong when I
> tried to crosspost this message, I'm not sure what, so I decided to try
> posting to each group individually.  It seems that one of the groups didn't
> get my messages, I didn't know that could hold back the postings for all of
> the other groups (doesn't make sense to me, but that seems to be the way it
> works). 

Think!

The whole point crossposted article is that is a single article that
appears in multiple groups because is has multiple items in the
Newsgroup line.

If the article must either appear in all groups listed or none.

> In any case, I've localized which newsgroup was the problem by
> posting to each in turn - sorry if it's caused you any inconvenience.

What was the "problem"?  Was it that you were too impatient to wait
for the moderator?

My post to alt.perl at all?  Surely there's nobody cluefull who'd
answer in alt.perl who wouldn't answer in the mainstream Perl groups?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 31 Jan 2003 18:59:03 GMT
From: t.k.fuglerud@hf.uio.no (Tor Fuglerud)
Subject: Re: dereferencing anonymous arrayref: doesn't work?
Message-Id: <3d89d2c5.184392762@nntp.uio.no>

On Thu, 19 Sep 2002 15:21:18 +0200, Paul <rev_1318@hotmail.com> wrote:

>Hi,
>
>I simply don't understand why the following script doesn't work:
>
>#!/usr/bin/perl
>
>use warnings;
>use strict;
>
>my %hash = ();
>
>$hash{one} = '1';
>$hash{two} = [ '2', '3' ];
>
>foreach my $key (sort keys %hash) {
>  print "ref $key = " . ref($hash{$key}) . "\n";
>
>  print "\$hash\{$key\} = ";
>
>  if ( ref eq "ARRAY" ) {

	^^^^^^^^^^^^^^
if (ref  $hash{$key} eq "ARRAY" ) {

You are testing ref $_ 

>    print join ",", @{ $hash{$key} }
>  }
>  else {
>    print "$hash{$key}"
>  }
>
>  print "\n";
>}

perldoc -f ref
ref EXPR
ref     Returns a true value if EXPR is a reference, false otherwise. If
        EXPR is not specified, "$_" will be used. The value returned
        depends on the type of thing the reference is a reference to.
        Builtin types include:



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

Date: Fri, 31 Jan 2003 09:41:17 -0700
From: "ColdCathoids" <mememe@meme.com>
Subject: Re: Email attachment with IO::Socket
Message-Id: <b1e8vi$121v7u$1@ID-158028.news.dfncis.de>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:d3x_9.8953$LY2.528542@newsc.telia.net...
> ColdCathoids wrote:
> > Is there anyway of telling which ones will and won't run from a local
> > directory?
>
> Not sure what you mean. Any module will run from a local library as long
> as it's not dependent on resources that are not installed.
>
> > Also how would dependencies work? Say I want to use module A which
> > depends on Module B. Neither are installed. If both A and B are in a
> > local directory and I use:
> >
> > use lib '/path/to/lib';
> > use ModuleB;
> > use ModuleA;
> >
> > will dependencies be satisfied?
>
> Yes. It works as if they had been installed in one of the ordinary
> directories. The "use lib" statement just adds another path where Perl
> will look for modules that are loaded via "use" or "require".
>
Well looks like loading the module in a local directory works ... but the
Mail::Sender module requires other modules which aren't installed. It's a
very slimmed down installation of Perl that I am dealing with. Blah! It's
hard to work with your hands tied. (Sorry for the vent :) ) I would try
installing all the missing modules but time is a consideration.

But your response will definently help me in the future. The sending file
attachments would have just been a bonus to the project. Thanks again.




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

Date: Fri, 31 Jan 2003 13:23:52 -0500
From: Andrew Lee
Subject: Re: Email attachment with IO::Socket
Message-Id: <qdfl3v09add8o54ml5e5jsckirmfkai8sf@4ax.com>

On Fri, 31 Jan 2003 08:20:06 -0700, "ColdCathoids" <mememe@meme.com>
wrote:

[snip conversation]
>
>
>Is there anyway of telling which ones will and won't run from a local
>directory? 

perl -V

>Also how would dependencies work? Say I want to use module A
>which depends on Module B. Neither are installed. If both A and B are in a
>local directory and I use:
>
> use lib '/path/to/lib';
>use ModuleB;
>use ModuleA;
>
>will dependencies be satisfied?

use ModuleA ought to be enough, ModuleA will find ModuleB based on the
use lib statement.

Also, setting PERL5LIB will work (however other users will get compile
time errors if they don't have the same environment).



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

Date: Fri, 31 Jan 2003 13:49:51 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help With Nested Hash/Array Requested
Message-Id: <3E3AC54F.F3124FFF@earthlink.net>

Charles R. Thompson wrote:
[snip]
> Currently the records are stored as follows with tab delimeters:
> 
> 192.123.39.23,192.123.39.20,mydomain.com    CompanyName
> http://www.companyname.com
> 
> When loading the flatfile I simply set up a hash and key it off each
> hostname/ip as a key.
> 
> $Addresses{'192.123.39.23'}{1} = 'CompanyName';
> $Addresses{'192.123.39.23'}{2} = 'http://www.companyname.com';
> $Addresses{'192.123.39.20'}{1} = 'CompanyName';
> $Addresses{'192.123.39.20'}{2} = 'http://www.companyname.com';
> $Addresses{'mydomain.com'}{1} = 'CompanyName';
> $Addresses{'mydomain.com'}{2} = 'http://www.companyname.com';
> 
> This makes lookups rather easy by passing the hostname/ip to a
> function that returns the companyname/website address, but I want
> things a bit more organized and definitely more flexible... especially
> when it comes to weeding through the barrage of *aol.com accounts,
> proxies located in global corporate domains and various ISPs hitting
> the server. I'm looking for some way to reorganize where I could do
> something like this (pseudo):
> 
> $Addresses{'(.*?)aol.com$'}{1} = 'Aol User';

Hmm...  How about something like this:

   # Order of fields within the file.
   use constant COMPANY_NAME => 0;
   use constant COMPANY_ADDRLIST => 1;
   use constant COMPANY_WEBSITE => 2;
   use constant COMPANY_CLASSIFICATION => 3;
   use constant COMPANY_ISCLIENT => 4;

   while( <$fh> ) {
      my (@info) = split /\t/;
      my @addrs = split /,/, $info[COMPANY_ADDRLIST];
      $info[COMPANY_ADDRLIST] = \@addrs;
      ADDRESS: for (@addrs) {
         s/^\.*//; s/\.\.+/\./g; s/\.\z//;
         if( /^[\d.]*\z/ ) {
            $Addresses{ips}{$_} = \@info;
            next;
         }
         my $bycomponent = \$Addresses{names};
         for(reverse split /\./) {
            $$bycomponent{$_} ||= {};
            $bycomponent = \$$bycomponent{$_};
         }
         $$bycomponent->{''} = \@info;
      } # end ADDRESS loop.
    } # end <> loop.

    use Data::Dumper;
    print Dumper \%Addresses;

Now, you can do:

   # set the default for <blahblah>.aol.com
   $Addresses{names}{com}{aol}{''}[COMPANY_NAME] = "AOL User";

   sub nameinfo {
      my $name = shift;
      s/^\.*//, s/\.\.+/\./g, s/\.\z// for $name;
      if( $name =~ /^[\d.]*\z/ ) {
         my $i = $Addresses{ips}{$name} or return;
         return wantarray ? ( $i, $name ) : $i;
      }
      my @components;
      my $bycomponent = $Addresses{names};
      my ($info, $domain);
      for (reverse split /\./, $name) {
         $bycomponent = $bycomponent->{$_} or last;
         push @comopnents, $_;
         my $i = $bycomponent->{''} or next;
         $info = $i;
         $domain = join(".", reverse @components);
      }
      return unless $info;
      wantarray ? ($info, $domain) : $info;
   }
   my $i = nameinfo("foo.bar.aol.com");
   print $i->[COMPANY_NAME];
   # should print "AOL User" unless either
   # of foo.bar.aol.com or bar.aol.com exist.
   __END__
[untested]

Note that you now need to change stuff like this:

   if( $AddressAliases{$entry}{2} ne '901' ) {
     if( $AddressAliases{$entry}{3} eq '1' ) {
     ......

Into stuff like this:

    my $i = nameinfo($entry);
    if( $i->[COMPANY_CLASSIFCATION] ne '901' ) {
       if( $i->[COMPANY_ISCLIENT] eq '1' ) {
       ......

Personally, I think that using named constants looks better anyway.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Fri, 31 Jan 2003 16:28:14 +0000
From: RA Jones <ra.jones@NO_UCE*cwcom.net>
Subject: Re: inconsistent handling of undefined values?
Message-Id: <TQ+52jHeQqO+EwS8@nildram.co.uk>

In message <slrnb3l64i.o3d.tadmc@magna.augustmail.com>, Tad McClellan 
<tadmc@augustmail.com> writes
>RA Jones <ra.jones@NO_UCE*cwcom.net> wrote:
>
>> I have isolated and corrected the problem by 'defining' all values in
>> @vals like so:
>>
>> $_ ||= '' foreach(@vals);
>>
>> but the question is a) is this the correct way to handle undefined
>> values in an array
>
>
>No.
>
>Your code does NOT test for "definededness", it tests for "truth".
>
>If any element in @vals contains 0 or '0', your code above will
>change it to the empty string!
>
>Use the defined() operator to test for definededness.
>
>   foreach ( @vals ) {
>      $_ = '' unless defined;
>   }
>
>or
>
>   $_ = defined() ? $_ : '' for @vals;
>
>
Thanks Tad, I stand corrected.

But why does Perl hang when I try to print an undefined value, despite 
using 'strict', '-w' and CGI::Carp(fatalsToBrowser)?
-- 
RA Jones
remove NO_UCE* from 'reply-to' address
ra(dot)jones(at)see-double-you-com(dot)net



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

Date: Fri, 31 Jan 2003 21:44:31 +0530
From: Thens <thens@nospam.com>
Subject: Makefile viewer
Message-Id: <20030131214431.3a20949e.thens@nospam.com>

Hi,
    Can you point me to any perl resource that speaks about
displaying Makefiles with their dependency graph (either in text or a
GUI with TK). 
     I came across Graphviz::Makefile but iam looking for
something light and less fancier. 

Thanks,
Thens.


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

Date: Fri, 31 Jan 2003 18:44:43 +0100
From: "Michael Peuser \(h\)" <post@mpeuser.de>
Subject: Re: Multi-line (with \n's) regex search
Message-Id: <b1eckc$t6d$06$1@news.t-online.com>


"Tad McClellan" <tadmc@augustmail.com> schrieb im Newsbeitrag
news:slrnb3l3f7.nte.tadmc@magna.augustmail.com...
> Chris <c_campise@hotmail.com> wrote:
>
>
> > I'm attempting to scan a C header file (.h) looking for typedef struct
> > declarations.

> That is not possible using only regular expressions, you need
> a Real Parser for the C language.

Though this is true, one could do fine with more than 99% of programs (s.
below)



> while ( /typedef struct.*?{(.*?)}/sg ) {
>    my $block = $1;
>    while ( $block =~ /(\w+)\s+(\w+);/g ) {

This can be improved by
while ( $block =~ /\s*([^;]+)\s+(\w+);/g ) {

>       print "$1  ==> $2\n";
>    }
>    print "-----\n";
> }

In any case remove all comments /*  and // as well as strings "..." in a
first step.
It could be tricky to remove strings however; so remove \" in a very first
step.

There is more of course; but I think you will catch 99% ...

Kindly Mike




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

Date: Fri, 31 Jan 2003 17:59:32 GMT
From: Noerd <n_joeller@sharblbaziilyar.com>
Subject: Re: newbie EASY problem :-)
Message-Id: <3E3AB96F.34609126@sharblbaziilyar.com>

Tad McClellan wrote:

> Noerd <n_joeller@sharblbaziilyar.com> wrote:
>
> > I use the following perl code:
> > $itemdescription[2] =~ s+\(W\\/(.*?)\)+
>
> You don't use it for much then, as it will not even compile.
>

That's just the RELEVENT part of the code!

Where do I put the "Pages" part?

The above example works perfectly for my examples. Now I want to use
"Pages."

Can you help? Or not?



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

Date: Fri, 31 Jan 2003 18:15:21 GMT
From: Noerd <n_joeller@sharblbaziilyar.com>
Subject: Re: newbie EASY problem :-)
Message-Id: <3E3ABD27.54452038@sharblbaziilyar.com>

Jeff D Gleixner wrote:

> [...]
> > "Owners manual (W/383 Pages)"
> >
> > Where would I put the word, "Pages," in my perl code
> >
> > I tried these, but they don't work:
> > $itemdescription[2] =~ s+\(W\\/(.*?)Pages\)+
> > $itemdescription[2] =~ s+\(W\\/(.*Pages)\)+
> >
> > Thank you!!!
> >
> > Oh, by the way, I need to leave all the backslashes "\" in there because
> > the previous portion of my script has to escape all kinds of characters
> > (I want to leave my code format, etc., intact....I just what to find out
> > where in the dickens to put the word, "Pages."  :-)
>
> Why are you using  the substitute (=~ s)?
>

Here is what I had in mind:

##"Processor (W/16MB Ram)"
$itemdescription[2] =~ s+\(W\\/(.*?)\)+\<FONT
COLOR\=\"\#FFGG00\"\>\<B\>Reminder\:\<\/B\>\<\/FONT\> Comes with $1. +;
##will upload this into my sql database, via many lines of perl code:
## "Processor REMINDER: Comes with 16MB Ram."

##"Owners Manual (W/287 Pages)"
$itemdescription[2] =~ s+\......WHAT GOES HERE.......+\<FONT
COLOR\=\"\#FFGG00\"\>\<B\>NOTICE\:\<\/B\>\<\/FONT\> This has $1. +;
##Heres what I want:
## "Owners Manual NOTICE: This has 287 Pages."

Thank you!!!  :-)






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

Date: Fri, 31 Jan 2003 12:39:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie EASY problem :-)
Message-Id: <slrnb3lgn7.35i.tadmc@magna.augustmail.com>

Noerd <n_joeller@sharblbaziilyar.com> wrote:
> Tad McClellan wrote:
>> Noerd <n_joeller@sharblbaziilyar.com> wrote:
>>
>> > I use the following perl code:
>> > $itemdescription[2] =~ s+\(W\\/(.*?)\)+
>>
>> You don't use it for much then, as it will not even compile.
>>
> 
> That's just the RELEVENT part of the code!


It is not Perl code. It does not compile. 

You have no replacement part for the s///

   $itemdescription[2] =~ s+\(W\\/(.*?)\)++;  # now it _is_ Perl code

(and it matches when "Pages" is present.)


> Where do I put the "Pages" part?


You do not need to add a Pages part.


> The above example works perfectly for my examples. Now I want to use
> "Pages."


It works perfectly when the data includes "Pages" too.

What is the problem that you need to solve?


> Can you help? Or not?


I already have for the question you asked.



Perhaps you meant to ask some other question?

Maybe:

   How can I get just the number part of "(W\/22 Pages)"


If that is what you meant to ask, then you can do it like this:

   m#\(W\\/(\d+).*?\)#;

Still no need to add "Pages" anywhere.

Or Maybe:

   How can I get just the number part of "(W\/22 Pages)"
   but only when the string "Pages" is present?

then:

   m#\(W\\/(\d+) Pages\)#;


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


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

Date: Fri, 31 Jan 2003 09:22:47 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Oracle DBD
Message-Id: <3E3AA2D7.3050002@indra.com>

Download Oracle from technet.oracle.com and do a client install.  This 
will install the necessary libraries and makefiles for you to build 
DBD::Oracle.

roym wrote:
> Hello everyone,
> 
> I have seen some related emails in the archives about the Oracle DBD driver,
> but they still don't quite answer my questions.  I am simply trying to talk
> to an Oracle database on another server using my Perl script.
> 
> Am I correct that in order to build the driver, you must have Oracle
> installed on your server?  The DBD readme simply states that you must have
> Oracle at least *partially* installed.  How much is partially?  Will
> installing an Oracle client be enough to build the driver?  I don't know
> enough about Oracle for the DBD docs to be of much help....
> 
> I don't have a copy of Oracle.  Are there some places where I can download
> Oracle DBDs that are already compiled?
> 
> What other ways could I use to talk to the Oracle database from my Perl
> script?  Could I use an ODBC driver for Linux?
> 
> Thanks & Regards,
> roy
> 
> 
> 
> 



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

Date: Fri, 31 Jan 2003 11:26:43 -0500
From: Jim Agnew <jpagnew@vcu.edu>
Subject: Re: Oracle DBD
Message-Id: <3E3AA3C3.AC0BCDA6@vcu.edu>

roym wrote:
> 
> Hello everyone,
> 
> I have seen some related emails in the archives about the Oracle DBD driver,
> but they still don't quite answer my questions.  I am simply trying to talk
> to an Oracle database on another server using my Perl script.
> 
> Am I correct that in order to build the driver, you must have Oracle
> installed on your server?  The DBD readme simply states that you must have
> Oracle at least *partially* installed.  How much is partially?  Will
> installing an Oracle client be enough to build the driver?  I don't know
> enough about Oracle for the DBD docs to be of much help....
> 
> I don't have a copy of Oracle.  Are there some places where I can download
> Oracle DBDs that are already compiled?
> 
> What other ways could I use to talk to the Oracle database from my Perl
> script?  Could I use an ODBC driver for Linux?
> 
> Thanks & Regards,
> roy

well, for, partially may mean:  server foo has db2 installed, server bar
has a db2 *CLIENT* installed, so you chat to the client on server bar,
and it's getting the data for you nicely, but the db2 database is on
server foo, instead of server bar, but it's doesn't matter..

clear as mud??

you can download a personal version of oracle for yourself from the
oracle site. any more details would have to come from someone else, but
hopefully i'm giving back to the group something..

jim


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

Date: Fri, 31 Jan 2003 13:44:14 -0500
From: Andrew Lee
Subject: Re: Oracle DBD
Message-Id: <kvfl3v8oo79vs0pt71ka11hjko77g8nl8h@4ax.com>

On Fri, 31 Jan 2003 13:41:25 GMT, "roym" <roymain@sbcglobal.net> wrote:

>Hello everyone,
>
>I have seen some related emails in the archives about the Oracle DBD driver,
>but they still don't quite answer my questions.  I am simply trying to talk
>to an Oracle database on another server using my Perl script.
>
>Am I correct that in order to build the driver, you must have Oracle
>installed on your server?  The DBD readme simply states that you must have
>Oracle at least *partially* installed.  How much is partially?  Will
>installing an Oracle client be enough to build the driver?  I don't know
>enough about Oracle for the DBD docs to be of much help....

This is a tricky issue on some platforms.  In principle, though, when
you download Oracle and you start to install it -- you have the choice
of installing the client only -- this is enough to build DBD::Oracle.

>
>I don't have a copy of Oracle.  Are there some places where I can download
>Oracle DBDs that are already compiled?

That has never worked for me.  You need several libraries that have to
be binary compatible with your system.  Considering the number of
variables (compiler version, OS version, library verions) it is best to
download the entire Oracle database and install the client.
 
>
>What other ways could I use to talk to the Oracle database from my Perl
>script?  Could I use an ODBC driver for Linux?

If you want to open that can of worms.  But that's just trading one
headache for another.

I went through this about a year ago and it took me a week to get
everything installed properly.  Fortunately, Oracle 9i is reported to be
more Linux friendly than previous versions.

Usually I would say that this is off-topic -- but the Oracle docs and
newsgroups or Linux docs and newsgroups have little information about
DBD::Oracle and you are more likely to encounter someone who has gone
through the setup in this newsgroup than any other that I can think of.
The situation may have improved with this more recent release of 9i
though.

Good luck


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

Date: 31 Jan 2003 08:36:10 -0800
From: bl8n8r@yahoo.com (bad_knee)
Subject: Re: perl data structure question
Message-Id: <e817ca4d.0301310836.3e6d7900@posting.google.com>

Well, there's definately much food for thought in there.  Thanks
for the pointers!!

bl8n8r


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

Date: 31 Jan 2003 10:05:50 -0800
From: michael.robbins@us.cibc.com (Michael Robbins)
Subject: Regex help
Message-Id: <c6c65b14.0301311005.3a261b66@posting.google.com>

I have a large file that consists of many lines concatenated together.

Each author's name appears at the beginning of his message (a bunch of
lines) followed by another author's name and more lines, etc.

I have a regex to find the author's name in a line.

I slurp in the file

I loop through each line.

If I find an author's name, I add a tag to the end of each subsequent
line to identify the author until I find another author's name and
repeat.

so. if the message is:

bla bla bla Author1
bla bla blabla bla bla
bla bla bla bla bla bla
bla bla bla Author2
bla bla blabla bla bla
bla bla bla bla bla bla

I want to produce

bla bla bla Author1@Author1
bla bla blabla bla bla@Author1
bla bla bla bla bla bla@Author1
bla bla bla Author2@Author2
bla bla blabla bla bla@Author2
bla bla bla bla bla bla@Author2

Is this the right aproach to get this result?


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

Date: 31 Jan 2003 18:19:18 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regex help
Message-Id: <u965s518t5.fsf@wcl-l.bham.ac.uk>

michael.robbins@us.cibc.com (Michael Robbins) writes:

> I have a large file that consists of many lines concatenated together.
> 
> Each author's name appears at the beginning of his message (a bunch of
> lines) followed by another author's name and more lines, etc.

How do you know that you are looking at another author's name and not
part of the first author's message.

> I have a regex to find the author's name in a line.
> 
> I slurp in the file
> 
> I loop through each line.
> 
> If I find an author's name, I add a tag to the end of each subsequent
> line to identify the author until I find another author's name and
> repeat.

> Is this the right aproach to get this result?

Er? Sounds OK but I'd probably process the file line-wise rather than
slurp unless there is some other reason to slup.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 31 Jan 2003 16:28:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regular expression / matching
Message-Id: <b1e878$4b8$1@mamenchi.zrz.TU-Berlin.DE>

agape <bionic_man1@yahoo.com> wrote in comp.lang.perl.misc:
> -b /my_directory/file.m,v -m 100 -f -s direcotry -ex "-m file"
> -b /his_directory/file3.m, -m 90000 -n -s direcotry_650 -ex "-m file8"
> -b /her_directory/file4.m -m 100 -f -s direcotry -ex "-m file_908"
> 
> The above is an example of three records on that file that I am
> parsing.
> I want to be able to parse. I want to keep the integrity of ".m,v" and
> ".m," and ".m" as they are so is there a reg exp that I can use that
> parses the argument that is passed to "-b" option above and keeps the
> file extensions as they are.

Apart from top-posting and full-quoting my article, you give little
indication that you have even read it.  Instead you come back with
a rather different problem than the one you originally indicated.
Please make up your mind about what your problem is before asking for
help with it.

> 
> Intention is to parse each record(here is three of them)
> replace -b with blank which is easy
> leave the argument to -b untouched (this is what fails)meaning if I
> do:
> $captured_test =~ s/-b//; Then the script ignores everything including
> other arguments and leave me with this:
> /my_directory/file.m
> /his_directory/file3.m
> /her_directory/file4.m


What's wrong with

    my ( $arg) = $record =~ /-b\s+(\S+)/;

Anno


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

Date: Fri, 31 Jan 2003 12:28:26 -0500
From: "Duke" <thisis@bogus.com>
Subject: RFC Date
Message-Id: <v3lchrmp35uq19@news.supernews.com>

I use HTTP::Date to get an RFC-formatted:

print time2str();

This outputs current time as:
Fri, 31 Jan 2003 15:43:43 GMT

I would like to have the actual timezone difference instead of GMT, as in
Fri, 31 Jan 2003 10:43:43 -0500

As you may have guessed, this is for a email script (and yes using GMT is
just fine).  I know I can probably use Date::Parse, but it does not seem to
have the ability to generate the current date on it's own - I'm wondering if
there's something that can generate it all at once (i.e. one function call).




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

Date: Fri, 31 Jan 2003 12:41:18 -0500
From: "Duke" <thisis@bogus.com>
Subject: Re: RFC Date
Message-Id: <v3lda0d0m675a9@news.supernews.com>

I must be smoking crack - either that or I need to get used to perl's
documentation ;)

use Date::Format;

my $rfcdate = time2str('%a, %e %b %Y %X %z', time);
print $rfcdate;




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

Date: Fri, 31 Jan 2003 18:03:26 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: RFC Date
Message-Id: <mbudash-2B25C2.10032531012003@typhoon.sonic.net>

In article <v3lda0d0m675a9@news.supernews.com>,
 "Duke" <thisis@bogus.com> wrote:

> I must be smoking crack - either that or I need to get used to perl's
> documentation ;)
> 
> use Date::Format;
> 
> my $rfcdate = time2str('%a, %e %b %Y %X %z', time);
> print $rfcdate;
> 
> 


if i understand the thread (it's not completely posted):

you could skip the [possible] need to install Date::Format and use the 
built-in Posix module.

perldoc Posix

search for 'strftime'

hth-


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

Date: Fri, 31 Jan 2003 18:59:03 GMT
From: t.k.fuglerud@hf.uio.no (Tor Fuglerud)
Subject: Re: Sorting A Referenced Hash of a Hash
Message-Id: <3cff5b43.2316064013@nntp.uio.no>

On Thu, 6 Jun 2002 08:41:35 -0400, "adsouza@nospam.net" <adsouza@nospam.net>
wrote:

>Greetings,
>
>Need some help with this....
>
>I have a function we will call get_users() which returns a reference of a hash.
>
>so the hash when returned to the body of the program will look like:
>
>	$ref->{$key}->{'login name'}
>	$ref->{$key}->{'first name'}
>
>
>Right when I print "####HERE####" i am printing  the list out.  I want that list
>sorted alphabetically but without case sensitivity.  So basically, how can I do
>this?

>
>foreach my $key ( keys %{$ref} ) {
>	# assign values
>	my $first_name	= $ref->{$key}->{'First Name'};
>	my $last_name	= $ref->{$key}->{'Last Name'};
>	my $login_name	= $ref->{$key}->{'Login Name'};
>
>	my $emp_fullname = "$first_name $last_name";
>
>	#### HERE ####
>	print LIST "$emp_fullname - $login_name\n";
>
>}


asuming you want to sort on Lastname , Firstname replace:

foreach my $key(keys %{$ref})

with:

for my $key (sort{
    uc $ref->{$a}->{'Last Name'} cmp uc $ref->{$b}->{'Last Name'} or
        uc $ref->{$a}->{'First Name'} cmp uc $ref->{$b}->{'First Name'}
}keys %{$ref})



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

Date: 31 Jan 2003 10:34:28 -0800
From: it.andrew.mccall@oldham.gov.uk (Andrew McCall)
Subject: Web server permissions problem for Quota::query??
Message-Id: <acc5b949.0301311034.763fa6c2@posting.google.com>

Hi All,

Following my previous post, I have started to work with Quota:Query. 
I have written a script, and it works from the command line, and does
indeed return the correct % of quota used.

However when I run it from a browser via my web server, it always
tells me there is a problem with the user here is the script :

#!/usr/bin/perl

use Quota;

# Set up the partition we want to check
$dev="/dev/sda2";

&return_user_quota;

sub return_user_quota {

        # Set what to get the quota for...
        my $uid = "1000";

        # Get the quota information...
        ($bc,$bs,$bh,$bt,$fc,$fs,$fh,$ft) = Quota::query($dev, $uid);

        print "Content-type:text/html\n\n";

        if (defined($bc)) {
                $percent=($bc/$bh)*100;
                print "<HTML>\n<TITLE>\nQuota
Result\n</TITLE>\n<BODY>\n$percent has been
used.\n</BODY>\n</HTML>\n";
        }#if

        else {
                print "<HTML>\n<TITLE>\nQuota
Result\n</TITLE>\n<BODY>\nUser didn't exist.\n</BODY>\n</HTML>\n";
        }#else

        exit;

}#get_user_quota

Could it be something to do with permissions? I.e. The user my web
browser is set to isn't allowed to get the quota for the user I want
to see?

How do I get round this?

Thanks for any help,

Andrew McCall.


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

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.  

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


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