[13644] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1054 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 13:56:22 1999

Date: Fri, 15 Oct 1999 10:56:11 -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: <940010171-v9-i1054@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Oct 1999     Volume: 9 Number: 1054

Today's topics:
        add to a file. <christian@wix.dk>
    Re: add to a file. <jeffp@crusoe.net>
    Re: add to a file. <sariq@texas.net>
    Re: Advanced text substitution in FILEHANDLES <admin@gatewaysolutions.net>
        ANNOUNCEMENT: NEW VERSION: HTML::Template 0.96 <sam@tregar.com>
    Re: Anyone know Everysoft Everyauction cgi script and i <aqumsieh@matrox.com>
        ARGV use in Win32 PERL <stephen.No.SpAm@cubitts.freeserve.co.uk>
    Re: ARGV use in Win32 PERL <cassell@mail.cor.epa.gov>
        backup to change (Jimtaylor5)
    Re: backup to change <pdobbs@home.com>
    Re: backup to change (Malcolm Ray)
        Basic Domain name lookup <sbohler@hideaways.com>
    Re: Basic Domain name lookup (Peter Galbavy)
        binmode on backticks? zeushao@my-deja.com
    Re: binmode on backticks? <uri@sysarch.com>
    Re: binmode on backticks? <rootbeer@redcat.com>
    Re: binmode on backticks? (Ilya Zakharevich)
    Re: binmode on backticks? shapirojNOSPAM@logica.com
    Re: binmode on backticks? <dan@tuatha.sidhe.org>
    Re: binmode on backticks? (Ilya Zakharevich)
    Re: binmode on backticks? <dan@tuatha.sidhe.org>
    Re: binmode on backticks? zeushao@my-deja.com
    Re: binmode on backticks? (Larry Rosler)
    Re: binmode on backticks? <uri@sysarch.com>
        business day logic <inna@raykhman.com>
    Re: business day logic (Bill Moseley)
    Re: business day logic (Andrew Johnson)
        Can a perl script output image? <stacey_hill50@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Oct 1999 16:49:04 +0200
From: Christian Wix <christian@wix.dk>
Subject: add to a file.
Message-Id: <38049BDF.3CE02F68@wix.dk>

Hi
I need help to create a function that add's a string to a file every
time the function is called. ( So the file will be bigger and bigger )
Please help me,

--
Christian Wix
Bergsøekollegiet 23,st - 2309
Søllerød
2850 Nærum
Denmark
Phone: +45 45505171-(tone)-2309 / +45 26258162
Email & www: mailto:christian@wix.dk - http://www.wix.dk
ICQ #21322285




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

Date: Wed, 13 Oct 1999 13:14:45 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: add to a file.
Message-Id: <Pine.GSO.4.10.9910131313500.14462-100000@crusoe.crusoe.net>

[posted & mailed]

On Oct 13, Christian Wix blah blah blah:

> I need help to create a function that add's a string to a file every
> time the function is called. ( So the file will be bigger and bigger )

You want to append to a file:

  open FILE, ">> filename" or die "can't append to filename: $!";
  print FILE "newcontent\n";
  print FILE "more content\n";
  close FILE;

Read perlfaq5.

-- 
jeff pinyan    japhy@pobox.com
perl stuff     japhy+perl@pobox.com
CPAN ID: PINYAN            http://www.perl.com/CPAN/authors/id/P/PI/PINYAN



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

Date: Wed, 13 Oct 1999 12:49:56 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: add to a file.
Message-Id: <3804C644.C89B17E5@texas.net>

Christian Wix wrote:
> 
> Hi
> I need help to create a function that add's a string to a file every
> time the function is called. ( So the file will be bigger and bigger )

perldoc -f open
perldoc -f print
perldoc -f close

- Tom


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

Date: Wed, 13 Oct 1999 20:43:36 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Re: Advanced text substitution in FILEHANDLES
Message-Id: <s0ad4i80hu293@corp.supernews.com>

Hello PD

