[12516] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6116 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 24 10:07:24 1999

Date: Thu, 24 Jun 99 07:00:22 -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 Jun 1999     Volume: 8 Number: 6116

Today's topics:
    Re: @array= qx{<command>} - handling ()
    Re: @array= qx{<command>} - handling <tchrist@mox.perl.com>
    Re: A foreach question (Paul David Fardy)
    Re: A month behind using localtime(time) ? (Paul David Fardy)
    Re: Can I do this?  Conditional Operator construct.... <tchrist@mox.perl.com>
        child process communication question <msoulier@americasm01.nt.com>
    Re: deleting whitespace (Marc Bissonnette)
    Re: fdghfg (Juho Cederstrom)
        help on modules/packages <daniel.heiserer@bmw.de>
        How can I read a whole file in one go ? <janson6@etu.unige.ch>
    Re: How can I read a whole file in one go ? ()
    Re: How can I read a whole file in one go ? <tchrist@mox.perl.com>
    Re: How can I read a whole file in one go ? <gellyfish@gellyfish.com>
    Re: How can I read a whole file in one go ? <rolm@my-deja.com>
    Re: How can I use Perl variables in Javascript ? <qtxnmaj@kk.etx.ericsson.se>
    Re: How can I use Perl variables in Javascript ? (Bart Lateur)
    Re: How do you use XML Modules with ActiveStatePerl? <matt.sergeant@ericsson.com>
    Re: how to read a file reverse (Anno Siegel)
    Re: Intelligent case conversion? (eg., Title Case) <garethr@cre.canon.co.uk>
    Re: Losing Date/Time Information from Oracle Database ()
        MySQL / PHP / PERL form problem matthijs.van.der.wel@mediacenter.nl
        OO / @ISA question with Curses.pm (Konstantinos Agouros)
        Question - Returning Exit codes sjoshi@ingr.com
    Re: Question - Returning Exit codes (Malcolm Ray)
        Replacing i with e etc <Your.Name@icl.com>
    Re: Upload multiple files by broswer (Marc Bissonnette)
    Re: Viral matters [completely off-topic] (Philip 'Yes, that's my address' Newton)
        Where can i find Nik Silver's exercise answers? <mboertien@my-deja.com>
    Re: Where can i find Nik Silver's exercise answers? (Malcolm Ray)
    Re: Writing to a terminal from a perl script <ronald_f@my-deja.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 24 Jun 1999 12:41:59 GMT
From: mr@kells.kells ()
Subject: Re: @array= qx{<command>} - handling
Message-Id: <slrn7n4a8o.el.mr@kells.kells>

Perl will not do something as distructive are removing a 
newline unless you tell it to. Thats what chop and chomp are
for.

Martin
mpr@webcamnow.com

On 24 Jun 99 10:27:31 GMT, Martin Leja <martin@unix-ag.uni-siegen.de> wrote:
>hi,
>
>consider the following code:
>bash$ perl -e '@array=qx{/usr/bin/printf "bla\nblub\n"}; print("*$array[0]*$array[1]*");'
>*bla
>*blub
>*bash$
>
>ok, the two lines are split correctly into the array, but why does every
>array variable still contain a trailing '\n'?
>
>-- 
>Regards, martin@unix-ag.org


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

Date: 24 Jun 1999 07:11:07 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: @array= qx{<command>} - handling
Message-Id: <37722e6b@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Martin Leja <martin@unix-ag.uni-siegen.de> writes:
:ok, the two lines are split correctly into the array, but why does every
:array variable still contain a trailing '\n'?

Given that

    $a = `echo foo`;

produces a 4-byte string, why would you expect 

    $a = `echo foo; echo bar`;

to produce anything but an 8-byte string?  And by extension, since

    @a = `echo foo`;

produces a list with one 4-byte element, why would you expect

    @a = `echo foo; echo bar`;

to produce anything but a list with two different 4-byte strings
to be assigned into that array?

chomp.

--tom
-- 
It does not do to leave a live dragon out of your calculations, if you
live near him.                                     -- J. R. R. Tolkein


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

Date: 24 Jun 1999 13:09:45 GMT
From: pdf@morgan.ucs.mun.ca (Paul David Fardy)
Subject: Re: A foreach question
Message-Id: <7ktamq$5dn$1@coranto.ucs.mun.ca>

Different semantics: this one may match baz on consecutive lines.

#!/local/bin/perl -w

use strict;

my $foo;
while (<DATA>) {
    chomp;
    $foo and /baz/ and printf "%3d: Matched baz in \"%s\"\n", $., $_;
    $foo = /foo/;
}
__END__
zilch
foobar
bashbazbam
zorp
barfoo
bashBAZbam
snafoo
bazil foo
bazically
quux
foofuraw
second baz match
foo with no line following it


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

Date: 24 Jun 1999 12:47:27 GMT
From: pdf@morgan.ucs.mun.ca (Paul David Fardy)
Subject: Re: A month behind using localtime(time) ?
Message-Id: <7kt9cv$jdt$1@coranto.ucs.mun.ca>

Dale Henderson <dhenders@cpsgroup.com> writes:
>     Well how did you know anything at all about the localtime
>     function?  Did you randomly type in localtime and pray? Or did
>     you steal it from someone elses code?  

Read the manuals:

    man perl
      "perlfunc            Perl builtin functions"

    man perlfunc
      "Time-related functions:
            gmtime, localtime, time, times"

Paul Fardy
-- 
Paul David Fardy                      |  pdf@morgan.ucs.mun.ca
Computing and Communications          |  pdf@InfoNET.st-johns.nf.ca
Memorial University of Newfoundland   |
St. John's, NF  A1C 5S7               |


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

Date: 24 Jun 1999 06:46:06 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Can I do this?  Conditional Operator construct....
Message-Id: <3772288e@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    lr@hpl.hp.com (Larry Rosler) writes:
:I believe there is a compiler bug lurking here.  If I understand it, the 
:grammar is:
:
:      EXPR ? EXPR : EXPR
:
:and the precedences are such that the inner EXPR can be *anything*.  It 
:works for a single assignment, though '=' has lower precedence than '? 
::'.  So why shouldn't it work for ',' also???

It does not work for single assigment.

   Because this operator produces an assignable result, using assignments
   without parentheses will get you in trouble.  For example, this:

           $a % 2 ? $a += 10 : $a += 2

   Really means this:

       (($a % 2) ? ($a += 10) : $a) += 2

   Rather than this:

       ($a % 2) ? ($a += 10) : ($a += 2)

Of course, that's better written as:

       $a += ($a % 2) ? 10 : 2;

--tom
-- 
    It's documented in The Book, somewhere...
            --Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>


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

Date: Thu, 24 Jun 1999 08:56:36 -0400
From: "Soulier, Michael [SKY:1Z22:EXCH]" <msoulier@americasm01.nt.com>
Subject: child process communication question
Message-Id: <37722B04.54CEA383@americasm01.nt.com>

	Hey guys...
 
       I'm trying to interface with a child process that is normally
meant for
human interaction. I was hoping to do this in Perl without getting into
Expect. I've tried several techniques, the nicest being IPC::Open2. I
have a scheme for echoing the child's STDOUT to the user, and when I see
the prompt from the child again, I can stop echoing and send it
commands. 
        Unfortunately, I'm not seeing the prompt. I believe that this is
due to
the line buffering, since the prompt doesn't include a newline. I've
been trying FileHandle->setvbuf, trying to select no buffering for the
output filehandle from the child, but I can't seem to get the syntax
right, or I get Bad filehandle: GEN0 at
/home/msoulier/projects/prepare/genloadEcho line 24, where line 24 is
the line that I"m trying to use the setvbuf method. 

        Any ideas?

        Here's a sample:

use lib "/bnr/projects/pegasus/bin";
use PegSDE 1.01 qw(&check_MCE);

check_MCE();

$cmd = 'subcom pls list msoulier';
print "executing $cmd\n";
#open(CMD, "$cmd | ") 
#       or die("Can't execute $cmd: $!\n");
#while(<CMD>) {
#       print;
#}
#close(CMD)
#       or warn("Warning: Could not close pipe from $cmd: $!\n");

use IPC::Open2;
use IO::Handle;
use FileHandle;

$reader = new FileHandle;
$writer = new FileHandle;
$reader->setvbuf($buffer1, _IONBF, 0);
$writer->setvbuf($buffer2, _IONBF, 0);
open2($reader, $writer, $cmd);
LISTENER: while (1) {
        for ($curpos = tell($reader); $read = <$reader>; $curpos =
tell($reader)) {
                print $read;
                # stop listening condition
                last LISTENER if $read =~ /MCE\(pegasus\)/;
        }
        sleep 1;
        seek($reader, $curpos, 0);
}

        The commented sample works fine, but that doesn't let me truly
interact
with the child. 

        Thanks,

        Mike

-- 
Michael P. Soulier
1Z22, SKY
Tel: 613-765-4699 (ESN: 39-54699)
Email: msoulier@nortelnetworks.com
Carrier Packet Solutions
Nortel Networks Corporation
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."
   -Harley Hahn, A Student's Guide to UNIX


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

Date: Thu, 24 Jun 1999 13:50:47 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: deleting whitespace
Message-Id: <XIqc3.19806$5a.25979@news20.bellglobal.com>

In article <MPG.11dacf91634a4fdf989c34@nntp.hpl.hp.com>, lr@hpl.hp.com says...
>
>That deletes the first space character only.
>
>Why not let perlre and the FAQ answer the question, as three other 
>people have already suggested? 

Rats! Should have been $line =~ s/ //g;

Yes, the FAQ is the best place for it, but here's my reasoning, flawed or not:

Over the last four years, I've asked my share of questions on this newsgroup, a 
lot of them (if not the staggering majority) could have been answered by the 
FAQ's in far less time than it took to compose the question and wait for a 
response. Every now and then, however, some kind soul would take pity on me and 
post the answer to my question :)

