[13735] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1145 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 21 19:05:34 1999

Date: Thu, 21 Oct 1999 16:05:12 -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: <940547112-v9-i1145@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 21 Oct 1999     Volume: 9 Number: 1145

Today's topics:
        [ANNOUNCE] Audio-DSP-0.01 <sjohns17@uic.edu>
        ANNOUNCE: CGI::EncryptForm Version 1.00 <maral@phase-one.com.au>
        ANNOUNCE: Net::xAP 0.02 (Kevin Johnson)
        Announce: Parse-Yapp-1.00 released <desar@club-internet.fr>
        ANNOUNCE: Text::Template::Ptml 1.5 (Malcolm Dew-Jones)
    Re: At the risk of making myself an idiot ...How to cre <genlabs@gmx.net>
    Re: At the risk of making myself an idiot ...How to cre <genlabs@gmx.net>
    Re: Can't FTP to unix after Stripping ^M's from files u <lr@hpl.hp.com>
    Re: exiting non-zero at end of perl -[np] (Andrew Johnson)
    Re: exiting non-zero at end of perl -[np] (Jack Applin)
    Re: Help substituting '/' ? <lr@hpl.hp.com>
    Re: Help substituting '/' ? <rick.delaney@home.com>
        HELP- WILL PAY!!! <gary@cowboyfurniture.com>
    Re: How can print a HTML file? <makkulka@cisco.com>
        How come no interface to mmap? (Keith Michaels)
        How do you split a string into fixed sized pieces? (Scott Frazer)
    Re: How do you split a string into fixed sized pieces? <marcel.grunauer@lovely.net>
    Re: How do you split a string into fixed sized pieces? <lr@hpl.hp.com>
    Re: How do you substitute '/' ? <lr@hpl.hp.com>
        HTTPi/1.0 released <ckaiser@stockholm.ptloma.edu>
        Problem with file upload and attachment princyraj@my-deja.com
        problem with substitute op (s) iami@my-deja.com
        Regexp global match mystery? <webmaster@webmagic.n.se>
    Re: subroutine <ltl@rgsun5.viasystems.com>
    Re: subroutine <ltl@rgsun5.viasystems.com>
    Re: subroutine (Craig Berry)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 21 Oct 1999 22:31:13 GMT
From: Seth David Johnson <sjohns17@uic.edu>
Subject: [ANNOUNCE] Audio-DSP-0.01
Message-Id: <7uo47h$5q9$1@play.inetarena.com>

Audio::DSP - Perl interface to *NIX digital audio device

Version 0.01

Description

    Audio::DSP is built around the OSS (Open Sound System) API and allows
    perl to interface with a digital audio device. The Audio::DSP object
    stores I/O parameters and also supplies temporary storage for raw
    audio data.

Requirements

    In order to use Audio::DSP, you'll need to have the necessary OSS 
    drivers/includes installed. OSS is available for many popular Unices,
    and a GPLed version (with which this extention was developed and 
    tested) is distributed with with the Linux kernel. See "See Also"
    below for relevant URLs.

Download

    The latest version may be downloaded from pdamusic.com:
        http://www.pdamusic.com/computer/audio-dsp.html

