[7143] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 768 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 24 11:17:47 1997

Date: Thu, 24 Jul 97 06:00:49 -0700
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, 24 Jul 1997     Volume: 8 Number: 768

Today's topics:
     Re: accessing .dbf files (Honza Pazdziora)
     Re: Another Newbie question about s/// <sfairey@adc.metrica.co.uk>
     Re: Argh! (FIXED!) (robert)
     Argh! 5.00401 gets Bus errors (LONG-ish) (robert)
     Re: Benchmarking Perl Compile Times <merlyn@stonehenge.com>
     Re: cgi, server side include help <rootbeer@teleport.com>
     Re: CGI.pm file uploads with Internet Explorer <asparks@nss.harris.com>
     Re: Date to Number function? <sfairey@adc.metrica.co.uk>
     DB_FILE versus dbmopen <kinlum@wco.com>
     Re: DON"T Pay For $ex Site Entry <alan@mattress.atww.org>
     Re: Easy question-new user (Ken Williams)
     Faking CORE:: subs <axel@ramge.de>
     File access from Perl <chrisl@worktechnology.com>
     Re: Formating text: changing the \n to a <P> (Faust Gertz)
     Re: Global Vars : Why would I want to use "use strict" (Paul Vermette [NiD/BiM])
     Help with RSH command (Leon Keylin)
     Help: How to count subsitutions <ltattrie@icrossroads.com>
     Re: Help: How to count subsitutions <rootbeer@teleport.com>
     HELP: Telnet program <jtstepni@socs.uts.EDU.AU>
     Re: how to reverse substitution order ? (Tim  Smith)
     Re: Loading hash crashes computer <sfairey@adc.metrica.co.uk>
     Re: Making a matrix... (M.J.T. Guy)
     Re: Making a matrix... (Helmut Jarausch)
     Re: Matching lowercase in regexp? (Tad McClellan)
     Re: Newbie: Backtracking with regexp <ajohnson@gpu.srv.ualberta.ca>
     OraPerl Perl scipt to track db time sought! (Carol Smith)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Jul 1997 08:56:36 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: accessing .dbf files
Message-Id: <adelton.869734596@aisa.fi.muni.cz>

Mike Aarset <mikus@sirius.com> writes:

[...]
> need to read some info off the file I can only
> read  a line at a time.
> @my_file = <MYFILE>
> and then from the array I can read certain lists
> in the @my_file.
> Do I need to create a database file.
> I've seen .dbf files on my server.
> Am I on the right track.
> Where can I go on the web to learn how to create 
> .dbf files and do I need a module like
> oracle?
> xbase?

Module Xbase is read only interface to dBase's and FoxBase's dbf
files. Also, I am affraid that the module is no longer supported by
its author -- I sent him a patch for some 5.004 warnings a month ago
but did not get any answer.

> I don't want to use other peoples databases but create my
> own.

Why, do you think that other people's work is not worth using it?
Since your application is probably small, MiniSQL and DBD::mSQL module
might be good solution.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
    European RC5 56 bit cracking effort -> http://www.cyberian.org/


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

Date: Thu, 24 Jul 1997 11:30:24 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Robert John Kindel <kindel@sun-valley.Stanford.EDU>
Subject: Re: Another Newbie question about s///
Message-Id: <33D72EBD.26D34103@adc.metrica.co.uk>

Robert John Kindel wrote:

> Howdy!
>
> I am just starting to get a grasp on all the things that perl can do,
> and I
> found an instance where I just can't get it to do quite what I think
> it
> should.  Basically, I want to set up an associative array where the
> key is a
> regexp to match and the value is a regexp to change to.  This has led
> to the
> following code...
>
> $Changes{'(\w+)->pr[[]([^\]]*)[\]]'} = '\1->El(\2)';

Sorry it's not a direct answer to your question ( I am waiting to one of
the gurus to give you the reason why it doesn't work ) but in the mean
time to get you going, the following will work. Change the value of the
above key to:  '$1.\'->El(\'.$2.\')\''

