[18751] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 919 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 17 00:06:40 2001

Date: Wed, 16 May 2001 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990072308-v10-i919@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 16 May 2001     Volume: 10 Number: 919

Today's topics:
        [newbie question] writing to an open file (Kevin James)
    Re: [newbie question] writing to an open file <yf32@cornell.edu>
    Re: [newbie question] writing to an open file <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: \nhelp (Tad McClellan)
    Re: aol proxy <godzilla@stomp.stomp.tokyo>
    Re: FOREACH sort <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: help needed in regex alternation (Tad McClellan)
    Re: help needed in regex alternation <mischief@velma.motion.net>
    Re: HELP.....Need help with Perl Script <mischief@velma.motion.net>
    Re: HELP.....Need help with Perl Script <mischief@velma.motion.net>
    Re: How to invoke another script in a CGI script? (Tad McClellan)
        I don't understand this regex result- help please? <nospam@cfl.rr.com>
    Re: I don't understand this regex result- help please? <joe+usenet@sunstarsys.com>
    Re: Initialisation of object <johnlin@chttl.com.tw>
    Re: map only when defined? <prlawrence@lehigh.edu>
    Re: Measuring the time (Tad McClellan)
    Re: Measuring the time (Craig Berry)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <mischief@velma.motion.net>
    Re: Sending wav-file through perl-script <godzilla@stomp.stomp.tokyo>
    Re: To compress and uncompress text files ? <nosabi@snospamabi.com>
    Re: To compress and uncompress text files ? <nosabi@snospamabi.com>
    Re: To compress and uncompress text files ? <nosabi@snospamabi.com>
    Re: uniq users (Craig Berry)
    Re: uniq users <mischief@velma.motion.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 May 2001 01:24:09 -0000
From: kvjames22@hotmail.com (Kevin James)
Subject: [newbie question] writing to an open file
Message-Id: <Xns90A3D96706936kvjames22hotmailcom@207.126.101.100>

Hello all,

I'm a VB programmer now trying my best to come up to speed with perl.  What 
I'm trying to accomplish is to query a database (Sybase - using sybperl) and 
write some of its contents to a logfile for export to another system.  It 
sounds simple enough, but I can't seem to stop clobbering my previous writes 
to the file, ending up with only the last logfile entry.

The structure is like this:



open(LOGFILE, ">export.log");  #start with a brand new logfile

#main query to database here...

while (looping through main result set) {

   #subquery to another database based off looping result set

      while (looping through subquery result set) {
         
         if (meets criteria for exporting) {
    	       
               $export_line = criteria contatenated with commas;
    	    	    
               # ************************************
               # problem below: keeps overwriting
               # all of the previous file contents
               # with $export_line (I was kind of 
               # expecting for it to continually
               # append to the bottom of the file).
               # ************************************

               print LOGFILE $export_line;
            }
      }   
   }
close (LOGFILE);


I basically want to continually add lines to this open file, without 
having to repeatedly closing and reopening the logfile with appending 
(">>export.log").

Any clues would be much appreciated...
Thank You,
Kevin James



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

Date: Wed, 16 May 2001 22:16:48 -0400
From: Young Chi-Yeung Fan <yf32@cornell.edu>
Subject: Re: [newbie question] writing to an open file
Message-Id: <3B033490.D33E44BF@cornell.edu>

Kevin James wrote:

> Hello all,
>
> I'm a VB programmer now trying my best to come up to speed with perl.  What
> I'm trying to accomplish is to query a database (Sybase - using sybperl) and
> write some of its contents to a logfile for export to another system.  It
> sounds simple enough, but I can't seem to stop clobbering my previous writes
> to the file, ending up with only the last logfile entry.

Are the previous writes that are overwritten from previously running the script,
or are they part of the loop you have after you open the log file? If you used
">>export.log" instead of ">export.log", log file entries from previous calls to
the script won't get erased. If it's stuff in the loop that is not showing up,
there might be some logic errors within the loop -- you might want to take
another look at your queries and criteria for exporting.