Installation

    The usual.

    perl Makefile.PL
    make
    make test (optional)
    make install

    NOTE: If for some reason the tests fail, it may be because the options
    specified in the tests are not compatible with your soundcard. I've
    used "lowest common denominator" settings (8 bit unsigned, 8 kHz 
    mono), but they may not be so "common" to your soundcard. :-) In which
    case (if you know what you're doing) you may modify or simply skip the
    tests and do what you will...

To Do / Suggestion for Data Manipulation Extentions

    I may, in the future, implement PerlIO in the Audio::DSP module. For 
    reasons on which I won't expound here, the initial (0.01) release of
    Audio::DSP relies on C library fcntl/ioctl functions (rather than on
    the PerlIO abstraction layer) in order to interface with the system's
    audio device file.

    In keeping with purpose, I have not included any methods for data
    manipulation in the Audio::DSP extension (the Audio::DSP object
    provides storage for raw audio data read from the device, but that is
    all). It would, however, be nice to implement a suite of modules for
    the purpose of data manipulation (converting the data to common audio
    file formats, filtering, etc.). I would suggest a sort of shared
    "audio data object," to be passed between classes, containing the raw 
    audio data as well as a few necessary paramters. A hash reference
    looking something like:

        {
            data     => 'gobbledegook',
            format   => 16,
            rate     => 44100,
            channels => 2,
        }

    would probably suffice. Let me know if this is something on which
    you'd be interested in collaborating.

Author

    Seth David Johnson
    affection@pdamusic.com

Copyright

    Copyright (c) 1999 Seth David Johnson. All Rights Reserved. This
    program is free software; you can redistribute it and/or modify
    it under the same terms as Perl itself.

See Also

    Open Sound System homepage
        http://www.opensound.com/

    Open Sound System - Audio programming
        http://www.opensound.com/pguide/audio.html

    A GPLed version of OSS distributed with the Linux kernel was used in
    the development of Audio::DSP. See "The Linux Sound System":

        http://www.linux.org.uk/OSS/

    For those curious, the Advanced Linux Sound Architecture (ALSA) API
    should remain compatible with the OSS API on which this extension is
    built. ALSA homepage:

        http://www.alsa-project.org/





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

Date: 21 Oct 1999 22:31:04 GMT
From: "Peter Marelas" <maral@phase-one.com.au>
Subject: ANNOUNCE: CGI::EncryptForm Version 1.00
Message-Id: <7uo478$5q8$1@play.inetarena.com>

CGI::EncryptForm - Implement trusted stateful CGI Form Data using
cryptography.

AUTHOR
    Copyright 1999, Peter Marelas. All rights reserved.

    This library is free software; you can redistribute it and/or
    modify it under the same terms as Perl itself.

    Bug reports and comments to maral@phase-one.com.au.

ABSTRACT
    Many CGI programmers take for granted the validity of stateful
    CGI form data.

    Im talking about the common scenario where you present a form to
    the browser, the user fills in the form, you verify the form
    values, store them in the next form as hidden fields, the user
    fills in another form, the script appends these results to the
    next form in hidden fields and so on.

    Using hidden form fields is one mechanism where by CGI scripts
    can maintain state in the process of collecting information from
    the user.

    Unfortunately, it is also one of the weakest to implement
    because the CGI script must trust the hidden form fields and
    there values, provided by the users browser. At some point in
    time the CGI program does something with this stateful
    information. To be completely sure the hidden fields haven't
    been altered along the way and thus rendered initial
    verification checks useless, the programmer must continually
    verify all new form fields and previous state (encapsulated in
    hidden form fields) to be sure the desired constraints are met.
    This process of verification becomes tedious to program
    especially if there are many forms required to produce a final
    result.

    To tackle this problem I created CGI::EncryptForm, where by
    instead of including state in hidden form fields verbatim, we
    use SHA1 encryption algorithm to provide a satisfactory level of
    trust between the users browser and the CGI script.

DESCRIPTION
    An object is created with a secret key defined by the CGI
    script. The objects encrypt() method is called with a perl data
    structure, which in the context of CGI scripts would normally
    contain key/value pairs. The encrypt() method returns an
    encrypted string. The encrypted string is stored in a hidden
    form field. The user fills in the form. The CGI script processes
    the form, extracts the encrypted string from the hidden form
    field, decrypts the string and returns the original data
    structure. Further results from the form are added to the data
    structure, then it is encrypted again and stored in the next
    form as a hidden field. This process continues until the CGI
    script has all the desired information and is ready to process
    it. To process the results, the CGI script decrypts the
    encrypted string from the last hidden form field, which contains
    the collective state of all previous form input.

    Along the way, the users input was verified only once. The fact
    that state was encrypted and therefore trusted, renders the
    process of continually verifying all state for each form
    processed, unnecessary.

METHODS
    new CGI::EncryptForm([secret_key => $s [, autoescape => $a]])
        Create a new CGI::EncryptForm object. All of the paramaters
        are optional. $s specifies the secret key to use during
        encryption/decryption. $a specifies whether to enable (1) or
        disable (0) the automatic URL escape/unescape of the
        encrypted/decrypted result. By default this is enabled.

    encrypt($hashref)
        Encrypt the data structure and return an encrypted string.
        $hashref must be a reference to an associative array
        supported by the Storable module. If called with no
        arguement, returns the previous encrypted string.

        Upon error, the method returns -1 and sets error().

    decrypt($encrypted_string)
        Decrypt the encrypted string and return a reference to an
        associative array. $encrypted_string must be a scalar
        previously generated by encrypt(). If called with no
        arguement, returns the previous reference.

        Upon error, the method returns -1 and sets error(). If the
        encrypted string is tampered with the decryption routine
        should fail with -1, but this is ultimately dependant on the
        strength of SHA1 digests.

    secret_key($secret)
        Sets the secret key for use during encryption/decryption.
        This method is analogues to the secret_key paramater when
        creating a CGI::EncryptForm object. If called with no
        $secret it returns the current secret key or -1 if
        undefined.

        Upon error, the method returns -1 and sets error().

    autoescape(1)
        Enables or disables the automatic URL escape/unescape of
        encrypted/decrypted strings. This method is analogues to the
        autoescape paramater when creating a CGI::EncryptForm
        object. By default autoescape is enabled (1) and should be
        ignored unless you use this module in non CGI programs.

    error()
        Returns the last error as a scalar. You would normally read
        this if any method returns -1. error() is always cleared for
        each method that executes successfully.








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

Date: 21 Oct 1999 22:31:33 GMT
From: kjj@cx570310-a.chnd1.az.home.com (Kevin Johnson)
Subject: ANNOUNCE: Net::xAP 0.02
Message-Id: <7uo485$5qc$1@play.inetarena.com>

"It's not dead - it's sleeping!"				-- mpfc

This posting is to announce the availability of the second alpha
release of the Net::xAP module for perl.

It's been a long time since a version has been released, but a small
side project got in the way (ISBN: 0-201-43288-9). ;-)

