[10792] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4393 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 9 20:07:30 1998

Date: Wed, 9 Dec 98 17:00:20 -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, 9 Dec 1998     Volume: 8 Number: 4393

Today's topics:
        Ambiguous use of values (Bill Moseley)
        ascii file:extracting,sorting merging <arm@home.net>
        ascii fixed file: revision help <arm@home.net>
    Re: Assignment to same variable <dgris@moiraine.dimensional.com>
    Re: Assignment to same variable <uri@ibnets.com>
        Best way to retrieve from Database? <tturton@cowboys.anet-dfw.com>
    Re: Better way to get values from a list? <r28629@email.sps.mot.com>
    Re: Can someone tell me why .... <info@kn1.com>
    Re: Can someone tell me why .... <crn@itga.com.au>
    Re: Checking if a Dir exists <r28629@email.sps.mot.com>
        fixed ascii file:merging,extracting,sorting <arm@home.net>
    Re: fixed ascii file:merging,extracting,sorting (Brand Hilton)
    Re: Forward slash in Win95 ?? & Perl on Win32 (Larry Rosler)
        How to read a binary file in Perl? How to install mod_p <wtang@flash.net>
    Re: How to read a binary file in Perl? How to install m <rick.delaney@home.com>
        Need help on comparing a file to itself by array in PER cgi@higherlove.com
    Re: Perl, ORacle & Linux brewer@avanticorp.com
    Re: Perl, ORacle & Linux brewer@avanticorp.com
    Re: Perl, ORacle & Linux (Stephen Harris)
    Re: reading comma delimited data files <rick.delaney@home.com>
    Re: Regular Expression:  Irregular spacing in email mes <aqumsieh@matrox.com>
    Re: Regular Expression:  Irregular spacing in email mes (Larry Rosler)
    Re: Regular Expression:  Irregular spacing in email mes <due@murray.fordham.edu>
    Re: system(chmod) fails in SETUID Perl Script (brian d foy)
    Re: take out periods <rick.delaney@home.com>
    Re: take out periods (Craig Berry)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 10 Dec 1998 00:03:23 GMT
From: moseley@best.com (Bill Moseley)
Subject: Ambiguous use of values
Message-Id: <366f0fcb$0$222@nntp1.ba.best.com>

I'm getting the following error

  Ambiguous use of values => resolved to "values" => at reg2.cgi line 523.

  523  print $query->hidden(-name=>$name,-values=>$_[0]);

What's the proper quoting syntax for this to avoid the warning?

I don't get this under Active State 5.005_02

But I do on 5.004_04 on my ISP.







-- 
( Please CC: by email if not too much trouble )
--------------
Bill Moseley
moseley@best.com



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

Date: Wed, 09 Dec 1998 23:08:44 GMT
From: Alan Melton <arm@home.net>
Subject: ascii file:extracting,sorting merging
Message-Id: <366F00FA.3D06A305@home.net>

I have written a file that extracts data from a fixed length
ascii file:

ANTH -232 -A  -34BROCKMANN      0010CONDON         0-8135-1364-2INUIT
YOUTH (P)                                             RUTGRYCR
SOC-232-A-20     0010    88 17.55
13.1500000000054956                              11209882SPRING 1999
ANTH -232 -A  -34BROCKMANN      0010SCHLEGEL      
0-02-927895-3ADOLESCENCE: ANTHROPOLOGICAL INQUIRY                       
SS   YCR SOC-232-A-20     0010    91 36.10
27.1000000000054955                              11209882SPRING 1999
ANTH -250 -A  -34PATRON         0015GALEANO        0-85345-991-6OPEN
VEINS OF LATIN AMERICA (25TH ANNIV ED) (P)             MONTHYCR
250-A-20         0015    98 18.00
13.5000000000059685                              12019882SPRING 1999

perl program is:

#!/usr/local/bin/perl
$basedir='/info/www/etc/';
$searchdir='/info/www/etc/';