PB <pb@decoteka.com> wrote in message
news:7ttcb1$8t4$1@birch.prod.itd.earthlink.net...
> I'm new to Perl and have read "Learning Perl" and am half way through
> "Programming Perl".  However, I have not found a way to do the following:
>
> Taking the following txt file as input to a FILEHANDLE (in this case
> sample.txt) and print output (after cleaning with s///) to FILEHANDLE2
>
> --------- start sample.txt ----------------
> john
> doe
> blow
> mike
> Above name is not in group
> susan
> peter
> gerry
> Above name is not in group
> james
> ----------- end sample.txt -------------
>
> I'm trying to get rid of lines that read:
> "Above name is not in group"
> and the name on the line just above that.
>
> In this case, I would like to get rid of:
>     mike
>     Above name is not in group
>     gerry
>     Above name is not in group
>
> and print the remaining of the file to FILEHANDLE2.
>
> Does anyone know how to do this?
>
> Cheers,
> pb
>
>
This should do it.

#!/usr/bin/perl -w

use strict;

my $replace = 'Above name is not in group';
my $file1 = 'test1.txt';
my $file2 = 'test2.txt';
if (&process_file($file1, $file2, $replace,1)){
 print "Replacement made\n";
} else {
 print "Could not find '$replace'\n";
}

sub process_file {

 # Set $int to the number of lines before $replace
 # to take with it.
 my ($file1, $file2, $replace, $int) = @_;
 my ($now,$return,@cache);

 # Don't want to change $. outside this routine
 local $.;
 open FILE,"$file1" or die "Can not open $file1: $!";
 OUTER: while (<FILE>){
  chomp;
  if (/^\Q$replace\E$/){
   $return = 1;
   $now = $.;
   $. -= $int;
   INNER: while (<FILE>){
    pop @cache;
    if ($. eq $now){
     $.++;
     redo OUTER;
    }
   }
  } else {
   push @cache,$_;
  }
 }
 close FILE or die "Can not close $file1: $!";

    if ($return) {
        open FILE, ">$file2" or die "Can not open $file2: $!";
        #flock(FILE,2); seek(FILE, 0, 2);
        while (@cache) {
            print FILE shift (@cache),"\n";
        }
        #flock(FILE,8);
        close FILE or die "Can not close $file2: $!";
    }
    return $return;

}
__END__

HTH

Scott Beck







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

Date: 15 Oct 1999 14:36:56 GMT
From: Sam Tregar <sam@tregar.com>
Subject: ANNOUNCEMENT: NEW VERSION: HTML::Template 0.96
Message-Id: <7u7e68$12g$1@play.inetarena.com>

ANNOUNCEMENT: NEW VERSION: HTML::Template 0.96

NAME

HTML::Template - a Perl module to use HTML Templates

CHANGES

0.96
        - Added "ESCAPE=1" option to <TMPL_VAR> to HTML-escape
          variable values.  (Peter Marelas, thanks!)
        - more bug fixes (David Glasser, James William Carlson -
          thanks)
        - even *more* code cleanup!
        - new FAQ concerning pre-loading templates and mod_perl.

DESCRIPTION

This module attempts make using HTML templates simple and natural.  It
extends standard HTML with a few new HTML-esque tags - <TMPL_VAR>,
<TMPL_LOOP>, <TMPL_INCLUDE>, <TMPL_IF> and <TMPL_ELSE>.  The file
written with HTML and these new tags is called a template.  It is
usually saved separate from your script - possibly even created by
someone else!  Using this module you fill in the values for the
variables, loops and branches declared in the template.  This allows
you to seperate design - the HTML - from the data, which you generate
in the Perl script.

This module is licenced under the GPL.  See the LICENCE section of the
README.


AVAILABILITY

The module is available on CPAN.  You can get it using CPAN.pm or go
to:

http://www.cpan.org/authors/id/S/SA/SAMTREGAR/


MOTIVATION

It is true that there are a number of packages out there to do HTML
templates.  On the one hand you have things like HTML::Embperl which
allows you to freely mix Perl with HTML.  On the other hand lie
home-grown variable substitution solutions.  Hopefully the module can
find a place between the two.

One advantage of this module over a full HTML::Embperl-esque solution
is that it enforces an important divide - design and programming.  By
limiting the programmer to just using simple variables and loops in
the HTML, the template remains accessible to designers and other
non-perl people.  The use of HTML-esque syntax goes further to make
the format understandable to others.  In the future this similarity
could be used to extend existing HTML editors/analyzers to support
this syntax.

An advantage of this module over home-grown tag-replacement schemes is
the support for loops.  In my work I am often called on to produce
tables of data in html.  Producing them using simplistic HTML
templates results in CGIs containing lots of HTML since the HTML
itself could not represent loops.  The introduction of loop statements
in the HTML simplifies this situation considerably.  The designer can
layout a single row and the programmer can fill it in as many times as
necessary - all they must agree on is the parameter names.

For all that, I think the best thing about this module is that it does
just one thing and it does it quickly and carefully.  It doesn't try
to replace Perl and HTML, it just augments them to interact a little
better.  And it's pretty fast.


DOCUMENTATION

The documentation is in Template.pm in the form of POD format
perldocs.  Even the above text might be out of date, so be sure to
check the perldocs for the straight truth.


CONTACT INFO

This module was written by Sam Tregar (sam@tregar.com) for Vanguard
Media (http://www.vm.com).


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




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

Date: Tue, 12 Oct 1999 16:50:30 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Anyone know Everysoft Everyauction cgi script and its addons?
Message-Id: <x3yemf0717u.fsf@tigre.matrox.com>


"Jason Latek" <jlatek@interTeccorp.com> writes:

> I am building a site and am trying to use everysoft's everyauction. I can
> get the basic script to work, but I want to use the addons. I am having
> trouble with most of them. Please let me know if you know how to configure
> them and how much you charge to do it.

How would posting to a Perl newsgroup help you with your quest?
I see no reason why anybody lurking around this newsgroup should know
the answer to your question. Please ask elsewhere in a more
appropriate forum.

--Ala



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

Date: Wed, 13 Oct 1999 22:03:36 +0100
From: "CUBE" <stephen.No.SpAm@cubitts.freeserve.co.uk>
Subject: ARGV use in Win32 PERL
Message-Id: <7u2s4c$jri$1@news5.svr.pol.co.uk>

I use PERL on a UNIX machine at work to do text processing, the scripts take
file names from the command line using ARGV etc. It is useful to be able to
develop these at home as well so I also had a Win32 version of PERL at home
(build 315) on which I can run the UNIX scripts with no problems. PERL
always returned the appropriate filenames when I included something like
"*.txt" in the command line.

I have now upgraded Perl on my PC to build 520. However while it still
accepts explicit filenames from the comand line, it no longer interprets
wild cards, so instead of receiving a list of name I simply get "*.txt".

I can not find any reference in the documentation or FAQs, any idea if this
build of PERL can automaticallly deal with comand line wild cards.

Stephen Cubitt





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

Date: Wed, 13 Oct 1999 15:27:26 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: ARGV use in Win32 PERL
Message-Id: <3805074E.FDE9B69B@mail.cor.epa.gov>

CUBE wrote:
> 
> I use PERL on a UNIX machine at work to do text processing, the scripts take
> file names from the command line using ARGV etc. It is useful to be able to
> develop these at home as well so I also had a Win32 version of PERL at home
> (build 315) on which I can run the UNIX scripts with no problems. PERL
> always returned the appropriate filenames when I included something like
> "*.txt" in the command line.
>
> I have now upgraded Perl on my PC to build 520. However while it still
> accepts explicit filenames from the comand line, it no longer interprets
> wild cards, so instead of receiving a list of name I simply get "*.txt".

It was decided that win32 Perl should do like the other versions
of Perl do, and let the shell do the globbing, such as it is.
So, since COMMAND.COM is useless on this, you get the observed
results.

> I can not find any reference in the documentation or FAQs, any idea if this
> build of PERL can automaticallly deal with comand line wild cards.

Look at the docs for File::DosGlob, and you'll see how to
get a glob() that works.

perldoc File::DosGlob

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 15 Oct 1999 12:01:03 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: backup to change
Message-Id: <19991015080103.10734.00000206@ng-cd1.aol.com>

can anyone demonstrate some code that would back up a file temporarily while my
program makes  changes to the file? And if possible to do it so the backup
itself is not over written by the corrupt file if the program was run a second
time?  Thanks in Advance for any help.


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

Date: Fri, 15 Oct 1999 15:08:21 GMT
From: Paul D <pdobbs@home.com>
Subject: Re: backup to change
Message-Id: <3807448B.ECC4049A@home.com>

I'll take a stab at this.. I'm doing it with something I'm making now
actually for the purposes of dealing with possible multiple accesses to
text files. Here's an idea for you..HEAVILY commented for your pleasure
:-)

$File variable holds your original file's filename 

# First we'll make a filename from your file but replace
# those last 3 characters from its .ext with .lok
$FileLock = $File; $FileLock =~ s/(.{3})$/lok!i;

# Now we use a simple loop to see if that file.lok exists
# and if it does, we wait 1 second. We run the loop a max
# 10 times, so thus we give the program 10 seconds to
# see the file.lok was removed, checking after each 1 second
# If we waited 10 seconds and it didn't go, we note that
# by using a flag - the $Locked variable being set to 1
# If it does clear, or didn't exist yet even, we then make it
# for THIS run of the program so other runs of the program will
# have to wait for THIS one to finish (we put a 0 in the dummy
# file called file.lok so that its not a zero byte size file)
for ($counter = 1; $counter <= 10; $counter++)
{
 if (-e $FileLock)
  {sleep 1; $Locked = 1;}
 else
  {
   $Locked = 0; 
   open (HANDLE, ">$FileLock"); print HANDLE "0"; close (HANDLE);
   last;
  }
}

# Your loop is done so lets check the Lock status
# If its 1 we couldn't get into it after 10 seconds so
# we'll report an error
# If its 0 the file isn't locked and we can work on it
# and when done that work, we'll delete the file.lok
if ($Locked == 1)
 {print "Dammit, the file was still locked after 10 seconds! No work
done on it";}
if ($Locked == 0)
 {
  open (HANDLE, "$File");
  # do whatever processing you want to do to this file
  unlink ("$FileLock");
 }
 


Ok? So thats the jist of it. You're just making an "empty" file to use
as a marker to tell the program to wait for another running
instance of the program to finish first in such a case where you might
have 2, 3 or 300 executions of this program to do some work on a file.
Hope this wasn't too much blabber for you! Just wanted to help. :-)

Paul


Jimtaylor5 wrote:
> 
> can anyone demonstrate some code that would back up a file temporarily while my
> program makes  changes to the file? And if possible to do it so the backup
> itself is not over written by the corrupt file if the program was run a second
> time?  Thanks in Advance for any help.


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

Date: 15 Oct 1999 15:38:56 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: backup to change
Message-Id: <slrn80eikg.jj5.M.Ray@carlova.ulcc.ac.uk>

On Fri, 15 Oct 1999 15:08:21 GMT, Paul D <pdobbs@home.com> wrote:
>I'll take a stab at this.. I'm doing it with something I'm making now
>actually for the purposes of dealing with possible multiple accesses to
>text files. Here's an idea for you..HEAVILY commented for your pleasure
>:-)

Your suggested code isn't safe for dealing with concurrent file access.

>for ($counter = 1; $counter <= 10; $counter++)
>{
> if (-e $FileLock)
>  {sleep 1; $Locked = 1;}
> else
>  {
>   $Locked = 0; 
>   open (HANDLE, ">$FileLock"); print HANDLE "0"; close (HANDLE);
>   last;
>  }
>}

Whoa!  You've got a classic race condition there.  Consider what happens
if there are two instances of this program running concurrently, and
both perform the file existence check almost simultaneously.  They will
both think they are free to create the file.  See the section on locking
in perlfaq5.

-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Fri, 15 Oct 1999 08:46:58 -0400
From: "Steve Bohler" <sbohler@hideaways.com>
Subject: Basic Domain name lookup
Message-Id: <38071fcd.0@newsfeed.vitts.com>

Is there an existing Perl 'packaged' program out there which, when given an
IP address, returns the domain name?

I'm sure it's out there on the 'Net somewhere, but I haven't been able to
find it.

Any pointers would be appreciated.

Steve




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

Date: 15 Oct 1999 13:34:04 GMT
From: peter@office.knowledge.com (Peter Galbavy)
Subject: Re: Basic Domain name lookup
Message-Id: <slrn80ebac.8qg.peter@office.knowledge.com>

In article <38071fcd.0@newsfeed.vitts.com>, Steve Bohler wrote:
>Is there an existing Perl 'packaged' program out there which, when given an
>IP address, returns the domain name?
>
>I'm sure it's out there on the 'Net somewhere, but I haven't been able to
>find it.

perldoc -f gethostbyaddr

Regards,
-- 
Peter Galbavy
Knowledge Matters Ltd
http://www.knowledge.com/


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

Date: Tue, 12 Oct 1999 20:59:54 GMT
From: zeushao@my-deja.com
Subject: binmode on backticks?
Message-Id: <7u07g1$dai$1@nnrp1.deja.com>

Hello! I'm working with perl on NT. I have a program (a compiled
executable) which dumps raw JPEG data from a databae. So, I have the
following in my perl script:

@ImageFile = `imagedump -i 121`;

Where 121 is the number of the image in the database that imagedump is
looking up data in. When I do this from the command line, it dumps what
appears to be a jpeg file (a bunch of garbled text). When I do the same
from a perl script, I get only a portion of the data. I think this has
to do with a binmode/textmode problem. Basically, what I want to do is:

@ImageFile = binmode `imagedump -i 121`;

Excepting that this returns 0. How do I make a backtick read be binmode?

--Johnny Wales

Replies by email preferred: vegas@my.bomis.com


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


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

Date: 12 Oct 1999 17:24:48 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binmode on backticks?
Message-Id: <x7zoxojmqn.fsf@home.sysarch.com>

>>>>> "z" == zeushao  <zeushao@my-deja.com> writes:

  z> @ImageFile = binmode `imagedump -i 121`;

  z> Excepting that this returns 0. How do I make a backtick read be binmode?

i will hate myself in the morning for helping out a winblows problem. in
fact i hate myself for it right now. i will now sterilize my hands and
keyboard.

you can't get at the handle of `` to enable binmode. so use a regular
open call with a pipe and then binmode that handle.

extremely untested and likely to reformat your disk which will be good
for you. do not taunt this code. :-)

	open( CMD, 'imagedump -i 121 |' ) || die "bill gates must" ;
	binmode CMD ;
	{ local $/ ; $jpeg = <CMD> ; }