The module has been posted to CPAN as NetxAP-0.02.tar.gz under my
author id (KJOHNSON) and name (Kevin_Johnson).

Net::xAP implements the client portion of the protocol substrate
present in the IMAP, IMSP, ACAP, and ICAP application protocols, hence
the name `xAP'.  A usable IMAP module is also provided.  The IMSP,
ACAP, and ICAP protocols are being worked on.

    IMAP = Internet Message Access Protocol
    IMSP = Internet Message Support Protocol
    ACAP = Application Configuration Access Protocol
    ICAP = Internet Calendar Access Protocol

The module is still in alpha release.  Think twice (maybe thrice)
about using it for anything important, particularly if modifying data
is involved.

Being an alpha release also means that nearly all aspects of the
module are subject to change until it goes to beta.  As an example,
the callback design for this release is significantly different from
version 0.01.  Trust me, it's a `good thing'(tm). ;-)

The main purpose of this release is to get feedback on the interface
and to run it through its paces.  I am keenly interested in feedback
from folks that have a non-trivial familiarity with the IMAP, IMSP,
ACAP, or ICAP protocols.

This release was developed and tested using 5.005_03.

Refer to the provided README file for additional information and
warnings.

Please report any bugs/suggestions to <kjj@pobox.com>.

Copyright (c) 1997-1999 Kevin Johnson <kjj@pobox.com>

All rights reserved.  This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.

-- 
thx,
Kevin Johnson             http://www.pobox.com/~kjj/




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

Date: 21 Oct 1999 22:30:45 GMT
From: =?iso-8859-1?Q?Fran=E7ois=20D=E9sarm=E9nien?= <desar@club-internet.fr>
Subject: Announce: Parse-Yapp-1.00 released
Message-Id: <7uo46l$5pu$1@play.inetarena.com>

Parse-Yapp-1.00 has just been uploaded to CPAN. It should be
available soon on your nearest CPAN mirror.

Since it seems pretty stable, its status changed from BETA to Released.

For the last changes between 0.31 and 1.00, read the Changes file.

If you have ideas on how to improve Parse::Yapp, don't hesitate
to email me.

Enjoy,

François Désarménien


Here is the README file:
 

Parse::Yapp - Parse::Yapp  Yet Another Perl Parser compiler

Compiles yacc-like LALR grammars to generate Perl OO parser modules.

COPYRIGHT

(c) 1998-99 Francois Desarmenien, all rights reserved.
(see the Copyright section in Yapp.pm for usage and distribution rights)

IMPORTANT NOTES

This is production release version 1.0 of Parse::Yapp.

As those last month I've had little time to invest in its development
and it seems pretty stable now, having been in BETA for more than six
monthes without any bug reports, I decided to pass it in 'production'
status.

While I'll will maintain and improve it through your comments and bug
reports, further developments will go in another version numbering
scheme I haven't choosed yet (probably "a la linux", with even sub-numbers
beeing production. Advises are, of course, very welcome).

Note that with future versions, the interface *may* change and be
incompatible with previous version, although I'll try hard not to break
backward compatibility, I'll always choose efficiency as a first
criteria.

The Parse::Yapp pod section is the main documentation and it assumes
you already have a good knowledge of yacc. If not, I suggest the GNU
Bison manual which is a very good tutorial to LALR parsing and yacc's
grammar syntax.

The yapp frontend has now its own documentation using either
'perldoc yapp' or (on systems with man pages) 'man yapp'.

The documentation is (still) only a draft and should be rewritten (I think).
Any help on this issue would be very welcome.

DESCRIPTION

This is production release 1.0 of the Parse::Yapp parser generator.

It lets you create Perl OO fully reentrant LALR(1) parser
modules (see the Yapp.pm pod pages for more details) and has
been designed to be functionnaly as close as possible to yacc,
but using the full power of Perl and opened for enhancements.

REQUIREMENTS

Requires perl5.004 or better :)

It is written only in Perl, with standard distribution modules,
so you don't need any compiler nor special modules.

INSTALLATION

perl Makefile.PL
make
make test
make install

WARRANTY

This software comes with absolutly NO WARRANTY of any kind. 
I just hope it can be useful.


FEEDBACK

Send feedback, comments and bug reports to:

Francois Desarmenien
desar@club-internet.fr




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

Date: 21 Oct 1999 22:31:22 GMT
From: yf110@victoria.tc.ca (Malcolm Dew-Jones)
Subject: ANNOUNCE: Text::Template::Ptml 1.5
Message-Id: <7uo47q$5qb$1@play.inetarena.com>
Keywords: Template Merge Ptml

Ptml 1.5 is now available.  

Ptml is used to merge data into templates.  It handles macros, loops,
etc., and is not an extension of HTML, which I find makes it useful for
making templates for generating HTML as the templates can be usefully
viewed with a browser.  It is 100% perl and requires no installation to
speak off - simply copy to a suitable directory.

Look on CPAN under /modules/by-module/Text   for
	Ptml0150.readme    and/or
	Ptml0150.tgz 	