chdir "$basedir" or die "Cannot chdir: $!";
open OUTPUT, ">sxu.dat" or die "cannot append to output: $!";
chdir "$searchdir" or die "Cannot chdir: $!";
for $filename ("sxutext.txt") { 
  open (IN, "<$filename") or die "Cannot read $filename: $!";


$count=0001;

@titles = qw/CAT CAT21 CAT3 CAT22 CAT4 CAT23 CAT2 CAT5 CAT24 CAT6 CAT7
NAME CAT8 CAT9 CAT25 CAT10 PRICE/;
while (<IN>) {
    chomp;
    
    @f = unpack 'A5 A1 A3 A2 A3 A1 A2 A15 A4 A15 A13 A60 A5 A1 A25 A5
A6', $_;
    $count++;


  print OUTPUT join ('|', map {$_ . '=' . shift @f} @titles),
"|SKU=$count|TAX=Y|SHG=A|SH=\@total|\n";

  
}
    close IN;
}
1;

export is wonderful but I want to take the values of CAT2, CAT3 and CAT4
and merge them together into one field in that order, even though they
are being extracted in a different order.
Would also like to exclude the (including) joining of CAT21, CAT22,
CAT23 from final output.

How can I modify the program to do this.

A Melton


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

Date: Wed, 09 Dec 1998 23:15:35 GMT
From: Alan Melton <arm@home.net>
Subject: ascii fixed file: revision help
Message-Id: <366F0295.2E6348B8@home.net>

I have written a file that extracts data from a fixed length
ascii file:

ANTH -232 -A  -34BROCKMANN      0010CONDON         0-8135-1364-2INUIT
YOUTH (P)                                             RUTGRYCR
SOC-232-A-20     0010    88 17.55
13.1500000000054956                              11209882SPRING 1999
ANTH -232 -A  -34BROCKMANN      0010SCHLEGEL      
0-02-927895-3ADOLESCENCE: ANTHROPOLOGICAL INQUIRY                       
SS   YCR SOC-232-A-20     0010    91 36.10
27.1000000000054955                              11209882SPRING 1999
ANTH -250 -A  -34PATRON         0015GALEANO        0-85345-991-6OPEN
VEINS OF LATIN AMERICA (25TH ANNIV ED) (P)             MONTHYCR
250-A-20         0015    98 18.00
13.5000000000059685                              12019882SPRING 1999

perl program is:

#!/usr/local/bin/perl
$basedir='/info/www/etc/';
$searchdir='/info/www/etc/';

chdir "$basedir" or die "Cannot chdir: $!";
open OUTPUT, ">sxu.dat" or die "cannot append to output: $!";
chdir "$searchdir" or die "Cannot chdir: $!";
for $filename ("sxutext.txt") { 
  open (IN, "<$filename") or die "Cannot read $filename: $!";


$count=0001;

@titles = qw/CAT CAT21 CAT3 CAT22 CAT4 CAT23 CAT2 CAT5 CAT24 CAT6 CAT7
NAME CAT8 CAT9 CAT25 CAT10 PRICE/;
while (<IN>) {
    chomp;
    
    @f = unpack 'A5 A1 A3 A2 A3 A1 A2 A15 A4 A15 A13 A60 A5 A1 A25 A5
A6', $_;
    $count++;


  print OUTPUT join ('|', map {$_ . '=' . shift @f} @titles),
"|SKU=$count|TAX=Y|SHG=A|SH=\@total|\n";

  
}
    close IN;
}
1;

export is wonderful but I want to take the values of CAT2, CAT3 and CAT4
and merge them together in that order, even though they are being
extracted in a different order.
Would also like to exclude the (including) joining of CAT21, CAT22,
CAT23 from final output.

How can I modify the program to do this.

A Melton


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

Date: 09 Dec 1998 16:05:11 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Assignment to same variable
Message-Id: <m3ww40udaw.fsf@moiraine.dimensional.com>

Uri Guttman <uri@ibnets.com> writes:

> >>>>> "NT" == Niral Trivedi <niral@corporate.planet.net> writes:
> 
>   NT> and the syntax for join is :
>   NT> $domain = join('.',$dns[$loop],$domain)
<snip>

> in fact, join( $string, $value ) is a silly thing to write. maybe it
> should be warned under -w.
<snip>

> please don't post broken code like that.

Uri, could you explain, please?  I have no idea what you
think is wrong with that code (other than the unnecessary
parens :-).

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 09 Dec 1998 19:37:51 -0500
From: Uri Guttman <uri@ibnets.com>
To: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Assignment to same variable
Message-Id: <39yaogvnkw.fsf@ibnets.com>

