[17174] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4586 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 11 18:05:50 2000

Date: Wed, 11 Oct 2000 15:05:25 -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: <971301925-v9-i4586@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 11 Oct 2000     Volume: 9 Number: 4586

Today's topics:
    Re: A lot of s///g; feels like a slow idea. <lr@hpl.hp.com>
    Re: A problem with parsing (Mark-Jason Dominus)
        Altered files sometimes go empty! <ryandear@ucar.edu>
    Re: Altered files sometimes go empty! <sariq@texas.net>
    Re: Altered files sometimes go empty! (Randal L. Schwartz)
    Re: Bidirectional client-server : needs tweaking (Mark-Jason Dominus)
    Re: Bidirectional client-server : needs tweaking <bruce_phipps@my-deja.com>
    Re: Bidirectional client-server : needs tweaking (Gary E. Ansok)
    Re: Calculating in Perl. (Craig Berry)
        Calling Perl scripts inside HTML file within a Windows  <aycwong2@yahoo.com>
    Re: Convert array to string? (Martien Verbruggen)
        Convert text from ISO 8859-x to utf8 <no-spam@filthaut.com>
    Re: Cutesy Arrows - Just say no! (was Re: Convert array (brian d foy)
    Re: Cutesy Arrows - Just say no! (was Re: Convert array <james@NOSPAM.demon.co.uk>
    Re: Cutesy Arrows - Just say no! (was Re: Convert array <tony_curtis32@yahoo.com>
    Re: Cutesy Arrows - Just say no! (was Re: Convert array (Randal L. Schwartz)
        DBD::RAM question... (Jeff Z.) <mcdonabNO@SPAMyahoo.com>
    Re: Defining an Operator (not overloading) (Ilya Zakharevich)
        Filehandle to string (or HTTP::Request)? <jboes@eomonitor.com>
    Re: files changes when uploading. <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: files changes when uploading. <tim@ipac.caltech.edu>
        Help with newbie question <michael.segulja@sgi-lsi.com>
    Re: Help with newbie question (Chris Fedde)
        hoe to alter @INC? <zakazan@gmx.de>
    Re: hoe to alter @INC? eedlin@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Oct 2000 14:32:54 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: A lot of s///g; feels like a slow idea.
Message-Id: <MPG.144e7c638cacdcec98ae29@nntp.hpl.hp.com>

In article <8s278o$ill$1@nnrp1.deja.com> on Wed, 11 Oct 2000 17:16:16 
GMT, mexicanmeatballs@my-deja.com <mexicanmeatballs@my-deja.com> says...

 ...

> my $char_list= '(['.join("", keys(%translations)).'])';

 ...

> $line=~s/$char_list/$translations{$1}/gsoe;

No need for the 's' or 'e' modifiers.

And you can eliminate the 'o' modifier by quoting $char_list with qr() 
instead of just q().

I don't know if any of that would make it faster, though, and I'm too 
lazy to benchmark it.

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


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

Date: Wed, 11 Oct 2000 18:05:51 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: A problem with parsing
Message-Id: <39e4abff.45e1$2f@news.op.net>

In article <39e425dd$0$1464@echo-01.iinet.net.au>,
Cameron Elliott <celliot@tartarus.uwa.edu.au> wrote:
>I am searching for the \\$rtf_key_ref->[15]
>then I want to find the first occurence of \\$rtf_key_ref->[14]
>and then copy all the data up until the second occurence of
>\\$rtf_key_ref->[14]
>then I want to insert $summary_ref->{'BUF'}[$i][$j] in front of each
>occurence of \cell incrementing $j each time.

First break the string into three pieces: The part before the first
$rtf_key_ref[14], the part following that up to the second
$rtf_key_ref[14], and the part after that.  Then do the insertion on
just the middle part.  Then put the three parts back together:

        { my $sep = "\\$rtf_key_ref[14]";
          @parts = split /\Q$sep/, $target, 3;   
          my $j=0;
          $parts[1] =~ s{\\cell(?=[\s\\])}
                        {$summary_ref->{BUF}[$i][$j++]\\cell}g;
          $target = join $sep, @parts;
        }

You had:
>        $temp1 =~ s/(\\cell[\s|\\]?)/$summary_ref->{'BUF'}[$i][0]$1/g;

/g means to apply the substitution to *every* appearance of the
pattern.  So your version would replace *every* appearance of \\cell
with $summary_ref->{'BUF'}[$i][0]$1.  

Also [...] does not mean what you think.  [abc] matches a single 'a',
'b', or 'c'.  No vertical bar is required between the a, b, and c.
[\s|\\] matches a single \s (any whitespace character), a single '|',
or a single backslash.  You probably meant to write [\s\\] instead.

In my example, (?=[\s\\]) is a special pattern that only matches if
\\cell is *followed* by [\s\\].  But it does not actually match
[\s\\]; it only looks to see *if* it could have matched [\s\\].  So if
\cell is not followed by [\s\\], the substitution is not applied; if
it is followed by [\s\\], the substitution is applied to \cell, but
not to the following [\s\\].

>Otherwise I will have to break it into smaller problems..

That is what you should probably have done in the first place.


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

Date: Wed, 11 Oct 2000 11:58:31 -0600
From: Ryan Deardorff <ryandear@ucar.edu>
Subject: Altered files sometimes go empty!
Message-Id: <39E4AA46.107DCCA3@ucar.edu>

For a few years now, I've been using Perl to update some "real-time"
pages on a rather large website.  The idea is, we update our content
every half hour or so with content found at other sites that is
continually updated with new data...

Perl makes this very easy, of course, HOWEVER, I have noticed a rather
unpleasant side-effect, which is that occasionally, the files I'm trying
to update with new content suddently go missing!  While the file itself
still exists, it will have 0 size!  My solution has been, BEFORE my
scripts attempt to change the file, they create a backup copy first.
Then, I have another script run every once in a while to look at these
files, and see if they are of 0 size--if they are, then they are
restored from the backup copy....

But obviously, this is not a desirable way to handle things!  Does
anybody know WHY such files would suddenly be zeroed out?  I'm not sure
if it's an issue with the way I'm using Perl (works MOST of the time),
or something system-specific (SPARC Solaris)?  It seems like the kind of
thing that might happen if two processes were trying to write to the
same file at the same time, but as far as I can tell this isn't what's
happening...

Any help is greatly appreciated!  Please send responses to
ryandear@ucar.edu, as I'm not sure I'll continue to have access to this
newsgroup in the near future...

Ryan



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

Date: Wed, 11 Oct 2000 18:57:43 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: Altered files sometimes go empty!
Message-Id: <39E4B827.74B5144C@texas.net>

Ryan Deardorff wrote:
> 
> occasionally, the files I'm trying
> to update with new content suddently go missing!  While the file itself
> still exists, it will have 0 size!

First Guess:  There is a bug on line 17.

Second Guess:  perldoc -q lock

> Please send responses to
> ryandear@ucar.edu

Nope.  This is Usenet, not your personal helpdesk.

- Tom


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

Date: 11 Oct 2000 12:01:50 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Altered files sometimes go empty!
Message-Id: <m11yxnmcbl.fsf@halfdome.holdit.com>

>>>>> "Ryan" == Ryan Deardorff <ryandear@ucar.edu> writes:

Ryan> For a few years now, I've been using Perl to update some "real-time"
Ryan> pages on a rather large website.  The idea is, we update our content
Ryan> every half hour or so with content found at other sites that is
Ryan> continually updated with new data...

Ryan> Perl makes this very easy, of course,

Well, there are many ways to do it "too easy", and blow it.  Perhaps
you have one of those.

Ryan>  HOWEVER, I have noticed a rather
Ryan> unpleasant side-effect, which is that occasionally, the files I'm trying
Ryan> to update with new content suddently go missing!

Yup.  Sounds like you took a too-short shortcut.  Post code, and we can
help.  Or look at my columns online at:

        http://www.stonehenge.com/merlyn/WebTechniques/
        http://www.stonehenge.com/merlyn/UnixReview/
        http://www.stonehenge.com/merlyn/LinuxMag/

for some tips about how to handle concurrent updates.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 11 Oct 2000 18:34:19 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Bidirectional client-server : needs tweaking
Message-Id: <39e4b2aa.46ce$158@news.op.net>
Keywords: Conklin, ionic, sextuplet, slime

In article <8s1tp8$400$1@sshuraac-i-1.production.compuserve.com>,
Bruce Phipps <bruce_phipps@my-deja.com> wrote:
>but I get:
>>one
>>two
>>received by server: two
>>three
>>four
>>received by server: four
>
>Can someone help me on this, please?

As you know, each time you do <HANDLE>, you read a line of data from
HANDLE.  For example:

        while (<HANDLE>) {   # read a line into $_
          print $_;          # .. and print it
        }

Now, what does this do?

        while (<HANDLE>) {   # read a line into $_
          $in = <HANDLE>;    # read another line into $in
          print $in;          # ... and print it
        }
        
Since only the $in lines are being printed, and the $_ lines are being
ignored and thrown away, the loop prints only every second line of input.

Now look at your code:

>while (<$remote>) {
>$incoming = <$remote>;
>#send acknowledgement to client
>print $remote "received by server:$incoming";
>}

Oho.



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

Date: Wed, 11 Oct 2000 20:09:50 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Re: Bidirectional client-server : needs tweaking
Message-Id: <8s2dvd$d8b$1@sshuraac-i-1.production.compuserve.com>

You are right, I fixed this by changing the server code to

while (<$remote>) {
$incoming = $_;
#send acknowledgement to client
print $remote "received by server:$incoming";
}


So, it should be possible for me to implement a custom front-end/log in
screen for my client-server connection. IO::Socket is pretty impressive!

Thanks
Bruce




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

Date: 11 Oct 2000 21:58:33 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Bidirectional client-server : needs tweaking
Message-Id: <8s2nq9$31s@gap.cco.caltech.edu>

In article <8s1tp8$400$1@sshuraac-i-1.production.compuserve.com>,
Bruce Phipps <bruce_phipps@my-deja.com> wrote:
>while (<$remote>) {

This reads a line from $remote and puts it into $_.

>$incoming = <$remote>;

This reads another line from $remote and puts it into $incoming.

-- Gary Ansok


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

Date: Wed, 11 Oct 2000 21:37:18 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Calculating in Perl.
Message-Id: <su9nceljghltb9@corp.supernews.com>

Paul Dortman (paul@crocodile.iis.nsk.su) wrote:
: I'm writing program in Perl, that must perform calculation with certain
: accuracy. I'll try to explain what I mean: I need to have all
: calculations (addition, subtraction,  multiplication and division) only
: with two or three digits after decimal point. Standard Perl calculation is
: not appropriate, they have not high accuracy and it is not convenient to
: round result each time.

The easiest way is to do 'implicit decimal' arithmetic on integers.  Each
integer really represents .001 times its apparent value (for three digits
after the decimal).  You would then insert the decimal only for display
purposes.  Addition and subtraction can be done using the normal operators
in this scheme; multiplication and division take more work:

  sub multiply { $_[0] * $_[1] / 1000; }
  sub divide   { 1000 * $_[0] / $_[1]; }

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Wed, 11 Oct 2000 18:30:09 -0000
From: <aycwong2@yahoo.com>
Subject: Calling Perl scripts inside HTML file within a Windows environment
Message-Id: <su9cdh6shh5s2e@corp.supernews.com>

Hi.. I just setup my Win2k server and installed ActivePerl on my machine.. 
I can run the scripts from the scripts folder correctly, but how do I call 
the scripts inside my HTML file??

For example, a simple counter program, in all the resources I have found 
they have used <!-- #exec cgi="/scripts/counter.pl"-->. But my webpage is 
not showing the results. If I tried to just run the script like 
http://my.website.com/scripts/counter.pl, the counter will run and return 
a new count.

Pls help. I am having a hard time to find CGI-Perl support for Windows 
environment.

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Wed, 11 Oct 2000 21:54:53 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Convert array to string?
Message-Id: <slrn8u9od4.8q8.mgjv@verbruggen.comdyn.com.au>

[Please, in the future, post your reply AFTER the suitably trimmed
down text you reply to]

On Wed, 11 Oct 2000 15:53:40 GMT,
	Mike Balenger <MBalenger@att.net> wrote:
> 
> Summary: "=>" works similarly to ",". I would suggest using comma in the
> proposed solution.
> 
> 
> => (equal-greater) is another way to say , (comma) except that it acts like
> a binary operator, forcing the lefthand side to be interpreted as a string.

Since you don't refer the poster to the relevant portion of the perlop
documentation, I'll do that for you.
It is important, becasue of a slight inaccuracy in your statement. 

Read perlop:

# perldoc perlop
[snip]
       The => digraph is mostly just a synonym for the comma
       operator.  It's useful for documenting arguments that come
       in pairs.  As of release 5.001, it also forces any *word* to
       the left of it to be interpreted as a string.
[snip]

[emphasis is mine]

The important bit here is 'word' (and even that isn't really accurate
enough). It doesn't autoquote everything.

> That behavior is most often useful in ARRAYS that are used to initialize
> HASHES.  They aren't really used *directly* in hashes.  Ala ...

Not arrays. You can't use => in arrays. You use it in lists.

# perldoc -q 'list.*array'

> You see that the => is actually used in an *array*.  The array is then used

*list*

> to initialize the hash.  Notice also that whitespace is not preserved on the

But whitespace not being preserved has nothing to do with , or =>.
It's a language thing. Whitespace separates tokens, if you want a
single one, you need to quote in some way.

[SNIP jeopardy quote]

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.   | selective about its friends.
NSW, Australia                  | 


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

Date: Wed, 11 Oct 2000 20:30:54 +0200
From: "Filthaut" <no-spam@filthaut.com>
Subject: Convert text from ISO 8859-x to utf8
Message-Id: <8s2bn0$fkc$1@news.rrz.Uni-Koeln.DE>

Hi,

I search a hint how to solve this problem in Perl.

I have a mail text and know the character sets e.g. ISO 8859-6 (arabic).
I have to convert the text into a utf8 unicode text with ncs's characters
(&#1530;).

Thankx
Marc




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

Date: Wed, 11 Oct 2000 14:48:13 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Cutesy Arrows - Just say no! (was Re: Convert array to string?)
Message-Id: <brian-ya02408000R1110001448130001@news.panix.com>

In article <m18zrvpd9z.fsf_-_@halfdome.holdit.com>, merlyn@stonehenge.com (Randal L. Schwartz) posted:

> >>>>> "Rafael" == Rafael Garcia-Suarez <rgarciasuarez@free.fr> writes:

> Rafael>   $str = join 'a' => 'b', 'c', 'd', 'e';

> Rafael> [That] way to write it stresses the semantic difference between the
> Rafael> first argument and the rest of the arguments.


> And then you get bit with:
>     use constant MY_SEPARATOR => 'a';
>     $result2 = join MY_SEPARATOR => 'b', 'c', 'd', 'e';


of course, if you wanted to stress the semantic difference, it's
much more meaningful to show:

   join $glue, ('b', 'c', 'd', ...);

which doesn't suffer from the side effects and clearly shows the
list portion.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Wed, 11 Oct 2000 22:23:26 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Cutesy Arrows - Just say no! (was Re: Convert array to string?)
Message-Id: <ant112126d07fNdQ@oakseed.demon.co.uk>

In article <Ca1F5.5725$524.345772@bgtnsc05-news.ops.worldnet.att.net>,
Mike Balenger <URL:mailto:MBalenger@att.net> wrote:
> Randal L. Schwartz <merlyn@stonehenge.com> wrote in message
> news:m1lmvvnxrr.fsf@halfdome.holdit.com...
> >
> > But your posting didn't qualify that, so that creates a cargo-cult
> > misunderstanding,
> 
> Cargo-cult?

Yes, I'd like to know what that means. I'd come to the conclusion that
it was a cultural reference specific to America and that I'd never
find out exactly what nuance it had. It clearly means "bad" in some
sense, but more than that I haven't been able to deduce.

Could someone in the know please explain the derivation, history, and
current usage of the term "cargo-cult" please.

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: 11 Oct 2000 16:27:06 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Cutesy Arrows - Just say no! (was Re: Convert array to string?)
Message-Id: <878zrvf4r9.fsf@limey.hpcc.uh.edu>

>> On Wed, 11 Oct 2000 22:23:26 +0100,
>> James Taylor <james@NOSPAM.demon.co.uk> said:

> Could someone in the know please explain the derivation,
> history, and current usage of the term "cargo-cult"
> please.

http://www.tuxedo.org/~esr/jargon/html/entry/cargo-cult-programming.html

hth
t
-- 
Namaste!
And an "oogabooga" to you too!
                                         -- Homer Simpson


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

Date: 11 Oct 2000 15:03:06 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Cutesy Arrows - Just say no! (was Re: Convert array to string?)
Message-Id: <m18zrvjasl.fsf@halfdome.holdit.com>

>>>>> "Tony" == Tony Curtis <tony_curtis32@yahoo.com> writes:

>> Could someone in the know please explain the derivation,
>> history, and current usage of the term "cargo-cult"
>> please.

Tony> http://www.tuxedo.org/~esr/jargon/html/entry/cargo-cult-programming.html

And that's precisely the meaning I meant here.  The use of a cutesy
arrow will have people start ritually using it in inappropriate
context without understanding why.  And it will generate damage.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 11 Oct 2000 12:27:45 -0700
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: DBD::RAM question... (Jeff Z.)
Message-Id: <lb3F5.16$t74.36834@news.pacbell.net>


"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:39E48133.CFA607BA@vpservices.com...
> Brian McDonald wrote:
> >
> > I am writing a text-to-XML parser that operates on a CSV raw data file.
>
> Uh, in that case, why don't you just use DBD::RAM which can read and
> write both CSV and XML using DBI methods?
>
> --
> Jeff
> perl -MDBI -e "$d=DBI->connect('dbi:RAM:');$d->func({data_type=>'XML',
> data_source=>'<phrase><w1>Just</w1><w2>Another</w2><w3>Perl</w3><w4>
> Hacker</w4></phrase>',record_tag=>'phrase',col_names=>'w1,w2,w3,w4'},
> 'import');print join ' ',$d->selectrow_array('SELECT * FROM table1')"
>

Hi Jeff,

I've checked out the documentation for DBD::RAM at CPAN and don't really
understand how you envision it's utility for my application. What I need to
do is to take an input CSV file, parse it, and then generate an XML
document.

I see this module as being potentially useful for the other processor I
need: i.e. the script that takes our XML files (like the one txt2xml.pl is
creating), parses them, and injects the data into SQL.

Am I missing something?

Brian






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

Date: 11 Oct 2000 19:42:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Defining an Operator (not overloading)
Message-Id: <8s2frh$ltn$1@charm.magnus.acs.ohio-state.edu>

[Did not get an original yet, so I reply to a reply.]

[A complimentary Cc of this posting was sent to Marco Natoni 
<mnatoni@rumbanet.it>],
who wrote in article <39E48328.D46125AC@bar.va>:
> Daniel Yacob wrote:
> > My interest is to simply define a new operator, imported from its 
> > own package via 'use', and have it be functional for scalars, it 
> > can reject any arguements that are refs.  

See my user-defined operators patch (for 5.005_50).

Ilya


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

Date: Wed, 11 Oct 2000 13:32:50 -0400
From: Jeff Boes <jboes@eomonitor.com>
Subject: Filehandle to string (or HTTP::Request)?
Message-Id: <39e4d0d3$0$30013$44a10c7e@news.net-link.net>

Okay, don't everyone jump me for this...

I have an existing package that is used in dozens of places in our
production system. It retrieves web pages using socket opens and other
evils. I'm going to rewrite the innards to use LWP.

However, the visible interface to the package sets up a file handle to
retrieve the content. I would like to preserve that interface if only so
I don't have to strip down and rebuild another 10,000 lines of code...

So my problem is: given the existing LWP code (I don't want to rewrite
that to serve my purpose either, as maintenance could be rough), how can
I write a layer on top of it that will define a filehandle so that
content is retrieved by normal reads?

Simpleminded approach: grab the content, open a file in /tmp, write it
out, open a read-only filehandle to it.

Complex approach: overload the '<>' operator.

Other approaches: ??

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Wed, 11 Oct 2000 12:28:56 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: files changes when uploading.
Message-Id: <39E4BF78.FC0A1C65@jpl.nasa.gov>

Johan Ditmar wrote:
> ----
> open (SAVE,">./bitfile.bit") || die $!;
> 
>    while (read($bitfile,$data,1024)) {
>      print SAVE $data;
> 
>    }
>    close SAVE;
> ----
> For my application, it's very important that the uploaded file is not
> changed in any way. It seems though that it is changed when using my code.
> It becomes a little larger also. Is there some way to upload files without
> changing them?

You might be having problems with the CR LF translations the perl does. 
Take a look at perldoc -f binmode for a possible solution.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Wed, 11 Oct 2000 13:51:25 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: files changes when uploading.
Message-Id: <39E4D2CD.A407B1D4@ipac.caltech.edu>

Johan Ditmar wrote:
> open (SAVE,">./bitfile.bit") || die $!;
> 
>    while (read($bitfile,$data,1024)) {
>      print SAVE $data;
> 
>    }
>    close SAVE;
> ----
> For my application, it's very important that the uploaded file is not
> changed in any way. It seems though that it is changed when using my code.
> It becomes a little larger also. Is there some way to upload files without
> changing them?

What is $bitfile? Unless it is a filehandle pointing at ./bitfile.bit this code
does not alter it. Are you sure some other part of the upload process isn't
expanding it somehow (e.g. line terminator translation)?

--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: Wed, 11 Oct 2000 19:17:26 GMT
From: Michael Segulja <michael.segulja@sgi-lsi.com>
Subject: Help with newbie question
Message-Id: <8s2ebu$p99$1@nnrp1.deja.com>

I am writing a perl script to enter the tag info from my mp3 files into
a MySql database as a way to learn perl.  I'm a little stuck though, so
I hope somebody can help me.  I sort of know what I need to do, but I
need a push in the right direction.  Basically, here's what I have:

My Perl script reads the MP3 files from a specific directory, gathers
the info and tag information, and assigns the values to certain
variables, i.e. $album, $title, $artist, etc.

Next, I connect to the MySql database and insert the tag info into the
appropriate columns: Album, Artist, Title, etc.

I added a UNIQUE INDEX to the title column to prevent songs being
entered twice.  Obviously as I add CDs to my collection, I'll need to
run the script again.  I want it to determine if the title is already
in the database, and if so go on to the next mp3 file.  Otherwise, I
want it to insert it.  Here's my code that I have so far:

# Connect to the database mp3db.
my $dbh = DBI->connect("DBI:mysql:database=$db;host=$host",
          $user, $password, {RaiseError => 1} );

# Insert MP3 tag info into table mp3main.
my $sth=$dbh->prepare("INSERT INTO mp3main
  (album, artist, title, genre, comment, bitrate, version, mpeg_layer,
  durationS, year) VALUES (?,?,?,?,?,?,?,?,?,?,?)" );

$sth->execute($album, $artist, $title, $genre, $comment, $bitrate, $vers
     $durationM, $durationS, $year) || die "Insert Failed";

# Disconnect from database.
$sth->disconnect();

This is a foreach loop that ends once the last MP3 file is found.  It
works fine until it hits a duplicate entry, and it just stops.  I guess
I need something that says

   if $title is already in the database
          go to next mp3 file
   else
      $sth->execute($album, $artist, $title, etc., etc.);

I'm not real sure what the code would be, so hopefully somebody can
point me in the right direction.  I really appreciate everybody's help.
I have already learned a ton of stuff from this newsgroup.

Thanks,

Michael


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 11 Oct 2000 21:45:19 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Help with newbie question
Message-Id: <Pb5F5.19$T3.170882560@news.frii.net>

In article <8s2ebu$p99$1@nnrp1.deja.com>,
Michael Segulja  <michael.segulja@sgi-lsi.com> wrote:
>
>   if $title is already in the database
>          go to next mp3 file
>   else
>      $sth->execute($album, $artist, $title, etc., etc.);
>

To check that a row is in the database use sql like 

    select count(title) from mp3main where title = ?;

You need to prepare this into another statement handle then execute
and fetch on it.  It will return a row with one column containing
the number of matches.  Read up on the fetchrow_* DBI methods.
You should probably also check the return values of the $sth->execute
statements.  otherwise you might not know if there has been an error.

BTW, Are you sure that title is unique for all albums and artists? 

chris
-- 
    This space intentionally left blank


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

Date: Wed, 11 Oct 2000 21:40:52 +0200
From: "Werner, Wolfgang" <zakazan@gmx.de>
Subject: hoe to alter @INC?
Message-Id: <39E4C243.6906DDCE@gmx.de>

hi,
how can i change @INC?
i wan to have a new dir for modules
thans



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

Date: Wed, 11 Oct 2000 20:10:03 GMT
From: eedlin@my-deja.com
Subject: Re: hoe to alter @INC?
Message-Id: <8s2hek$s14$1@nnrp1.deja.com>

use lib 'new/path/to/modules';

This will add the path into @INC at compile-time.

In article <39E4C243.6906DDCE@gmx.de>,
  "Werner, Wolfgang" <zakazan@gmx.de> wrote:
> hi,
> how can i change @INC?
> i wan to have a new dir for modules
> thans
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4586
**************************************


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