malcolm dew-jones (various addresses, including 73312,2317@compuserve.com)

--




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

Date: Fri, 22 Oct 1999 00:06:13 +0200
From: "paranoid" <genlabs@gmx.net>
Subject: Re: At the risk of making myself an idiot ...How to create files in Perl ?
Message-Id: <940543574.705579@news.vbs.at>


Craig Berry <cberry@cinenet.net> schrieb in im Newsbeitrag:
s0uk275er0159@corp.supernews.com...
> paranoid (genlabs@gmx.net) wrote:
> : Ì hope anyone of you can answer my question,
> : and mildly ignore it's dumbness .
>
> If and only if you pledge never to place an apostrophe in possessive
> 'its', ever again, so long as you shall live.

Excuse me ? Is this comp.lang.perl.misc ? I'm relieved , for a moment I
thought it was
alt.languages.english.grammar . Arrogancy could be taken for a lack of
self-esteem...


> : I'm writing a subroutine that should do the following:
> : 1) Check if a filename is available (not  containing illegal chars etc.,
not
> : already existing in the write directory)
>
> The illegal-char check is a tough one; it's OS specific.  My suggested
> approach would be to use -e (see perlop) to confirm that the file does not
> exist, then simply attempt to open it with the user-supplied name and
> check for success.  Note that you'll need to do flock-controlled
> synchronization if multiple instances of your program may be running
> simultaneously; there's a race condition between the -e check and the
> attempt to open.

I'll try so , for the char-check I thought about assigning variables with
OS-specific-illegal-chars then
check the filename step by step for equals . But your approach would save
some time and failure potential.

> : 2) Then Create the file
> : The filename has to be variable (userdefined) , the extension stays
fixed .
> : Since the only Perl Book I ever read was "Perl for Dummies" - which
should
> : explain why I'm posting here ;-),
>
> So why haven't you fixed that?  The Llama is the universally recommended
> perl-for-beginners book, and the Camel is the essential reference for all
> of us.  You're doing yourself a grave disservice by trying to code using a
> book which proudly proclaims that it considers you to be a dummy for
> having bought it.

Yeah, I admit that. I like Rich Tennant's sense of humor and I know about
Camel. Hard to get in German.
And of course, I'm not a dummy. I didn't even think about learning Perl
before I kind of stumbled across the book
in the library .

> : and there is nothing to cover this topic, I thought it would be not
possible
> : with Perl .
>
> Very little that is possible at all under a given OS is impossible in
> Perl.

Cool .

> : Can you create files from a Perl script ? If the answer is yes, what's
the
> : command and syntax ?
>
> perldoc -f open

That's the syntax ? I think I'll better read the manual before I use that
line in my script !

Cheers

- ECC.
> --
>    |   Craig Berry - cberry@cinenet.net
>  --*--  http://www.cinenet.net/users/cberry/home.html
>    |   "They do not preach that their God will rouse them
>       a little before the nuts work loose." - Kipling




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

Date: Fri, 22 Oct 1999 00:08:05 +0200
From: "paranoid" <genlabs@gmx.net>
Subject: Re: At the risk of making myself an idiot ...How to create files in Perl ?
Message-Id: <940543689.879923@news.vbs.at>

Thanks, it does .

Scratchie <AgitatorsBand@yahoo.com> schrieb in im Newsbeitrag:
BDHP3.874$LR3.154951@news.shore.net...
> paranoid <genlabs@gmx.net> wrote:
> : 1) Check if a filename is available (not  containing illegal chars etc.,
not
> : already existing in the write directory)
>
> To check whether a file exists you use something like
> if (-e $file) {
> print "File exists!\n";
> }
>
> This is more generally called a "-X file test operator", which is how
> you'll find it listed in the documentation (along with many other useful
> file tests). To check the name of the file, you'll probably want to use a
> regular expression.
>
> : Can you create files from a Perl script ? If the answer is yes, what's
the
> : command and syntax ?
>
> You use the "open" command with either a ">" or ">>" to indicate that you
> want to write to a file. Surely this is described in "Perl for Dummies"
> *somewhere*? If not, I would normally recommend that you consult "perldoc
> -f open", but I just tried that and it was all-but-illegible due to a
> preponderance of "C<'E<lt>'>" and suchlike. You might be better off
> reading the docs for "open" at
> http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfunc/open.html .
>
> Hope this helps,
>
> --Art
> --
> --------------------------------------------------------------------------
>                     National Ska & Reggae Calendar
>                   http://www.agitators.com/calendar/
> --------------------------------------------------------------------------




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

Date: Thu, 21 Oct 1999 14:59:36 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Can't FTP to unix after Stripping ^M's from files under NT
Message-Id: <MPG.12792c9ef5d3f2a198a0f4@nntp.hpl.hp.com>

In article <7uo0q8$9mq@news.or.intel.com> on Thu, 21 Oct 1999 14:32:59 -
0700, Maurice Maltbia <maurice.maltbia@intel.com> says...
> Larry,
> 
> Thanks for a great solution to stripping the ^M's.