>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

  DG> Uri Guttman <uri@ibnets.com> writes:
  >> >>>>> "NT" == Niral Trivedi <niral@corporate.planet.net> writes:
  >> 
  NT> and the syntax for join is : $domain =
  NT> join('.',$dns[$loop],$domain)
  DG> <snip>

  >> in fact, join( $string, $value ) is a silly thing to write. maybe
  >> it should be warned under -w.
  DG> <snip>

  >> please don't post broken code like that.

  DG> Uri, could you explain, please?  I have no idea what you think is
  DG> wrong with that code (other than the unnecessary parens :-).

larry r found my eyeballs. i will kill anyone who ever works for me who
doesn't use white space! 

just call me O.J. perl!

and using join for 2 scalars in overkill as well. use "" or .

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Wed, 09 Dec 1998 18:48:56 -0600
From: Tom Turton <tturton@cowboys.anet-dfw.com>
Subject: Best way to retrieve from Database?
Message-Id: <366F1A78.A934812E@cowboys.anet-dfw.com>

This is a multi-part message in MIME format.
--------------293E0A573E9FF2EEB189A884
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am experimenting with using databases in Perl.  I've tried reading
what I can find in my reference books (Programming Perl, Advanced Perl
Programming, Perl Cookbook), but I get the feeling I'm coming in on the
middle of something.

I've started with the MLDBM example in chapter 10 of APP.  Of course,
the example just shows you how to stick things INTO the db; I've played
around in order to learn how to RETRIEVE things in the db and have
managed to get what I want back out  from the code below.

Is there a more elegant way to input and retrieve database data?

If somehow I've overlooked a clear writeup of Perl database usage (from
a beginner's view), please indicate where I can find such a write up.
Thanks much.

---Tom Turton
=================


--------------293E0A573E9FF2EEB189A884
Content-Type: text/plain; charset=us-ascii; name="DB_example.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="DB_example.txt"

#!/usr/local/gnu/bin/perl -w
use diagnostics;

unshift (@INC, "/usr/local/gnu/perl5.004_02/lib");
use Fcntl;
use SDBM_File;
use MLDBM qw (SDBM_File);

tie (%h, 'MLDBM', 'bar', O_RDWR|O_CREAT, 0666) || die $!; 

$sample = {'burnt'    => 'umber',
           'brownian' => 'motion'};   # sample

$h{pairs}    = $sample;
$next_sample = {'WX' => {'precip' => 'rainy', 
                         'Temp'   => '69',
                         'Wind'   => '33015'
                        },
                'Landings' => '2200'};
$h{'19981208'} = $next_sample;

%sample_out = %{$h{pairs}};
while ( ($key_i, $value_i) = each(%sample_out) ) {
    print "\$key_i = $key_i; \$value_i = $value_i\n";
}

%sample2_out = %{$h{19981208}->{WX}};
while ( ($key_j, $value_j) = each(%sample2_out) ) {
    print "\$key_j = $key_j; \$value_j = $value_j\n";
}

%sample3_out = %{$h{19981208}};
print "value for Landings = $sample3_out{Landings}\n";

untie %h;

===============================================
output:

$key_i = brownian; $value_i = motion
$key_i = burnt; $value_i = umber
$key_j = Wind; $value_j = 33015
$key_j = precip; $value_j = rainy
$key_j = Temp; $value_j = 69
value for Landings = 2200






--------------293E0A573E9FF2EEB189A884--



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

Date: Wed, 09 Dec 1998 17:16:31 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: karl_jensen@hp.com
Subject: Re: Better way to get values from a list?
Message-Id: <366F04CF.BE0EC52B@email.sps.mot.com>

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

Karl G. Jensen wrote:
> 
> Thanks to all for the help. You folks are great! I kept the "foreach"
> alternative because it's easier to read than the "map" alternative. I
                           ^^^^^^^^^^^^^^
and you will miss the power of Perl ;-)

-TK


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

Date: Thu, 10 Dec 1998 00:19:21 +0100
From: "Owen" <info@kn1.com>
Subject: Re: Can someone tell me why ....
Message-Id: <74n0k1$g0s$1@black.news.nacamar.net>

I did not write the script. It is Freeware from the CGI resource.

That said, I posted here hoping to get some help and maybe learn something
form you guys.

I wish I had not bothered.

