[12737] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 147 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 14 22:07:13 1999

Date: Wed, 14 Jul 1999 19:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 14 Jul 1999     Volume: 9 Number: 147

Today's topics:
    Re: ADO Insert cursor to SQLServer (Matthew Bafford)
    Re: bug in vars.pm? <dgris@moiraine.dimensional.com>
    Re: C-like #define macros in Perl (Abigail)
    Re: C-like #define macros in Perl (Abigail)
    Re: Can I do this? (Andrew Allen)
        CGI.pm and redirect <jscott@oro.net>
        constants in PERL <hannak@rochester.rr.com>
    Re: constants in PERL (Greg Bacon)
        Display an image in HTML with PERL <webXmaster@terragon.com>
    Re: Display an image in HTML with PERL (Matthew Bafford)
    Re: eval() risky? (Andrew Allen)
    Re: eval() risky? (Sami Rosenblad)
    Re: file test for existence of path? (Andrew Allen)
        file to array ? stu7@usa.net
        generate the return html for browser client <gabriel@asiaep.com>
    Re: Getting very irregular single 'name' field into fir (Tad McClellan)
    Re: Greedy regular expression... <aperrin@mcmahon.qal.berkeley.edu>
    Re: Greedy regular expression... (Matthew Bafford)
    Re: Hash Size Limit? (Matthew Bafford)
    Re: Hash Size Limit? (Andrew Allen)
        Help: reading from COM1 (George Avison)
    Re: How can I use image as a submit botton ? (Matthew Bafford)
    Re: how many files can you open? <bwalton@rochester.rr.com>
    Re: how many files can you open? <rra@stanford.edu>
    Re: How to delete an element in the middle of an array (Greg Bacon)
    Re: How to delete an element in the middle of an array (Sami Rosenblad)
    Re: How to delete an element in the middle of an array (Matthew Bafford)
    Re: I want to do something interesting with ranges (Andrew Allen)
    Re: perl 5.005_3 on hp/ux 10.20 (Andrew Allen)
        Q: panic pp_iter with foreach spertus@mills.edu
        Splitting into two-character array <hiller@email.com>
    Re: Splitting into two-character array (Greg Bacon)
        stripping html tags <zigmart@zigmart.com>
    Re: stripping html tags (Greg Bacon)
        time funciton or module <lansong@idirect.com>
    Re: Why Perl instead of ColdFusion? lvirden@cas.org
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Jul 1999 00:38:55 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: ADO Insert cursor to SQLServer
Message-Id: <slrn7oqacs.sv.*@dragons.duesouth.net>

[CC tied to bullet and shot to Dorr Lewright <dlewright@nuworld.com>]

Newsgroups: comp.lang.perl.misc
                      ^^^^
                      
On Wed, 14 Jul 1999 23:40:03 GMT, Dorr Lewright <dlewright@nuworld.com>
held some poor sysadmin at gunpoint, and sent the following into
comp.lang.perl.misc: 
: Does anyone have an example using ADO where you prepare an insert cusor,
: then insert rows, then close the cursor?

You're going to have a lot better luck with this question in a group
like microsoft.public.ado [1].

We discuss Perl here, not cursors, rows, or even closing cursors.

: I am inserting to a SQLServer 7.0 database.

Then perhaps one of these fine newsgroups will be of use to you:

    microsoft.public.fr.sql.beta.communication!
    git.sql-help!
    microsoft.public.fox.fox2x.queries-sql!
    relcom.fido.su.dbms.sql!
    microsoft.public.vstudiobeta.vfp.clisvr-sql!
    borland.public.vdbase.data.sql!
    microsoft.public.kr.sql!
    microsoft.public.fox.vfp.queries-sql!
    borland.public.intrabuilder.data.sql!
    fido7.su.dbms.sql!
    
: Thanks,

HTH,

:         ...Dorr

--Matthew

-- 
I guess.  I have no idea what ado might be.  That group is, however, at
least a little bit more relevant than clpm.


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