>
> The structure is like this:
>
> open(LOGFILE, ">export.log");  #start with a brand new logfile
>
> #main query to database here...
>
> while (looping through main result set) {
>
>    #subquery to another database based off looping result set
>
>       while (looping through subquery result set) {
>
>          if (meets criteria for exporting) {
>
>                $export_line = criteria contatenated with commas;
>
>                # ************************************
>                # problem below: keeps overwriting
>                # all of the previous file contents
>                # with $export_line (I was kind of
>                # expecting for it to continually
>                # append to the bottom of the file).
>                # ************************************
>
>                print LOGFILE $export_line;
>             }
>       }
>    }
> close (LOGFILE);
>
> I basically want to continually add lines to this open file, without
> having to repeatedly closing and reopening the logfile with appending
> (">>export.log").
>
> Any clues would be much appreciated...
> Thank You,
> Kevin James



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

Date: 17 May 2001 02:21:49 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: [newbie question] writing to an open file
Message-Id: <86ae4clnpe.fsf@jon_ericson.jpl.nasa.gov>

kvjames22@hotmail.com (Kevin James) writes:

> I'm a VB programmer now trying my best to come up to speed with perl.  What 
> I'm trying to accomplish is to query a database (Sybase - using sybperl) and 
> write some of its contents to a logfile for export to another system.  It 
> sounds simple enough, but I can't seem to stop clobbering my previous writes 
> to the file, ending up with only the last logfile entry.

Any particular reason you aren't using DBI?
 
> open(LOGFILE, ">export.log");  #start with a brand new logfile

It's really important to check the return code of file opens.  Here's
one way:

  open(LOGFILE, ">export.log") or die "can't open export.log: $!";

[snip loop stuff]
>                $export_line = criteria contatenated with commas;

>                print LOGFILE $export_line;
[snip]

> close (LOGFILE);
> 
> 
> I basically want to continually add lines to this open file, without 
> having to repeatedly closing and reopening the logfile with appending 
> (">>export.log").

The above code should clobber export.log on open, print $export_line
at the end of the file each time through the loop, and close the file.
Does this minimal test case do what you want?  If so, there is
something going on that you haven't mentioned.

Jon


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

Date: Wed, 16 May 2001 20:03:32 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: \nhelp
Message-Id: <slrn9g65ak.o6k.tadmc@tadmc26.august.net>

jtjohnston <jtjohnston@courrier.usherb.ca> wrote:

>I am parsing the contents of a text file.


Please do not post the same thing multiple times. Once is enough.


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


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

Date: Wed, 16 May 2001 19:21:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: aol proxy
Message-Id: <3B03359F.6E5B9649@stomp.stomp.tokyo>

Patrick Joyce wrote:
 
> i have a problem. what is up with aols proxy servers i have written a perl
> script that needs a uniqe host name. but with aol proxy the hostnames change
> often, how do i fix this and or why is this

You cannot. America Onlame is not the only major server
which exhibits this problem.

Without parameters, without a brief description of what
you are doing, no one person can give you a good answer;
it is guesswork.

I am making a presumption you are not referring to the
first perl locale line, a shebang line called by some.
AOL does not allow cgi scripts. Logic dictates you
are looking for a specific host name, for some other
purpose, possibly a "forbid access" need. Who knows?

You may use the index function to emulate hostname
criteria indexing. With AOL, their initials as shown,
lowercase, will always appear, regardless of spider
proxy in use. 

if (index ($hostname, "aol") > -1)
 { &Blow_Up_Users_Monitor; }


Check me on lowercase, pretty sure they come through
in lowercase letters. Check this though.

In the future, you will do yourself a good favor by
providing some parameters and a brief description of
what you are doing.

Godzilla!


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

Date: 17 May 2001 02:26:12 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: FOREACH sort
Message-Id: <8666f0lni3.fsf@jon_ericson.jpl.nasa.gov>

"Ng Huay Ping" <hpng@mpmsb.com> writes:

> May I know how to sort 2 fields in the foreach ?????
> 
> foreach  $record(@record)
> {
> print"record : $record\n";
> 
> 
> }

Do you mean like:

  foreach my $record(sort @record){
    print "record : $record\n";
  }

or something else?

Jon


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

Date: Wed, 16 May 2001 19:38:45 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: help needed in regex alternation
Message-Id: <slrn9g63s5.o6k.tadmc@tadmc26.august.net>

Gavin Sherlock <sherlock@genome.stanford.edu> wrote:

>p53||p53 encoding protein||tp53
>
>and then say I have some input, p53, that I want to match against that
>text, but only to a whole entry, where whole entries are delimited by
>double pipes.

>It seems that I can't have an
 ^^^^^^^^