Since I figured there was a question I could finally return the favour for, I 
posted the answer (flawed though it was - next time I'll double check my answer 
through the docs :) :)

I did learn, eventually, that the FAQ's are faster than posting, for the simple 
stuff and actually have the FAQ's on my HD as a shortcut in my browser (no 
excuse not to use em now :)

-- 
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: Wed, 23 Jun 1999 18:19:40 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: fdghfg
Message-Id: <slrn7n1uoc.2fe.cederstrom@vortex.cede.net>

On Tue, 22 Jun 1999 18:31:53 +0100, 
Darren Boyle <darrenboyle@callnetuk.com> wrote:
> dfghdfgd

Are you sure you are using the -w switch?

That works if you don't use it:

vortex:~$ perl
dfghdfgd
vortex:~$         

But if you use -w, it says:
"
Unquoted string "dfghdfgd" may clash with future reserved word at - line 1.
Useless use of a constant in void context at - line 1.            
"

You should also use strict, then it says:
"
Bareword "dfghdfgd" not allowed while "strict subs" in use at - line 2.
Unquoted string "dfghdfgd" may clash with future reserved word at - line 2.
Execution of - aborted due to compilation errors.
"

You can specify -w easily in the shebang line. So your program should
look like:

"
#!/the/path/to/perl -w
use strict;
dfghdfgd                
"