Date: 14 Jul 1999 19:00:15 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: bug in vars.pm?
Message-Id: <m3wvw2k9r4.fsf@moiraine.dimensional.com>

"John M. Dlugosz" <john@dlugosz.com> writes:

> In the standard pragmatic module vars.pm, I see:
> 
>     if ($sym =~ tr/A-Za-Z_0-9//c) {

Good spot, this is a bug. 

<snip>

> Also, what is the benifit of using tr/// with an empty replacement string
> (which does nothing but returns a count of chars matching the source string)
> instead of the more common s// ?  Is this a technique we should all be
> using?

In this context tr/// is being used solely for its numeric value, as a
test for _any_ unusual characters in the input.  It doesn't matter how
many strange characters there are, just that there is at least one.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 14 Jul 1999 19:17:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: C-like #define macros in Perl
Message-Id: <slrn7oqa4c.c9j.abigail@alexandra.delanet.com>

TM Lehto (hiwi1krg@iitb.fhg.de) wrote on MMCXLIII September MCMXCIII in
<URL:news:378ca933.80071166@iitb>:
-- I am trying to write a Perl script that can print messages in several
-- languages. I have put all text strings to separate file (lang.pl). The
-- text strings have parts that change in run-time. When I try to print
-- them from my script, the variable part of the string either doesn't
-- show at all or shows as "This is directory: $working_dir" depending of
-- which combination of single and double quotes I use in every place.
--
-- Can I do it without using s/// substitution (perlfaq4 says something
-- about it but I don't want to use s///)?

You can use an eval. Or a tied scalar that does the eval behind the
scenes.

If you are using interpolation, the interpolation happens during
the creation of the string, not when you print it. And if you use
single quotes, there's no interpolation at all.


-- Can I define macros like in C language?

Yes, but that's a seldomly used technique, and not very useful in Perl.
Use the -P switch.



Here's a module you can tie strings to, and it will do interpolation
*when used*. Note that you have to give the string in single quotes,
and you can only interpolate package variables.



package Interpolate;


sub TIESCALAR  {
    my $class     =   shift;
    my $value     =   shift;

    bless \$value => $class;
}


sub STORE {
    my $self  =  shift;
    my $value =  shift;

    $$self    = $value;
}


sub FETCH {
    my $self    =  shift;
    my $package =  caller;

    eval "package $package; qq {${$self}}";
}


__END__


Example usage:

    tie my $string, "Interpolate", 'Hello, $foo\n';
    use vars qw /$foo/;
    $foo = "World";
    print $string;    # This will print:  Hello, World



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 14 Jul 1999 19:21:12 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: C-like #define macros in Perl
Message-Id: <slrn7oqaar.c9j.abigail@alexandra.delanet.com>

TM Lehto (hiwi1krg@iitb.fhg.de) wrote on MMCXLIII September MCMXCIII in
<URL:news:378ca933.80071166@iitb>:
** I am trying to write a Perl script that can print messages in several
** languages. I have put all text strings to separate file (lang.pl).

Oh, I just remembered. A recent Perl Journal (not the most recent,
but the one before) had an article about using strings in different
languages for localization. It might be of some use to you. (But then,
you be doing something totally different).



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 15 Jul 1999 01:01:10 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Can I do this?
Message-Id: <7mjbsm$ibi$4@fcnews.fc.hp.com>

Joan Richards (richj@home.com) wrote:
: So, in a nutshell, how can I access (through perl) the data structures
: or whatever that keeps the information for the 'df' command and use them
: in my own proggie?

A cursory glance at the CPAN module list 

  http://www.perl.com/modules/00modlist.long.html

reveals:

  File::Df
  Filesys::Df
  Filesys::DiskFree

which appears useful.

Andrew


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

Date: Wed, 14 Jul 1999 18:05:14 -0700
From: oronet Tech - Joshua Scott <jscott@oro.net>
Subject: CGI.pm and redirect
Message-Id: <378D33CA.5D210771@oro.net>

I am using the redirect in the CGI.pm.  For some reason I get this error
at the browser:

Status: 302 Found Uri: http://www.oro.net Location: http://www.oro.net
Content-type: text/html 

Any insights would be greatly appreciated.

=============================================================
Josh Scott                                           272.0799
oronet Technician                  http://www.oro.net/~jscott


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

Date: Wed, 14 Jul 1999 20:53:03 -0400
From: Victor Hannak <hannak@rochester.rr.com>
Subject: constants in PERL
Message-Id: <378D30EE.F905A4A4@rochester.rr.com>

I could not find documentation about constants in Perl.  Is there a way
to define a constant literal string as a number in order to make your
program more readable?

i.e.

BLUE = 0;
RED = 1;
BLACK = 2;

if ($old_house_color == BLACK) {
    $new_house = BLUE;
} else {
 $new_house = RED;
}


I know that you could just assign a variable (i.e. $BLACK = 0) but is
this the only way?

Thanks.



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

Date: 15 Jul 1999 01:10:31 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: constants in PERL
Message-Id: <7mjce7$gjd$1@info2.uah.edu>

In article <378D30EE.F905A4A4@rochester.rr.com>,
	Victor Hannak <hannak@rochester.rr.com> writes:
: I could not find documentation about constants in Perl.  Is there a way
: to define a constant literal string as a number in order to make your
: program more readable?

Take a look at the documentation on the standard constant pragma, or
look at the "Constant Functions" section in the perlsub manpage.

Greg
-- 
Nine out of ten men who try Camels prefer women.


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

Date: Wed, 14 Jul 1999 16:33:52 -0700
From: "Terragon" <webXmaster@terragon.com>
Subject: Display an image in HTML with PERL
Message-Id: <7mj6ua$2a5f@enews1.newsguy.com>

I'm trying to display an image in an HTML document (without server side
includes) by calling a perl script like this:

<img src="test.cgi">

I have seen several examples of how to do this, but I can't get any of them
to work.  Currently my script looks like:

  print "Content-type: image/gif\n\n";
  $image = "image.gif";
  open (IMG,"$image");
  print <IMG>;
  close (IMG);

The image is sort of displayed in the browser, but it looks all crunched.
Am I leaving something important out?

Thanks!






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

Date: Thu, 15 Jul 1999 01:09:02 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Display an image in HTML with PERL
Message-Id: <slrn7oqbdj.sv.*@dragons.duesouth.net>

[CC'd to webmaster@terragon.com]

On Wed, 14 Jul 1999 16:33:52 -0700, Terragon" <webXmaster@terragon.com>
held some poor sysadmin at gunpoint, and typed the following into
comp.lang.perl.misc: 
:   print "Content-type: image/gif\n\n";
:   $image = "image.gif";
:   open (IMG,"$image");
:   print <IMG>;
:   close (IMG);
: 
: The image is sort of displayed in the browser, but it looks all crunched.
: Am I leaving something important out?

Are you, perhaps, operating on a Microsoft system?

perldoc -f binmode
 
: Thanks!

HTH!

--Matthew


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

Date: 15 Jul 1999 00:37:39 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: eval() risky?
Message-Id: <7mjagj$ibi$2@fcnews.fc.hp.com>

Sami Rosenblad (blade@leela.janton.fi) wrote:
: I read the perlsec manpage for hints about eval and Taint checking, but
: didn't find anything appropriate. Here's my problem:

: I have a CGI script that handles a dynamic forum with threaded reading,
: submitting, and searching facilities. Now, the search engine I wrote could
: be described as a quick hack, because it basicly does this:

: # this is from the form decoding routine

:    if (defined $FORM{keyword}) {
:       $SEARCH = $FORM{keyword};
:       for ($SEARCH) {
:          s#(\w+)#/$1/i#g;
:          s#/and/i#and#gi;
:          s#/or/i#or#gi;
:          s#/not/i#not#gi;
:       }
:    }


: So, $SEARCH is eval()'d, and may contain TAINTED data, right? Is there a
: (remote) possibility that somebody skilled enough could write a search
: string that would pass the initial substitutions and access the command
: shell or something like that?

Yes. One thing I can think of that $SEARCH='`x`', you would run /x/i
in the shell. That seems dangerously close. Why not _just_ allow
words, parentheses, and a limited set of operators, and disallow 
anything else.


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

Date: Thu, 15 Jul 1999 04:43:37 +0300
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: eval() risky?
Message-Id: <blade-1507990443370001@durandal.janton.fi>

In article <7mjagj$ibi$2@fcnews.fc.hp.com>, ada@fc.hp.com (Andrew Allen) wrote:

> Yes. One thing I can think of that $SEARCH='`x`', you would run /x/i
> in the shell. That seems dangerously close. Why not _just_ allow
> words, parentheses, and a limited set of operators, and disallow 
> anything else.

::slaps forehead::

Of course, the obvious solution is the hardest to find. I'll just zap
everything that's not alphanumeric and continue with the substitutions as
before.
Thanks, Andrew!

-- 
Sami Rosenblad -- blade@leela.janton.fi -- running linux since 1999


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

Date: 15 Jul 1999 00:50:53 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: file test for existence of path?
Message-Id: <7mjb9d$ibi$3@fcnews.fc.hp.com>

Vladimir Gabrielescu (vgabriel@lochaber.rutgers.edu) wrote:
: In <7mim3r$fef$1@lochaber.rutgers.edu> vgabriel@lochaber.rutgers.edu (Vladimir Gabrielescu) writes:

: >I just relized that there is no easy way to check if a path 
: >exits. For example, I wish to know if "/foo/bar" exits, regardless
: >of what file type it is. I was sort of wished that "-e" did the 
: >right thing, unfortunatly "-e" follows links. That way if "/foo/bar"
: >is a link to "/foo/baz" and "/foo/baz" does not exist, then 
: >(-e "/foo/bar") would be false. 

: Interestingly enough, "-e" seems to identify the existence of any
: file type except dangling links. I assume this is because of a 
: stat versus lstat issue. Is this intentional or a bug? I can't
: seem to find this behavior documented anywhere.

Read the stat(2) and lstat(2) UNIX man pages. You essentially just
want to do an lstat and see if it succeeds, which indicates the file
exists.

Keep in mind that since links are conceptually "invisible" (except to
lstat), you are using a non-standard definition of file existence by
using this method, i.e. most people would consider a link to a
non-existent file to be a non-existent file.

Andrew


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

Date: Thu, 15 Jul 1999 01:30:29 GMT
From: stu7@usa.net
Subject: file to array ?
Message-Id: <7mjdjm$1vf$1@nnrp1.deja.com>

  Is there a single PERL function which writes a file (by line)
to an array ?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 15 Jul 1999 01:52:06 GMT
From: Thien Syh <gabriel@asiaep.com>
Subject: generate the return html for browser client
Message-Id: <7mjes2$2bq$1@nnrp1.deja.com>

I'm facing a problem on my perl program , when i compile the program it
gave me the following error message:
content-type:texthtml

<html><head><title>Merchant Administration Page</title></head>
<CENTER><font face="helvetica"><B>EDC Merchant
Administration</B></center><P>

<H3>Sales Transaction Failed</H3><br><B>Detail :</B> Payment Server
unavaliable<
br>Please contact administrator.<br></body></html>]