> while(<INFILE>) {
>         foreach $key (keys %Changes) {
>                 print STDOUT "$key $Changes{$key}\n";
>                 s/$key/$Changes{$key}/g;

Then change this line to:  s/$key/$Changes{$key}/eeg;

See "How can I expand variables in text strings?" in the Perl FAQ for
the start of an explanation to the above.

Hope this helps you on your way.

Simon



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

Date: 24 Jul 1997 12:26:11 +0200
From: robert@ICK.il.fontys.nl (robert)
Subject: Re: Argh! (FIXED!)
Message-Id: <5r7ak3$bf@bsd1.hqehv-internal.ilse.net>

robert@il.fontys.nl (robert):
 >I've been plagued by signal 10's and 11's when trying to run a script from
 >cron (it seems to be working ok from the commandline).

Oh geez, the problem seemed to be a newline in the key of the data I
stored. Still have to figure out exactly why it croaks, though.

                                                              robert


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

Date: 24 Jul 1997 10:59:46 +0200
From: robert@il.fontys.nl (robert)
Subject: Argh! 5.00401 gets Bus errors (LONG-ish)
Message-Id: <5r75i2$ba@bsd1.hqehv-internal.ilse.net>

I've been plagued by signal 10's and 11's when trying to run a script from
cron (it seems to be working ok from the commandline).

Here's a stack-trace from gdb:
--
Core was generated by `perl5.00401_g'.
Program terminated with signal 10, Bus error.
Cannot access memory at address 0x6c2f6c61.
--
(FYI, the faulty address contains 'l/la')
--
#0  0x81304f8 in end ()
#0  0x81304f8 in end ()
#1  0x20a140 in end ()
#2  0x4e996 in safefree (where=0x2) at util.c:164
#3  0x56f55 in Perl_hv_undef (hv=0x1e99f8) at hv.c:856
#4  0x647ae in Perl_sv_clear (sv=0x1e99f8) at sv.c:2739
#5  0x64a69 in Perl_sv_free (sv=0x1e99f8) at sv.c:2858
#6  0x7bcca in Perl_free_tmps () at scope.c:105
#7  0x588b3 in Perl_pp_nextstate () at pp_hot.c:35
#8  0x587d1 in Perl_runops () at run.c:29
#9  0x227f6 in perl_run (sv_interp=0xc1010) at perl.c:900
#10 0x169b in main (argc=3, argv=0xefbfddf4, env=0xefbfde04) at perlmain.c:48
--
The parameter used with safefree() seems to be a bit on the low side too.

Here's the output of using -DDxm (relevant part of it, anyway):
--
0x2: (53110) free
--

Last line of -Dtx output:
--
(/usr/www/cgi/xsc.standalone:236)       nextstate
--

Last, line 236 in my script contains:
--
$tmp = \%{$averages{$key}};
--

Which leads me to another problem I've been having:
If I do not 'cast' $averages{$key} explicitly to a hash-reference, I
sometimes get 'not a HASH reference' when I try to use '$tmp->{whatever}'.

According to what I thought, and to people on #perl, the cast shouldn't be
necessary anyway, and that very line is in fact the only line in the
entire script where it goes faulty; I use the exact same method in several
other places in the script, without any problems whatsoever. And in fact,
when I comment out the code around line 236, everything works fine.

Could it in some way be related to %averages being tie'd (using MLDBM) to
a DB-file? (which would be strange, since I use lots of other tie'd hashes
in the script)

To put it in other words: HELP! :)

                                                                    robert


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

Date: 21 Jul 1997 07:22:08 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Benchmarking Perl Compile Times
Message-Id: <8c3ep81o4v.fsf@gadget.cscaper.com>

>>>>> "Benjamin" == Benjamin Kyan <bkyan@mindcast.com> writes:

Benjamin> Anyone know of a *quick* way to benchmark a script, including
Benjamin> compile times?  I think the Benchmark module ignores compile
Benjamin> times...

Not if you tell it to compile the stuff!...

    use Benchmark;
    timethis(100, q{ eval{
	    your code goes here
    }});

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 407 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Sun, 20 Jul 1997 22:00:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Raj Kumar <rajk@best.com>
Subject: Re: cgi, server side include help
Message-Id: <Pine.GSO.3.96.970720215443.27787G-100000@kelly.teleport.com>

On Sun, 20 Jul 1997, Raj Kumar wrote:

> I am trying to get the time stamp displayed on my web page, 
> but it isn't working.
> 
> I have renamed my html file to index.shtml
> and then I put the following in my file:
> 
> <!-- #config timefmt = "%I:%M:%S" -->
> 
> but it doesn't work.
> Any suggestions or comments.

Yep. You don't want this newsgroup. This newsgroup is about Perl, but your
question is about servers. If you can't find the answer in your server's
docs, check out a server newsgroup, or its FAQ. If you find sometime that
you have Perl questions which aren't covered in the FAQs and docs, those
questions will be welcome here. Thanks, and good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 20 Jul 1997 15:22:11 -0700
From: Alan Sparks <asparks@nss.harris.com>
Subject: Re: CGI.pm file uploads with Internet Explorer
Message-Id: <33D28F93.7D4E@nss.harris.com>

Used to be true, but not any longer.  MS finally (after a year or so)
finally kicked in with a add-in to IE 3.02 to support RFC file upload.
Don't remember the exact URL, but check out MS' web site:

http://www.microsoft.com/ie/

-Alan

Thomas R. Hall wrote:
> 
> : Does anyone know if there is an easy way to do file uploads with
> : Internet Explorer?  CGI.pm makes file uploads really easy assuming that
> : you are using netscape 2.0 or better, but I have seen nothing similar
> : for Internat Explorer.
> 
> Internet Explorer (all versions, including the new 4.0 betas) does not
> support HTTP-based file upload from the browser.  This is something that is
> supported by other browsers, and there is an RFC out for it (cannot
> remember the number right off hand), but it has never supported this
> feature.
> 
> I was hopeful that they would include support for this in the upcoming 4.0
> version, but no such luck so far.  Other browsers support this type of
> upload (in addition to Netscape Navigator), so hopefully IE will add this
> to their list of features, though I wouldn't hold my breath.
> 
> --
> Thomas R. Hall <trhall@indiana.edu>  BPO Web Services Coordinator
> http://php.indiana.edu/~trhall     Indiana University Bloomington
> RSA KeyID: 0x8F6DFD27   DSS/DH KeyID: 0x443AE82D   trhall@acm.org


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

Date: Thu, 24 Jul 1997 11:32:59 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Scott Card <ils@pipcom.com>
Subject: Re: Date to Number function?
Message-Id: <33D72F59.6D7C13E9@adc.metrica.co.uk>

Scott Card wrote:

> Is there a perl date to number function that converts the date to a
> number of days from a specific date (ie Jan 1, 1980)
>
> Thanks.

  Look at the Date modules on the CPAN, the JulianDate or somesuch
module may do what you require.

Simon



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

Date: Sun, 20 Jul 1997 20:29:16 -0700
From: Kenneth Kin Lum <kinlum@wco.com>
Subject: DB_FILE versus dbmopen
Message-Id: <33D2D78C.A22D817B@wco.com>

DB_FILE uses Berkeley's DB, and creates one file per database (table).
dbmopen, etc, uses two files per database (table).

Is one more efficient than the other in speed?  Or is DB_FILE just a 
concatenation of those two files per database?


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

Date: 22 Jul 1997 20:51:02 GMT
From: A. Reichert <alan@mattress.atww.org>
Subject: Re: DON"T Pay For $ex Site Entry
Message-Id: <5r36fm$kie$1@mattress.atww.org>

On Tue, 22 Jul 1997 11:47:55 -0400, Catherine Skidmore <cskidmore@arcus.net> wrote:
: David Faciane wrote:
: > 
: > What about @ex, %ex and regex?
: > 
: > :-)

: oh stop, you're turning me on.

How about the fettish crowd:  LaTex, or being "TcL"ed.  :-)



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

Date: Wed, 23 Jul 1997 19:06:27 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Easy question-new user
Message-Id: <ken-2307971906270001@news.swarthmore.edu>

Hi-

What problem are you having with this?  What's the output?  Have you
looked at the value of $gotit?  Is the mail getting sent?  Have you tried
just running mailx from a shell prompt (not in the perl script)?

I see a couple of things that I would change.  First, I'd let the script
sleep for a while when things look normal.  To sleep for 1 minute, do
"sleep 60;".

Also, why do you sleep for 1 second immediately after you find a problem? 
That's a little weird.  It seems like you'd want to send a message, then
sleep for a minute.  In fact, it looks like you want to sleep for a minute
regardless of whether you find a problem or not, right?  So put it outside
the if..else blocks.

Also, instead of 
if ( $sent != 12 && $sent %3 == 0 )
How about
if ( $sent %5 == 0 )

What's the $sent != 12 for?  


In article <33D51D95.153B@cobe.com>, Edward Bidinotto <edbid@cobe.com> wrote:
>I am just getting started with Perl.
>Here's what I'd like to do but can't make it work.
>I can't figure out how to mail messages to console every minute
>that the logs are down and at the same time actually mail a message
>to $recipients every 5 minutes that the logs are down.
>
>I know this is an easy fix but I'm not a programmer and I'm trying to
>get something in place and decided to learn Perl.
>
>Any ideas are appreciated.
>
>Tks..Ed
>edbid@cobe.com
>
>
>
>$date = `date`;
>$recipients = "root informix prodadmn";
>$mail = "The logical log process is not running\nas of $date";
>$subject = "The Informix ontape -c process has stopped";
>$mail_command = "echo \"$mail\" | /usr/bin/mailx -s \"$subject\"
>$recipients";
>
>$sent = 0;
>while (1)
>{
>        $gotit = `ps -fe | grep -v grep | egrep "ontape -c"`;
>        if ($gotit)
>        {
>                # Continous logging is operational-just keep looping
>                $sent = 0;
>        }
>        else
>        {
>                # Logs are down send out messages to the console every
>minute
>                # Until the operators do something
>
>                        print "Logs are down - send out msg to
>console\n";
>                        sleep 1;
>
>                # Also mail out a message and notify $recipients
>                # every 5 minutes that logs are down.
>
>                if ( $sent != 12 && $sent %3 == 0 )
>                  {
>                        system($mail_command);
>                        $sent++;
>                  }
>        }
>}

-Ken Williams
 The Math Forum
 ken@forum.swarthmore.edu


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

Date: 22 Jul 1997 07:22:53 +0200
From: Axel Ramge <axel@ramge.de>
Subject: Faking CORE:: subs
Message-Id: <m3wwmjhd8y.fsf@steiner.hh.ramge.de>

Hello,

I have a problem, trying to override builtin functions. The history
of my tries follows:

Implicit passing of @_ like

  sub foo {
    if ($bar) {
      # overriding code here
    } else {
      &CORE::foo;
    }
  }

does not work because builtin subs are `modern' functions (BTW: with 
respect to the work, this should be mentioned in the perlsub man page)
Passing @_ like this

  sub foo {
    if ($bar) {
      # overriding code here
    } else {
      CORE::foo(@_);
    }
  }

will not work because the call of CORE::foo(@_) doesn't match 
prototyping and 

  prototype(\&CORE::foo);

will not work either.

Is there a simple (or even automatic) way to get the prototypes of
the CORE builtins? (And another suggestion: Maybe the prototypes
of the builtin functions could be added to the perlfunc man page? 
This would be a nice example to learn more about this).

Thanks for your help.

Axel


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

Date: 24 Jul 1997 12:30:41 GMT
From: "Chris Lawless" <chrisl@worktechnology.com>
Subject: File access from Perl
Message-Id: <01bc982d$5023b940$5a605cc3@cml.worktechnology.com>

I'm new to perl so I guess my questions will be simple to more experienced
users but a few pointers would be much appreciated! I have Perl installed
and working and now want to write (or 'borrow') my first script.

All I want to do is pass data from an HTML form and write it to a comma
delimited file, I don't need to validate, just break down the data as it is
passed and write it away to a text file. My concerns, apart from not
knowing where to start (!) are making it adaptable, probably through
multiple copies rather than a cunning script, and any issues relating to
multiple accesses, ie if two or more users try to register at once.
Basically it'll be a very simple form handler, I've seen lots of handler
scripts but they all seem too complex for my simple needs. Any help or
pointers much appreciated, I'll be back here, hopefully often, but a mail
to chrisl@worktechnology.com would be appreciated too!

thanks, Chris.


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

Date: Wed, 23 Jul 1997 00:25:14 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Formating text: changing the \n to a <P>
Message-Id: <33d54a69.2786729@news.wwa.com>

On Tue, 22 Jul 1997 18:13:19 -0400, Mark McDonald <mark@nhgir.nih.gov>
wrote:

>Formating text: changing the \n to a <P> 

Do you really want to replace '\n' with '<P>'?  The P tag is used to
indicate paragraphs, as in '<P>This is a paragraph.</P>'. 

>Here is a hard one that has me puzzled! I need to kake the text out of a
>textarea re-format it to put a <P> where there is a line break. 

'<BR>' is a used to force line breaks within text, as in '<P>This<BR>
is<BR> a<BR> paragraph.</P>'

>This means finding the lines that have no text and begin with a new
>line.

I'm not clear that I am understanding your question. 

>I have tried sommany different things.
>
>i.e  $text =~ s/^\n/<p>/go; # TO MATCH AT THE BEGINING OF 

Well,

$text  =~ s/\n/<BR>/g;

will put a line break anywhere the person has hit return.  While this
is what I would do, it might not be what you want.

>Anybody know anything thta might work?

I am sure someone does, but it might not be me.  :-)