=)

-- 
#!/usr/bin/perl -wT -- Please take a look at my mail address when replying
use CGI;$a=reverse"r56%b6%36%16%H02%l27%56%P02%r56%86%47%f6%e6%A02%t37%".
"57%J=japh";$b=new CGI($a);$c=$b->param(lc(reverse("JAPH")));print"$c\n";


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

Date: Thu, 24 Jun 1999 15:11:29 +0200
From: Daniel Heiserer <daniel.heiserer@bmw.de>
Subject: help on modules/packages
Message-Id: <37722E81.1047D6BF@bmw.de>

Hi,
I am programming perl for a while now.
Now I want to use the modules/packages to clean
up my codes.

Unfortunately the stuff does not work the way I think
it should.
As far as I understood the "main" 
should become aware of the variable "why".
Why doesn't it.
please mailto:daniel.heiserer@bmw.deSigvald Refsum wrote:

#--------------------------------
#! /usr/local/bin/perl
use dh_default;
print "pl-why:$why";
if ($#ARGV==0){
        system("perldoc -t $0");
};

1;

__END__

=head1 NAME

TEST  -  TEST the gory details of perl
#--------------------------------
package dh_default;
### Daniel Heiserer, 24.June,1999

use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(why);
#make life nice and easy
$[=1;
$\="\n";
$,="-";
$why="I don't know";
#
print "argv=$#ARGV";
print "dollar-0=$0";
#if ($#ARGV==0){
#       system("perldoc -t $0");
#};
print "\$[=$[";
1;
#------------------------------------------------------------------------

Thanks, bye daniel

-- 
Mit freundlichen Gruessen
                                 Daniel Heiserer
-----
--------------------------------------------------------------
Dipl.-Phys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820
mailto:daniel.heiserer@bmw.de


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

Date: Thu, 24 Jun 1999 13:47:37 +0200
From: "Janson; Mikhael" <janson6@etu.unige.ch>
Subject: How can I read a whole file in one go ?
Message-Id: <37721AD9.41D7@etu.unige.ch>

Hello !

I'm looking for the way to read a whole file in one go into an array,
and not line by line.  

Here I'm doing 
@records = split/\<c\>/, <INPUTFILE>; 
and of course, this syntax reads line by line, and will only grab the
first line of my file.
But to put the whole file into @records, there is a syntax, but I've got
some trouble finding it ? 

Thanx  !

todatabase1.pl
____________________________________________________________
#!/usr/bin/perl
#
# Program to convert texts to my db format
#

# Ask for the input file name
print STDOUT "Enter the source file name: ";
chomp($myinput = <STDIN>);

# Set the book ID (dummy parameter at present stage)
$book_id = 1;

# Initialize the record counter variable
$record_id = 1;

# First open the input file
open (INPUTFILE, "$myinput") or die "Can't find $myinput: !\n";

# Read the whole file in one go and split it over the <c> marker
# an array of records
@records = split /\<c\>/, <INPUTFILE>;

# Print in a format suitable for importing into a database, namely
# lines of
foreach $record_text (@records) {
        print "$book_id \t $record_id \t $record_text \r\n";
        ++$parag_id;
}
________________________________________________________________




-- 
======================================
         janson6@etu.unige.ch
           mik@passtech.org
http://perso.wanadoo.fr/mikhael.janson
======================================


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

Date: 24 Jun 1999 12:51:46 GMT
From: mr@kells.kells ()
Subject: Re: How can I read a whole file in one go ?
Message-Id: <slrn7n4ar3.el.mr@kells.kells>

Here's a way. Read the entire file into a string and then split
the string.

{local $/; my $file = <INPUTFILE>; @records = split /\<c\>/, $file}

Martin
mpr@webcamnow.com

On Thu, 24 Jun 1999 13:47:37 +0200, <janson6@etu.unige.ch> wrote:
>Hello !
>
>I'm looking for the way to read a whole file in one go into an array,
>and not line by line.  
>
>Here I'm doing 
>@records = split/\<c\>/, <INPUTFILE>; 
>and of course, this syntax reads line by line, and will only grab the
>first line of my file.
>But to put the whole file into @records, there is a syntax, but I've got
>some trouble finding it ? 
>
>Thanx  !
>
>todatabase1.pl
>____________________________________________________________
>#!/usr/bin/perl
>#
># Program to convert texts to my db format
>#
>
># Ask for the input file name
>print STDOUT "Enter the source file name: ";
>chomp($myinput = <STDIN>);
>
># Set the book ID (dummy parameter at present stage)
>$book_id = 1;
>
># Initialize the record counter variable
>$record_id = 1;
>
># First open the input file
>open (INPUTFILE, "$myinput") or die "Can't find $myinput: !\n";
>
># Read the whole file in one go and split it over the <c> marker
># an array of records
>@records = split /\<c\>/, <INPUTFILE>;
>
># Print in a format suitable for importing into a database, namely
># lines of
>foreach $record_text (@records) {
>        print "$book_id \t $record_id \t $record_text \r\n";
>        ++$parag_id;
>}
>________________________________________________________________
>
>
>
>
>-- 
>======================================
>         janson6@etu.unige.ch
>           mik@passtech.org
>http://perso.wanadoo.fr/mikhael.janson
>======================================


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

Date: 24 Jun 1999 07:06:00 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How can I read a whole file in one go ?
Message-Id: <37722d38@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "Janson; Mikhael" <janson6@etu.unige.ch> writes:
:I'm looking for the way to read a whole file in one go into an array,
:and not line by line.  

% man perlfaq5
 
[deletia]

  How can I read in an entire file all at once?

    The customary Perl approach for processing all the lines in a
    file is to do so one line at a time:

        open (INPUT, $file)         || die "can't open $file: $!";
        while (<INPUT>) {
            chomp;
            # do something with $_
        } 
        close(INPUT)                || die "can't close $file: $!";

    This is tremendously more efficient than reading the entire file
    into memory as an array of lines and then processing it one
    element at a time, which is often -- if not almost always -- the
    wrong approach. Whenever you see someone do this:

        @lines = <INPUT>;

    You should think long and hard about why you need everything
    loaded at once. It's just not a scalable solution. You might
    also find it more fun to use the the standard DB_File module's
    $DB_RECNO bindings, which allow you to tie an array to a file so
    that accessing an element the array actually accesses the
    corresponding line in the file.

    On very rare occasion, you may have an algorithm that demands
    that the entire file be in memory at once as one scalar. The
    simplest solution to that is:

        $var = `cat $file`;

    Being in scalar context, you get the whole thing. In list
    context, you'd get a list of all the lines:

        @lines = `cat $file`;

    This tiny but expedient solution is neat, clean, and portable to
    all systems that you've bothered to install decent tools on,
    even if you are a Prisoner of Bill. For those die-hards PoBs
    who've paid their billtax and refuse to use the toolbox, or who
    like writing complicated code for job security, you can of
    course read the file manually.

        {
            local(*INPUT, $/);
            open (INPUT, $file)     || die "can't open $file: $!";
            $var = <INPUT>;
        }

    That temporarily undefs your record separator, and will
    automatically close the file at block exit. If the file is
    already open, just use this:

        $var = do { local $/; <INPUT> };


-- 
Common sense is the collection of prejudices acquired by age 18.
      --Einstein


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

Date: 24 Jun 1999 14:18:01 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I read a whole file in one go ?
Message-Id: <37723009@newsread3.dircon.co.uk>

Janson; Mikhael <janson6@etu.unige.ch> wrote:
> Hello !
> 
> I'm looking for the way to read a whole file in one go into an array,
> and not line by line.  
> 
> Here I'm doing 
> @records = split/\<c\>/, <INPUTFILE>; 
> and of course, this syntax reads line by line, and will only grab the
> first line of my file.
> But to put the whole file into @records, there is a syntax, but I've got
> some trouble finding it ? 
> 

You could replace the above with:

$/ = '<c>';

@records = <INPUTFILE>;

Look in the perlvar manpage for more on $/

/J\
-- 
"You look lovely this evening. Have you decreased in mass?" - Alien,
The Simpsons


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

Date: Thu, 24 Jun 1999 13:33:37 GMT
From: RoLm <rolm@my-deja.com>
Subject: Re: How can I read a whole file in one go ?
Message-Id: <7ktc3g$5u8$1@nnrp1.deja.com>

In article <37721AD9.41D7@etu.unige.ch>,
  "Janson; Mikhael" <janson6@etu.unige.ch> wrote:
> Hello !
>
> I'm looking for the way to read a whole file in one go into an array,
> and not line by line.
>
> Here I'm doing
> @records = split/\<c\>/, <INPUTFILE>;
> and of course, this syntax reads line by line, and will only grab the
> first line of my file.
> But to put the whole file into @records, there is a syntax, but I've
> got
> some trouble finding it ?
>
i've been told it's called a slurpy.  do the same thing you're doing now
but without the split.

@records = <INPUTFILE>;

Ciao,

RoLm



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 24 Jun 1999 13:53:30 +0200
From: Nina Mayor <qtxnmaj@kk.etx.ericsson.se>
Subject: Re: How can I use Perl variables in Javascript ?
Message-Id: <37721C3A.A7EA04EC@kk.etx.ericsson.se>

> Thank's !

But   I mean this :

#!/EDUP/Perl/5.004/bin/perl -w
print "Content-type:text/html\n\n";

$myvariable="true";

print <<EndOFHTML;
<HTML><HEAD><TITLE>CGITEST</TITLE>

<SCRIPT language= "JavaScript">
<!--
    function java_open(fileobj)
    {
        var fileinteger, fileString, URL, java_variable
        fileinteger=fileobj.selectedIndex

       <!-----------   $myvariable is not anderstood in this Javascript
--------------->
        java_variable = $myvariable;    <-- <-- <--

        filestring=fileobj.options[fileinteger].text;
        alert("Your choise is " +java_variable);      <!--   And the alert
window doesn't show the value of java_valiable ----->
    }
//-->
</SCRIPT>


</HEAD>  ------
-------
--
---
------
---------
------------
---------------
-----------------



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

Date: Thu, 24 Jun 1999 11:59:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How can I use Perl variables in Javascript ?
Message-Id: <37721cdd.155108@news.skynet.be>

Nina Mayor wrote:

>      <!-----------   $myvariable is not anderstood in this Javascript
>--------------->
>        java_variable = $myvariable;    <-- <-- <--

Of course it isn't. You have to fill in the value for that Perl
variable, which, BTW, I think you do. Only, you have to make it look
like a constant for Javascript. In other words: I *think* (my Javascript
experience is extremely limited) that it might work as is for numbers,
but for text strings, you'll have to provide some quotes.

        java_variable = "$myvariable";

So that the HTML turns out like

	java_variable = "Hello, world!";

   HTH,
   Bart.


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

Date: Thu, 24 Jun 1999 14:27:13 +0100
From: Matt Sergeant <matt.sergeant@ericsson.com>
Subject: Re: How do you use XML Modules with ActiveStatePerl?
Message-Id: <37723231.AC411E9F@ericsson.com>

Arved Sandstrom wrote:
> 
> You'll probably end up installing Matt's latest build of XML::Parser using
> PPM. I suggest perusing the Perl-XML FAQ at
> 
> http://www.perlxml.com/faq/perl-xml-faq.html
> 
> which describes the exact PPM options for obtaining this build.

Actually, AS's perl already has v2.23 installed. However, my repository
does try and keep up with the latest build faster than AS, so if there's
a new release to CPAN I generally have a binary that day. (this is
subject to change in the very near future as I'm leaving this job [hint:
anyone in the south of England looking to hire perl contractors - get in
touch]).