Arrogance is here in abundance.

You should maybe all take a break for a few weeks and just sit around
reading the positive vibes from alt.html

If you ever need any html or Java help, dont come looking to us.

Owen




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

Date: 10 Dec 1998 11:47:19 +1100
From: Clive Newall <crn@itga.com.au>
Subject: Re: Can someone tell me why ....
Message-Id: <v5ogpcakmg.fsf@itga.com.au>

So why don't you ask the _author_ to debug their own script?
Note that:
1: It says "beta"!
2: It includes contact details for the author.

"Owen" <info@kn1.com> writes:

> this script for a chat programm does not delete the message database when
> the limit is reached. It does reset the counter to 0 but does not delete the
> database
<SNIP>
> # Simple Chat version 1.000 beta release 1
<SNIP>
> # The authors website at http://wmcdirectmg.hypermart.net provides
> # minimal support and offers forms for submitting bug reports, comments,
> # and registering your copy with the author (FREE).


-- 
Clive Newall <crn@itga.com.au> / ITG Australia Ltd, Melbourne Australia
"I think Casper is the ghost of Richie Rich. I wonder how Richie died?"
"Perhaps he realized how hollow the pursuit of money is and took his own life"
  --Bart and Lisa Simpson


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

Date: Wed, 09 Dec 1998 17:31:07 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: Re: Checking if a Dir exists
Message-Id: <366F083B.8995D208@email.sps.mot.com>

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

Dennis Kowalski wrote:
> 
> Artoo wrote:
> >
> > Hi All
> >
> > How can you check to see if a directory already exists before trying to
> > create one?
> >
> > Many thanks
> > Artoo
> 
> Try this
> 
> $dir = "some-value";
> if (! -d $dir)

  unless (-d $dir)    # idiomatic perl

> {
>   mkdir($dir); 
> }

what'd happen if there is a file called 'some-value'?

-TK


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

Date: Wed, 09 Dec 1998 23:06:12 GMT
From: Alan Melton <arm@home.net>
Subject: fixed ascii file:merging,extracting,sorting
Message-Id: <366F0061.C3C14F79@home.net>

I have written a file that extracts data from a fixed length
ascii file:

ANTH -232 -A  -34BROCKMANN      0010CONDON         0-8135-1364-2INUIT
YOUTH (P)                                             RUTGRYCR
SOC-232-A-20     0010    88 17.55
13.1500000000054956                              11209882SPRING 1999
ANTH -232 -A  -34BROCKMANN      0010SCHLEGEL      
0-02-927895-3ADOLESCENCE: ANTHROPOLOGICAL INQUIRY                       
SS   YCR SOC-232-A-20     0010    91 36.10
27.1000000000054955                              11209882SPRING 1999
ANTH -250 -A  -34PATRON         0015GALEANO        0-85345-991-6OPEN
VEINS OF LATIN AMERICA (25TH ANNIV ED) (P)             MONTHYCR
250-A-20         0015    98 18.00
13.5000000000059685                              12019882SPRING 1999

perl program is:

#!/usr/local/bin/perl
$basedir='/info/www/etc/';
$searchdir='/info/www/etc/';

chdir "$basedir" or die "Cannot chdir: $!";
open OUTPUT, ">sxu.dat" or die "cannot append to output: $!";
chdir "$searchdir" or die "Cannot chdir: $!";
for $filename ("sxutext.txt") { 
  open (IN, "<$filename") or die "Cannot read $filename: $!";


$count=0001;

@titles = qw/CAT CAT21 CAT3 CAT22 CAT4 CAT23 CAT2 CAT5 CAT24 CAT6 CAT7
NAME CAT8 CAT9 CAT25 CAT10 PRICE/;
while (<IN>) {
    chomp;
    
    @f = unpack 'A5 A1 A3 A2 A3 A1 A2 A15 A4 A15 A13 A60 A5 A1 A25 A5
A6', $_;
    $count++;


  print OUTPUT join ('|', map {$_ . '=' . shift @f} @titles),
"|SKU=$count|TAX=Y|SHG=A|SH=\@total|\n";

  
}
    close IN;
}
1;

export is wonderful but I want to take the values of CAT2, CAT3 and CAT4
and merge them together INTO ONE FIELD in that order, even though they
are being extracted in a different order.
Would also like to exclude the (including) joining of CAT21, CAT22,
CAT23 from final output.