It depends on how people are going to indicate a new paragraph.
If they are always going to indicate a new paragraph by hitting return
twice, then perhaps you could do:

#    Initially markup the string as one paragraph

$text = "<P>".$text."</P>";

#    Then use the regex to substitute '</P><P>' everywhere 
#    there appears '\n\n' or whatever you want to use as
#    the indication of a new paragraph.  [Note: I am a 
#    newbie, so there is probably a better way to handle 
#    these regular expressions.]
 
$text  =~ s#\n\n#</P><P>#g;

#    Finally, in the event the user hit return twice at the
#    end of the text, use the regex to remove the empty 
#    paragraph. 

$text  =~ s#<P></P>##g;

But this only works if the users are very careful about how they enter
text into that textarea of yours.  If they merely hit return once
after a paragraph and use a tab or a number of spaces to indicate a
new paragraph, obviously this won't work.  :-(  So you might have to
be clever in figuring out how many different ways you want to try to
capture your users' intentions when it comes to paragraphs without
creating a HTML nightmare if they do something different than you have
anticipated.

>Please mail me at mark@nhgri.nih.gov

Ok.


HTH

Faust Gertz
Philosopher at Large

"I had ambition once, but I got it removed by a doctor in Buffalo."  
-- Tom Waits


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

Date: 24 Jul 1997 11:32:13 GMT
From: e5ir@jupiter.sun.csd.unb.ca (Paul Vermette [NiD/BiM])
Subject: Re: Global Vars : Why would I want to use "use strict"
Message-Id: <5r7eft$g82@sol.sun.csd.unb.ca>