should this be an FAQ? i have seen it a few times here.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
www.sysarch.com  -----  Perl Books: http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 12 Oct 1999 14:44:36 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: binmode on backticks?
Message-Id: <Pine.GSO.4.10.9910121441200.19155-100000@user2.teleport.com>

On Tue, 12 Oct 1999 zeushao@my-deja.com wrote:

> Basically, what I want to do is:
> 
> @ImageFile = binmode `imagedump -i 121`;
> 
> Excepting that this returns 0. How do I make a backtick read be binmode?

I don't think it can be done currently. But it looks to be a useful
feature, perhaps with some better syntax than what you've suggested. I'd
consider using this:

    my $output = qx`command`b;

Be sure to let us know when the patch is ready. :-)

The workaround may be to use a piped open. See the entry on open in the
perlfunc manpage. Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 Oct 1999 23:29:45 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: binmode on backticks?
Message-Id: <7u0g99$qp8$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Phoenix 
<rootbeer@redcat.com>],
who wrote in article <Pine.GSO.4.10.9910121441200.19155-100000@user2.teleport.com>:
> > Excepting that this returns 0. How do I make a backtick read be binmode?
> 
> I don't think it can be done currently. But it looks to be a useful
> feature, perhaps with some better syntax than what you've suggested. I'd
> consider using this:
> 
>     my $output = qx`command`b;
> 
> Be sure to let us know when the patch is ready. :-)