You're welcome.  I thought so too.  (Perl Golf winner. :-)

> I am using FTP in the Win32::Internet module to tranfer the stripped files,
> but they will not transfer to my unix host.  FTP works great on the same file
> before stripping it.
> Do you have any suggestions?

Transfer 'stripped' (i.e., binary) files using binary mode.  Transfer 
'text' files using 'ascii' mode.  FTP will then handle the line endings 
correctly, in either direction.

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


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

Date: Thu, 21 Oct 1999 22:08:00 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: exiting non-zero at end of perl -[np]
Message-Id: <49MP3.248$pA3.3858@news1.rdc1.mb.home.com>

In article <7unuir$kk4$1@nnrp1.deja.com>,
 jrw32982@my-deja.com <jrw32982@my-deja.com> wrote:
! How can I exit with a non-zero return code when using perl -n or perl
! -p?
! 
! What I want to do is something like:
!    perl -ne 'exit 0 if /.../; END { exit 1 }'
! 
! I get an exception if I try to exit from an END block.  If I set
! $SIG{__DIE__} and die from the END block, I get the signal handler
! calling itself several times before finally dying, which is pretty ugly.

as perldoc -f exit explains, exit() calls any END blocks before
exiting.

The POSIX::_exit() function doesn't call  END blocks
so this may be more along the lines of what you want:

perl -MPOSIX -ne 'POSIX::_exit(0) if /foo/;END{POSIX::_exit(1)}'

andrew

-- 
Andrew L. Johnson   http://www.manning.com/Johnson/
      I've always maintained a cordial dislike for indent, because it's
      usually right.
          -- Larry Wall in <199806221558.IAA07251@wall.org>
      


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

Date: 21 Oct 1999 22:09:01 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Re: exiting non-zero at end of perl -[np]
Message-Id: <7uo2tt$rf8$1@fcnews.fc.hp.com>

jrw32982@my-deja.com wrote:
> How can I exit with a non-zero return code when using perl -n or perl
> -p?

The perlvar man page states:

	Inside an END subroutine $? contains the value that is going
	to be given to exit().  You can modify $? in an END subroutine
	to change the exit status of the script.

						-Jack Applin
						 neutron@fc.hp.com


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

Date: Thu, 21 Oct 1999 15:01:16 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help substituting '/' ?
Message-Id: <MPG.12792d0a3df2c9e798a0f5@nntp.hpl.hp.com>

In article <7uo135$5lk@dfw-ixnews17.ix.netcom.com> on Thu, 21 Oct 1999 
21:36:38 GMT, Sebastian <not@this.address> says...
> In article <0a0133f8.71573350@usw-ex0101-008.remarq.com>,
>    shylock <junkNOjuSPAM@tfw.net.invalid> wrote:
> >I'm trying to strip / (forward slashes) off a report using perl.
> >ex:
> >$line =~ s/\///;
> >
> >any advice?
> 
> $line =~ s!/!!g;
> $line =~ s=/==g;
> $line =~ s?/??g;
> You can use any non-alphanumeric, non-whitespace delimiters you want.

Sure, but the original code works also -- on the first slash -- and on 
all of them with the /g modifier.  Maybe that's all that was missing.

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


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

Date: Thu, 21 Oct 1999 22:12:33 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Help substituting '/' ?
Message-Id: <380F8FDC.EE10C402@home.com>

Sebastian wrote:
> 
> $line =~ s!/!!g;
> $line =~ s=/==g;
> $line =~ s?/??g;
> You can use any non-alphanumeric, non-whitespace delimiters you want.

You can use alphanumeric delimiters.

    $line =~ s g/ggg;    

You can also use the quicker op.

    $line =~ y d/ddd;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Fri, 22 Oct 1999 03:11:39 -0700
From: "Gary Kelley" <gary@cowboyfurniture.com>
Subject: HELP- WILL PAY!!!
Message-Id: <s0v3p3r6r0145@corp.supernews.com>

I need someone to write some perl (?) scripting for me, I am not coherent
enough to do it myself. Here's what I need:
I have a web site that I am showing an EXCEL (lotus) file on, I can upload
the file, but I need to maintain the functionability of the program, ie. I
need to make chagnes in certain cells, and have cooresponding cells make
changes based on data input. sound crazy? heres the website;
www.buyherefords.com/exfp.htm check it out and let me know, this is NOT a
trick to get people to visit a site,this is a legitimate offer, reply to me
at: gary@buyherefords.com
Gary Kelley




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

Date: Thu, 21 Oct 1999 15:32:49 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: How can print a HTML file?
Message-Id: <380F9490.26B80B1D@cisco.com>

Jing Shi wrote:

> Will that print out the file with all the HTML tags?

yes.

> ..how I can get the print out just like I print it from Netscape?

There is no way that I know of. HTML has to be rendered
by some agent before printing it.

> BTW, is HTML::Parse same as HTML::Parser? If not, where can I get it?

Check CPAN at www.perl.com/CPAN/

---



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