: #############################
: #!/usr/bin/perl -w

: my($foo) = "bar";
: baz();

: sub baz {
:         print "\$foo is $foo";
: }
: ##### output : "$foo is bar" #####

: Understanding this point has made me realize that "local()" is indeed
: seldom needed, as all the books I have read keep stating. I had
: previously thought that I would need "local" to do exactly what "my"
: does in the program above....

: I am disabused!

: Jason Duell

I wish that was going to work, but it didn't.. I tried it.  what version
of perl are you using?


--
              '''                    ______      _____
             (o o)                 /_____ /\   /_____ /|  / \        /|
 .------oOOO---(_)---------------. |   __  \/| |_    _|/  |\   \    /| |
|    Paul Vermette [NiD/BiM]    | |  |__|  |/   |  | |   |  \   \/  | |
|          e5ir@unb.ca          | |       /\    |  | |   |    \/    | |
| B O D i E S  i N  M o T i O N | |   __  \/|   |  | |   |  \    /  | |
`-------------------oOOO--------' |  |__|  |/  /|  |/ /| |  | \//|  | |
            |__|__|               |_______/   |______|/  |__|/   |__|/
             || ||                /BODIES/   ////IN//   ////MOTION//
            ooO Ooo               //////   ////////   ////    ////


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

Date: Thu, 24 Jul 1997 00:59:56 GMT
From: ehtics13@mindspring.com (Leon Keylin)
Subject: Help with RSH command
Message-Id: <33d6a84c.478241@news.mindspring.com>

I have not seen this questioned posed and I need help with it. So
please if you know how, give me a hand. 

Here's what I have:
(definition file is nodes.def which holds a list (big list) of nodes
that I want to rsh over and run the specific K-shell script. 

if (open(NODES, "nodes.def"))
{
    while($nodes= <NODES>)
    {
        chop($nodes);
        print "$nodes\n";
    }
        foreach $nodes ($b) {
        
    exec "rsh $nodes -n
directory/k-script.ksh"

The above works only for the local node (in other words I have my own
machine in the nodes.def file and the above program obviously does not
r-shell over to the other machines. 

Anyway that I can r-shell over to the other machines and run one (or
multiple) k-shells/commands?

Thanks in advance. 


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

Date: Sun, 20 Jul 1997 10:48:05 -0600
From: LTattrie <ltattrie@icrossroads.com>
Subject: Help: How to count subsitutions
Message-Id: <33D24145.6654@icrossroads.com>

Hi,
A file has been read in as one string then the command
$file =~ s/abc/def/sig;
is done to do global changes.  What I would like to know is how many
changes were done if any.  Is there a Perl variable which counts the
number of changes in a substitution?  Is the only way to count the
changes to do a loop and add one to a variable?  Would putting some of
the strings in parens help s/(abc)/def/sig ?
- Lawrence


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

Date: Sun, 20 Jul 1997 21:53:58 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: LTattrie <ltattrie@icrossroads.com>
Subject: Re: Help: How to count subsitutions
Message-Id: <Pine.GSO.3.96.970720215145.27787F-100000@kelly.teleport.com>

On Sun, 20 Jul 1997, LTattrie wrote:

> A file has been read in as one string then the command
> $file =~ s/abc/def/sig;
> is done to do global changes.  What I would like to know is how many
> changes were done if any.  

perlop(1) says this:

    s/PATTERN/REPLACEMENT/egimosx

    Searches a string for a pattern, and if found, replaces that pattern
    with the replacement text and returns the number of substitutions
    made. Otherwise it returns false (specifically, the empty string).

That looks like it. Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 24 Jul 1997 11:53:43 +1000
From: Joe Stepniewski <jtstepni@socs.uts.EDU.AU>
Subject: HELP: Telnet program
Message-Id: <Pine.SOL.3.95.970724115159.23183A-100000@charlie>

Hi,
 
I am writing a program to telnet to variuos routers and perform small
tasks on them. I assume it would be good to use chat2.pl, but I do not
know how to interface with it.
 
I need to telnet to a specified ip address and port number and send
login prompts, passwords, and exec commands - these vary for different
routers as well as the login/password prompts so I would need to expect
different responses.
 
Any help on this subject would be greatly appreciated
 
Thankyou
 
Joe Stepniewski <jtstepni@socs.uts.edu.au>



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

Date: 23 Jul 1997 16:58:47 -0700
From: trs@azstarnet.com (Tim  Smith)
Subject: Re: how to reverse substitution order ?
Message-Id: <5r65rn$fo6@web.azstarnet.com>

In article <5r64qc$9ie@web.azstarnet.com>,
Tim  Smith <trs@azstarnet.com> wrote:
>In article <33D5C9F1.41C6@geocities.com>,
>Proux Jean-Philippe  <proux@geocities.com> wrote:
>
>>if I use:
>>$chemin =~ s/\/\w*\/\.\.//g;
>>$chemin =~ s/\.\///g;
>
>It might work better for you to split the path name up, then deal with
>each component of the path in turn.  This isn't fully tested, but it
>might get you started.

I forgot to test for an empty component in the path.  If it's empty,
then either it's the initial '/' of an absolute path or it's a redundant
'/'.  You can tell between the two by whether or not there are any
components in @path.

Tim



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

Date: Thu, 24 Jul 1997 10:54:36 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Marshall Dudley <mdudley@execonn.com>
Subject: Re: Loading hash crashes computer
Message-Id: <33D7265B.65E2625C@adc.metrica.co.uk>

Marshall Dudley wrote:

> I am trying to load up a hash with values, but when I do, the comptuer
>
> will lock up, or get an invalid
> instruction fatal interrupt and close the window I am compiling in.
>
Not on mine it doesn't.

> Basically filehandle TABLE contains a table of x y entries, the number
>
> of impressions and click-thrus from system x to system y.  The same
> keys
> systems are located on the rows and columns.
>
> Anyway, the following is the section of code which pulls the values
> out
> of the matrix, and puts then into a two dimensional hash.

Which is not what you are doing. You are creating a 1D hash with keys
which are concatenations of the strings within the {}. In the example
below each hash ends up with 9 keys which are a combination of the 3
names in @name, i.e.'Links2GoLinks2Go'
'ExecutiveConnectionLinks2Go'
etc....

> @names is an
> array of the site names in the same order as the both the rows and
> columns are in.  As you may guess this is for a banner exchange
> application.
>
I hadn't but then impressions and click-thrus mean little to me.

> ie. for an array with 3 entries (we actually have about 80):
>
> If we have ExecutiveConnection Links2Go Seacom in @name array and then
>
> the <TABLE> file will look like this:
>
> 0=0       327=12     4736=213
> 873=43    0=0        9872=75
> 9872=432  8726=387   0=0
>
> @lines = <TABLE>;       #lines has the data for the sites
> $n = 0;
> foreach $line (@lines) {
>         $maxctr = 0;
>         $o = 0;
>         @pairs = split(' ',$line);
>         foreach $pair (@pairs) {

>                 ($impressions, $clicks) = split('=',$pair);
>                 $impression{@name[$n],@name[$o]} = $impressions; #will
>
> crash system
>                 $click{@name[$n],@name[$o]} = $clicks;           #will
> carsha

Whan you are accessing individual elements of an array you should be
putting $name[$o] and not @name[$o]. I know the latter will work but its
probably not good practice, and it might be what is crashing your system
( I wonder if this feature works in older versions of Perl? ).

> system
>                 ++$o;

>         }
>         ++$n;
> }
>
Why not replace the above with:

$n = 0;
foreach(<TABLE>){
  chomp; # Always a good idea
  $maxctr = 0;
  $o = 0;
  foreach(split) {
    ($impression{$name[$n],$name[$o]}, $click{$name[$n],$name[$o]}) =
split /=/;
    $o++;
  }
  $n++;
}

Thats just the minimalist in me.....Its probably a bit unsafe, but it
could probably also be made smaller. Either way you save yourself the
extra variables and arrays.

> Everything works as would be expected if I comment out the lines which
>
> build the hash for %impression and %click. But if either of those two
> lines are left to compile, the system will crash, lock-up, or the
> process will abort with an invalid instruction error, and the window
> will close.
>
> Anyone know why these instructions are causing these problems, and how
>
> to get around it?
>
> Thanks,
>
> Marshall

  I suggest you decide exactly how you want to store the data, look in
the perllol man page for some examples. If you are still having problems
once you have decided on how you want your data stored then shout. It
sounds like some sort of matrix i.e. a 3x3 array might be want you want,
but if you put it in a hash it will make accessing the data far easier.

Hope this gets you on your way

Simon



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

Date: 20 Jul 1997 12:48:07 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Making a matrix...
Message-Id: <5qt1e7$6bk@lyra.csx.cam.ac.uk>

Steffen Beyer <sb@en.muc.de> wrote:
>
>*** OR ***
>
>  $course = [ $semester, $teaches, $hours ];
>
>  $course[0][2] is element "summer"
>  $course[1][1] is element "Science"
>  $course[2][0] is '1'

Nope.   That says "Take element 0 of @course, dereference as an array and
take element 2" etc.     That first -> is essential:

   $course->[0][2] is element "summer"


Mike Guy


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

Date: 22 Jul 1997 07:30:57 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
To: Guilherme Braz de Carvalho <gbraz@dcc.ufmg.br>
Subject: Re: Making a matrix...
Message-Id: <5r1njh$3tj$1@news.rwth-aachen.de>

In article <Pine.SOL.3.96.970711104820.14486A-100000@turmalina>, Guilherme Braz de Carvalho <gbraz@dcc.ufmg.br> writes:
|> 
|>  Can I create a matrix in Perl ?  It would be a array into a array , all
|> right ? Can can it be ? like this ?
|> 
|> @curse =($semester,@teaches,$hours);
|> 
|> How can I make reference to an element of curse[0], teaches[1], would it
|> be like   $curse[0][1][1]  ?
|> 
|> Can I find some help like this in Programming Perl ? Where ? 
|> 

Nearly, look at the perlref man page or the corresponding chapter in
'Programming Perl' about references.

For your above example

use strict;

my ($semester,$hours)= (3,10);
my @teaches= (5,6,7);
my @curse = \($semester,@teaches,$hours);
#           ^----  note this

print "first and third element : ${$curse[0]} and ${$curse[2]}\n";

print "teaches  @{$curse[1]}\n";

print "third element of teaches  $curse[1][2]\n";

Hope, this helps a bit.

-- 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


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

Date: Wed, 23 Jul 1997 07:54:24 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Matching lowercase in regexp?
Message-Id: <0uu4r5.v61.ln@localhost>

I myself (tadmc@flash.net) wrote:
: Jason H. Elbaum (jhelbaum@holly.mr) wrote:

: : Here's a short, simple one that I've been unable to find in
: : the perl docs:

: from the perlre man page:


[ snip my answer to a question. unfortunately, it was not the
  poster's question. Sorry...
]


: : Thanks,

: You're welcome.


Duh, I should wait until my second cup of coffee before reading news...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Wed, 23 Jul 1997 10:45:49 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Newbie: Backtracking with regexp
Message-Id: <33D6272D.5CB98C2D@gpu.srv.ualberta.ca>

Stefan Berglund wrote:
[snip]
! Maybe this is of academic interrest only as I solved my actual problem
! with a workaround but I want to know what I should have done...
! 
! I have a file that looks like:
! 
! <entry>
! <topic>Computers</topic>
! <url>http://www.nisse.se</url>
! <title>Nisse</title>
! <comment>akjfhafaskfj</comment>
! <date>868432637</date>
! </entry>
! <entry>
! <topic>Entertainment</topic>
! <url>http://www.ti.com</url>
! <title>Texas</title>
! <comment>Texas lilla sida</comment>
! <date>868432637</date>
! </entry>
[snip]
! I want to match one entry (one block between <entry> and </entry>)
! using the expression between <url> and </url> tags.
 [snip]
! How can I do that using _one_ regular expression?

here's one way to do it using _one_ regular expression...
if the file is definitely in the form you give, you could
save yourself a lot of work by setting the record separator
to $/="</entry>\n" and then printing the record if the $url
matches:

$/="</entry>\n";
open(FILE,"filename")||die "can't open file $!";
$url="http://www.ti.com";
while (<FILE>) {
   print if m#$url#;
}

if you want to be able to repeatedly search for different
$url's, and memory isn't a problem, you can read the records
into an array and grep though them at your leisure.

regards
andrew


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

Date: Wed, 23 Jul 1997 01:17:45 GMT
From: cl_smith@sabre.com (Carol Smith)
Subject: OraPerl Perl scipt to track db time sought!
Message-Id: <3313CDA8B61A7D36.B1003FD5FF1B45A1.24AFD96A7960733E@library-proxy.airnews.net>

Looking for a Perl script that will track database connection time and
then after a specified amount of time, disconnect.   I am using
OraPerl to connect and disconnect.

Tnanks!


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 768
*************************************

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