Aha, this is the sixth case of opening.  So a sixth bit of ${^BINARY}
may be used:

  use binary 'qw';

in addition to explicit/explicit-read/write, and perl-scripts.

Ilya


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

Date: Wed, 13 Oct 1999 12:13:26 -0400
From: shapirojNOSPAM@logica.com
Subject: Re: binmode on backticks?
Message-Id: <MPG.126e79b3c55109b198968a@news.logica.co.uk>

In article <7u07g1$dai$1@nnrp1.deja.com>, zeushao@my-deja.com says...
> Hello! I'm working with perl on NT. I have a program (a compiled

> Excepting that this returns 0. How do I make a backtick read be binmode?
> 
> --Johnny Wales

<advocacy>

I posted something like this to c.l.p.moderated, but I don't think I know
how to use moderated newsgroups, so I'm posting it here.

WHY not have Perl default to binmode, and provide a 'textmode' (or should 
it be 'cpmmode'?) function, which only does something on WinXX? I don't 
know if we need to worry about breaking existing scripts, but I know I've 
wasted plenty of time tracking down missing 'binmode's. [Two hours, once, 
in LWP::Protocol::File. Sure, I understand LWP a whole lot better now, 
but should I have to?]

Remember, many of us NT-stranded folks can't compile our own Perl, and 
are dependant on the ActiveState configurations.