Date: Thu, 21 Oct 1999 21:51:53 GMT
From: krm@sdc.cs.boeing.com (Keith Michaels)
Subject: How come no interface to mmap?
Message-Id: <FJz3EH.n10@news.boeing.com>

I need to read a large random access database of fixed length records.
In the old days I would use mmap with C for efficiency.  What is the
counterpart in perl?  Why isn't there an mmap package?

-- 
 -------------------------------------------------------------
| Keith R. Michaels   Archival Evangelist                     |
| (425)865-6415       Boeing Archival Service (ufs.boeing.com)|
| Enterprise Servers, Technical Services, SSG.                |
 -------------------------------------------------------------


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

Date: 21 Oct 1999 22:03:28 GMT
From: scott.frazer@ericsson.com (Scott Frazer)
Subject: How do you split a string into fixed sized pieces?
Message-Id: <8E66B7B0Dscottfrazerericssonc@cnn.exu.ericsson.se>

OK, I'm new to Perl and can't figure out how to split a long string
into fixed sized pieces.  For example:

input -> "0123456789abcdef"
output -> an array of "0123", "4567", "89ab", "cdef"

It seems like I should be able to use 'split', but since there are
no delimiters I don't know how to do it.  I tried various regexp's
to force a match on four of any character, but couldn't work it out.
I thought maybe 'unpack' also, but no luck there either.  There are
obvious ways around it using loops and such, but that seems very
un-Perl-like.  It would also be nice if the string was not evenly
divisible by the fixed size it would just throw the leftover in the
last array element.

Help!
Scott


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

Date: Thu, 21 Oct 1999 22:20:49 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: How do you split a string into fixed sized pieces?
Message-Id: <bJ8POJQKuQRdpbEd5ZtOxYvAErUp@4ax.com>

On 21 Oct 1999 22:03:28 GMT, scott.frazer@ericsson.com (Scott Frazer)
wrote:

> OK, I'm new to Perl and can't figure out how to split a long string
> into fixed sized pieces.  For example:
> 
> input -> "0123456789abcdef"
> output -> an array of "0123", "4567", "89ab", "cdef"
> 
> It seems like I should be able to use 'split', but since there are
> no delimiters I don't know how to do it.  I tried various regexp's
> to force a match on four of any character, but couldn't work it out.
> I thought maybe 'unpack' also, but no luck there either.

But unpack() is what you need, it would seem:

$in  = "0123456789abcdef";
@out = unpack("A4"x4,$in);
print join "\n" => @out;

HTH.


-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Thu, 21 Oct 1999 15:52:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How do you split a string into fixed sized pieces?
Message-Id: <MPG.127938eef0976fc498a0f7@nntp.hpl.hp.com>

In article <8E66B7B0Dscottfrazerericssonc@cnn.exu.ericsson.se> on 21 Oct 
1999 22:03:28 GMT, Scott Frazer <scott.frazer@ericsson.com> says...
> OK, I'm new to Perl and can't figure out how to split a long string
> into fixed sized pieces.  For example:
> 
> input -> "0123456789abcdef"
> output -> an array of "0123", "4567", "89ab", "cdef"
> 
> It seems like I should be able to use 'split', but since there are
> no delimiters I don't know how to do it.  I tried various regexp's
> to force a match on four of any character, but couldn't work it out.
> I thought maybe 'unpack' also, but no luck there either.  There are
> obvious ways around it using loops and such, but that seems very
> un-Perl-like.  It would also be nice if the string was not evenly
> divisible by the fixed size it would just throw the leftover in the
> last array element.

I didn't do well with split() either, without another filter for null 
strings.  Perhaps someone else can help.

But here are two other ways also, using a regex or unpack().


#!perl -w
use strict;

$_ = 'xxxxyyyy' x 4 . 'z';

my @a;

@a = grep length, split /(.{1,4})/s;
print "@a\n";

@a = /(.{1,4})/gs;
print "@a\n";

@a = unpack 'A4' x (length()/4) . 'A*' => $_;
print "@a\n";


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


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

Date: Thu, 21 Oct 1999 15:02:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How do you substitute '/' ?
Message-Id: <MPG.12792d516690176598a0f6@nntp.hpl.hp.com>

In article <17599f0b.70b34094@usw-ex0101-008.remarq.com> on Thu, 21 Oct 
1999 14:08:07 -0700, shylock <junkNOjuSPAM@tfw.net.invalid> says...
> Having trouble getting perl to susbstitute / (forward slash)
> using $line =~ s/\///;
> 
> Any advice?

Yes.  If you submit the same question twice within two minutes, use your 
newsreader to cancel one of them.

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


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

Date: 21 Oct 1999 22:30:56 GMT
From: Cameron Kaiser <ckaiser@stockholm.ptloma.edu>
Subject: HTTPi/1.0 released
Message-Id: <7uo470$5q1$1@play.inetarena.com>

The first full release (non-beta) of HTTPi is announced (version 1.0).