Matt.


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

Date: 24 Jun 1999 12:18:25 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to read a file reverse
Message-Id: <7kt7mh$onm$1@lublin.zrz.tu-berlin.de>

Mark-Jason Dominus <mjd@op.net> wrote in comp.lang.perl.misc:
>In article <Pine.GSO.4.02A.9906190846380.25127-100000@user2.teleport.com>,
>Tom Phoenix  <rootbeer@redcat.com> wrote:

[finding the last 14 lines of a file]

>We can embellish this a little to make it more robust:
>
>	$LINE_LENGTH = 80;
>	while (@lines < 14) {
>	  seek FILE, -($LINE_LENGTH * 14), 2;
>	  <FILE>;
>	  @lines = <FILE>;
>	  $LINE_LENGTH *= 2;
>	} 
>	splice @lines, 0, @lines-14;

Have you ever met a file with fewer than 14 lines?

        while ( @lines < 14 and seek FILE, -($LINE_LENGTH * 14), 2 ) {
        # ...
        }

Anno


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

Date: Thu, 24 Jun 1999 13:34:00 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Intelligent case conversion? (eg., Title Case)
Message-Id: <sivhcdbu47.fsf@cre.canon.co.uk>

Lee Borkman <borkman@usa.net> wrote:
> I would like something like this:
> 
> $line = tcase($line, @exclusions);
> 
> ...to supply my own list of words that shouldn't be capitalized
> (except at the start of a sentence).