</advocacy>


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

Date: Wed, 13 Oct 1999 18:16:01 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: binmode on backticks?
Message-Id: <B%3N3.628$IZ5.15579@news.rdc1.ct.home.com>

shapirojNOSPAM@logica.com wrote:
> In article <7u07g1$dai$1@nnrp1.deja.com>, zeushao@my-deja.com says...
>> Hello! I'm working with perl on NT. I have a program (a compiled

>> Excepting that this returns 0. How do I make a backtick read be binmode?
>> 
>> --Johnny Wales

> <advocacy>

> I posted something like this to c.l.p.moderated, but I don't think I know
> how to use moderated newsgroups, so I'm posting it here.

> WHY not have Perl default to binmode, and provide a 'textmode' (or should 
> it be 'cpmmode'?) function, which only does something on WinXX? I don't 
> know if we need to worry about breaking existing scripts, but I know I've 
> wasted plenty of time tracking down missing 'binmode's. [Two hours, once, 
> in LWP::Protocol::File. Sure, I understand LWP a whole lot better now, 
> but should I have to?]

Because unconditional binmoding of files will break some platforms badly,
VMS amongst them. (binmoding on VMS does a lot more than it does on Win32.
It's the moral equvalent of using open() and <> on an xDBM file instead
of accessing it via the appropriate xDBM library) Also, text mode does
CRLF->LF translations for you on windows, which is usually a good thing
with text files.