How can I modify the program to do this.

A Melton


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

Date: 9 Dec 1998 23:57:15 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: fixed ascii file:merging,extracting,sorting
Message-Id: <74n2or$as4@mercury.adc.com>

First off, I'm going to go with my first instincts and assume that the
other two things you posted, with different but similar titles, were
identical to this one.

In article <366F0061.C3C14F79@home.net>, Alan Melton  <arm@home.net> wrote:
>I have written a file that extracts data from a fixed length
>ascii file:
>
>ANTH -232 -A  -34BROCKMANN      0010CONDON         0-8135-1364-2INUIT
>YOUTH (P)                                             RUTGRYCR
>SOC-232-A-20     0010    88 17.55
>13.1500000000054956                              11209882SPRING 1999
>ANTH -232 -A  -34BROCKMANN      0010SCHLEGEL      
>0-02-927895-3ADOLESCENCE: ANTHROPOLOGICAL INQUIRY                       
>SS   YCR SOC-232-A-20     0010    91 36.10
>27.1000000000054955                              11209882SPRING 1999
>ANTH -250 -A  -34PATRON         0015GALEANO        0-85345-991-6OPEN
>VEINS OF LATIN AMERICA (25TH ANNIV ED) (P)             MONTHYCR
>250-A-20         0015    98 18.00
>13.5000000000059685                              12019882SPRING 1999
>
>perl program is:
>
>#!/usr/local/bin/perl
>$basedir='/info/www/etc/';
>$searchdir='/info/www/etc/';
>
>chdir "$basedir" or die "Cannot chdir: $!";
>open OUTPUT, ">sxu.dat" or die "cannot append to output: $!";
>chdir "$searchdir" or die "Cannot chdir: $!";
>for $filename ("sxutext.txt") { 
>  open (IN, "<$filename") or die "Cannot read $filename: $!";
>
>
>$count=0001;
>
>@titles = qw/CAT CAT21 CAT3 CAT22 CAT4 CAT23 CAT2 CAT5 CAT24 CAT6 CAT7
>NAME CAT8 CAT9 CAT25 CAT10 PRICE/;
>while (<IN>) {
>    chomp;
>    
>    @f = unpack 'A5 A1 A3 A2 A3 A1 A2 A15 A4 A15 A13 A60 A5 A1 A25 A5
>A6', $_;
>    $count++;
>
>
>  print OUTPUT join ('|', map {$_ . '=' . shift @f} @titles),
>"|SKU=$count|TAX=Y|SHG=A|SH=\@total|\n";
>
>  
>}
>    close IN;
>}
>1;
>
>export is wonderful but I want to take the values of CAT2, CAT3 and CAT4
>and merge them together INTO ONE FIELD in that order, even though they
>are being extracted in a different order.
>Would also like to exclude the (including) joining of CAT21, CAT22,
>CAT23 from final output.
>
>How can I modify the program to do this.

Probably the easiest way would be to use splice to remove CAT21,
CAT22, and CAT23 from @f (or, alternatively, just change unpack's
format string so that they never get stored in @f in the first place),
and then another couple of splice operations to remove CAT3 and CAT4
from @f and concatenate them onto the CAT2 element of @f.  Don't
forget to remove/change the appropriate elements from @titles.

HTH

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: Wed, 9 Dec 1998 15:33:15 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Forward slash in Win95 ?? & Perl on Win32
Message-Id: <MPG.10d8a894e5ce5b29898b9@nntp.hpl.hp.com>

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

In article <366EFF5D.207C0635@concentric.net> on 09 Dec 1998 14:51:53 
PST, Michael Moon <mmoon@concentric.net> says...

> Can't load 'C:\Perl\lib/auto/Win32/NetResource/NetResource.pll' for
> module Win32
> ::NetResource: 31 at C:\Perl\lib/DynaLoader.pm line 450.
 ...
> I imagine the error is due to the forward slashes in the PATH to
> NetResource.pll.  In the Wintel environment a forward slash "/" is a
> command line switch.  Is there an update or setting I need to update to
> correct this, or if the error is something else that is obvious, I would
> appreciate the help.