It's probably better to use a hash instead of a list of excluded words
since the primary operation will be looking up the word in the list.

Here's an implementation:

     # title_case($text, $hashref) title-cases $text, except for words
     # that are keys in $hashref.  $hashref may be omitted, in which
     # case a default list of words is used.

     my %default_exclusions;
     @default_exclusions{qw(a an and for in of or the to)} = ();

    sub title_case {
      my @text = split /(\s+)/, lc shift;
      my $x = shift || \%default_exclusions;
      join '', ucfirst shift @text,
	map { exists $x->{$_} ? $_ : ucfirst } @text;
    }

-- 
Gareth Rees


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

Date: 24 Jun 1999 12:55:32 GMT
From: mr@kells.kells ()
Subject: Re: Losing Date/Time Information from Oracle Database
Message-Id: <slrn7n4b25.el.mr@kells.kells>

Definitly Oracle specific.

Martin
mpr@webcamnow.com

On Thu, 24 Jun 1999 04:33:23 GMT, Lee Borkman <borkman@usa.net> wrote:
>Many thanks,  that's perfect.
>
>btw, will to_char work with other databases, or is it Oracle specific?
>
>thanks again,
>Leeb.
> 
>


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

Date: Thu, 24 Jun 1999 12:31:42 GMT
From: matthijs.van.der.wel@mediacenter.nl
Subject: MySQL / PHP / PERL form problem
Message-Id: <7kt8ff$4fn$1@nnrp1.deja.com>