Kind of a pity M$ didn't bring over VMS' filesystem w/metadata when they
ripped off the rest of the kernel. (But they got what they did steal
mostly wrong anyway, so I suppose it doesn't really matter...)

					Dan


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

Date: 13 Oct 1999 22:29:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: binmode on backticks?
Message-Id: <7u3156$fro$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Dan Sugalski 
<dan@tuatha.sidhe.org>],
who wrote in article <B%3N3.628$IZ5.15579@news.rdc1.ct.home.com>:
> Kind of a pity M$ didn't bring over VMS' filesystem w/metadata when they
> ripped off the rest of the kernel. (But they got what they did steal
> mostly wrong anyway, so I suppose it doesn't really matter...)

Apparently, they did.  See discussion of green bits on p5p.

Ilya



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

Date: Thu, 14 Oct 1999 14:23:11 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: binmode on backticks?
Message-Id: <jHlN3.800$IZ5.16902@news.rdc1.ct.home.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to Dan Sugalski 
> <dan@tuatha.sidhe.org>],
> who wrote in article <B%3N3.628$IZ5.15579@news.rdc1.ct.home.com>:
>> Kind of a pity M$ didn't bring over VMS' filesystem w/metadata when they
>> ripped off the rest of the kernel. (But they got what they did steal
>> mostly wrong anyway, so I suppose it doesn't really matter...)

> Apparently, they did.  See discussion of green bits on p5p.

Whatever they brought over bore no resemblance to VMS' filesystem.
I don't remember anything in that discussion coming anyhwere close.

Of course, it's possible that M$ messed things up so badly that it
was totally unrecognizable, but I doubt it. This is low-level stuff,
and Cutler & crew are pretty good at that.

					Dan


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

Date: Thu, 14 Oct 1999 16:08:55 GMT
From: zeushao@my-deja.com
Subject: Re: binmode on backticks?
Message-Id: <7u4v6a$qdq$1@nnrp1.deja.com>

In article <x7zoxojmqn.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:
>> @ImageFile = binmode `imagedump -i 121`;
>>Excepting that this returns 0. How do I make a backtick read be [...]
>i will hate myself in the morning for helping out a winblows problem.
in
> fact i hate myself for it right now. i will now sterilize my hands and
> keyboard.

I know exactly what you mean. My last job was on FreeBSD and Linux,
where things actually work in some logical fashion. For cryin out loud,
why would anyone differentiate between binary and text? It's 8 bits,
either way you slice it. It's not like you're saving 1/8 of the space
by ignoring the 8th bit. You're just messing things up. -sigh- NT with
IIS is a -horrendous- development platform. Give me ANSI/POSIX
compliance over MFC and all it's silly 'wizards' any day.

> you can't get at the handle of `` to enable binmode. so use a regular
> open call with a pipe and then binmode that handle.

Well, that's odd. The whole reason I tried binmode `imgdump` is that
perl always seems to be able to guess what I'm trying to tell it,
sytactically correct or not. This seems to violate that principle.
Mayhaps this should be changed in Perl 6?

> extremely untested and likely to reformat your disk which will be good
> for you. do not taunt this code. :-)

I chuckled at it a bit, does that count as taunting? :)

> 	open( CMD, 'imagedump -i 121 |' ) || die "bill gates must" ;
> 	binmode CMD ;
> 	{ local $/ ; $jpeg = <CMD> ; }

It works! Woo Hoo! Thank you Uri, you rock. And, one might say to keep
with the parlance of our times, Roll.

> should this be an FAQ? i have seen it a few times here.

It'd be handy if it were listed someplace. The camel book mentions
nothing about not being able to manipulate the `` filehandle. It does
say that binmode has to be done on an open filehandle, though.

--Johnny Wales


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


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

Date: Thu, 14 Oct 1999 10:43:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: binmode on backticks?
Message-Id: <MPG.126fb3f222e48b9c98a093@nntp.hpl.hp.com>

In article <7u4v6a$qdq$1@nnrp1.deja.com> on Thu, 14 Oct 1999 16:08:55 
GMT, zeushao@my-deja.com <zeushao@my-deja.com> says...

 ...

> ... For cryin out loud,
> why would anyone differentiate between binary and text? It's 8 bits,
> either way you slice it. It's not like you're saving 1/8 of the space
> by ignoring the 8th bit. You're just messing things up. -sigh-

The difference between binary files and text files in Windows/DOS 
systems has nothing to do with the high-order bit.

