[11138] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4738 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 24 22:17:13 1999

Date: Sun, 24 Jan 99 19:00:25 -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           Sun, 24 Jan 1999     Volume: 8 Number: 4738

Today's topics:
    Re: ***** BEST GIRLS ******* <spam@dikkelul.com>
    Re: Bar code gif generation lucinda.moutou@digital.com
        Browser History in Perl - Possible? <skate@vt.edu>
    Re: Can somebody point out the error of my ways please? (Martien Verbruggen)
        Creating a standalone executable from a perl script (Wi (Martin Packer)
    Re: Help - file output problem <jdf@pobox.com>
    Re: Help - file output problem <dales@enhanced-performance.com>
    Re: How do I split this string? <myparu@_usa_.net>
        How I direct STDIN to shell command? <dbikle@rahul.net>
    Re: How I direct STDIN to shell command? (Sam Holden)
        How to detect an empty hash ? <kprice@cardinal.co.nz>
    Re: How to insert newline break into a long string (Ronald J Kimball)
        How to sort <johkar@netins.net>
    Re: humor: site for cheap crappy perl books (David W. Crawford)
    Re: JPEG manipulation in PERL <jdf@pobox.com>
    Re: JPEG manipulation in PERL (Bart Lateur)
    Re: JPEG manipulation in PERL <jdf@pobox.com>
    Re: Need Help Removing (Unlinking) Files in PERL Script <donnywi@yahoo.com>
    Re: Need Help Removing (Unlinking) Files in PERL Script (Martien Verbruggen)
    Re: Need Help Removing (Unlinking) Files in PERL Script (Martien Verbruggen)
    Re: Newbie question: writing file scott.craig@moh.hnet.bc.ca
    Re: Perl Criticism (Bart Lateur)
        perl header zinger_0@my-dejanews.com
    Re: Perl problem :(Offline mode... <andrewf@beausys.demon.co.uk>
    Re: Perl problem :(Offline mode... <andrewf@beausys.demon.co.uk>
    Re: Problem with dbm hash (Ronald J Kimball)
    Re: Problem with dbm hash (Steve)
    Re: Problem with dbm hash (Steve)
    Re: Regular expression to parse RealAudio logs? (Ronald J Kimball)
        S: RSH/RCP module (Thorsten Dombach)
    Re: searching a binary file (Ronald J Kimball)
    Re: Trying to change a line in a file (Ronald J Kimball)
        Want to output $29.85 not $29.8585 ya know? <wer@cstone.net>
    Re: Want to output $29.85 not $29.8585 ya know? (Martien Verbruggen)
        What's a script worth? (Simon Whitaker)
    Re: What's a script worth? (brian d foy)
    Re: Where can I find text parsing samples (Ronald J Kimball)
    Re: Writing files (Ronald J Kimball)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 25 Jan 1999 01:37:43 +0100
From: "Willem" <spam@dikkelul.com>
Subject: Re: ***** BEST GIRLS *******
Message-Id: <78geja$ia5$1@dinkel.civ.utwente.nl>

>No need to flame or complain - we are responsible people and
>when asked politely we will respond in a professional manner.

Get this guy to jail....




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

Date: Mon, 25 Jan 1999 02:22:31 GMT
From: lucinda.moutou@digital.com
Subject: Re: Bar code gif generation
Message-Id: <78gkh0$mro$1@nnrp1.dejanews.com>

Thanks, Leo, I found it.

However the best solution turns out to be exec'ing the unix 'convert'
command... duh... guess I should have looked for that first.

Lucinda

In article <77do6d$2of$1@fu-berlin.de>,
  schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk) wrote:
> If you're working on unix,
> GhostScript can produce a ppm file from a PostScript file,
> and ppmtogif converts that to gif.  This is packaged in
> pstogif which happens to be a perl script.  I
> don't know where we got it but the following is from the comments and is
> probably enough to help you find it (if you don't already have it!)
>
> # pstogif.pl v1.0, July 1994, by Nikos Drakos <nikos@cbl.leeds.ac.uk>
> # Computer Based Learning Unit, University of Leeds.
> #
> # Accompanies LaTeX2HTML Version 96.1
> #
> # Script to convert an arbitrary PostScript image to a cropped GIF image
> # suitable for incorporation into HTML documents as inlined images to be
> # viewed with WWW browsers.
> #
> # This is based on the pstoepsi script
> # by Doug Crabill dgc@cs.purdue.edu
> #
>
> lucinda.moutou@digital.com wrote:
> : Hi,
>
> : I need to generate barcode GIFs (or jpegs).  The perl module for this
> : purpose generates postscript.  Also, there is a postscript/TT font available
> : that does barcodes.  Finally, there must be someone who's done this before.
>
> : From this one need and three pieces, can anybody suggest how to connect
point
> : A to point B? (ie convert ps to gif, print fonts as gifs, or other solution)
>
> : Thanks,
> : Lucinda
>
> : -----------== Posted via Deja News, The Discussion Network ==----------
> : http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>
> --
> ------------------------------------------------------------
>    schalkwy@mpimg-berlin-dahlem.mpg.de
>

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


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

Date: Sun, 24 Jan 1999 21:06:27 -0500
From: "Paul" <skate@vt.edu>
Subject: Browser History in Perl - Possible?
Message-Id: <78gjfe$3to$1@solaris.cc.vt.edu>

Hello, is there anyway to find out the user's browser history via PERL?  My
project involves two frames.  I simply want the URL of the lower frame, so
when the user clicks on the upper frame to change the page, i can reload
another page, and put that same page the user was viewing in the lower
frame, back but full screen.

Also, maybe there is just a way to tell what the current URL is of a certain
frame or page?

Thanks much!!
paul
skate @ vt . edu




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

Date: Sun, 24 Jan 1999 23:06:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Can somebody point out the error of my ways please?
Message-Id: <%HNq2.67$b32.2742@nsw.nnrp.telstra.net>

In article <36ab4ff7.1765611@news.icon.co.za>,
	elvis@theking.org (Bob Dubery) writes:
> Consider this code...

You are obviously not using strict. bad.
Are you using -w?

> @terms = ('please','tell','told');
> 
>  foreach $thisword(@terms) {
>         $hashname = "/usr/syschanges/$thisword";
>         dbmopen(%WORDHASH,$hashname,0666);

You should always check the result of these sorts of things. How do
you know it succeeded? Is there anything in the database at all?

Maybe you should consider using one of the modules that have
superceded this functionality.

# perldoc AnyDBM_File

>         foreach $hashentry(keys %WORDHASH) {

Instead of keys, you may want to use each:

# perldoc -f each

as explained in the dbmopen documentation:

# perldoc dbmopen

> It doesn't do what I expected it to do. The line 
> 	print "$hashentry has $howmany \n";
> never produces any output.
> 
> In fact, given that the line
> 	print "$hashentry";

In other words: nothing produces output. I fail to see why you
consider the first of these two statements more meaningful than the
second. Oh well.

> never gets to generate any output I conclude that, for some reason,
> the foreach loop is not being execute.

Very likely. If you check whether dbmopen succeeds or not, you may
find out why.

> Now I think it's something to do with the variable $hashname. If I
> change the line assigning it to
> 	$hashname = "/usr/syschanges/tell";
> then I get to see some output. 

Really? is the code you gave us the _exact_ code you are using?
cut-and-paste? 

> The DBM files are there. If I change the inner loop to do
> 	print -r $hashentry;
> instead of opening the hash and trying to loop through it then I get
> to see 3 ones (1).

There may be permission problems. Unless you check the return value of
dbmopen and inspect $! on failure, you may never find out.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | In the fight between you and the world,
Commercial Dynamics Pty. Ltd.       | back the world - Franz Kafka
NSW, Australia                      | 


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

Date: Sun, 24 Jan 1999 21:13:41 -0500
From: mpacker@concentric.net (Martin Packer)
Subject: Creating a standalone executable from a perl script (Win32)
Message-Id: <36aed1bb.13976788@news.mindspring.com>

I am trying to use a simple perl script I wrote to the server at a Middle
School that I am doing some volunteer work for.  If I can get away with it,
I would rather not have a full Perl (even in binary form) install on their
server.  Given that, I am trying to puzzle out how I would turn a Perl
script into a stand alone .exe file (this is all a Win32 environment).

The Perl FAQ at http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.htm
states "Malcolm Beattie has written a multifunction backend compiler,
available from CPAN".  I couldn't find it in my meanderings on that site.
Any help?

P.S. I currently went the wimp route and only have the binaries of Perl
installed on my machine.  Please indicate if I need to download the source
for some reason to get from here to there (that's assuming I can get there
at all).

TIA,


Marty Packer
Elbow Technologies
"Reason with them, it drives them crazy"


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

Date: 25 Jan 1999 00:04:46 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Dale Sutcliffe <dales@enhanced-performance.com>
Subject: Re: Help - file output problem
Message-Id: <m3sod0l1bl.fsf@joshua.panix.com>

Dale Sutcliffe <dales@enhanced-performance.com> writes:

> For some reason, the script below is adding extra | to the end of the
> file.  Any ideas why?

> unless (open FILE, "+<$secfile") {
>     print "Error can not open file: $!\n";
>     exit 1;
> } else {
>     while (<FILE>) {

Oof.  Why not just do it the canonical way, which will save you some
braces and a lot of typing?

  open(FILE, "+< $secfile") || die "Error cannot open $secfile: $!\n";
  while (<FILE>) {  

>    print FILE $LoL[$i][0],"|",$LoL[$i][1],"|1|\n";
                                               ^
Is that the "extra" | of which you speak?------'

>    print FILE $LoL[$i][0],"|",$LoL[$i][1],"|",$LoL[$i][2],"|\n";
                                                             ^
Is that?-----------------------------------------------------'

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sun, 24 Jan 1999 18:57:01 -0800
From: Dale Sutcliffe <dales@enhanced-performance.com>
Subject: Re: Help - file output problem
Message-Id: <36ABDD7D.C37E9EE3@enhanced-performance.com>

>
>   open(FILE, "+< $secfile") || die "Error cannot
open $secfile: $!\n";
>   while (<FILE>) {
>
> >    print FILE
$LoL[$i][0],"|",$LoL[$i][1],"|1|\n";
>                                                ^
> Is that the "extra" | of which you speak?------'

No, there are several extra |
I use the | as deliminators and what results is
several extra | although
the program should just be going through the array
and printing out what
was put in.  It is almost as if the program is
flushing before closing.

>
>
> >    print FILE
$LoL[$i][0],"|",$LoL[$i][1],"|",$LoL[$i][2],"|\n";
>
^
> Is
that?-----------------------------------------------------'





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

Date: Mon, 25 Jan 1999 08:10:19 +0530
From: Murali Ravipudi <myparu@_usa_.net>
To: Ken Williams <tekkin@hotmail.com>
Subject: Re: How do I split this string?
Message-Id: <36ABD993.56369F44@_usa_.net>

I would :

  $string="inet addr:.................";
  split / /,$string; shift; $string = shift; split /:/, $string; shift;
  $result=shift;

comments....

murali



Ken Williams wrote:
> 
> inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
> 
> The above is from ifconfig.  I need to pull the IP's out.  Specifically the
> first.  How do I split with a starting character of : and an ending character
> of space?
> 
> For example:
> 
> ($IP, $BC, $MASK) = split (/: ??? /);
> 
> Anyone?
> 
> Thanks.


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

Date: 25 Jan 1999 02:31:35 GMT
From: Dan Bikle <dbikle@rahul.net>
Subject: How I direct STDIN to shell command?
Message-Id: <78gl27$iiv$1@samba.rahul.net>

Hi,

suppose I have a shell command, /usr/bin/dc for example, 
which allows a user to feed it chars via STDIN.

All UNIX shells allow me to construct a script which 
directs STDIN from the shell script rather than the keyboard.

Here is a demo:

#! /bin/sh
 
/usr/bin/dc << EOF
1
1
+
p
q
EOF

My question is ...

How do I write a perl script which directs STDIN from the
perl script to a shell command?

A similar question:  How would you port the above shell syntax
to perl syntax??

-Dan
---------------------------------------------------------------------
Daniel B. Bikle/Independent Oracle Consultant
bikle@bikle.com | 650/941-6276 | P.O. BOX AG LOS ALTOS CA 94023
http://www.bikle.com
---------------------------------------------------------------------




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

Date: 25 Jan 1999 02:51:42 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How I direct STDIN to shell command?
Message-Id: <slrn7ann1u.k8v.sholden@pgrad.cs.usyd.edu.au>

On 25 Jan 1999 02:31:35 GMT, Dan Bikle <dbikle@rahul.net> wrote:
>Hi,
>
>suppose I have a shell command, /usr/bin/dc for example, 
>which allows a user to feed it chars via STDIN.
>
>All UNIX shells allow me to construct a script which 
>directs STDIN from the shell script rather than the keyboard.
>
>Here is a demo:
>
>#! /bin/sh
> 
>/usr/bin/dc << EOF
>1
>1
>+
>p
>q
>EOF
>
>My question is ...
>
>How do I write a perl script which directs STDIN from the
>perl script to a shell command?

One would read the documentation that comes with perl...

'perldoc perlipc' is probably appropriate...

>
>A similar question:  How would you port the above shell syntax
>to perl syntax??

One could use something like the following after reading the documentation
to find out what 'DC' is and how to get one :

print DC <<EOF; 
1
1
+
p
q
EOF
# strangely similar isn't it....

-- 
Sam

comments on data are usually much more helpful than on algorithms
	--Rob Pike


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

Date: Mon, 25 Jan 1999 15:21:52 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: How to detect an empty hash ?
Message-Id: <36ABD540.F24898CF@cardinal.co.nz>

Does anyone know of a cute/cool way to check if a hash is empty ?

I know I can compare scalar %hash to /^0\/*/ or scalar (keys %hash) to
zero, but I was wondering if there was anything cuter/cooler ?

Could I compare to an anonymous empty hash ? and if so how ?

Just curious,

Kelvin


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

Date: Sun, 24 Jan 1999 13:58:56 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to insert newline break into a long string
Message-Id: <1dm4zws.162tz5m1xyj50gN@bay2-63.quincy.ziplink.net>

Sun Qinghe <sunq@ERE.UMontreal.CA> wrote:

> I want to insert newline
> break into this long string at certain interval. Could you give me
> a hint ?

use Text::Wrap;

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 24 Jan 1999 20:38:32 -0600
From: johkar <johkar@netins.net>
Subject: How to sort
Message-Id: <36ABD928.3287@netins.net>

I want to modify a Free for All Links Script that I got off a perl
site.  It works great except that it puts all the new links on the
bottom of the list instead of the top. The perl file stores the links in
a flat text file and assigns a unique $id to each row added.

Can someone point me to a resource for this answer or give me a possible
solution?

Thanks,

John
-- 
Check out the Des Moines Mountain Bike Page! website at:
http://www.netins.net/showcase/zoodas1/


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

Date: 24 Jan 1999 21:47:15 -0500
From: dc@panix.com (David W. Crawford)
Subject: Re: humor: site for cheap crappy perl books
Message-Id: <xz37luchxvw.fsf@panix3.panix.com>

I've seen 'Perl Harbor memorabilia' and 
'Gold charm with Amythest and Perl: Item #58534524' on ebay.com .

Fodder for perl.advocates:
based on an ebay.copm search, and my creative interpretation:

people giving up on   PERL and selling their kit:  15
people giving up on Python and selling their kit: 131

dc
how many of those python jobs were not for software engineering,
but for running away with a flying circus ?

Jonathan Feinberg <jdf@pobox.com> writes:

> 
> Uri Guttman <uri@home.sysarch.com> writes:
> 
> > check out this link. the page has perl misspelled as pearl (next
> > to a correct spelling). it also groups perl books with cgi ones.
> 
> Lately I've seen several web pages with forms that ask you which
> language you use for most of your development work.  It usually goes
> something like this
> 
>      C/C++           [as if they belong together]
>      JavaScript      [puhleeze]
>      Java            [at least they know to separate those]
>      Perl/CGI        [D'oh!]
> 
> -- 
> Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
> http://pobox.com/~jdf



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

Date: 25 Jan 1999 00:06:11 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Andrew.Wild@env.qld.gov.au
Subject: Re: JPEG manipulation in PERL
Message-Id: <m3pv84l198.fsf@joshua.panix.com>

Andrew Wild <Andrew.Wild@env.qld.gov.au> writes:

> I am trying to find out if there are any modules/libaries availble to do
> JPEG image manipulation. i.e. To resize a JPEG image etc.

The first and best place to check for the existance of a Perl module
is the CPAN, available at

   http://www.perl.com/CPAN-local/

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sun, 24 Jan 1999 23:22:32 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: JPEG manipulation in PERL
Message-Id: <36acaaf0.875614@news.skynet.be>

Andrew Wild wrote:

>I am trying to find out if there are any modules/libaries availble to do
>JPEG image manipulation. i.e. To resize a JPEG image etc.

No. The C-source from the Independent JPEG Group (IJG) is excellent,
though. Maybe you could combine the two (Perl + C)?

	Bart.


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

Date: 25 Jan 1999 00:52:29 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: JPEG manipulation in PERL
Message-Id: <m3k8yckz42.fsf@joshua.panix.com>

bart.lateur@skynet.be (Bart Lateur) writes:

> Andrew Wild wrote:
> 
> >I am trying to find out if there are any modules/libaries availble to do
> >JPEG image manipulation. i.e. To resize a JPEG image etc.
> 
> No. The C-source from the Independent JPEG Group (IJG) is excellent,
> though. Maybe you could combine the two (Perl + C)?

While I wouldn't want to squash your fun suggestion to build a
Jpeg.pm, I should point out the the PerlMagick distribution will
certainly allow you to manipulate jpegs (and gif, and png, and...).

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sun, 24 Jan 1999 18:11:32 -0600
From: Donny Widjaja <donnywi@yahoo.com>
To: wabba@globalnet.co.uk
Subject: Re: Need Help Removing (Unlinking) Files in PERL Script
Message-Id: <36ABB6B4.C8273D0E@yahoo.com>

I think you need to do this:
unlink("../htdocs/project/$TestName/$TestName\.test");

Add a backslash before the period.


wabba@globalnet.co.uk wrote:

> Hello Everyone.  I am in desperate need of help with regards to PERL
> programming. I am currently using Perl Scripting (with CGI), to increase the
> portability of a test program running withing my school. This is my 6th Year
> Project.  I thought everything was going well, until I ran into the problem
> of not being able to delete (unlink) files from within my PERL scripts. I am
> using SuSE Linux. I have read all of the PERL man pages in Linux and I have
> tried the following pieces of code to unlink files:
>
> 1)    @Args=('rm','../htdocs/project/$TestName/$TestName.test');
>       system(@Args);
>
> and
> 2)    unlink("../htdocs/project/$TestName/$TestName.test");
>
> I am aware that the unlink command is meant to be used with a List Parameter,
> but I would expect it to work with a single parameter as well. Also, I have
> tried putting in the full path-name instead of the shortened name with ".."
> but this does not help either.  I have also checked that the permissions are
> okay by looking at both the HTTPD  effective ID and the file ID, and these
> are okay, and the operation is therefore permittable.
>
> PLEASE HELP! I would be grateful for any suggestions you have, and don't
> hesitate to contact me if you have any ideas on how to solve this problem,
> thanx.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own





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

Date: Mon, 25 Jan 1999 00:40:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Need Help Removing (Unlinking) Files in PERL Script
Message-Id: <64Pq2.135$b32.5886@nsw.nnrp.telstra.net>

In article <36ABB6B4.C8273D0E@yahoo.com>,
	Donny Widjaja <donnywi@yahoo.com> writes:
> I think you need to do this:
> unlink("../htdocs/project/$TestName/$TestName\.test");
> 
> Add a backslash before the period.

Not necessary. A . is just a . in a quoted string. It's not a regexp.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.       | password?
NSW, Australia                      | 


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

Date: Mon, 25 Jan 1999 00:44:49 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Need Help Removing (Unlinking) Files in PERL Script
Message-Id: <58Pq2.137$b32.5886@nsw.nnrp.telstra.net>

In article <78g355$aj4$1@nnrp1.dejanews.com>,
	wabba@globalnet.co.uk writes:

> 1)    @Args=('rm','../htdocs/project/$TestName/$TestName.test');
>       system(@Args);
> 
> and
> 2)    unlink("../htdocs/project/$TestName/$TestName.test");

This post is almost, but not entirely, the same as your other one. In
this one you actually have point 1) and 2), instead of just 2).

This post, however, really shows me that you don't seem to realise
that double and single quotes are totally different things. You use
single quotes in your call to rm, but you use double quotes in the
call to unlink. In your other post, you were using single quotes for
that.

When you post code here, please always make sure that it is _exactly_
(REPEAT: EXACTLY) the same as the code you are actually using. A
difference that you see as minor, like single instead of double
quotes, may actually be the whole problem.

Now. If none of the posts in these two threads you started have
pointed you at the problem, post again, this time showing us the exact
code you use. Cut and paste. Photocopy. Fax. But do not type it.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.       | reflects this.
NSW, Australia                      | 


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

Date: Sun, 24 Jan 1999 23:43:30 GMT
From: scott.craig@moh.hnet.bc.ca
Subject: Re: Newbie question: writing file
Message-Id: <78gb71$gd1$1@nnrp1.dejanews.com>

In article <36A987A3.E0A39ED5@ma.ultranet.com>,
  chester@ma.ultranet.com wrote:

> What am I doing wrong here?
>
> #! /usr/local/bin/perl5.003
> ...
> open(token_file, ">$token_file_name") || &err_trap("Cannot open
> $token_file_name for writing\n");
> print(token_file "$token\n");
> close token_file;
> ...
>
> All I get is "Cannot open tokens/262805729 for writing ".

Are you sure tokens is an existing directory under the current working
directory? Do you have permission to write to it? If file 262805729 already
exists there, do you have permission to overwrite?

You may have to create the tokens directory with mkdir, or change permissions
with chmod.

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


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

Date: Sun, 24 Jan 1999 23:18:53 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl Criticism
Message-Id: <36aba8a7.291102@news.skynet.be>

Gregory Snow wrote:

>Here is my answer to your challange:

>  open(IN, "myfile.dat") || die "unable to open myfile.dat: $!\n";

>Your alternative would be something like:

>  if( !open(IN, "myfile.dat") ){
>    die "unable to open myfile.dat: $!\n";
>  }

>Correct?  (ignoring how you might phrase the error differently).

This is one of my favorite examples too. The second solution (let's call
it "the C-like version") feels patricularily awkward, because it puts
the stress on the "if". The fact that it opens a file, is a mere side
effect which could just a well be ignored. Well, that what it looks
like.

The short-circuit version says to me: "Let's open a file, and if that
fails, die." The code agrees with this thought sequence. In contrast,
the C-like version looks turned inside-out.

	Bart.


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

Date: Mon, 25 Jan 1999 02:33:40 GMT
From: zinger_0@my-dejanews.com
Subject: perl header
Message-Id: <78gl64$n9n$1@nnrp1.dejanews.com>

Is there a way to run a perl program (anyfile.pl) and leave the default header
option on and turn it off on other file such as a *.nph file?

Thanks

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


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

Date: Sun, 24 Jan 1999 23:28:23 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <fsw4uAAXy6q2EwQ2@beausys.demon.co.uk>

In article <comdog-ya02408000R2301991858230001@news.panix.com>, brian d
foy <comdog@computerdog.com> writes
>In article <ySpTxGAxekq2Ew2x@beausys.demon.co.uk>, Andrew Fry 
><andrewf@beausys.demon.co.uk> posted:
>
>> In article <1dm0coc.rvp0jx189rs0vN@bay3-116.quincy.ziplink.net>, Ronald
>> J Kimball <rjk@linguist.dartmouth.edu> writes
>> >Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
>> >
>> >> I was talking about how it is important for me, as company director,
>> >> to use my time wisely ... and how I have only a limited amount of
>> >> time to plough through Perl on-line docs.
>
>give me a break.  using time wisely in not a function of position.  
>do you let your entry level employees use their time less
>efficiently?

Why yet another misinterpretation/misrepresentation of what I was
trying to say ???
I did *NOT* say that using time wisely is a function of position. But
it is still, nonetheless, important for me to use my time wisely, ...
and, to be frank, I do not wholly agree with your statement.
The consequences of a company director and an entry-level employee
wasting their time are quite different. In fact, I think that many
entry-level employees havent yet learned how to make best use of their
time, and they learn this with experience.

---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).


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

Date: Sun, 24 Jan 1999 23:36:19 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <VsZ6+GAz56q2EwwP@beausys.demon.co.uk>

I have to say, to be frank, that, in view of the hassle
(unhelpful, arrogant, patronising, condescending and
positively offensive remarks) that has arisen as a result of
my daring to ask a question that may be answered in the
documentation, I have given some serious thought about not
using this newsgroup again.

However, it would seem that I am not alone in this view,
for I have had a number of e-mails from others who
themselves have encountered such remarks and unhelpfulness on
previous occasions. Some say that they have largely given
up using the newsgroup.

I cant say that I am surprised.

---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).


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

Date: Sun, 24 Jan 1999 13:58:59 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem with dbm hash
Message-Id: <1dm50gq.178mb8atlpf28N@bay2-63.quincy.ziplink.net>

Steve <root@coredcs.com> wrote:

> I'm having a problem with a hash database file.  I need to store
> multiple values in one key and thus I'm using an array(per the Perl
> Cookbook).  My problem is in syntax for viewing the data once entered.

In general, multilevel hashes and dbm files don't mix.  Fortunately, the
module MLDBM was created to fill this gap.  There are three versions
available right now:

<http://www.perl.com/CPAN-local//authors/id/GSAR/>

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 25 Jan 1999 02:40:03 GMT
From: root@coredcs.com (Steve)
Subject: Re: Problem with dbm hash
Message-Id: <36abd950.1027010068@news.coredcs.com>

On a related note to MLDBM - maybe I'm just not grasping the concept
of how to optimize it.  Are there any other docs or examples working
with it other than the docs and man page for it?

Steve


On Sun, 24 Jan 1999 17:57:57 GMT, Eric Bohlman <ebohlman@netcom.com>
wrote:

>Steve <root@coredcs.com> wrote:
>
>: I'm having a problem with a hash database file.  I need to store
>: multiple values in one key and thus I'm using an array(per the Perl
>: Cookbook).  My problem is in syntax for viewing the data once
entered.
>
>: I can input the values into the hash and they seem to be correct
and
>: getting into the hash array variable.  However when, on the next
run,
>: I try to view any of the previously entered data, nothing comes up.
I
>: _know_ I am doing something syntactically and simply wrong.
>
>Nope, your problem is that tied-hash database files can only store 
>strings as values, but you need to store complex data structures.
The 
>solution is to use something like MLDBM, which will "serialize" your
data 
>structures when they're stored and "unserialize" them when they're 
>retrieved.  You might want to read the chapter on persistence in 
>_Advanced Perl Programming_ for other ideas.
>



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

Date: Mon, 25 Jan 1999 02:38:40 GMT
From: root@coredcs.com (Steve)
Subject: Re: Problem with dbm hash
Message-Id: <36abd8ac.1026846043@news.coredcs.com>

Hello,

I d/l'ed MLDBM and installed it.  Seems that it won't do it.  What I
mean by that is that it's too slow.  Also creates a waste of time and
code.  Yuck.

There should be a way to do this in Perl without adding on slow
packages.

Steve


On Sun, 24 Jan 1999 17:57:57 GMT, Eric Bohlman <ebohlman@netcom.com>
wrote:

>Steve <root@coredcs.com> wrote:
>
>: I'm having a problem with a hash database file.  I need to store
>: multiple values in one key and thus I'm using an array(per the Perl
>: Cookbook).  My problem is in syntax for viewing the data once
entered.
>
>: I can input the values into the hash and they seem to be correct
and
>: getting into the hash array variable.  However when, on the next
run,
>: I try to view any of the previously entered data, nothing comes up.
I
>: _know_ I am doing something syntactically and simply wrong.
>
>Nope, your problem is that tied-hash database files can only store 
>strings as values, but you need to store complex data structures.
The 
>solution is to use something like MLDBM, which will "serialize" your
data 
>structures when they're stored and "unserialize" them when they're 
>retrieved.  You might want to read the chapter on persistence in 
>_Advanced Perl Programming_ for other ideas.
>



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

Date: Sun, 24 Jan 1999 13:59:00 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Regular expression to parse RealAudio logs?
Message-Id: <1dm50xg.1ay4eng57483gN@bay2-63.quincy.ziplink.net>

<mrgigabyte@hotmail.com> wrote:

> 210.201.65.104 - - [22/Jan/1999:18:19:06 -0800] "GET live/radio.ra
> PNA/10" 200 6243360 [Win95_4.0_6.0.3.128_play32_PN01_en-US_486] [Stat1:
> 12910         44          0          0          1
> 20_Kbps_Stereo_Music][Stat2:     20000      19996       1496          1
> 546         44         44          1          0          0       4293
> 20_Kbps_Stereo_Music] 0 0 2497 44 0
> 
> 
> The data I must extract is: 
> 
> * The timestamp info between the first set of brackets
> * Filename between the spaces and after the GET
> * The bytes_sent which is between the space after return_code and the
> space before the next left bracket
> * The sent_time which is 3rd piece of data from the end.

Here is an effective but not particularly elegant regular expression:

(
 $ip, $timestamp, $file_name, $proto, $return_code, $bytes_sent,
 $client, $stat1, $stat2, $file_size, $file_time, $sent_time,
 $resends, $failed_resends
) = m/^
      (\S+)\s-\s-\s              # <IP address> - - 
      \[([^\]]+)\]\s             # [<timestamp>] 
      "GET\s(\S+)\s([^\s"]+)"\s  # "GET <filename> <protocol>" 
      (\S+)\s(\S+)\s             # <return code> <bytes sent> 
      \[([^\]]+)\]\s             # [<client id>] 
      \[([^\]]+)\]               # [<stat1>]
      \[([^\]]+)\]\s             # [<stat2>]
      (\S+)\s(\S+)\s(\S+)\s      # <file size> <file time> <sent time>
      (\S+)\s(\S+)               # <resends> <failed resends>
      $
     /x;


You could also capture to an array and slice out the elements you
needed, if you didn't want all those extra scalar variables.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 24 Jan 99 18:02:13 GMT
From: dombach@ryder.network-consult.de (Thorsten Dombach)
Subject: S: RSH/RCP module
Message-Id: <36ab6025.0@ryder.network-consult.de>

Hi all!

I search a module for rsh and rcp commands.
So then I didn4t had to use the unix commands.

ciao
Thorsten
-- 
-------------------------------------------------
dombach@informatik.uni-muenchen.de
-------------------------------------------------


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

Date: Sun, 24 Jan 1999 13:59:01 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: searching a binary file
Message-Id: <1dm51rs.11dsndx1mbhylnN@bay2-63.quincy.ziplink.net>

<ps258@hotmail.com> wrote:

> I suspect that it's reaching a ^D or ^Z in the
> binary file and just taking it as the eof.

In that case, you want to call binmode() on the filehandle just after
you open.  Read about binmode() in the perlfunc documentation.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 24 Jan 1999 13:59:03 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Trying to change a line in a file
Message-Id: <1dm51wm.w3kw03exinxgN@bay2-63.quincy.ziplink.net>

THE Groovy <thegroovy@aol.comNOSPAM> wrote:

> I am making a script that has several users, all with ID's (starting with
> 1 and going up) and each ID has a line in a file that logs hits to an area
> with their ID. The hit file is in the format ID|TotalHits\n. When there is
> another hit for someone with an ID, I want it to add 1 to the Total Hits
> for that user. I was trying to do it with the splice function, but
> couldn't find enought information on it. Here is the code I have, which
> doesn't work :-).
> 
> open (HITS,"hits.log");
> @hits=<HITS>;
> close(HITS);

If you add

chomp(@hits);

here, then...

> foreach $reseller (@hits) {

 ...you no longer need this line:

>   $reseller =~ s/\n//g;

>   @reseller_info = split(/\|/, $reseller);
> 
>   if ($reseller_info[0] == "$idnumber") {

It's kinda silly to convert a number to a string for a numeric
comparison, wouldn't you say?


>     $hits = $reseller_info[1];
>     $new_hits = $hits++;
>     $new_info =~ s/$idnumber|$hits/$idnumber|$new_hits\n/;

'|' is a regex metacharacter.  It means 'match this or match that'.  You
don't really want a regex substitution here anyway.

$new_info = "$idnumber|$new_hits";


>     open (HITS,"hits.log");

You're opening for reading a file that you need to write to.


>     s/$reseller/$new_info/g;

This line operates on the variable $_.  You're expecting it to effect
the file you just opened.  Sadly, you can't change the contents of a
file without reading it in and writing it back out.  (Or at least part
of it.)

Also keep in mind that $reseller contains the character '|', which is a
regex metacharacter.  See above.   


>     close(HITS);
>   }
> }
> 
> 
> Any ideas on why it won't add 1 to the total hit count?

You forgot to output anything!


You might be interested in the FAQ 

<http://language.perl.com/newdocs/pod/perlfaq5.html#How_do_I_change_one_
line_in_a_fi>

You can also find this question answered in perlfaq5, on your local
system.


So, fix the unwanted usage of regexes, check out the FAQ, see how far
you can get with that, and if you're still stuck come back and show us
where you've gotten to.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 24 Jan 1999 19:48:44 -0500
From: Bill Reid <wer@cstone.net>
Subject: Want to output $29.85 not $29.8585 ya know?
Message-Id: <36ABBF6C.21F3EEAA@cstone.net>

Hey.

I have a simple script that takes some things from a form and then
computes the cost.... When I applay a tax (like 0.065) it displays four
digits behind the decimal.  I just want to truncate the last two
digits.... or force two digits past the decimal point.  Any suggestions?

Start sub:

sub tax {
if ($tate eq "pa"||$tate eq "PA") {          #This determines if tax
applied
$tax =(($vidtotal + $booktotal)* 0.065);     #This figures tax for
items.
print "<td align=right>tax:</td><td><b>&#36</b>$tax</td>";
print "</tr><tr>";
}
else{
$tax = 0;
}
}

 ...Now I know it's messy.  But it is my first time using Perl.

so basically my end total is often 1 or 4 digits.  I want it to be 2.

(and if you really feel like being helpful :)  I would also love to know
how to not care about "case" sensativity for "PA" above.

I figure I will get it... But I would love to make some buddies.


-=Bill



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

Date: Mon, 25 Jan 1999 00:49:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Want to output $29.85 not $29.8585 ya know?
Message-Id: <fcPq2.140$b32.5886@nsw.nnrp.telstra.net>

In article <36ABBF6C.21F3EEAA@cstone.net>,
	Bill Reid <wer@cstone.net> writes:
> Hey.
> 
> I have a simple script that takes some things from a form and then
> computes the cost.... When I applay a tax (like 0.065) it displays four
> digits behind the decimal.  I just want to truncate the last two
> digits.... or force two digits past the decimal point.  Any suggestions?

truncate? That's a bit nasty, isn't it? Do you mean round? Unless you
don't cre about all those cents getting lost, you probably do.

# perldoc -q round
=head1 Found in /usr/local/lib/perl5/5.00502/pod/perlfaq4.pod

=head2 Does perl have a round function?  What about ceil() and
floor()?  Trig functions?

For those of you with an older perldoc:

# perldoc perlfaq4
/round

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd.       | population.
NSW, Australia                      | 


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

Date: Mon, 25 Jan 1999 01:00:17 GMT
From: spam@netcetera.org (Simon Whitaker)
Subject: What's a script worth?
Message-Id: <36abc052.20605062@news.u-net.com>

I've been learning Perl for a while and have put it to use for various tasks
on my website. Recently a commercial body has shown interest in a set of
pages and scripts I have written, and is asking about buying them from me.
Whilst the scripts themselves are fairly basic and don't do much more than
some simple maths and presentation, it's clear that the commercial body
involved want them and don't know how to create something similar
themselves.

Problem is, I have no idea how to cost the scripts. I've never sold my
services as a programmer before, and so was hoping that some kind soul here
could give me a rough idea as to how much I should be asking for. (I'm in
the UK if that makes a difference.)

You can view the pages concerned at http://netcetera.org/clawback/

(If you want to work your way through, click on "I am a contractor" then
enter the figures 120000, 12, 1200 in that order on the next page, then
follow your nose after that. Don't expect it to make much sense though!)

TIA,

Simon

-- 
Take a STAND against ill-considered UK anti-crypto legislation
currently under proposal -- http://www.stand.org.uk/step1.php3

[Please alter spam to simon if replying to me by mail. Thanks]


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

Date: Sun, 24 Jan 1999 20:33:57 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: What's a script worth?
Message-Id: <comdog-ya02408000R2401992033570001@news.panix.com>

In article <36abc052.20605062@news.u-net.com>, spam@netcetera.org (Simon Whitaker) posted:

> I've been learning Perl for a while and have put it to use for various tasks
> on my website. Recently a commercial body has shown interest in a set of
> pages and scripts I have written, and is asking about buying them from me.
> Whilst the scripts themselves are fairly basic and don't do much more than
> some simple maths and presentation, it's clear that the commercial body
> involved want them and don't know how to create something similar
> themselves.
> 
> Problem is, I have no idea how to cost the scripts. I've never sold my
> services as a programmer before, and so was hoping that some kind soul here
> could give me a rough idea as to how much I should be asking for. (I'm in
> the UK if that makes a difference.)

it's not about what the scripts are worth,  it's about how much they'll
pay for them.  charge as much as you think you can get.  charge more if
you lose the rights to them.  charge even more if they will want technical
support.

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


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

Date: Sun, 24 Jan 1999 13:59:04 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Where can I find text parsing samples
Message-Id: <1dm52jx.1j9xwjl1hh33vfN@bay2-63.quincy.ziplink.net>

Ron <e_ron.no.spam@netvision.net.il> wrote:

> Any other built in function which can help in parsing text? And can I
> detect special characters while splitting such as \t tab?

perlfunc starts with the list of functions organized by use.  For
example:

  Functions for SCALARs or strings

    chomp, chop, chr, crypt, hex, index, lc, lcfirst, length,
    oct, ord, pack, q/STRING/, qq/STRING/, reverse, rindex,
    sprintf, substr, tr///, uc, ucfirst, y///

  Regular expressions and pattern matching

    m//, pos, quotemeta, s///, split, study


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 24 Jan 1999 13:59:05 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Writing files
Message-Id: <1dm52n5.1dgzso81bk4a5hN@bay2-63.quincy.ziplink.net>

Rick Delaney <rick.delaney@home.com> wrote:

> Ronald J Kimball wrote:
> > 
> > I don't believe you can create a file by opening it for reading.
>  
> use Fcntl;
> sysopen(FH, $file, O_RDONLY | O_CREAT) or die "Can't open:  $!\n";

I knew I should have clarified...

You cannot create a file by opening it for reading, _using the open()
function_.

> Why one would do this, I don't know, but it can be done.

:-P

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

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


Administrivia:

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

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

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 4738
**************************************

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