What behavior have you observed to make that seem to be the case?


>alternation between a pipe and the beginning/end of a string, eg,
>something like:
>
>if ($text =~ /(^|\|)\b$input\b(\||$)/){ #stuff }
>
>but obviousy you can't alternate caret or dollar to get them to mean
>beginning or end.  


Yes you can. You _have_ in fact.

The above looks fine to me (but the \b's are now redundant if
$input starts and ends with a word character).


>Is there a way I can do this?


I think you _have_ done that  :-)


>Any suggestions?


I fail to see the problem. I must be missing something...


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


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

Date: Thu, 17 May 2001 02:25:14 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: help needed in regex alternation
Message-Id: <tg6dkarnkcoaa@corp.supernews.com>

Gavin Sherlock <sherlock@genome.stanford.edu> wrote:
> Hi,
>    I have some line of text that I want to check for matches, that eg
> may be like:

> p53||p53 encoding protein||tp53

> and then say I have some input, p53, that I want to match against that
> text, but only to a whole entry, where whole entries are delimited by
> double pipes.  I did try:

> if ($text =~ /\b$input\b/){ #stuff }

Here's the method I would recommend:

    /(?:\A|\|\|)($input)(?:\|\||\Z)/

Here's the whole script which which I tested:

    #!/usr/bin/perl -w
    use strict;
    my $input = $ARGV[0];
    my $foo = 'p53||p53 encoding protein||tp53';
    if( $foo =~ /(?:\A|\|\|)($input)(?:\|\||\Z)/ ) {
        print "$1\n";
    }

However, I'm not so sure you can't alternate those
punctuation-like anchors. Take a look at this one
which gives me substantially the same results:

    if( $foo =~ /(?:^|\|\|)($input)(?:\|\||$)/ ) {

This one does too:

    /^|\|\|($input)\|\||$/

To read about the \A, \Z, and \z anchors, take a look at:
    perldoc perlre

That's an ugly regex above. This might be a little clearer:

    my $input = $ARGV[0];
    my $foo = 'p53||p53 encoding protein||tp53';
    my @bar = split /\|\|/, $foo;
    for ( @bar ) {
       print $_ . "\n" if $input eq $_;
    }

As you said, though, this split method could be slower
than the regex.

Chris
-- 
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997



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

Date: Thu, 17 May 2001 01:22:48 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: HELP.....Need help with Perl Script
Message-Id: <tg69v8gg7qe6fb@corp.supernews.com>

Craig Berry <cberry@cinenet.net> wrote:
> Steve Jones (carsonmtv@MailAndNews.com) wrote:
> : I am trying to create yet another paid to read email program and am having 
> : trouble with the script.

> You'd be considered trendier if you were having trouble with the business
> model. :)

> : What I am actually using is a preexisting click affiliate script.  That
> : is, a program that users signup for, and are emailed their code so they
> : can put that code on a webpage of their own.  They will recieve credits
> : in thier account, for unique ip address clicks.  The problem is that,
> : the script logs their ip address, so as too not pay them for clicking 
> : the link on their own webpage.

> This can't possibly work the way you want.  Not only is it utterly trivial
> to circumvent (how many clicks would it take to pay for a $15/month second
> account?), it will fail to catch cheaters with dynamically assigned IP
> addresses (dialup users, for example) even if they just use the same
> machine as they registered with.

Not to mention people like me who have 32 contiguous class Cs
with which to play, and like to play with such scripts just
for the sake of play. Yes, someone at an ISP is not necessarily
above inflating poll responses and such for the sake of fun and
demonstration. I personally would have ethical issues with a
pay-to-click script, but some people would not.

An IP is not a user. A cookie is not a user (although a better
measure of one than an IP). A username and a password might be
a user. A username, a password, and a serialized cookie is
somewhat likely to be a user. A username, a password, a serialized
cookie, and a response to an email sent to the user's email address
is probably the user. None of this is absolute. Biometrics could
be almost certain of a user, but then you either have network
lag (which ruins the usability of such a plan) or client-side
software reporting back across the network (which ruins the
security because someone could fake the results). The web is
not a platform upon which to base extremely sensitive
authentication measures. SOme might even say the web is not
a platform. In many ways they'd be right.

You could always try a cookie containing a number serially
assigned out of a pre-created bath of random numbers along
with a username and password. This is not as convenient as
just a simple serialized cookie, but it is much more secure.

Chris
-- 
Even in the worst of times, there is always someone who's
never had it better. Even in the best of times, there is
always someone who's never had it worse.



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

Date: Thu, 17 May 2001 02:54:12 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: HELP.....Need help with Perl Script
Message-Id: <tg6fak14oa2jd4@corp.supernews.com>

Chris Stith <mischief@velma.motion.net> wrote:
> You could always try a cookie containing a number serially
> assigned out of a pre-created bath of random numbers along

s/bath/batch/;

Chris
-- 
Programming is a tool. A tool is neither good nor evil. It is
the user who determines how it is used and to what ends.



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

Date: Wed, 16 May 2001 20:13:01 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to invoke another script in a CGI script?
Message-Id: <slrn9g65sd.o6k.tadmc@tadmc26.august.net>


[ no modules here, f'ups set ]


Chris <rebelvideo@hotmail.com> wrote:

>the ./ just means current directory, which one would assume is the first
>place the shell looks for the command!


Heavens no!

Best (most secure) is to NOT have the current directory in
the path *at all*.

Next best would be for the current directory to be *last* in
the path. (crackers sprinkle directories with "typoed" filenames,
eg: sl (ls), gerp (grep) and then wait for you to make a mistake
and run their program for them).

Having the current directory first in the path is a very insecure
practice. (crackers sprinkle "ls"s around to get you to run
their program)


[snip Jeopardy quoted text]

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


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

Date: Thu, 17 May 2001 02:57:11 GMT
From: Ed <nospam@cfl.rr.com>
Subject: I don't understand this regex result- help please?
Message-Id: <3B033DA6.A4EDAC5F@cfl.rr.com>

In programming Perl (v2), it says that unless ()'s are in the regex,
either a 1 or "" is returned as the result. Yet I get this result:

$_='catmousedog';

# non-global
my @l=/o/;
print "non-global: ";
print "$_\n" foreach @l;

# global
my @l=/o/g;
print "global: ";
print  foreach @l;

 *********************************
csh> perl x.pl

non-global: 1
global: oo

Now that is strange! using /g causes it to return the match itself and
not 11? CAMEL explicitly says unless there are parens, 1 or "" is
returned. I have no parens yet I didn't get a 1,"".

I didn't read anything in the text about /g changing the result type.
The number of results sure, but the returned value type?

Apparently.

Thanks for enlightening me..




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

Date: 16 May 2001 23:08:03 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: I don't understand this regex result- help please?
Message-Id: <m3eltozn8s.fsf@mumonkan.sunstarsys.com>

Ed <nospam@cfl.rr.com> writes:

> In programming Perl (v2), it says that unless ()'s are in the regex,
> either a 1 or "" is returned as the result. Yet I get this result:
> 
> $_='catmousedog';
> 
> # non-global
> my @l=/o/;
> print "non-global: ";
> print "$_\n" foreach @l;
> 
> # global
> my @l=/o/g;
> print "global: ";
> print  foreach @l;
> 
>  *********************************
> csh> perl x.pl
> 
> non-global: 1
> global: oo

  % perldoc perlop
 ...
               The "/g" modifier specifies global pattern
               matching--that is, matching as many times as
               possible within the string.  How it behaves
               depends on the context.  In list context, it
               returns a list of all the substrings matched by
               all the parentheses in the regular expression.  If
               there are no parentheses, it returns a list of all
               the matched strings, as if there were parentheses
               around the whole pattern.
 ...

> Now that is strange! using /g causes it to return the match itself and
> not 11? CAMEL explicitly says unless there are parens, 1 or "" is
> returned. I have no parens yet I didn't get a 1,"".
> 
> I didn't read anything in the text about /g changing the result type.

You haven't looked carefully at page 71 then.

-- 
Joe Schaefer    "Whoever undertakes to set himself up as a judge of Truth and
                    Knowledge is shipwrecked by the laughter of the gods."
                                               --Albert Einstein


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

Date: Thu, 17 May 2001 10:16:10 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Initialisation of object
Message-Id: <9dvc51$hpv@netnews.hinet.net>

<nobull@mail.com> wrote
> "Michael Stroeck" writes:
> > my $msg = new ForumMessage;
> > $msg->{
> >                 thread_id => $cgi->param('thread_id'),
> >                 user_id => $cgi->param('user_id'),
> >             }
>
> The most direct way is:
>
> %$msg = (
>          %$msg,
>          thread_id => scalar $cgi->param('thread_id'),
>          user_id => scalar $cgi->param('user_id')
> );

The syntax using "Slices" may be closer to what the OP wanted.

@{$msg}{'thread_id', 'user_id'} = ($cgi->param('thread_id'), $cgi->param('user_id'));

Note that we can't use

$msg->{'thread_id', 'user_id'} = ($cgi->param('thread_id'), $cgi->param('user_id'));

although it looks better.

John Lin





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

Date: Wed, 16 May 2001 20:58:04 -0700
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: map only when defined?
Message-Id: <9dv7e3$jru@fidoii.CC.Lehigh.EDU>

Everyone identified the problem neatly:
> change that to () not ''
Thanks!

For posterity, however, note that in my example:
> print join ' | ' =>
>            map {
>                    (defined $args->{$_})
>                      ? ($_, $args->{$_})
>                      : ''
>                }
>                qw/ -w -lpp -ms -o -s -c /,
>       ' | ';

that final pipe is just feeding into map along with the elements of
qw// -- obviously not what I intended!

The corrected example:
#!/usr/local/bin/perl -w
use diagnostics;
use strict;

my $args =
{
    -ms => 'letter',
    -o  => 'portrait'
};

print join ' | ' =>
           map {
                   (defined $args->{$_})
                     ? ($_, $args->{$_})
                     : ()
               }
               qw/ -w -lpp -ms -o -s -c /;





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

Date: Wed, 16 May 2001 19:54:54 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Measuring the time
Message-Id: <slrn9g64qe.o6k.tadmc@tadmc26.august.net>

Craig Berry <cberry@cinenet.net> wrote:

>On the topic of the proposed 'guidelines', I don't really understand why
>discussion continues here.  Any group or individual can post something
>labeled 'clpm posting guidelines', asserting any rules and using any
>language they please. 


This same thought occurred to me a few days ago. None of the other
past/present regularly posted articles endured such open contributions.

I'm just making an effort to be open minded. Perhaps I should 
exert less effort.

It surely would be easier that way...


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


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

Date: Thu, 17 May 2001 01:18:29 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Measuring the time
Message-Id: <tg69n55ba8985a@corp.supernews.com>

Tad McClellan (tadmc@augustmail.com) wrote:
: Craig Berry <cberry@cinenet.net> wrote:
: >On the topic of the proposed 'guidelines', I don't really understand why
: >discussion continues here.  Any group or individual can post something
: >labeled 'clpm posting guidelines', asserting any rules and using any
: >language they please. 
: 
: This same thought occurred to me a few days ago. None of the other
: past/present regularly posted articles endured such open contributions.
: 
: I'm just making an effort to be open minded. Perhaps I should 
: exert less effort.
: 
: It surely would be easier that way...

I've found that the 'cooking' phase for a document like this is best
handled offline, by a small group of those interested in preparing it.
You'll never get consensus on wording from the thousands of active clpm
readers.  Do the best job you can, post it, listen to reasonable feedback,
go back into the back room to revise.

It's similar to the reasoning behind not debating the Perl 6 feature set
here.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Wed, 16 May 2001 19:46:51 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <slrn9g64bb.o6k.tadmc@tadmc26.august.net>

Chris Stith <mischief@velma.motion.net> wrote:

>So perhaps one of the things in those guidelines should be:
>
>   Things you Must NOT do:
>      reply to FAQs with snide putdowns. We are trying to
>      get along here. Please be polite, even when correcting
>      someone for lack of compliance with this document.


That's a good one. I predict you will see something very
like that in the next revision. (except I think non-snide
putdowns should be avoided as well)

Thanks.


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


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

Date: Thu, 17 May 2001 02:50:03 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <tg6f2ri2nvog93@corp.supernews.com>

Tad McClellan <tadmc@augustmail.com> wrote:
> Chris Stith <mischief@velma.motion.net> wrote:

>>So perhaps one of the things in those guidelines should be:
>>
>>   Things you Must NOT do:
>>      reply to FAQs with snide putdowns. We are trying to

[...]

> like that in the next revision. (except I think non-snide
> putdowns should be avoided as well)

True. I was caught up in the context of the post to which
I was replying, and used the phrasing found therein. All
personal attacks should be kept to an absolute minimum.

Chris

-- 
You can never entirely stop being what you once were. That's
why it's important to be the right person today, and not put
it off till tomorrow. -- Larry Wall, 3rd State of the Onion



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

Date: Wed, 16 May 2001 18:57:56 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Sending wav-file through perl-script
Message-Id: <3B033024.5F6E921E@stomp.stomp.tokyo>

Chris wrote:

(snipped previous article)
 
> to get around the "inherent problem' (see below) and still process the
> wave file with your script
 
> you could try calling the script in this fashion
 
> http://mydomain.com/cgi-bin/waveprocess.pl?sound.wav
 
> the browser sees the last .wav and uses that as the file extension and
> therefore the helper program gets a proper extension
 
> I am not sure if this will work with all browsers on all platforms, but
> give it a try


My compliments. I tried your method and it does work
on a Sun Solaris / Mozilla 4.x combination. This will
most likely work on many system / browser combinations.

I tested two methods, both were successful:

Method One:

print "Content-type: audio/midi\n\n";

undef $/;
open (MIDI, "/internal/path/to/sound/file.mid");
binmode (MIDI);
$midi = <MIDI>;
close (MIDI);
print $midi;


Method Two:

print "Content-type: audio/midi\n\n";

open (MIDI, "/internal/path/to/sound/file.mid"");
binmode (MIDI);
while (<MIDI>)
 { print $_; }
close (MIDI);


I did not test removal of the binmode of the filehandle.
However, this is more of a system specific consideration.

Additional tests were run with printing to a logfile,
in addition to my test scripts above, as is. This was
also successful. This would be a good method to log
accesses to a binary file and keep a file location
relatively hidden.

Still, there is a bit of a letdown in having to dedicate
a script to this single function of printing a binary
and printing to a file handle which does not require a
Content-type, with no ability to generate a page for
viewing via a browser, with sounds.

This will work though as a hot link within a page,
if a file location is to be kept relatively hidden.
Not as fast as a direct link, but works!

Say, you have any secret methods for printing both
html and a binary file with one script?

Godzilla!


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

Date: Wed, 16 May 2001 21:35:46 -0400
From: "nosabi" <nosabi@snospamabi.com>
Subject: Re: To compress and uncompress text files ?
Message-Id: <9dv9ti$70v$1@sshuraac-i-1.production.compuserve.com>


Kurt Stephens <kstep@pepsdesign.com> wrote in message
news:9dshsk$teo$1@slb7.atl.mindspring.net...
> "nosabi" <nosabi@snospamabi.com> wrote in message
> news:9dsc7u$abk$1@sshuraab-i-1.production.compuserve.com...
> > How are you doing ?
> >
> > I have this perl script running a bullitn board for free postings of
ads.
> > After someone submits an ad  the email address, ad subject, ad message,
> > date&time, #of months to display ad,
> > is comma separated into an array and appended to a text file. Then
saved.
> > This file is accessed using perl to display ads.
> >
> > Since this is a popular feature on my board. The text file is becoming
> > large. Is there a built in feature of PERL to
> > compress and uncompress these text files "On The Fly"?
> > Or what should I be looking at to upgrade it to the Next Level ?
>
> The 'Next Level' would be a real DBMS such as MySQL.  With a flat text
> database, I would worry more about sluggish performance as the file grows
> than I would about eating up disk space.  Adding a compression/extraction
> pass to each access would slow things down even further.
>
> You should check with your hosting provider to find out what databases are
> supported, then use the DBI module with the appropriate drivers.  These
may
> already be installed on your system.  The DBI documentation is fairly
> complete, and includes links to other sites with FAQs, tutorials and such.
>
> To answer your original question, check out the Compress::Zlib or
> Archive::Zip modules on CPAN if you still think that compression is the
way
> to go.
>
> HTH,
>
> Kurt Stephens

Hi,
And Thank You Very Much Kurt for your Valuable Knowledge and Experience.
I'll have a case of the Killarney's Beer ordered for you  :)    And all you
guys.
My web sever provider does provide the MySQL. I never noticed it till the
Kurt recomended it.

I could'nt find anything written about transfering my text array database
(non- fixed length).
Will this be a problem ?
Should I do it now before the database gets any bigger or  won't it really
matter if it doubles or triples
in size before I go and buy the five books I saw on BN or Amazon ?
It looked to me like I was supposed to cut and past each feild of my data
base into  MySQL
and MySQL wanted it in fixed length chunks.
Sombody tell me please that Im not going to Hate  the way I did my database
and MySQL.

Anybody ?












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

Date: Wed, 16 May 2001 22:32:38 -0400
From: "nosabi" <nosabi@snospamabi.com>
Subject: Re: To compress and uncompress text files ?
Message-Id: <9dvd86$8op$1@sshuraac-i-1.production.compuserve.com>


Hi,
And Thank You Very Much Kurt for your Valuable Knowledge and Experience.
I'll have a case of the Killarney's Beer ordered for you  :)    And all you
guys.
My web sever provider does provide the MySQL. I never noticed it till the
Kurt recomended it.

I could'nt find anything written about transfering my text array database
(non- fixed length).
Will this be a problem ?
Should I do it now before the database gets any bigger or  won't it really
matter if it doubles or triples
in size before I go and buy the five books I saw on BN or Amazon ?
It looked to me like I was supposed to cut and past each feild of my data
base into  MySQL
and MySQL wanted it in fixed length chunks.
Sombody tell me please that Im not going to Hate  the way I did my database
and MySQL.

Anybody ?














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

Date: Wed, 16 May 2001 23:34:23 -0400
From: "nosabi" <nosabi@snospamabi.com>
Subject: Re: To compress and uncompress text files ?
Message-Id: <9dvgrv$91j$1@sshuraaa-i-1.production.compuserve.com>

Hi Bart,
Thank You for all the Great Info.

> In what way? Are all ads being skimmed , filtered, and the appropriate
> ones displayed? Or are you just displaying one ad at a time?

The perl script just displays each ad into html tables.
With the newest displayed at the top of the page.
Nothing Fancy I guess. I'm an old time trs-80 enthusiast
that use to love writting text adventure games, using lots of arrays.


> But I wonder if this is the solution to your problem. Which is...? Are
> you worried about disk space, or about speed issues? THis might save
> disk space, but it won't be faster. Er... un(g)zipping is quite fast,
> actually. Gzipping takes longer. So, since a simple "append" will no
> longer do, adding one ad to your archive will take a significant time.
>
> >Or what should I be looking at to upgrade it to the Next Level ?

Not untill you pointed out to me the time lag problem. I did want to
compress.
I was thinking more like..."If I could reduce the size of the file it might
load faster"
Because I am already running into a time lag problem. I don't think its my
web hosting provider.
Everything else, smaller files, load quick.

Anybody know what bench-mark or term for judging if my hosting provider is
my problem ?

But Bart, what is the MySQL doing that is different from the old text array
?


      Thanks again for all your help !





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

Date: Thu, 17 May 2001 01:09:39 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: uniq users
Message-Id: <tg696jf32i4o79@corp.supernews.com>

Patrick Joyce (joycefive@earthlink.net) wrote:
: i have a problem. i have a perl program and i need to get unique information
: from every user that gos to my site. before i used the ip address or
: hostname but i need it to work with proxy servers. what uniqu information
: can i get from them.

There's nothing unique you can grab without either (a) testing for a
cookie and setting a new unique one if they don't already have one, or (b)
prompting for an id (and perhaps password) on arrival, offering the chance
to get a new one if they haven't obtained one yet.

The cookie solution will break if the user's browser doesn not support
cookies (or if that support is turned off or scrubbed away by a firewall),
so the username entry option is probably your best bet.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Thu, 17 May 2001 02:43:24 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: uniq users
Message-Id: <tg6emc2eivv02f@corp.supernews.com>

[ line-wrapping performed for the original post ]

Patrick Joyce <joycefive@earthlink.net> wrote:
> i have a problem. i have a perl program and i need
> to get unique information from every user that gos
> to my site. before i used the ip address or hostname
> but i need it to work with proxy servers. what uniqu
> information can i get from them.

You can get whatever information that is provided by
the user's browser which is unique to that user. IOW,
you don't have much chance unless browsers start
handing out personal information.

You could set a cookie and check to see if the user
already has a cookie set, but that's a
same-user-on-same-machine[1] effect, even assuming they
don't delete the cookie.

[1] You could make them enter a name or such when they
first visit, and generate the cookie from that, then
assume that matching cookies are the same person across
machines, but this is problematic in its own varied
ways.

Good luck.

Chris

-- 
Parking for people we like only. All other vehicles will be vandalized.



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 919
**************************************


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