HTTPi is a miniaturized, extensible HTTP/0.9, /1.0 and /1.1 compliant webserver
written in 100% Perl. It requires no modules (just the executable: not even
Net.pm or Socket.pm are required), comes in three versions for daemon or
inetd/xinetd-based execution, and barely reaches 10K in size. It supports:

	* user filesystems a la http://host/~user/
	* IP-less and IP-based virtual hosting
	* executables
	* server-parsed pages (with inline Perl) -- new in 1.0
	* HTTP authentication
	* user/IP agent security

It is designed to be highly secure, fast and compact.

HTTPi/1.0 adds sundry bug fixes to 0.99 final beta. You can download it and get
complete documentation, including programming and user's guides, from the
official HTTPi home page, served by HTTPi itself:

	http://httpi.ptloma.edu/

Version 1.0 will be uploaded to CPAN momentarily. This is its fifth release.

--
  Cameron Kaiser * ckaiser@stockholm.ptloma.edu * posting with a Commodore 128
               personal page: http://calvin.ptloma.edu/~spectre/
  ** Computer Workshops: games, productivity software and more for C64/128! **
                   ** http://www.armory.com/~spectre/cwi/ **




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

Date: Thu, 21 Oct 1999 22:21:51 GMT
From: princyraj@my-deja.com
Subject: Problem with file upload and attachment
Message-Id: <7uo3ls$ogj$1@nnrp1.deja.com>

Hi,

   Got a weird problem . this following piece of my code uploads a file
and then sends it as an attachment.  Somehow the attachments are getting
corrupted. i checked the size of the file after getting uploaded with
the size on hard disk , they were the same. But the size of attachment
is realy small .
   any help or pointers will be greatly appreciated.

Thanks
Rajesh

P.S :  i dont want any suggestions to use standard modules like Mime:: .
i just want to know what is the exact problem is. Also i have tried
binmode(<file handle>) which is actually not required  (asper perldoc -f
binmode) ..............



--------------------------begin of my code------------------------------
#! /usr/local/bin/perl5

use CGI qw(:standard);                 # CGI Library                  #
use CGI qw(:escape unescape);          # CGI Library to escape strings #
use CGI::Carp 'fatalsToBrowser';       # Fatal Errors to Browser       #
$CGI::POST_MAX=1024 * 100;             # Max POST limit 100 K          #
$CGI::PRIVATE_TEMPFILES = 1;           # Dont Display temp upload file #

$| = 1;                                # Remove Cache Buffering        #


my($filename);
my(@fname);
my($attach);
my($mimetype);

print header;
print start_html(-title=>'SOLCAT (System for Online Case Tracking)',
                 -author=>'rkasmani@cisco.com',
                 -script=>$JSCRIPT);