Forward slash is a command line switch only to the command interpreter.  
In the Windows/DOS file system, it is exactly equivalent to backslash, 
and can be used interchangeably.  In fact, in a Perl program there is no 
need to use backslash (which requires extra ugly escaping) except when 
communicating with the command interpreter (one-argument system(), 
etc.).

So your configuration problem has nothing to do with the slashes.

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


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

Date: 9 Dec 1998 23:39:37 GMT
From: "William Tang" <wtang@flash.net>
Subject: How to read a binary file in Perl? How to install mod_perl?
Message-Id: <01be23cb$f4212a20$5d68b9a3@wtang-sgl.sugar-land.geco-prakla.slb.com>

Hello,

I have two questions:

1. I have a binary data file needs to be read from Perl. In C I do like
this:
File *fp;
float *stringptr;
stringptr = (float*)malloc((numberofdata)*sizeof(float));
fp = fopen("data.dat","rb);
fread(stringptr,sizeof(float),numberofdata,fp);
fclose(fp);
and the data will be found in stringptr

In perl I did not find any similar method to open this binary file. Can
Perl open a binary file, which will store the float number one by one
without '\n' ?

2. I tried to install mod_perl with Apache1.3.3, before I installed apache
as:
 ./Configure --prefix==/opt/server/host
make
make install
the source code at /opt/server/
I put the mod_perl in the same source area, and install it as shown in
INSTALL,
the httpd in /opt/server/apache_1.3.3/src will be overridden by the big
file, but it will look the default /usr/local/... for the conf file. How to
do I tell the server to look the correct directory
/opt/server/host/etc/apache/*.conf ?

Thanks.


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

Date: Thu, 10 Dec 1998 00:18:49 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to read a binary file in Perl? How to install mod_perl?
Message-Id: <366F1524.56BC1DF3@home.com>

[posted & mailed]

William Tang wrote:
> 
> Hello,
> 
> I have two questions:

I have one answer.

> fread(stringptr,sizeof(float),numberofdata,fp);
   ^^^^
> In perl I did not find any similar method to open this binary file. 

When looking for methods, a good place to start is the perlfunc manpage.

> Can Perl open a binary file, which will store the float number one by 
> one without '\n' ?

Yes, look up read in perlfunc.  You might also want to check out binmode
in there as well.  Depending what you're going to do with the data you
might want to look up pack and unpack as well.

If you have Perl 5.004 or later, you should be able to type 

perldoc -f read
perldoc -f binmode
perldoc -f pack

at the command line to find them quicker.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Wed, 09 Dec 1998 23:32:51 GMT
From: cgi@higherlove.com
Subject: Need help on comparing a file to itself by array in PERL
Message-Id: <366f03a1.19559363@news.phnx.uswest.net>

Hi!  I've got these two subroutines that just don't seem to want to
work together and I can't fiugre out what I'm doing wrong.
(The relevant subroutines are listed below my explanation)

The first subroutine (check) is supposed to read a file into an array,
close the file then re-open it to check each line's content.
If a line contains the string <!--begin-->, the system will replace
the line with the same text, however, if the line contains a matching
$ENV{'REMOTE_HOST'} and $ENV{'HTTP_REFERER} to that of the current
script user, the script will add a line to the file and redirect the
user to a page.

If the line matches neither, the script will print the current line in
the array back into the script until the array has been completed.

The subroutine (post) runs the same basic check for the string
<!--begin-->, but then it automatically adds the current users
environmental info followed by the rest of the lines in the array.

When I run the program, I just get dropped into the post subroutine
and rather than having one line of environmental info added to the
file, the program adds like 40 lines of the same info.

My hopes would be that if USER1 activated the script (as the first
user of it), the file would read:

<!--begin-->
USER1_HOST &&USER1_REFERER

then if the user tried again from the same referer, the file would
look like:

<!--begin-->
Attempted login by USER1_HOST from USER1_REFERER
USER1_HOST&&USER1_REFERER



I hope this is clear without being too detailed. I have a file that
will simply append such infomation to the end of a file, but I wanted
to use the array and "foreach" to run comparisons.

Any reply would be very helpful!

Thank you!

The code is below.


Lisa


sub check {
   
      open(MAIN,"$file_dir/$write_file") || die $!;
      @main = <MAIN>;
      close(MAIN);

      open(MAIN,">$file_dir/$write_file") || die $!;
      foreach $main_line (@main) {
         if ($main_line =~ /<!--begin-->/) {
            print MAIN "<!--begin-->\n";
         }
       ($who,$where) = split(/&&/,$main_line);

 if ($ENV{'REMOTE_HOST'} eq "$who" && $ENV{'HTTP_REFERER'} eq
"$where"){
         print MAIN "Attempted login by $ENV{'REMOTE_HOST'} from
$ENV{'HTTP_REFERER'}";
         print "Location:
http://www.luvcircuit.com/time/test1.html\n\n"; #not recognized

      }

      else {
         print MAIN "$main_line";
}
      close (MAIN);
	&post;
   }
}


##########
# Modify tracking page

sub post {

      open(MAIN,"$file_dir/$write_file") || die $!;
      @main = <MAIN>;
      close(MAIN);

      open(MAIN,">$file_dir/$write_file") || die $!;
      foreach $main_line (@main) {
         if ($main_line =~ /<!--begin-->/) {
            print MAIN "<!--begin-->\n";
            print MAIN "$ENV{'REMOTE_HOST'}&&$ENV{'HTTP_REFERER'}";
         }

         else {
            print MAIN "$main_line";
         }
      }

close(MAIN);
      print "Location: http://www.luvcircuit.com/time/test2.html\n\n";
#recognized hit
   }





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

Date: Wed, 09 Dec 1998 22:55:42 GMT
From: brewer@avanticorp.com
Subject: Re: Perl, ORacle & Linux
Message-Id: <74mv5d$uuf$1@nnrp1.dejanews.com>

I can say that finding information on Oracle, Linux, and Perl is not easy.  I
have spent most of the day looking myself.

My problem is as follows.  I'm setting up a WebServer on linux.  We want cgi
programs on the webserver to be able to talk to an Oracle7 database on a
Windows NT server.  I keep reading and being told I need sql*net for the perl
to oracle part of the problem.	Does sql*net exist for Linux?  What are these
"oracle libraries" I need to compile/link against to get part of the perl
interface working?

I can't believe I'm the first person to want to does this, someone else must
have tackled this problem before me.  (I base that on the popularity of
Apache, Perl, Linux, and Oracle!)

If you send e-mail please send to noble@pagesz.net

THanks for any help....

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


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

Date: Wed, 09 Dec 1998 23:09:28 GMT
From: brewer@avanticorp.com
Subject: Re: Perl, ORacle & Linux
Message-Id: <74mvv7$vhm$1@nnrp1.dejanews.com>

I can say that finding information on Oracle, Linux, and Perl is not easy.  I
have spent most of the day looking myself.

My problem is as follows.  I'm setting up a WebServer on linux.  We want cgi
programs on the webserver to be able to talk to an Oracle7 database on a
Windows NT server.  I keep reading and being told I need sql*net for the perl
to oracle part of the problem.	Does sql*net exist for Linux?  What are these
"oracle libraries" I need to compile/link against to get part of the perl
interface working?

I can't believe I'm the first person to want to does this, someone else must
have tackled this problem before me.  (I base that on the popularity of
Apache, Perl, Linux, and Oracle!)

If you send e-mail please send to noble@pagesz.net

THanks for any help....

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


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

Date: 9 Dec 1998 23:44:05 GMT
From: sweh@mpn.com (Stephen Harris)
Subject: Re: Perl, ORacle & Linux
Message-Id: <74n205$fkv$2@nebula.mpn.com>

brewer@avanticorp.com wrote:

: I can't believe I'm the first person to want to does this, someone else must
: have tackled this problem before me.  (I base that on the popularity of
: Apache, Perl, Linux, and Oracle!)

Goto www.hermetica.com and follow the links to DBD and DBI.  This lets you
talk to Oracle directly from perl.  Then you can write your CGI as normal,
retrieving/storing data in the database.

The latest versions compile fine AOK on Linux.

-- 

rgds
Stephen


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

Date: Wed, 09 Dec 1998 23:08:07 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: reading comma delimited data files
Message-Id: <366F0491.84F58EE0@home.com>

Cybernetic Bear wrote:
> 
> I have a comma delimited text file that contains 3 columns of data
> which looks basically like this:
> name, date, number-value
> 
> I can read in data one line at a time, but I would like to read the
> three values into 3 seperate variables, from the same line.
> 
> I'm sure its possible, but how?

perldoc -f split

while(<>){
    chomp;
    my ($name, $date, $number_value) = split /,/;
}


-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Wed, 9 Dec 1998 14:19:02 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Regular Expression:  Irregular spacing in email message
Message-Id: <x3y7lw1nn63.fsf@tigre.matrox.com>


"Allan M. Due" <Allan@due.net> writes:

> while (chomp ($in = <DATA>)) {

Tsk tsk .. chomp() returns the number of characters chopped. If there
is no \n at the end of the line, chomp() will return 0 and the while()
loop won't execute! Careful.



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

Date: Wed, 9 Dec 1998 16:15:29 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regular Expression:  Irregular spacing in email message
Message-Id: <MPG.10d8b27d4e1bd63e9898ba@nntp.hpl.hp.com>

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

In article <x3y7lw1nn63.fsf@tigre.matrox.com> on Wed, 9 Dec 1998 
14:19:02 -0500 , Ala Qumsieh <aqumsieh@matrox.com> says...
> 
> "Allan M. Due" <Allan@due.net> writes:
> 
> > while (chomp ($in = <DATA>)) {
> 
> Tsk tsk .. chomp() returns the number of characters chopped. If there
> is no \n at the end of the line, chomp() will return 0 and the while()
> loop won't execute! Careful.

'If there is no \n at the end of the line,' then it isn't a line, is it?

<> returns a 'line' from a 'text file'.  A 'line' is a sequence of 
characters terminated by a \n.  If there are dangling characters after 
the last \n in the file, they do not consitute a line (and 'vi', for 
example, complains) and the file is not, strictly speaking, a 'text 
file', which is a sequence of lines.  It is good that <> returns that 
dangling sequence before returning end-of-file, but they do not 
constitute a 'line'.

This is why I was so pissed by the gratuitous demand introduced into 
5.004 (to avoid a warning) for:

  while ($line = <>) { ...

to be rewritten as

  while (defined($line = <>)) { ...

which has now gone away in 5.005 (the compiler does the rewriting).

The purpose was to protect the unsuspecting against a final 'line' 
consisting only of a '0'.  Wowee!  The hours wasted in rewriting code to 
obviate the warnings are uncountable.

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


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

Date: 10 Dec 1998 00:40:05 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Regular Expression:  Irregular spacing in email message
Message-Id: <74n595$91p$0@206.165.167.241>

Ala Qumsieh wrote in message ...
>"Allan M. Due" <Allan@due.net> writes:
>> while (chomp ($in = <DATA>)) {

>Tsk tsk .. chomp() returns the number of characters chopped. If there
>is no \n at the end of the line, chomp() will return 0 and the while()
>loop won't execute! Careful.


Good call.  Checked failed the test, no \n for the last line will cause this
to fail.  Dang.  Three mistakes in one day.  Oh well, three's the charm.

AmD





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

Date: Wed, 09 Dec 1998 18:41:12 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: system(chmod) fails in SETUID Perl Script
Message-Id: <comdog-ya02408000R0912981841120001@news.panix.com>

In article <74mrbs$ri2$1@nnrp1.dejanews.com>, mike_orourke@em.fcnbd.com posted:

> > system("chown $file_owner '$directory/$filename'") && die "Could not run
> > CHMOD" ;

there is a Perl builtin for this...

-- 
brian d foy                     <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't.  it doesn't matter either way.


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

Date: Wed, 09 Dec 1998 23:04:42 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: take out periods
Message-Id: <366F03C4.C990B57C@home.com>

[posted & mailed]

jimbob4334@my-dejanews.com wrote:
> 
> Hello,
> 
> How do I take the "."'s out of the variable
> $release =  "2.9.0"
> and assign 290 to $rls_name?

($rls_name = $release) =~ tr/.//d;

perldoc perlop

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: 10 Dec 1998 00:26:03 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: take out periods
Message-Id: <74n4er$1s3$1@marina.cinenet.net>

jimbob4334@my-dejanews.com wrote:
: How do I take the "."'s out of the variable
: $release =  "2.9.0"
: and assign 290 to $rls_name?

OWTDI:   ($rls_name = $release) =~ tr/.//d;

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "The hills were burning, and the wind was raging; and the
       clock struck midnight in the Garden of Allah."


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

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

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