[10744] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4343 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 2 15:07:22 1998

Date: Wed, 2 Dec 98 12:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 2 Dec 1998     Volume: 8 Number: 4343

Today's topics:
    Re: Access Database <tripp.lilley@perspex.com>
        ANN: New Visual Interface for Perl <marty@solutionsoft.com>
        Behavior of C<for $var (..)> <jeffp@crusoe.net>
        Comparing lines from 2 different files? (Bryce Pursley)
    Re: Comparing lines from 2 different files? (Bryce Pursley)
    Re: Comparing lines from 2 different files? (Larry Rosler)
    Re: Date caluclations in PERL <botterwe@uni-koblenz.de>
        dbmopen <CHewell@ile.com>
    Re: does perl support Digital UNIX? <dparrott@ford.com>
    Re: field selection using "split" - question <r28629@email.sps.mot.com>
        Help with multiple database queries using Perl and Mysq xaqtnr@my-dejanews.com
        how to determine child pid ?? <kak@cisco.com>
    Re: how to determine child pid ?? (Greg Bacon)
    Re: imitating user input (Charles DeRykus)
    Re: Logging module with flock() ? <jay@rgrs.com>
        Multithread (Leonardo Kenji Shikida)
        Need Perl programming -- please advise... (Rick Ciaccio)
    Re: Newbie from Ottawa, Ontario Canada <harrisr@ugsolutions.com>
    Re: newbie question jkane@my-dejanews.com
        nt username <c.clark@student.unsw.edu.au>
    Re: PERL is TOO flexible <jeromeo@atrieva.com>
    Re: Perl Script to take data off a form and post it to  (Bradley K. Farrell)
    Re: Problems with 'setenv' within .sh and .pl scripts u <jjl@wk0c02g6.krf.noaa.gov>
        quickest way to merge two hashes? <kin@symmetrycomm.com>
    Re: quickest way to merge two hashes? <Allan@due.net>
    Re: quickest way to merge two hashes? (Larry Rosler)
    Re: Substitute <r28629@email.sps.mot.com>
        TOOLS EUROPE '99 - Call for Submissions <tools@tools.com>
    Re: Untainting Question (I R A Aggie)
    Re: Untainting Question (Greg Bacon)
        Using perl5 with Win95/dos command line. <CHewell@ile.com>
    Re: Using PERLDOC <r_larsen@image.dk>
        variable inside variable <qcoldiro@unlinfo.unl.edu>
    Re: Why is "... @foo ..." occasionally a syntax error? <r28629@email.sps.mot.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 02 Dec 1998 14:19:22 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Access Database
Message-Id: <366592BA.ACCD730A@perspex.com>



LSS wrote:

> # Here's a start.
> # It is simple, once you see how it is done.
> # Squint when you read the VB samples and you will see the Perl equivalents

Or you could go the more portable way and use DBI and DBD::ODBC. If'n
you don't already know, DBI is the "Database independent interface for Perl".
DBD::xxx is the namespace for DataBase Drivers that work with DBI.

Install DBI and DBD::ODBC (if you're using the ActiveState port, which I
assume you are, this is trivial using the PPM (Perl Package Manager)). That
done, read the docs for those packages. It's trivial, really. And the docs are
good. And the benefit to all of this is that you can fairly easily move your
scripts to work on non-Win32 platforms whenever you're ready, and to an
'industrial-strength' database.




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

Date: Wed, 02 Dec 1998 11:26:18 -0800
From: Marty Ford <marty@solutionsoft.com>
Subject: ANN: New Visual Interface for Perl
Message-Id: <3665945A.23B6@solutionsoft.com>

Hi,

I'd like to invite you to try a new experimental visual interface for
Perl and other scripting languages.

"BrowserApp" lets you use your web browser as a front end for
client-side Perl scripts. The visual interface for your script is
created using standard HTML forms. BrowserApp works in a similar fashion
to CGI, except that it works on the client, so web developers can use
their existing skills to create client-side scripts.

BrowserApp currently supports only Netscape 3.0 or later running under
Windows 95/98/NT.

You can download a free copy from
http://www.solutionsoft.com/BrowserApp.htm.

We are making this experimental release available to get feedback and
see if there is a need for this type of interface. Any feedback or
suggestions would be appreciated.

Thanks,

Marty Ford
Solutionsoft


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

Date: Wed, 2 Dec 1998 14:30:57 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Behavior of C<for $var (..)>
Message-Id: <Pine.GSO.3.96.981202142548.19230C-100000@crusoe.crusoe.net>

In debugging a script of mine recently (a variable had an unexpected
value), I came to a point where I thought I had found an error.  The
variable $x had an unexpected value, and I thought these lines were the
problem:

for $x (0..10){
	# something done
	# etc...
}

I decided to say C<for my $x (0..1)>.  However, upon later inspection, I
noticed that the following code produces the following results:

=for code
$var = "jeff";
for $var (0..10){ print $var; }
print $var;

# PRINTS

012345678910jeff
=end code