if ( param('submit') ) {
     $filename = param('fileuploadfield');
     $mimetype = uploadInfo($filename)->{'Content-Type'} || 'text/plain'
;
     while(<$filename>){
           $attach .= $_;
     }
     @fname = split(/\\/,$filename);
     if($#fname == -1){
       @fname = split(/\//,$filename);
     }
     $file=$fname[$#fname];
    sendMail('rshriyan@cisco.com', 'rshriyan@cisco.com', 'file
attachment testin
g', 'See file attachment', '','',$attach,$file) ;
     }
else{
    print start_multipart_form(-name=>'fileupload');
    print "<BR>";
    print filefield(-name=>'fileuploadfield',
                -default=>'c:\\data\\',
                -size=>50,
                -maxlength=>80);
    print "<BR><BR><BR><CENTER>";
    print submit(-name=>'submit',-value=>'submit');
    print "</center>";
   print end_form;
    }

print end_html;
exit(0);


sub sendMail {
    my($email_to, $email_from, $email_subject, $email_message,
$bcc_address,$cc_
address,$attachment,$file) = @_;

$seperator="01234";


my $body =<<BODY;
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="$seperator"

--$seperator
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

$email_message
mime Type is $mimetype
BODY

if($attachment) {
$body .=<<BODY;
--$seperator
Content-type: $mimetype ; name="$file"
Content-Disposition: attachment; filename="$file"
Content-Transfer-Encoding: 64bit

BODY
}

open MAIL, "|/usr/lib/sendmail -t -OIgnoreDots -f '$email_from'
2>/dev/null" ||
  die "Error Sending Mail..";

print MAIL "To: $email_to\n";
print MAIL "Cc: $cc_address\n" if ($cc_address);
print MAIL "Bcc: $bcc_address\n" if ($bcc_address);
print MAIL <<"DATA";
From: $email_from
Subject: $email_subject
$body

DATA
if($attachment) {
print MAIL $attachment."\n";
}
print MAIL <<"DATA";
--$seperator--


DATA
close MAIL;

}

---------------------------end of my code-------------------------------


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


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

Date: Thu, 21 Oct 1999 22:52:52 GMT
From: iami@my-deja.com
Subject: problem with substitute op (s)
Message-Id: <7uo5g4$po4$1@nnrp1.deja.com>



   hello.

   i will be brief.

   (please excuse any sperious wrap-arounds. i am posting this
    from deja.com.)

perl -v

This is perl, version 5.005_02 built for sun4-sunos


   code:

#!/usr/local/bin/perl

$_ = "-rw-rw-r--   1 root     ftp           148 Jun  5 22:01
uuencode.README\n";

print;

s/^.+[0-2][0-4]:[0-6][0-9]\040+//;

print;

$_ = "-rw-rw-r--   1 root     ftp           230 Jul 22 16:36
tiff.README\n";

print;

s/^.+[0-2][0-4]:[0-6][0-9]\040+//;

print;


   output:

-rw-rw-r--   1 root     ftp           148 Jun  5 22:01 uuencode.README
uuencode.README
-rw-rw-r--   1 root     ftp           230 Jul 22 16:36 tiff.README
-rw-rw-r--   1 root     ftp           230 Jul 22 16:36 tiff.README

the first string substitutes as expected.

the second case does not.

there are no non-printable characters in the second string.

???

   please post responses. mail sent to the listed address > /dev/null

   tia,

   david johnson



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


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

Date: Fri, 22 Oct 1999 00:29:18 +0200
From: WebMaster <webmaster@webmagic.n.se>
Subject: Regexp global match mystery?
Message-Id: <380F93BD.69C1A86F@webmagic.n.se>

I´m trying to learn about Perl and regular expressions by writing a
small online application where the user should be able to specify a
regular expression, set modifiers and input a string or upload a file to
see the results of the regexp.

Trying to validate the code I run into problem where the first match I
expect doesn´t show up in a global match.

The code where the global match is evaluated is shown below

if ($method eq "match") {
  print "Metoden är match",br;
   if ($mod=~ /g/) {
    print "Metoden är global match",br;
    $count=0;
    if ($result=~ /($regexp)/go) {
    ($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10) = ($result=~
/$regexp/go);
    @globalresult = ($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10);
    while (@globalresult[$count] && $count <10 ){
    print hr,"<CENTER>Matched parantheses number$count or matched
string$count if no parantheses in Regexp
is</CENTER>",br,$globalresult[$count],br;


The file I use as input looks like this

Rad 1 RAD 1
Rad 2 RAD2
Rad 3 RAD 3
Rad 4 RAD 4
Rad 5 RAD 5
Rad 6 RAD 6
Rad 7 RAD 7
Rad 8 RAD 8
Rad 9 RAD 9
Rad 10 RAD10

Using the regexp /Rad\s\d+/ return the results I expect except that the
first expected match (i.e Rad 1) isn´t returned in $globalresult[0], Rad
2 is???

Am I doing a perl programming mistake or misinterpretation of how the
regexp should work?

Per Wennman



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

Date: 21 Oct 1999 21:56:53 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: subroutine
Message-Id: <7uo275$rgg$2@rguxd.viasystems.com>

lt lindley <ltl@rgsun5.viasystems.com> wrote:
:>The common idiom is to write that as:

:>my $textToBeConverted = shift;
:># or
:>my ($textToBeConverted) = @_;
:># or if you like
:>my $textToBeConverted = @_[0];
--------------------------^
Eeeekkk!
my $textToBeConverted = $_[0];


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 21 Oct 1999 22:17:39 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: subroutine
Message-Id: <7uo3e3$rgg$3@rguxd.viasystems.com>

Larry Rosler <lr@hpl.hp.com> wrote:
:>In article <7unvo0$rgg$1@rguxd.viasystems.com> on 21 Oct 1999 21:14:40 
:>GMT, lt lindley <ltl@rgsun5.viasystems.com> says...


:>> It will help you learn Perl if you learn to use the debugger.
:>> I don't see that advice handed out here often, but it has
:>> been very much help to some of my coworkers and I have found
:>> it to be useful when something isn't working the way I expect.

:>I suggested using 'print' statements.  Old tools in old hands?

And I still use print statements liberally if it is a pain in the ass
to invoke the debugger.  C programs on an MVS system that require
complex JCL to provide real data, for example, is a place that I never
try to use a debugger.

But it is so easy to do with perl that we really should be recommending
it as an additional learning tool.  When people are first trying to
figure out when something is an array or a reference to an array, etc..,
the debugger is a fantastic tool.

:>> my $textToBeConverted = @_[0];

:>What did '-w' tell you about that last one?

As you already know, I did not test it.  :-(  I did see my error when
I read the thread again on the next pass.  I whipped out a correction
hoping I could beat everyone else to the punch.  Although I didn't
compare timestamps, you probably beat me to it.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 21 Oct 1999 22:48:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: subroutine
Message-Id: <s0v617qlr0119@corp.supernews.com>

Erik van Roode (newsposter@cthulhu.demon.nl) wrote:
: rancorr@hotmail.com wrote:
: 2 > 	my $textToBeConverted = @_;
: 
:   In a scalar context, an array is evaluated to the number of elements
: in it. So in line 2, textToBeConverted gets the value 1.
:
: To retrieve the value of the first argument to a subroutine:
:     my $textToBeConverted = $_[0];

Or in more common idioms,

  my ($textToBeConverted) = @_;
  my $textToBeConverted = shift;

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

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


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