Hi,

I'm trying to build a database driven website, using MySQL, PERL and
PHP. I would like to make a form to update a table where the input
options are values from another table.

For example, I have a table called "subscribers" that contains 2
collums: 'email_address' and 'list', where 'list' contains the ID of
the email list the subsciber would like to receive.
I also have another table 'lists' that contain two collums: 'ID' and
'list_types'. I want a user to fill in a form to add his/her email
address to the table and choose from one of the list from the table
'lists'.

I've tried to make a PHP script but ran into a lot of trouble when I
tried to use both PRINT" ....."; and a value="xxx" within 1 line (seems
to make sense that you can't use PRINT" .....value="xxx"..."; on 1
line!). I've also tried to use PERL to generate a HTML page but
couldn't figure the right syntaxes.

Any help would be helpful, I've already been to the websites
www.mysql.com, www.php.net, www.cgidir.com and cgi.resourceindex.com
but didn't find a solution.....


Thanks in advance!


Please post a reply or email me at:matthijs.van.der.wel@mediacenter.nl


--
Matthijs van der Wel
Information Manager
Media Informatie Center BV
*** www.mediacenter.nl ***


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 24 Jun 1999 06:10:59 GMT
From: elwood@news.agouros.de (Konstantinos Agouros)
Subject: OO / @ISA question with Curses.pm
Message-Id: <1999Jun24.061059.3327@news.agouros.de>