So.  I use Perl 5.004_04 (I'll be installing 5.005 soon, I hope).  I
wasn't able to find this behavior documented in the camel or perldoc... is
it?

--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
973-882-1022
www.crusoe.net



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

Date: Wed, 02 Dec 1998 19:07:14 GMT
From: hbpursle@duke-energy.com (Bryce Pursley)
Subject: Comparing lines from 2 different files?
Message-Id: <366664fe.1112622776@news.infoave.net>

Perl users,

I'm trying to take each line in file1 and match part of it to the
"first" matching line in file2 and then break out of file2 and go to
the next line in file1. (Obviously doing things to the lines when they
match but it's the control structure I'm struggling with.)

I open both files for read only and then this is what I'm trying to
do.

while (<file1>) {
      ($a, $b, $c) = split (/\s+/);
      $string1 = "$a$b$c";
   while (<file2>) {
      ($d, $e, $f) = split (/\s+/);
      $string2 = "$d$e$f";
         if (($a =~ $d) && ($b =~ $e)) {
            print "$string1$string2\n\n";
         }
   }
}

This appears to start working correctly but after it finds a match in
file2 it never seems to go back to file1.  I guess I don't really
understand the looping.  I'd appreciate a nudge in the right
direction.

Bryce Pursley


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

Date: Wed, 02 Dec 1998 19:28:13 GMT
From: hbpursle@duke-energy.com (Bryce Pursley)
Subject: Re: Comparing lines from 2 different files?
Message-Id: <366793e2.1124626747@news.infoave.net>

On Wed, 02 Dec 1998 19:07:14 GMT, hbpursle@duke-energy.com (Bryce
Pursley) wrote:

I may have answered my own question.  I added a "last;" statement at
the end of the second loop after the match line and it appears to be
doing what I want.  I'll keep testing and I would still appreciate
suggestions if you see something I'm doing that could be done better.
BP


>Perl users,
>
>I'm trying to take each line in file1 and match part of it to the
>"first" matching line in file2 and then break out of file2 and go to
>the next line in file1. (Obviously doing things to the lines when they
>match but it's the control structure I'm struggling with.)
>
>I open both files for read only and then this is what I'm trying to
>do.
>
>while (<file1>) {
>      ($a, $b, $c) = split (/\s+/);
>      $string1 = "$a$b$c";
>   while (<file2>) {
>      ($d, $e, $f) = split (/\s+/);
>      $string2 = "$d$e$f";
>         if (($a =~ $d) && ($b =~ $e)) {
>            print "$string1$string2\n\n";
>         }
>   }
>}
>
>This appears to start working correctly but after it finds a match in
>file2 it never seems to go back to file1.  I guess I don't really
>understand the looping.  I'd appreciate a nudge in the right
>direction.
>
>Bryce Pursley



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

Date: Wed, 2 Dec 1998 11:28:08 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Comparing lines from 2 different files?
Message-Id: <MPG.10cf34a0fa75b52d9898a4@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <366664fe.1112622776@news.infoave.net> on Wed, 02 Dec 1998 
19:07:14 GMT, Bryce Pursley <hbpursle@duke-energy.com> says...
> I'm trying to take each line in file1 and match part of it to the
> "first" matching line in file2 and then break out of file2 and go to
> the next line in file1. (Obviously doing things to the lines when they
> match but it's the control structure I'm struggling with.)
 ...
> while (<file1>) {
>       ($a, $b, $c) = split (/\s+/);
>       $string1 = "$a$b$c";
>    while (<file2>) {
>       ($d, $e, $f) = split (/\s+/);
>       $string2 = "$d$e$f";
>          if (($a =~ $d) && ($b =~ $e)) {
>             print "$string1$string2\n\n";

              last;

>          }
>    }
> }
> 
> This appears to start working correctly but after it finds a match in
> file2 it never seems to go back to file1.

You need to break out of the loop that is reading file2, and the above 
is the simplest way to do it.

Another way would be to put a label such as FILE1: on the outer loop, 
and replace the 'last;' statement above by 'next FILE1;'.  Many think 
that is more readable, but my C background makes that feel too much like 
the dreaded 'goto'.

You might also consider a test in the outer loop as to whether you have 
already reached the end of <file2>, so the loop on <file1> doesn't waste 
time spinning to its end.

BTW, Perl convention encourages all-upper-case names for filehandles.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 2 Dec 1998 19:57:46 +0100
From: "Goetz Botterweck" <botterwe@uni-koblenz.de>
Subject: Re: Date caluclations in PERL
Message-Id: <7442g7$sdd$1@newshost>


mvan@sprintmail.com wrote in message
<3664c6d1.1887391@nntp.a001.sprintmail.com>...
>I have a bunch of dates in a text file in the form MM/DD/YYYY and wish
>to calculate how many dates have elapsed from that date to todays
>date.


I can recommend Date::Manip.

First calc the Delta
  $delta=&DateCalc($date1,$date2,\$err);
  => 0:0:WK:DD:HH:MM:SS   the weeks, days, hours, minutes, and seconds
                          between the two

Then extract the difference in days
    str=&Delta_Format($delta,$dec,@format)

See the Manip.pod for more Details

HTH
GB
--
Goetz Botterweck
Institute for IS Research, University of Koblenz,  Germany
mailto:botterwe@uni-koblenz.de (MIME- and HTML-Mail welcome)
http://www.uni-koblenz.de/~botterwe/
Tel: +49 261 287-2564
Fax: +49 261 287-2521





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

Date: Wed, 2 Dec 1998 11:35:44 -0700 
From: Chris Hewell <CHewell@ile.com>
Subject: dbmopen
Message-Id: <2CD4D1A956A0D111B04100805F6F312CEBEDE3@email.ile.com>

Trying to map a hash out to disk files. I am running perl5 with
Win95/dos command line.
When trying to run the following code no .dir or .pag files are created.
What am I doing worng?

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

dbmopen (%last_good, "lastdb", 0666) || die "can't open lastdb: $!";
$last_good{$name} = time;
dbmclose (%last_good) || die "can't dbmclose lastdb: $!";

Chris Hewell 
Engineering Analyst
chewell@ile.com
303-245-7723
Ext. 7723



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

Date: Wed, 02 Dec 1998 13:22:39 -0500
From: "Dennis M. Parrott" <dparrott@ford.com>
To: GEMINI <dennis@info4.csie.nctu.edu.tw>
Subject: Re: does perl support Digital UNIX?
Message-Id: <3665856F.B37F7241@ford.com>

GEMINI wrote:
> 
> hi there,
> 
> our company are planning to purchase
> a DEC workstation & use Digital UNIX
> as the OS. I am wondering if the perl
> suuport it?
> thanks.

Seems to me that my friendly local
Unix admin pulled a 'setld' kit for
Perl directly from some box run by
Compaq (nee Digital).

try looking at ftp.digital.com in
/pub/DEC for a file called
PERL5004setld.tar and 
PERL5004setld.readme (or filenames
somewhat close to that...)
-- 

-----------------------------------------------------------------------
Dennis M. Parrott        |            Unix:  dparrott@ford.com
PCSE Webmaster           |           PROFS:  DPARROTT
Ford Motor Company       |             VAX:  EEE1::PARROTT
Dearborn, Michigan USA   | public Internet:  dparrott@ford.com
-----------------------------------------------------------------------
Voice: 313-322-4933  Fax: 313-248-1234  Pager: 313-851-2958


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

Date: Wed, 02 Dec 1998 12:15:25 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: field selection using "split" - question
Message-Id: <366583BD.8A9F9D83@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Bart Lateur wrote:
[...] 
> The [-1] subscript is very nice for taking the last element of an array.
> But it |!#|@!~ doesn't work for ranges.
> 
> For example, this does not work to take everything but the first array
> element:
> 
>         @ary[1..-1]
> 
> You HAVE to use
> 
>         @ary[1..$#ary]
> 
> which is very irritating if you need it for temporary arrays with no
> name; like (split /\//).
> 
> (Yes, I KNOW I can also use shift or splice, it's just an example.)

the problem is with the range operator, not subscripting. In your
specific case, this would work and look better than using splice or
shift:

        (undef, @wanted) = split /\//;

-TK


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

Date: Wed, 02 Dec 1998 19:15:03 GMT
From: xaqtnr@my-dejanews.com
Subject: Help with multiple database queries using Perl and Mysql.pm
Message-Id: <7443jk$58u$1@nnrp1.dejanews.com>

I am trying to do multiple (only 2) database queries using Mysql.pm and I keep
getting the following error:

>> Can't call method "Query" without a package or object reference at script.cgi
>> line 60.

I am positive all of my calls are correct since they work separately. I try
the following:

&sn_connect;
&check;

sub check{
  $password = &crypt($password);
  $good_pass_p = 0;
  $good_pass_c = 0;

  $query = qq{SELECT field FROM table WHERE field = 'value'};
  $sth = $sn_dbh->Query($query);

  while ($pass_chk = $sth->FetchRow){
    if ($pass_chk eq $password){
      $good_pass_p = 1;
      break;
    }
  }

  if ($good_pass_p <= 0){
    &cc_connect;
    $query = qq{SELECT fields FROM table where field <> 'value'};
    $sth = $cc_dbh->Query($query);

    while ($encr_pass = $sth->FetchRow){
      if ($encr_pass eq $password){
        $good_pass_c = 1;
        break;
      }
    }
  }
}


sub sn_connect{
  $loc = "hostname_one";
  $user = "user";
  $passwd = "passwd";
  $database = "dbase_one";
  $sn_dbh = Mysql->Connect($loc,$database,$user,$passwd);
}

sub cc_connect{
  $loc = "hostname_two";
  $user = "user";
  $passwd = "password";
  $database = "dbase_two";
  $cc_dbh = Mysql->Connect($loc,$database,$user,$passwd);
}


It works if I choose to retrieve data from the first database, but when I
attempt to retrieve data from the second database it gives me the error. I
have read some docs on Mysql.pm and it states that multiple database queries
are possible with different database handles, but I can't get it to work.

Help is much appreciated.



--

Shay

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 02 Dec 1998 13:23:01 -0500
From: Keith Kaple <kak@cisco.com>
Subject: how to determine child pid ??
Message-Id: <36658585.50D60E59@cisco.com>

I can kinda code around what is a parent and what is a child now, but I
would like to know _which_ child I am dealing with...

Could someone take mercy on me with some enlightenment, please?  In the
following, how would you print the child's pid to stdout?  I just get
all the children's data in stdout with no differenciation.

#!/usr/bin/perl
#
#
#       Forking Man-In-The-Middle server
#

$CALLPORT=1720;

use IO::Socket;

$SIG{CHLD} = sub{wait()};

$main_sock = new IO::Socket::INET (     LocalPort => $CALLPORT,
                                        Listen    => 20,
                                        Proto     => 'tcp',
                                        Reuse     => 1,         );
die "Socket could not be established.  Reason: $!\n" unless
($main_sock);
while ($new_sock = $main_sock->accept())        {
        $pid= fork();
        die "Cannot fork: $!" unless defined($pid);
        if ($pid == 0) {
                #child at play
                while (defined ($buf = <$new_sock>))    {
                        print $new_sock "Back at ya- $buf\n";
                        print "$buf -by pid:$pid";  #<----what variable
id's me as "child 3" or "child 1"
                }
                exit (0);       # bye child
        } #else parent back on accept
}
close ($main_sock);


--
Keith Kaple x25759 -----------------------
| New distribution, $40.  Linux compatible
| sound card, $89.  Three button mouse, $18.
| Nuking windows partitions....priceless.





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

Date: 2 Dec 1998 19:51:15 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: how to determine child pid ??
Message-Id: <7445nj$6nr$2@info.uah.edu>

In article <36658585.50D60E59@cisco.com>,
	Keith Kaple <kak@cisco.com> writes:
: Could someone take mercy on me with some enlightenment, please?  In the
: following, how would you print the child's pid to stdout?  I just get
: all the children's data in stdout with no differenciation.

In the child, use the magic variable $$ to get your pid.  If you want
to give each of your children a serial number, the children need to
inherit their serial numbers from the parent like

    my $serial = 0;

    while ($new_sock = $main_sock->accept) {
        $pid = fork;
        die "$0: cannot fork: $!" unless defined $pid;

        if ($pid == 0) {  # in child
            while (defined($buf = <$new_sock>) {
                print $new_sock "Back at ya- $buf\n";
                print           "$buf -by $$ (child $serial)\n";
            }

            exit 0;
        }

        $serial++;
    }

Hope this helps,
Greg
-- 
Ah, women. They make the highs higher and the lows more frequent.
    -- Nietzsche


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

Date: Wed, 2 Dec 1998 17:53:38 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: imitating user input
Message-Id: <F3Cn1E.E1M@news.boeing.com>

In article <7438ei$j6i$1@news.ibm.net.il>,
avshalom avital <avitala@macs.biu.ac.il> wrote:
>hi all,
>say I want to init a process, but continue monitoring it (imitating
>keyboard input, for
>instance, well- precisely), is there any way of doing that?
>e.g. - do the following automatically:
>run telnet
>input username and passwd
># run some commands #
>exit
>

Look at the 'Expect' module (Austin Schutz) on CPAN. There's
a telnet style program in the examples directory.  

hth,
--
Charles DeRykus


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

Date: 02 Dec 1998 13:17:01 -0500
From: Jay Rogers <jay@rgrs.com>
Subject: Re: Logging module with flock() ?
Message-Id: <82iufummsi.fsf@shell2.shore.net>

millerb@millerb.fc.hp.com (Bryan Miller) writes:

> Does anyone know of a version of Log-Logger or something
> similar that provides a logfile generation mechanism but
> also provide some sort of file locking mechanism?

Generally speaking, locking a log isn't necessary.

If you open the file for "append" then Unix will guarantee that each
write is at the end of file.  You should also turn-off buffering for
that filehandle.  I don't know if this is how Log-Logger works as I'm
not familiar with it.

--
Jay Rogers
jay@rgrs.com


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

Date: 2 Dec 1998 18:27:22 GMT
From: kenji@dcc.ufmg.br (Leonardo Kenji Shikida)
Subject: Multithread
Message-Id: <7440qa$63d$1@usenet.pop-mg.rnp.br>

I am working in a system like this:

Module A must telnet the router on port i, dial to a number, recover its
contents, save it to a file with a unique name.
Module A ends this and start the same process on port i+1, etc...

Well, i'm thinking about start i+n threads, each one dealing with each
port on the router. Module A so must talk to it's threads and schedule
them.

Is it a good idea ? Is it a good idea in Perl ?

I'll ask anyone that answer this to make it also by email above

Thanks in advance

http://www.dcc.ufmg.br/~kenji .............................. kenji@dcc.ufmg.br



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

Date: Wed, 02 Dec 1998 10:24:13 GMT
From: rick@mesagroup.nospam.com (Rick Ciaccio)
Subject: Need Perl programming -- please advise...
Message-Id: <36691549.129086984@news.earthlink.net>

Greetings,

A client is thinking of putting up an instant confirmation for their
reservations page in their Website whereby guests will get an instant
reservation number upon submitting their request.

The following are their concerns:

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

Say we have a 10 room inventory for each of our 7 hotels per day (total 70
rooms):

1. How can we keep track of  the room inventory?

2. Is the reservation number customisable? i.e. can we set it so that we
can have a different prefix for each hotel?

3. Do we get a copy of the reservation number when the customer submits
his reservation?

4. What happens if we get more than 10 bookings for that particular hotel
on a given day?

5. Can we generate a monthly summary report?

6. How much would it cost to implement the above & how long would it take?

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

We would like the scripts to be totally configurable and flexible so that
all parameters can be scaled as needed.

Please let us know asap if you can do this.

Best regards,

Rick Ciaccio
Mesa Internet Servers




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

Date: Mon, 30 Nov 1998 16:40:59 -0500
From: Randy Harris <harrisr@ugsolutions.com>
Subject: Re: Newbie from Ottawa, Ontario Canada
Message-Id: <366310EB.C09E9046@ugsolutions.com>

Hi Susie,

>From the sounds of your message, I am on a path similar to your own.  I
have been learning Perl out of necessity, developing an application that I
need to run on both NT and Unix.  I've found the Perl learning curve quite
steep.

I started by purchasing Learning Perl (the Unix version, however) and
Programming Perl but found them both somewhat difficult to use.  Neither
seemed to contain enough "simple" examples to work with and I found using
the code "fragments" difficult to include into my own program.  As I've
gained experience I do find the Programming Perl a fairly usable
reference.  I have not yet tackled some of the more advanced topics, such
as Packages and Modules.  (Soon)

I did like Robert's Perl Tutorial very much. Though it is quite
fundamental, I found it extremely clear and easy to follow.  The level of
user support in this news group has been, however, quite disappointing,
many more questions than answers.

I would be happy to lend a hand in your climb of that learning curve.  (I
am nowhere near Ottawa).  I have quite a lot of programming background,
professionally I teach software installation, system and database
administration on Unix systems.  If you don't receive a "better offer",
Email me at the address below to establish a dialog.

Randy Harris
harrisr@ugsolutions.com


Susie wrote:

> Hi there. My name is Susie. I want to learn Perl very badly. I have no
> programming experience other than writting scripts for popups for
> Mirc. <Yea I know...lol> In January I'm starting my diploma to become
> a Programmer Analyst so yes there is hope for me but Perl is not
> offered on this course and I've been advised by a few companies here
> that I should learn it. I've bought O'Reilly's books..."Learning Perl
> on Win32 Systems" and "Programming Perl". I started reading the
> Learning Perl one and I somewhat understand what it's saying but I'm
> getting confused. So with this I went searching on the web for a
> tutorial that may be more basic than Learning Perl. I found one <I
> thought> at http://www.netcat.co.uk/rob/perl/win32perltut.html
> It seems good but I'm still confused. I think my problem is that I've
> not seen Perl work. I'm confused about it's output and where it is
> used. Am I sounding confused? I certainly am.<smile> In any case I've
> subscribed to this newsgroup and a couple of others and I try finding
> stuff on newbies and maybe seeing if I could find something out that
> would help but I can't seem to find anything. If there is anyone out
> there who thinks they could help me please contact me and if anyone
> lives here in the Ottawa region it would be great to see how Perl
> actually works. Oh yes, and I tried to find out about someone offering
> a course but to no avail. Thank you all for your time.
> Cheers,
> Susie



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

Date: Wed, 02 Dec 1998 18:24:18 GMT
From: jkane@my-dejanews.com
Subject: Re: newbie question
Message-Id: <7440kf$2ih$1@nnrp1.dejanews.com>

In article <743pfb$ru1$1@nnrp1.dejanews.com>,
  dennishancy@eaton.com wrote:
> I have a CGI script that looks like this:
>
> open(STATS,">>../stats.txt");
>
> $mydate = `date`;
> print STATS "$mydate"."  "."$ENV{HTTP_USER_AGENT}  \n";
>
> close STATS;
>
> How come when I run this script, my output looks like this?
>
> Wed Dec  2 11:28:46 GMT 1998
>   Mozilla/4.06 [en] (Win95; I)
>
> Shouldn't everything be on the same line?

Because `date` returns a string with a CR in it.

-Jeff

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 03 Dec 1998 06:40:56 +1100
From: Chris Clark <c.clark@student.unsw.edu.au>
Subject: nt username
Message-Id: <366597C8.9BD303FA@student.unsw.edu.au>

Hi,

I'm using PERL on an Intranet, and I need to know how you determine the
NT username of someone who is looking at the Intranet website.  Is it as
simple as using an environment variable?  If so, what is it?  I've tried
REMOTE_USER, but that didn't work.....  is there something I need to
enable on the users' pcs????

Any assistance would be great,


thanks,

Chris Clark.



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

Date: Wed, 02 Dec 1998 09:54:20 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Dirk Kaufmann <kadi0012@fh-karlsruhe.de>
Subject: Re: PERL is TOO flexible
Message-Id: <36657ECC.BBB05456@atrieva.com>

Dirk Kaufmann wrote:

> > I would go so far as to say that for any given non-perl programmer, perl
> > is far more readable than most other languages.  I try to write
> > maintainable code, knowing that the person maintaining it behind me
> > might not be so perly.  It's a great language as far as that goes.
> 
> think about that there are always beginners, otherwise the laguage is gonna
> die.

I think that depends on what our beginner is beginning.  If a person has
no programming experience at all, perl might be easier to learn than,
say C/C++ or COBOL, but for someone with no perl, but experience with
C/C++ or COBOL, perl has a very low learning curve.

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Wed, 02 Dec 1998 18:01:53 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: Perl Script to take data off a form and post it to the operator
Message-Id: <366b7d02.128428435@news.m.iinet.net.au>

Neil Elliott <en02@gre.ac.uk> wrote:
>I have been trying to get this perl script to work with a form for ages
>and I have hit my head on a brick wall
[snip]

It appears that you may not have read the FAQ. If this is true, you
should go and read it now:
http://www.cpan.org/doc/FAQs/
[as detailed in the earlier message: How to find the Perl FAQ]

If you have read the FAQ, then may I suggest that you re-read:
  Where can I learn about CGI or Web programming in Perl?

HTH
-- 
Bradley K. Farrell
bradley@iinet.net.au


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

Date: Wed, 2 Dec 1998 12:33:12 -0600
From: John LaGue <jjl@wk0c02g6.krf.noaa.gov>
Subject: Re: Problems with 'setenv' within .sh and .pl scripts under AIX
Message-Id: <Pine.HPP.4.02.9812021231390.8096-100000@wk0c02g6.krf.noaa.gov>

On Tue, 1 Dec 1998, Craig Horton wrote:

> I want to change the ORACLE_SID environment variable within a perl script,
> so that I can automate the shutdown and startup of 3 instances of our
> databases, so we can back them up. However, I have found I can't seem to get
> setenv to make the change from within perl, using:
> 
> system('setenv ORACLE_SID $instance');
> 
> Since we had the same problem after installing Windows NT 4, SP4, we got
> around that by calling .cmd files to change the SID each time. If I do it
> from the shell prompt, ORACLE_SID is changed.
> 


  From within your perl script, try:
  
  ENV{ORACLE_SID} = $instance;
  
  
  John L.
  
  



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

Date: 02 Dec 1998 10:00:52 +0000
From: Kin Cho <kin@symmetrycomm.com>
Subject: quickest way to merge two hashes?
Message-Id: <un256yiaz.fsf@server3.symmetrycomm.com>

Is there a faster way then the following loop?

# merge %b with %a
while (($k,$v) = each(%a)) {
   $b{$k} = $v;
}

Thanks.

-kin


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

Date: Wed, 2 Dec 1998 14:16:44 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: quickest way to merge two hashes?
Message-Id: <7443dt$960$1@camel21.mindspring.com>

Kin Cho wrote in message ...
>Is there a faster way then the following loop?
># merge %b with %a
>while (($k,$v) = each(%a)) {
>   $b{$k} = $v;
>}


I might use a hash slice in this instance:

@b{keys %a} = values %a;

values from a overwrite values for b if there are duplicate keys is present.

AmD




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

Date: Wed, 2 Dec 1998 11:15:45 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: quickest way to merge two hashes?
Message-Id: <MPG.10cf31bc4eda055a9898a3@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <un256yiaz.fsf@server3.symmetrycomm.com> on 02 Dec 1998 
10:00:52 +0000, Kin Cho <kin@symmetrycomm.com> says...
> Is there a faster way then the following loop?
> 
> # merge %b with %a
> while (($k,$v) = each(%a)) {
>    $b{$k} = $v;
> }

This is the neatest, using the hash-slice approach:

@b{keys %a} = values %a;

It relies on the order of presentation of the values matching the order 
or presentation of the keys, which is guaranteed.

perldoc -f keys:

    The keys are returned in an apparently random order, but it is the
    same order as either the values() or each() function produces
    (given that the hash has not been modified).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 02 Dec 1998 12:36:48 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Substitute
Message-Id: <366588C0.3780D913@email.sps.mot.com>

Martien Verbruggen wrote:
> 
> In article <3664875D.DED235C0@email.sps.mot.com>,
>         Tk Soh <r28629@email.sps.mot.com> writes:
> 
> > DATA is a special filehandler that refers to anything after __END__ or
> > __DATA__ tokens. You should try to stay away from it.
> 
> I do agree that it is not adviseable to use DATA as a file handle,
> unless you mean the special one, but there is nothing wrong with it at
> all, and it will work as expected.
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> open(DATA, $0) || die "Couldn't open $0: $!";
> 
> while (<DATA>)
> {
>         print;
> }
> 
> __DATA__
> foo
> bar
> 
> The above neatly outputs the program itself.
> 

I assume they already know what they could do with even the special
handlers, hence the sentence "...should..."

-TK


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

Date: Wed, 2 Dec 1998 11:03:47 -0800
From: "TOOLS Conferences" <tools@tools.com>
Subject: TOOLS EUROPE '99 - Call for Submissions
Message-Id: <7442te$99s$1@news.rain.org>

*********************************************************
                   CALL FOR SUBMISSIONS

                     TOOLS EUROPE '99
    Technology of Object-Oriented Languages and Systems
    29th International Conference and Exhibition
                "OBJECTS, COMPONENTS, AGENTS"

               Nancy, France, June 7-10, 1999

                http://www.tools.com/europe
*********************************************************

Conference Chair: Jean-Pierre Finance, Henri Poincari University, France
Programmme Chair: Richard Mitchell, University of Brighton, UK
Tutorials Chair: Alan Cameron Wills, TriReme International Ltd, UK
Workshops & Panels Chair: Jan Bosch, University of Karlskrona/Ronneby,
Sweden
Organising Committee Chair: Martine Gautier, Henri Poincari University,
France
Conference Series Chair: Bertrand Meyer, ISE, USA

TOOLS Europe '99 is now soliciting contributions for technical papers,
tutorials, workshops, and panels.

Submission guidelines are available at http://www.tools.com/europe/

IMPORTANT DATES
Tutorial, Workshop and Panel proposals: Friday, January 8, 1999
Notice of submission for technical papers: Friday, February 12, 1999
Submission of technical papers: Friday, February 19, 1999
Notification of acceptance: Monday, March 29, 1999
Final manuscripts due at IEEE: Friday, April 16, 1999
Conference: Monday 7 to Thursday 10, June 1999

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TOOLS EUROPE '99 IS ORGANISED IN COOPERATION WITH
UNIVERSITI HENRI POINCARI, NANCY, FRANCE.

FOR MORE INFORMATION ON TOOLS USA '99,
VISIT OUR WEB SITE AT http://www.tools.com/europe
OR CONTACT US AT tools-europe@tools.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




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

Date: Wed, 02 Dec 1998 13:44:41 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Untainting Question
Message-Id: <fl_aggie-0212981344410001@aggie.coaps.fsu.edu>

In article <36657780.788878096@nntp.cts.com>, sprintfer@yahoo.com (Mike
D.) wrote:

+                 mkdir("$BASE_DIR/records/$directory", 0777);

+ Insecure dependency in mkdir while running with -T switch.

Either $BASE_DIR is insecure, or $directory is insecure.
 
+ Is there a way I can get around this without creating 676+ (a-za-z)
+ directories?  Or basically, is it possible to create directories and
+ files while in taint mode?

Yes, it is. Based on your code snippet:

#!/usr/bin/perl -Tw
$BASE_DIR='.';
$var='aname';
$directory = unpack("a2", $var);
mkdir "$BASE_DIR/$directory",0777;

Notice that $BASE_DIR and $directory do not come from user input, and are
untainted.

James


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

Date: 2 Dec 1998 19:36:29 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Untainting Question
Message-Id: <7444rt$6nr$1@info.uah.edu>

In article <36657780.788878096@nntp.cts.com>,
	sprintfer@yahoo.com (Mike D.) writes:
: Here is where I am running into problems:
: 
: 	## If the ID was pm00045 then directory will equal "pm"
: 	my ($directory) = unpack("a2", $self->{id});
: 
: 	if (! (-d "$BASE_DIR/records/$directory")) {
: 		mkdir("$BASE_DIR/records/$directory", 0777);
: 	}
: 	sysopen(FILE, "$BASE_DIR/records/$directory/$self->{id}",
:               O_WRONLY|O_CREAT|O_EXLOCK)
:           || die("$self->{id} :$! in customer class\n");
: 
: I get the error:
: Insecure dependency in mkdir while running with -T switch.

As another poster already pointed out, that means at least one of
$BASE_DIR and $directory is tainted.  Since you didn't show the
code that generates $BASE_DIR (which I assume is hardcoded and would
be, therefore, untainted) or $self->{id}, I'm assuming $self->{id}
is tainted somehow.  Instead of using unpack, why not do something
like

    my $directory;
    if ($self->{id} =~ /^(\w\w)/) {
        $directory = $1;  # $directory guaranteed to be untainted
    }
    else {
        die "Malformed id ($self->{id})";
    }

: Is there a way I can get around this without creating 676+ (a-za-z)
: directories?  Or basically, is it possible to create directories and
: files while in taint mode?

Yes, it's possible, but the information you pass must be untainted.

: I've read "Cleaning up your Path" (pg. 359) in Programming Perl and
: have added $BASE_DIR/records to $ENV{PATH} and this doesn't help.  Do
: I need to add something else?

When running in taint mode, perl requires that your PATH be untainted
if you try to run external programs (e.g. via ``, qx//, system, or
exec), but Perl's mkdir operator makes use of the mkdir system call
and not the mkdir command.  In short, the contents of your PATH are
irrelevant to this particular problem.

Read the perlsec manpage for a greater level of detail.

Hope this helps,
Greg
-- 
There are no facts, only interpretations.
    -- Nietzsche


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

Date: Wed, 2 Dec 1998 11:15:32 -0700 
From: Chris Hewell <CHewell@ile.com>
Subject: Using perl5 with Win95/dos command line.
Message-Id: <2CD4D1A956A0D111B04100805F6F312CEBEBD1@email.ile.com>

Just starting out with the perl language!
With that in mind I have a question regarding some examples I am trying
to run.
The examples come from the book"Learning Perl" by Randal L. Schwartz &
Tom Christiansen.

When I run the following sub routine I get the following:

Literal @ile no requires backslash at line#, within string.
Execution of filename.pl aborted due to compilation errors.

When I place a backslash as requested  no e-mail is sent to me when the
user enters an
incorrect password.

Any thoughts would help get me back on track!

sub good_word {
	my($somename,$someguess) = @_;        
	$somename =~ s/\W.*//;                         # Get rid of
everything after first word
	$somename =~ tr/A-Z/a-z/;                      # Place
everything into lowercase
	if  ($somename eq "Chris") {                   # No need to look
to hash table
		return 1;
	} elsif (($words{$somename} || "groucho") eq $someguess) { 
		return 1;
	} else {
		open (MAIL, "|mail chewell@ile.com");
		print MAIL "bad news: $someone guessed $someguess\n";
		close MAIL;
		return 0;
	}
}
 

Chris Hewell 
Engineering Analyst
chewell@ile.com
303-245-7723
Ext. 7723



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

Date: Wed, 02 Dec 1998 19:50:08 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Using PERLDOC
Message-Id: <VA.0000008e.002a9d88@octo>

"Allan M. Due" <Allan@due.net> wrote:
> 
> Hawkwynd wrote in message <3663d826.30963067@nntp.buf.adelphia.net>...
> >At the command line in Windows 98, when I run c:\>perldoc -f print
> >I get the following error message, or report:
> >No documentation found for "perlfunc".
> >perllocal.pod is located in the C:\Perl\5.005\lib\MSWin32-x86-object
> directory as well as:
> >POSIX.pod
> >lwpcook.pod
> >
> >The PATH statement is correct. Am I missing something in my perl
> installation? Otherwise,
> >all scripts run fine.
> >Thanks in advance.
> 
> 
> It is my understanding that ActiveState decided not to include the pod files
> with their distribution.  There is a pod subdirectory, but it only includes
> HTML files.  


I have installed perl 5.005_02 from ActiveState (build 506). During installation I 
selected to get more documentation? and the setup.exe made HTML files from the pod 
files. This is the content of my pod directory:

 Directory of  C:\Perl\lib\Pod\*

[.]                       [..]                      Functions.pm
Html.pm                   perl.pod                  perl5004delta.pod
perlapio.pod              perlbook.pod              perlbot.pod
 ....
[the rest is deleted]

This is the content of another pod directory:

 Directory of  C:\Perl\html\lib\Pod\*

[.]                       [..]                      Html.html
perl.html                 perl5004delta.html        perlapio.html
perlbook.html             perlbot.html              perlcall.html
 ....
[the rest is deleted]

I hope this helps.

Reni
--
Using Virtual Access
http://www.vamail.com



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

Date: Wed, 02 Dec 1998 13:26:55 -0600
From: quinn coldiron <qcoldiro@unlinfo.unl.edu>
Subject: variable inside variable
Message-Id: <3665947F.9240A9C9@unlinfo.unl.edu>

I'm working on a database with a table of names and a table of form
letters.
What I want to do is place variables in the form letter like this:

------------------------------------------
$fname $lname
$address


Dear $fname,

blah blah blah

Thank you,

Quinn
------------------------------------------

I read the formletter into $formletter, set the variables from the table
and print,
but I dont get the data, just the variable names.  Can I do this?

Quinn




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

Date: Wed, 02 Dec 1998 12:27:20 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <36658688.E33E0B7A@email.sps.mot.com>

John Chambers wrote:
> Well, I guess it's one more entry in my archive of perversities in various
> languages.  It's starting to take up a lot of disk space.  But the perl
> gang is way behind. I have a much larger tcl collection, despite having
> only used tcl half as long as perl ...

Everyone is free to choose what they think is better. So, if you decided
tcl is better (than Perl), then that should be the way to go.

-TK


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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