Here is my code where the problem happened. Please help!

### generate the return html for browser
client                               _
print("content-
type:text/html\n\n");                                          _
print("<html><head><title>Merchant Administration
Page</title></head>\n");    _
print("<CENTER><font face=\"helvetica\"><B>EDC Merchant
Administration</B></ce_
###
      _

with many thanks,
Gabriel.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 14 Jul 1999 16:17:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Getting very irregular single 'name' field into first/last name for credit card gateway -- what hit rate is possible?
Message-Id: <59rim7.39k.ln@magna.metronet.com>

Brad Long (bjl@uq.net.au) wrote:

: I have seen how Abigail not only says "...not a
: Perl question..."


: There does seem to be a merry band of minstrels that support Abigail's
: postings. Poor souls!

: Abigail, maybe you should think of creating a moderated list for Perl
: (moderated by you, of course). Or, maybe you should stick to newsgroups that
: are more appropriately labelled. I thought the ".misc" meant
: miscellaneous....i.e. miscellaneous questions/postings about perl. Surely
: this doesn't mean that if anyone mentions the word "UNIX" or "C" or anything
: else along with the word "Perl" it becomes "not a Perl question".

: ..... maybe ".misc" stands for "misconception"... or "miscreant" ....


Brad, maybe you should think of creating a newsgroup for Perl
(unmoderated, of course). Or maybe you should stick to newsgroups
that are more appropriately labelled.

Like: comp.lang.perl.I.don't.care.about.the.tenents.that.have.evolved. \
over.the.last.20.years.of.Usenet.because.*I*.am.here.now.and.I.will.     \
decide.how.it.is.going.to.be.from.now.on

or: comp.lang.perl.FAQs.and.questions.that.are.NOT.about.Perl


[ so long to those 40 lines again ]


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 14 Jul 1999 17:07:59 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Greedy regular expression...
Message-Id: <378D265F.B540DE06@mcmahon.qal.berkeley.edu>

Joan Richards wrote:

> I've got a little subroutine that replaces a line in my configuration
> file with another.  So, let's say that my config was:
> ...
>   if (/$old_line/)

> It looks like my /$old_line/ might be grabbing everything starting with
> "foo", however, I don't want it to do this.  I only want it to grab
> "foo".
>

Yup, that's exactly what's happening. If you just want to match the whole
string, there's no need for a regular expression at all;

if ($_ eq $old_line)

will do fine.

If you insist on using regular expressions, you can do:

if (/^$old_line$/)

but there's not much point to it.


--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting -
aperrin@mcmahon.qal.berkeley.edu
            I'M LOOKING FOR ANOTHER EXPERIENCED ACCESS
               DEVELOPER - CONTACT ME IF INTERESTED.
        http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Thu, 15 Jul 1999 00:38:56 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Greedy regular expression...
Message-Id: <slrn7oqao4.sv.*@dragons.duesouth.net>

On Wed, 14 Jul 1999 23:44:59 GMT, Joan Richards <richj@home.com> poured
coffee onto a keyboard, producing the following in comp.lang.perl.misc: 
: However, when I call my replace subroutine to remove foo, then it will
: remove both foo and foobar 30.

Not only that, but it'll also match the word catfoo.
 
:   if (/$old_line/)
        ^         ^

You want to use some anchors there.

Maybe one of

    /^$old_line$/

    or,

    /^\s*$old_line\s*$/
    
    or

    /\b$old_line\b/

or something totally different.

man perlre
perldoc perlre

: Any suggestions?

HTH,

: -J

--Matthew


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

Date: Thu, 15 Jul 1999 00:38:54 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Hash Size Limit?
Message-Id: <slrn7oqa13.sv.*@dragons.duesouth.net>

[CC'd using coffee on pages from _Learning_Python_]

On Wed, 14 Jul 1999 23:39:22 GMT, jrt915@hotmail.com poured coffee onto
a keyboard, producing the following in comp.lang.perl.misc: 
: Does anybody know if there is a size limit on hashes?  I assume they do
: their processing in memory, so maybe the limit is a system resource
: constraint.

The perl manual page does:

man perl:
 ...
                           Unlike most Unix utilities, Perl does not arbitrarily limit the
       size of your data--if you've got the memory, Perl can slurp in your whole file as a
       single string.  Recursion is of unlimited depth.  And the tables used by hashes
       (sometimes called "associative arrays") grow as necessary to prevent degraded
       performance.
 ...

: I am thinking about reading in two sets of data and putting them each
: in a multi-dimensional hash so I can do some easy referencing,
: comparison and processing.  Hashes are an ideal solution, but the size
: of them could be in the hundreds or records.

If the size gets to be too big, you can always use a disk based hash,
such as DB_File.
 
: Thanks.

HTH,

--Matthew


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

Date: 15 Jul 1999 01:10:42 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Hash Size Limit?
Message-Id: <7mjcei$ibi$6@fcnews.fc.hp.com>

jrt915@hotmail.com wrote:
: Greetings.

: Does anybody know if there is a size limit on hashes?

The amount of available memeory in your system. And perl is rather
efficient at using it up quickly :)

Andrew


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

Date: Thu, 15 Jul 1999 01:53:52 GMT
From: avisong@widomaker.com (George Avison)
Subject: Help: reading from COM1
Message-Id: <378d3d1b.123015447@news.widomaker.com>

I'm trying to read a text file coming through COM1 on an NT 4.0
system.  I'm using the following commands in a Perl script:

  open (Scanner, "COM1") or die "Can't open COM1/n";
  $h=0;
  while ($line = Scanner) {
    $linearray[$h] = $line;
    $h++;
 }

The open command seems to accept okay, but my script seems to hang
after that (in the 'while' line).  I know that the expected data is
getting transmitted into COM1 -- is there more that I need to do to be
able to read from COM1?  

Thanks for any help you can give me -- I'm obviously a Perl and NT
rookie.


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

Date: Thu, 15 Jul 1999 00:38:52 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: How can I use image as a submit botton ?
Message-Id: <slrn7oq9oj.sv.*@dragons.duesouth.net>

[CC'd with a photocopier]

And so it happened, on Thu, 15 Jul 1999 08:14:00 +0900, Yeong
Mo/Director Hana co." <factory@factory.co.kr> typed random characters
into perl, and ended up with the following posted to comp.lang.perl.misc: 
: How can I use image as a submit botton ?

I'd imagine you'd ask in a group where they talk about things that have
submit bottons.
 
: or text ?

Or text.

HTH,

--Matthew


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

Date: Wed, 14 Jul 1999 21:50:40 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: how many files can you open?
Message-Id: <378D3E70.3ED746A@rochester.rr.com>

Jobin James wrote:
 ...
is there any limit on the number of files

> that can be kept open simultaneously?
> i was trying to open 60+ files at the same
> time, but it always stops at the 56th one.

 ...
Maybe your OS has a limit?  What is your OS?  What version?  How much
memory?  What error message do you get exactly?



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

Date: 14 Jul 1999 18:55:21 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: how many files can you open?
Message-Id: <ylyagi8ynq.fsf@windlord.stanford.edu>

Bob Walton <bwalton@rochester.rr.com> writes:
> Jobin James wrote:
> ...
> is there any limit on the number of files

>> that can be kept open simultaneously?
>> i was trying to open 60+ files at the same
>> time, but it always stops at the 56th one.

> ...
> Maybe your OS has a limit?  What is your OS?  What version?  How much
> memory?  What error message do you get exactly?

Given that number, he's probably using Solaris, which by default has a
limit of 64 file descriptors (ridiculously low).  ulimit/unlimit should be
able to fix this.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 15 Jul 1999 00:14:23 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How to delete an element in the middle of an array
Message-Id: <7mj94v$frf$3@info2.uah.edu>

In article <378D2108.F6D12C7F@torranceweb.com>,
	Steve Montgomery <monty@torranceweb.com> writes:
: If I read a database (plain text file) into an array, how do I delete
: one of lines of the database (one element - let's call it $databse[10])
: and shift the remaining lines up to fill the gap.

Read what the Fine Manual has to say about Perl's splice() operator.

Greg
-- 
Windows was created to keep the stoopid people away from Unix, you know.
An "MS advocate" is already beneath contempt.
    -- Tom Christiansen


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

Date: Thu, 15 Jul 1999 03:28:43 +0300
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: How to delete an element in the middle of an array
Message-Id: <blade-1507990328430001@durandal.janton.fi>

In article <378D2108.F6D12C7F@torranceweb.com>, Steve Montgomery
<monty@torranceweb.com> wrote:

> If I read a database (plain text file) into an array, how do I delete
> one of lines of the database  ( one element - let's call it $databse[10]
> )
> and shift the remaining lines up to fill the gap.

The splice() function is your friend. This will do what you described:

#!/usr/bin/perl -w
use strict;

my @database = qw/00 01 02 03 04 05 06 07 08 09 10 11 12 13 14/;
my $removed = splice(@database, 10, 1);

print "database is now: @database\n";
print "$removed was removed\n";

> I've seen a DELETE command when using associative arrays but nothing
> in my book talks about standard arrays.
> 
> Is there also a simple way to delete many elements at one time? If you
> delete one, then I'm assuming the remaining elements will be called by
> a number that is one less than it was called before. Is deleting one at
> a time the only way to go?

The second argument for splice() is just for that:

my @removed = splice(@database, 5, 7);

-- 
Sami Rosenblad -- blade@leela.janton.fi -- running linux since 1999


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

Date: Thu, 15 Jul 1999 01:08:53 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: How to delete an element in the middle of an array
Message-Id: <slrn7oqb66.sv.*@dragons.duesouth.net>

[The bullet was loaded, the gun was cocked, the CC was sent]

On Wed, 14 Jul 1999 16:45:12 -0700, Steve Montgomery
<monty@torranceweb.com> held some poor sysadmin at gunpoint, and typed
the following into comp.lang.perl.misc: 
: If I read a database (plain text file) into an array, how do I delete
: one of lines of the database  ( one element - let's call it $databse[10] )
: and shift the remaining lines up to fill the gap.

splice

Also, you do know that variable names are not limited to 7 characters,
don't you?

@database would be so much easier on the eyes.

: I've seen a DELETE command when using associative arrays but nothing
: in my book talks about standard arrays.

No...

DELETE is a subroutine that is called on a tied hash.

delete is a function to delete an element (or more) of a tied hash.

: Is there also a simple way to delete many elements at one time? If you
: delete one, then I'm assuming the remaining elements will be called by
: a number that is one less than it was called before. Is deleting one at
: a time the only way to go?

splice, if you know the indices of the elements you wish to delete.

grep, if you want to delete/save elements based on a certain pattern.
 
: Thanks so much,

HTH,

: Steve

--Matthew


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

Date: 15 Jul 1999 00:00:43 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: I want to do something interesting with ranges
Message-Id: <7mj8bb$ibi$1@fcnews.fc.hp.com>

Steve Simmons (scs@ans.net) wrote:
(an interesting idea about extending .. for hash slices)

I think a better way to do this, instead of burdening .. with
additional magic is to define another variable valid during foreach,
grep, and map that is the current index. Assuming that we call this
$.., we'd write:

@lines=grep {($..==4)../MATCH/} (<STDIN>);

Andrew


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

Date: 15 Jul 1999 01:07:56 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: perl 5.005_3 on hp/ux 10.20
Message-Id: <7mjc9c$ibi$5@fcnews.fc.hp.com>

H. Merijn Brand (h.m.brand@hccnet.nl) wrote:
: Warning: -Ae is ignored by cpp, use -Aa instead. Contact with HP
:          learned that this might be an HP bug :-(

Baloney. -Ae and -Ae both use /lib/cpp.ansi. Now if you're using the
bundled HP-UX compiler instead of the one we charge for, that is a bug
(probably both that we bundle a braindead compiler, and charge for a
decent one).

Andrew


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

Date: Thu, 15 Jul 1999 01:25:15 GMT
From: spertus@mills.edu
Subject: Q: panic pp_iter with foreach
Message-Id: <7mjd9i$1se$1@nnrp1.deja.com>

I am getting the following error:

    panic: pp_iter at treasure.pl line 191, <SOURCE> chunk 1.

I got the following information from perldiag:

    (P) The foreach iterator got called in a non-loop context frame.

Could somebody tell me what this means or what I am doing wrong?  I was
unable to find any further documentation on loop contexts or pp_iter.

Here are the relevant lines from my program:

182:  while($bigline = <SOURCE>) {
183:    print STDERR "\nBIGLINE = /$bigline/\n";
184:    if ($bigline) {
185:      @lines = split /\n|\r|\f/, $bigline;
186:      $numlines = @lines;
187:      print STDERR "Number of lines = $numlines\n";
188:      foreach $line (@lines) {
189:	    print STDERR "\nLine: $line\n";
190:      }
191:      foreach $line (@lines) {
192:	    print STDERR "Current line: /$line/\n";
            # do a bunch of stuff, none of it modifying $line or
       	    # leaving the loop
        }
      }
    }

I have read the FAQ, searched Usenet, used "-w" and "-d", etc.  I am
using perl5.005_03 built for i386-linux under Redhat 6.  I would also be
grateful for any workarounds.

Ellen Spertus


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 15 Jul 1999 00:07:35 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Splitting into two-character array
Message-Id: <378D264A.CD986767@email.com>

I know if I want an array of the characters in a string I can do this:
@array = split(//, $str);

But is there a quick-and-dirty way to split by every two characters instead of
one? For example @array would equal ('ab', 'cd') instead of ('a', 'b', 'c',
'd'). 

Thanks in advance.
Jordan Hiller


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

Date: 15 Jul 1999 00:20:47 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Splitting into two-character array
Message-Id: <7mj9gv$frf$5@info2.uah.edu>

In article <378D264A.CD986767@email.com>,
	Jordan Hiller <hiller@email.com> writes:
: But is there a quick-and-dirty way to split by every two characters
: instead of one? For example @array would equal ('ab', 'cd') instead
: of ('a', 'b', 'c', 'd'). 

    @array = $str =~ /(..?)/g;

Greg
-- 
Democracy: Two wolves and a sheep voting on what's for dinner.


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

Date: Wed, 14 Jul 1999 16:57:38 -0700
From: Rita Van Leer <zigmart@zigmart.com>
Subject: stripping html tags
Message-Id: <378D23F1.3BB3CCEC@zigmart.com>


i am running an auction site done with perl and it auto sends email with

the description of the item

the only problem is that if the user has html tags in the description it

passes this also and looks like crap

is there any way to automatically strip the html tags out of the
description before it is sent



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

Date: 15 Jul 1999 00:17:44 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: stripping html tags
Message-Id: <7mj9b8$frf$4@info2.uah.edu>

In article <378D23F1.3BB3CCEC@zigmart.com>,
	Rita Van Leer <zigmart@zigmart.com> writes:
: is there any way to automatically strip the html tags out of the
: description before it is sent

People ask this all the time.  That makes yours a Frequently Asked
Question.  There is a document called a FAQ (Fart on All Queriers)
that has collections of these Frequently Asked Questions and high
quality responses to them.

Please avail yourself of this wonderful resource.

Greg
-- 
Nine out of ten men who try Camels prefer women.


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

Date: Wed, 14 Jul 1999 21:54:09 -0700
From: "Jim Bell" <lansong@idirect.com>
Subject: time funciton or module
Message-Id: <378d3fb2@nemo.idirect.com>

Is there a built-in function or existing module which
generates the current date in the format of 19990714?

Thanks for your time!

--
_____
Regards,
Jim Bell




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

Date: 15 Jul 1999 01:20:06 GMT
From: lvirden@cas.org
Subject: Re: Why Perl instead of ColdFusion?
Message-Id: <7mjd06$kiv$1@srv38.cas.org>


According to brian d foy <brian@pm.org>:
:In article <7mghiu$1nn$1@nnrp1.deja.com>, Henry Porter <porterh@yahoo.com>
:wrote:
:>To me, the huge advantage, the real value of CF, and the main reason I'm
:>asking this question, is time of development.  A given project can
:>be developed in CF in a fraction of the time it would take to create it
:>in Perl. I do not consider my Perl skills to be on such a level that I

Perhaps it would be worthwhile to see what features of ColdFusion are
referenced when discussing "time of development".  Could it be that the
original poster just isn't aware of appropriate perl tools?  Or even, gasp,
that with the addition of some new perl tools, perl would take away the
unimaginable but slightly possible edge to which Mr. Porter refers?
-- 
<URL: mailto:lvirden@cas.org> Quote: Saving the world before bedtime.
<*> O- <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

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

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


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