Hi,

I am trying to do the following:

----------------------------------------------
#! /usr/local/bin/perl
# $Id$

package UI;

@Options=qw(Curses Screen);

sub new
{
    my $type = shift;
    my $class = {};

    # See if we can continue this...

    foreach $o (@Options)
    {
	if (($realref = eval("UI::$o->available()")))
	{
	    $class = eval("UI::$o->new()");
	    print "Class $class\n";
	    last;
	}
    }

    bless $class, $type;
}

package UI::Curses;

sub new
{
    my $type = shift;
    my $class = {};

    bless $class,$type;

    $class->{"win"} = new Curses;
    $class->{"win"}->initscr();
    $class->{"win"}->addstr(10,10,"Hallo");
    $class->{"win"}->refresh();
    sleep 5;
    return $class;
}
    my $type = shift;
    my $class = {};
    
    bless $class,$type;
}

sub available
{
    return 1;
}

package main;

$ui = UI->new();
--------------------------------------------
First thing I tried was simply initscr() in UI::Curses::new. But the strange
thing is that after that the return $class is never reached. Someone also poin-
ted out to me that I would need to call import but this also jumps out of my
new routine without reaching $class. I suspect the AUTOLOADER. If I leave out
the two other calls after the initscr I get my classreference back, but the
screen is not blanked. Can anybody help me?

Perl-Version is 5.003_99 and Curses.pm 1.02.

Konstantin
-- 
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres


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

Date: Thu, 24 Jun 1999 13:29:08 GMT
From: sjoshi@ingr.com
Subject: Question - Returning Exit codes
Message-Id: <7ktbql$5ql$1@nnrp1.deja.com>

Is it possible to intercept exit codes from a program being called from
a perl script using the system command.

thanks
Sunit


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 24 Jun 1999 13:56:09 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Question - Returning Exit codes
Message-Id: <slrn7n4e7o.bsp.M.Ray@carlova.ulcc.ac.uk>

On Thu, 24 Jun 1999 13:29:08 GMT, sjoshi@ingr.com <sjoshi@ingr.com> wrote:
>Is it possible to intercept exit codes from a program being called from
>a perl script using the system command.
>
>thanks
>Sunit