As far as I know, the only distinction of a text file from a binary file 
is that the conventional line terminator is the two-character sequence 
"\015\012", which the C library (and hence Perl) translates to "\n" 
("\012") on input, and back to "\015\012" on output.  Also, on input the 
character "\cZ" ("\032") is interpreted as end-of-file.

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


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

Date: 14 Oct 1999 15:06:01 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binmode on backticks?
Message-Id: <x7k8opkbja.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> As far as I know, the only distinction of a text file from a binary file 
  LR> is that the conventional line terminator is the two-character sequence 
  LR> "\015\012", which the C library (and hence Perl) translates to "\n" 
  LR> ("\012") on input, and back to "\015\012" on output.  Also, on input the 
  LR> character "\cZ" ("\032") is interpreted as end-of-file.

on a historical note, the ^Z EOF byte goes back to RT-11 in 1971 or
so. its file system only had 512 byte block resolution so it used that
to mark the eof for text files. binary files were supposed to know how
to be read correctly. also dec used crlf (as did others) to drive the
teletypes of the day which needed the cr to move the print head back to
the left margin and lf to scroll the paper up a line. they still are
used this way in all cursor addressable screens. fortunately unix
realized that storing that in a file was dumb and did the conversions in
the drivers. unfortunately for POB's they kept the file line ending from
rt-11 to cp/m to dos.

hurray for backwards compatibility!! anyone wanna read my old rt-11
files on 8 inch floppies? i think i actually still have them (from
1983).

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
www.sysarch.com  -----  Perl Books: http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 13 Oct 1999 10:18:56 -0700
From: inna raykhman <inna@raykhman.com>
Subject: business day logic
Message-Id: <3804BF00.27557335@raykhman.com>


Hi,

i have looked through the faq's and couldn't find anything :)
anyway, i'm looking for a perl for windows module that would allow be to
calculate the business days back and forth, i can do the workdays vs.
weekdays, but there are also holidays this year, next year and so on.

so, if someone could suggest something, that would be greatly
appreciated.

thanks,
inna



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

Date: Wed, 13 Oct 1999 08:04:29 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: business day logic
Message-Id: <MPG.126e3f59bdd82d769897fe@nntp1.ba.best.com>

inna raykhman (inna@raykhman.com) seems to say...
> i have looked through the faq's and couldn't find anything :)
> anyway, i'm looking for a perl for windows module that would allow be to
> calculate the business days back and forth, i can do the workdays vs.
> weekdays, but there are also holidays this year, next year and so on.

perldoc Date::Calc might offer some help

perldoc Date::Manip, too.

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Wed, 13 Oct 1999 15:10:38 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: business day logic
Message-Id: <Oh1N3.80$gm.2738@news1.rdc2.on.home.com>

In article <3804BF00.27557335@raykhman.com>,
 inna raykhman <inna@raykhman.com> wrote:
! 
! Hi,
! 
! i have looked through the faq's and couldn't find anything :)
! anyway, i'm looking for a perl for windows module that would allow be to
! calculate the business days back and forth, i can do the workdays vs.
! weekdays, but there are also holidays this year, next year and so on.

if you are looking for a module, then CPAN is a good place to start
your search

check out the Date::Manip module available on CPAN

andrew

-- 
Andrew L. Johnson   http://www.manning.com/Johnson/
      Some people, when confronted with a problem, think 'I know,
      I'll use regular expressions.'  Now they have two problems.
          -- Jamie Zawinski, on comp.lang.emacs
      


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

Date: Fri, 15 Oct 1999 12:42:59 -0400
From: "    Stacey" <stacey_hill50@hotmail.com>
Subject: Can a perl script output image?
Message-Id: <s0em94hhr0157@corp.supernews.com>

Can a perl script output an image? Some HTML files display images (eg hit
counters) as the output of a cgi file. How is this done?
I found the following code in a web page.

<p align="center"><img
src="http://www.myserver.com/cgi-bin/Count.cgi?id=abcdef"></p>


Thanks in advance,
Stacey Hill





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

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


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