What did you find when you consulted the standard Perl documentation
for the system function?  I could have sworn it had an example of
doing exactly that.
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Thu, 24 Jun 1999 14:46:11 +0100
From: "Your Name" <Your.Name@icl.com>
Subject: Replacing i with e etc
Message-Id: <3772344b.0@145.227.194.253>

does anybody know of perl code to replace all characters with accents (e.g.
i, s, h etc) with the standard a-z chars

thanks
philip.howarth@icl.com




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

Date: Thu, 24 Jun 1999 13:53:15 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: Upload multiple files by broswer
Message-Id: <fLqc3.19808$5a.25979@news20.bellglobal.com>

In article <376E47E6.1462CDF4@i-cable.com>, tanya@i-cable.com says...
>
>is there any possible ways to upload multiple files by a broswer instead
>of upload files one by one

Yes : http://www.terminalp.com/scripts/file_upload.shtml


-- 
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: Thu, 24 Jun 1999 13:57:04 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Viral matters [completely off-topic]
Message-Id: <37723907.83161774@news.nikoma.de>

On Thu, 24 Jun 1999 09:33:53 +0100, Matt Sergeant
<matt.sergeant@ericsson.com> wrote:
>"Philip 'Yes, that's my address' Newton" wrote:
>> On Wed, 23 Jun 1999 17:18:33 +0100, Matt Sergeant
>> <matt.sergeant@ericsson.com> wrote:
>> >BS. So I take it "Bliss" is a figment of my imagination?
>> Who's he/she/it?
>You have access to the internet, right?

Oh. Um. Yeah. Now that you mention it... I found something about it.
Thanks.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.net>


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

Date: Thu, 24 Jun 1999 12:47:32 GMT
From: Nostradamus <mboertien@my-deja.com>
Subject: Where can i find Nik Silver's exercise answers?
Message-Id: <7kt9d1$4qh$1@nnrp1.deja.com>

I'm learning perl and found that this site :

http://agora.leeds.ac.uk/Perl/

had a very good (and short) Perl tutorial...every chapter ends with
some exercises, but i can't seem to find the answers...does anyone have
them or knows where i could find them???

Thanks in advance


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 24 Jun 1999 13:50:15 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Where can i find Nik Silver's exercise answers?
Message-Id: <slrn7n4dsn.boo.M.Ray@carlova.ulcc.ac.uk>

On Thu, 24 Jun 1999 12:47:32 GMT, Nostradamus <mboertien@my-deja.com> wrote:
>I'm learning perl and found that this site :
>
>http://agora.leeds.ac.uk/Perl/
>
>had a very good (and short) Perl tutorial...every chapter ends with
>some exercises, but i can't seem to find the answers...does anyone have
>them or knows where i could find them???
>
>Thanks in advance

I don't want to be too critical of that tutorial, because I only gave it
a very quick scan, but I noticed:

1. Shebang lines without '-w'
2. No mention of 'use strict'
3. Use of 'local', but no mention of lexical variables
4. Lots of opening of files without checking return status (unforgiveable!)
5. Use of chop; no mention of chomp

I suspect it hasn't been updated for Perl 5.  Hopefully someone can suggest
a better tutorial.
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Thu, 24 Jun 1999 11:16:17 GMT
From: Ronny <ronald_f@my-deja.com>
Subject: Re: Writing to a terminal from a perl script
Message-Id: <7kt41t$33b$1@nnrp1.deja.com>

In article
<Pine.BSF.4.05.9906231451060.13773-100000@lister.acm.wwu.edu>,
  Shane Fisher <fishers@lister.acm.wwu.edu> wrote:
> Greets,
>
> I am trying to figure out how to write to my terminal from a perl
script
> invoked by another process.  For example, a biff-like "new mail"
notice
> when procmail pipes a message to a perl script.  I understand that
> whenever procmail executes a script, it invokes it with the same
> environment as the intended recipient.

What do you mean exactly by "the environment of the intended recipient"?

> So, I'm wondering if there is an
> environment variable that the perl script can use to "find" the
terminal
> to write to.

I don't see how you would decide automatically which terminal to chose.
Say you running an X session, and you have 4 xterm windows open - which
one should receive your mail notice? Or should all your terminals be
informed? In this case, you could do a
	who
to get at the list of terminals belonging to the recipient.

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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