[17498] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4918 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 18 14:10:31 2000

Date: Sat, 18 Nov 2000 11:10:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974574615-v9-i4918@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 18 Nov 2000     Volume: 9 Number: 4918

Today's topics:
        qq~ <jenshoja@t-online.de>
    Re: qq~ (Prasanth A. Kumar)
    Re: qq~ (Honza Pazdziora)
    Re: Question about Buttons and Subroutines (Honza Pazdziora)
    Re: reading post variable values from a html form with  (Honza Pazdziora)
    Re: reading post variable values from a html form with  (Garry Williams)
        Reading Serial ports? <jaford@watford53.freeserve.co.uk>
        Send a form to a script AND email/file meniac@my-deja.com
    Re: sendmail with cgi.pm? (Honza Pazdziora)
        simple perl script question james_offer@my-deja.com
        simple question: can Perl do this? (talking to a perman <-@-.com>
    Re: simple question: can Perl do this? (talking to a pe <kd@panix.com>
    Re: simple question: can Perl do this? (talking to a pe (Honza Pazdziora)
        storing and retrieving <textarea> items <david.featley@virgin.net>
    Re: string checking problem <uri@sysarch.com>
    Re: will this locking get me in trouble? (Honza Pazdziora)
        XSUB output strings gleNOSPAMnn@greenoak.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 18 Nov 2000 18:02:17 +0100
From: "news" <jenshoja@t-online.de>
Subject: qq~
Message-Id: <8v6cnk$jpj$07$1@news.t-online.com>

Hello Cracks,
some questions what does this mean:
$variab=qq~\$~
What does qq~....~.
Thanx a lot
jens




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

Date: Sat, 18 Nov 2000 17:24:21 GMT
From: kumar1@home.com (Prasanth A. Kumar)
Subject: Re: qq~
Message-Id: <m34s15uray.fsf@C654771-a.frmt1.sfba.home.com>

"news" <jenshoja@t-online.de> writes:

> Hello Cracks,
> some questions what does this mean:
> $variab=qq~\$~
> What does qq~....~.
> Thanx a lot
> jens

The 'qq' allows the character which follows it to be used as a quoting
operator. This is useful is the string to be quoted has lots of the
standard " or ' characters embedded in it without escaping them.

-- 
Prasanth Kumar
kumar1@home.com


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

Date: Sat, 18 Nov 2000 17:22:04 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: qq~
Message-Id: <G48DKs.qx@news.muni.cz>

On Sat, 18 Nov 2000 18:02:17 +0100, news <jenshoja@t-online.de> wrote:
> Hello Cracks,
> some questions what does this mean:
> $variab=qq~\$~

The same as

	$variab = '$';
or
	$variab = "\$";

> What does qq~....~.

Double quoted interpolated string. See man perlop(1).

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 18 Nov 2000 15:23:56 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Question about Buttons and Subroutines
Message-Id: <G4883w.F50@news.muni.cz>

On Fri, 17 Nov 2000 23:52:00 GMT, pape_98@my-deja.com <pape_98@my-deja.com> wrote:

> This is the Sub that I want to call.
> sub add {

[...]

> print end_html;
> }
> 
> These are the methods I've tried.
> 
> $Add->button(name=>'Add', value=>'Add A User', OnClick=>add());
> 
> $Add->button(text=>'Add A User', command=>add());
> 
> Both of them give me the same output.
> They call the Sub without me having to click on the button. i.e the Sub
> is called when I get onto the page.
> Can you tell me what I'm missing here.

You probably want to say

	$Add->button(name=>'Add', value=>'Add A User', OnClick=>"add()");

But note that you cannot call from browser window a subroutine in
server script this way.

Hope this helps,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 18 Nov 2000 15:09:53 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: reading post variable values from a html form with post or get?
Message-Id: <G487GH.1F1@news.muni.cz>

On Mon, 13 Nov 2000 12:49:16 -0800, Mark D <mark@dtekunlimited.com> wrote:
> 
> Obviously, this is a simplistic representation, and I do not consider myself
> a programmer, but I do have some understanding (from making changes to
> personalize OP's code)
> I have a freeware script that simply put all the variables into a html
> screen as an array, but I need to keep the separate (not in an array, I
> believe)
> 
> any examples would be greatly appreciated...

	my $1First_Name = $array[34];

will copy the thirtyfifth element of array @array to scalar variable
$1First_Name.

Hope this helps,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 18 Nov 2000 18:21:59 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: reading post variable values from a html form with post or get?
Message-Id: <bNzR5.887$xb1.55650@eagle.america.net>

On Sat, 18 Nov 2000 15:09:53 GMT, Honza Pazdziora <adelton@fi.muni.cz>
wrote:
>On Mon, 13 Nov 2000 12:49:16 -0800, Mark D <mark@dtekunlimited.com>
>wrote:
>>
>> Obviously, this is a simplistic representation, and I do not
>> consider myself a programmer, but I do have some understanding
>> (from making changes to personalize OP's code) I have a freeware
>> script that simply put all the variables into a html screen as an
>> array, but I need to keep the separate (not in an array, I believe)
>>
>> any examples would be greatly appreciated...
>
>	my $1First_Name = $array[34];
>
>will copy the thirtyfifth element of array @array to scalar variable
>$1First_Name.

Will it?  Did you bother to try that before posting it?  

    $ cat x
    #!/usr/local/bin/perl -w
    use strict;
    my @array = (1..50);
    my $1First_Name = $array[34];
    print "$1First_Name\n";
    $ perl x
    Can't use global $1 in "my" at x line 4, near "my $1"
    Bareword found where operator expected at x line 4, near
    "$1First_Name"
	    (Missing operator before First_Name?)
    syntax error at x line 4, near "$1First_Name "
    Execution of x aborted due to compilation errors.
    $ 

-- 
Garry Williams


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

Date: Sat, 18 Nov 2000 15:42:32 +0000
From: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Reading Serial ports?
Message-Id: <3A16A368.D603CB4D@watford53.freeserve.co.uk>

I would like to attach some hardware to (say) one of the control lines
of a serial port, such that I can count the number of times it 'wiggles'
up and down. I'd also like to do it in Perl.

Has anyone any ideas or pointers, please?

Regards: Jim Ford



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

Date: Sat, 18 Nov 2000 16:23:16 GMT
From: meniac@my-deja.com
Subject: Send a form to a script AND email/file
Message-Id: <8v6adf$n6k$1@nnrp1.deja.com>

I have a form on my site where the data is send to a remote hosted
script, and I have no access to make changes in that.

I would like to have one of the fields information saved to a file on
my own server when the user submit the form, or if that can't be done
have the field information emailed to me.

Are any of this possible?

Regards
Mike


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


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

Date: Sat, 18 Nov 2000 15:21:38 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: sendmail with cgi.pm?
Message-Id: <G48802.D2w@news.muni.cz>

On Sat, 18 Nov 2000 09:19:14 GMT, xlr6drone@my-deja.com <xlr6drone@my-deja.com> wrote:
> I am using a guestbook script with cgi.pm but I am unable to get
> the sendmail program to work.  I want the users inputted data to
> be sent to an email address.  The sendmail function is at the
> bottom of my code.  It has worked with other scripts but obviously
> cgi.pm works differently in this area.  Would I have to use the
> param() in order to use the variables in the sendmail program?  If
> so how would this be done?  Any suggestions would be
> appreciated.

[ long code snipped ]

> open (MAIL, "|/usr/lib/sendmail -t") || &ErrorMessage("error
> opening sendmail");
> 
> print MAIL "To: lex\@mindspring.com\n";
> print MAIL "From: test\@mail.com\n";
> print MAIL "Subject: $subject\n\n";
> print MAIL "$location\n\n";
> 
> close (MAIL);

What doesn't work? What doesn't it do that you'd like it to do? Does
the open open at all? What's the return status of close? What if you
redirect 2> to some error log file?

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 18 Nov 2000 16:50:30 GMT
From: james_offer@my-deja.com
Subject: simple perl script question
Message-Id: <8v6c0l$oe3$1@nnrp1.deja.com>

Hi

I'm sure there is a way to do this, but I don't know how - I have very
little experience in Perl. Anyway, how would I go about creating a Perl
script that contains some basic HTML and pass a variable into it to
display a picture for example?

i.e.:

display.pl?picture=myphoto.jpg

The end result a basic HTML page with the photo link dynamically
generated. I really don't want to be stuck with 100s of individual HTML
files and Perl is the only scripting language I have access too at this
moment in time.

Any suggestions?

Thanks,
James.


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


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

Date: Sat, 18 Nov 2000 15:58:26 -0800
From: "Mauro" <-@-.com>
Subject: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <8v65db$4nd$1@nslave3.tin.it>

I think this is a simple question but I can't figure out how can I do it:
I've a site with a PERL  CGI   that  performs thousands of consecutive
substitutions like:

$foobar=~s/.*un.*/one/;
$foobar=~s/.*deux.*/two/;
$foobar=~s/.*trois.*/three/;
$foobar=~s/.*quatre.*/four/;
$foobar=~s/.*cinq.*/five/;
and so on...

doing thousands of theese substitutions takes too much time in perl

I saw the same substitutions executed by a unix SED (all contained in a
script-file) takes a lot less time

The server is a Intel P3-500,  start time of the  SED -f script.sed  is
about 8 seconds because script.sed is 10MB (!) in size  but the "answer"
time from STDIN to STDOUT  is about 1 sec.

how can I open SED only _ONE TIME_(ie. when I start Apache..) and  do that
when  the user calls the CGI  it just pass  the request (a french number)
to the STDIN of SED and read STDOUT?

(I know it could be a problem if two+ users do a request at the same/near
time)

thanks to any guru who know how to do it!

Marco




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

Date: 18 Nov 2000 16:36:33 GMT
From: Ken Dunlap <kd@panix.com>
Subject: Re: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <8v6b6h$rtl$1@news.panix.com>

If it is possible for you to eliminate the metecharacters in the 
regular expressions, they should compile and run much faster.

Ken

Mauro <-@-.com> wrote:
> I think this is a simple question but I can't figure out how can I do it:
> I've a site with a PERL  CGI   that  performs thousands of consecutive
> substitutions like:

> $foobar=~s/.*un.*/one/;
> $foobar=~s/.*deux.*/two/;
> $foobar=~s/.*trois.*/three/;
> $foobar=~s/.*quatre.*/four/;
> $foobar=~s/.*cinq.*/five/;
> and so on...

> doing thousands of theese substitutions takes too much time in perl

> I saw the same substitutions executed by a unix SED (all contained in a
> script-file) takes a lot less time

> The server is a Intel P3-500,  start time of the  SED -f script.sed  is
> about 8 seconds because script.sed is 10MB (!) in size  but the "answer"
> time from STDIN to STDOUT  is about 1 sec.

> how can I open SED only _ONE TIME_(ie. when I start Apache..) and  do that
> when  the user calls the CGI  it just pass  the request (a french number)
> to the STDIN of SED and read STDOUT?

> (I know it could be a problem if two+ users do a request at the same/near
> time)

> thanks to any guru who know how to do it!

> Marco



-- 
--
The only thing to fear is fearlessness
					REM


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

Date: Sat, 18 Nov 2000 17:18:39 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <G48DF3.K5o@news.muni.cz>

On Sat, 18 Nov 2000 15:58:26 -0800, Mauro <-@-.com> wrote:
> I think this is a simple question but I can't figure out how can I do it:
> I've a site with a PERL  CGI   that  performs thousands of consecutive
> substitutions like:
> 
> $foobar=~s/.*un.*/one/;
> $foobar=~s/.*deux.*/two/;
> $foobar=~s/.*trois.*/three/;
> $foobar=~s/.*quatre.*/four/;
> $foobar=~s/.*cinq.*/five/;
> and so on...
> 
> doing thousands of theese substitutions takes too much time in perl

How about

	my %translate = qw(
		un	one
		deux	two
		trois	three
		quatre	four
		cinq	five
		);
	my $keys = join '|', keys %translate;
	$foobar =~ s/.*($keys).*/$translate{$keys}/e;

> I saw the same substitutions executed by a unix SED (all contained in a
> script-file) takes a lot less time
> 
> The server is a Intel P3-500,  start time of the  SED -f script.sed  is
> about 8 seconds because script.sed is 10MB (!) in size  but the "answer"
> time from STDIN to STDOUT  is about 1 sec.
> 
> how can I open SED only _ONE TIME_(ie. when I start Apache..) and  do that
> when  the user calls the CGI  it just pass  the request (a french number)
> to the STDIN of SED and read STDOUT?

Use IPC::Open2, but of course different CGI scripts won't share the
handle. You'd need to run under mod_perl or similar to achieve that.

It's much better to fix the Perl code to run fast that to run external
process to achieve the same result.

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 18 Nov 2000 16:05:35 -0000
From: "David Featley" <david.featley@virgin.net>
Subject: storing and retrieving <textarea> items
Message-Id: <fExR5.2976$3k.64144@news6-win.server.ntlworld.com>

I am trying to store a number of fields including the contents of a
<textarea> field in a text file using join etc, and then in another script
retrieve it using split. This all works fine unless the data in the text
area contains newlines or carriage returns.

I can sort this by chomping the field which strips it out but obviously I
want to keep all the formatting entered into the text area.

Can anybody point me in the right direction

Thanks




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

Date: Sat, 18 Nov 2000 16:40:45 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: string checking problem
Message-Id: <x71yw9fd2q.fsf@home.sysarch.com>

>>>>> "f" == fhinchey  <fhinchey@my-deja.com> writes:

  f>     while ($file = readdir(FOO)) {
  f>         push @list, $file;
  f>     }

that is overkill. just slurp in the dir like this:

	@list = readdir( FOO ) ;

  f> @sorted = sort{uc($a) cmp uc($b)}@list;

  f> Does this give you enough to go on? BTW, a weird thing is sometimes
  f> this code actually works, then it stops working (on the same file
  f> name). it's really frustrating!

no, it is not enough. i asked for input DATA, not just the code. and you
keep saying it stops working which is meaningless. what does it do when
it is working and what does it do when it is not working? show the
RESULTS so we can see something. the code looks fine on the surface and
you say it works most of the time. do you get it? we can't fix something
if it looks like it works?

and don't post jeopardy style. put your reply AFTER the edited quotes
from the previous post.

uri

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


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

Date: Sat, 18 Nov 2000 15:05:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: will this locking get me in trouble?
Message-Id: <G4878H.Knv@news.muni.cz>

On Sun, 12 Nov 2000 17:38:46 GMT, webqueen, queen of the web <webqueen@my-deja.com> wrote:
> I'm updating a file from a remote system using File::Remote. Its am
> htaccess password file, so Apache is using it to validate logins on the
> local node. Also, perscripts open it (with my $r=flock(P, LOCK_SH) and
> read from it node. No updates to the file occur on the local node, only
> reads from Perl or Apache.
> 
> Is this safe? I don't think that file locking is possible with
> File::Remote from what I can tell. Or will I discover a corrupt file one
> of these days when Perl and/or Apache are reading when a remote update
> comes in?

Since no lock appears in the Remote.pm at all, there is a slight
chance that the file may be hit when only half of it has been written,
so the logins from the other half will not be found until the copy
went trought well.

Your best bet is to copy the file to some temporary location
(".htaccess.new.$$" might be a reasonable try) and then do rename,
which is atomic. It will also give you chance to check -s on the
copied file, so that you don't create corrupted result because of the
filesystem being full.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 18 Nov 2000 16:38:14 GMT
From: gleNOSPAMnn@greenoak.com
Subject: XSUB output strings
Message-Id: <3A16B003.C5515785@greenoak.com>

I have a question about output strings with XSUB. If I simply want to
have an output string parameter, the following appears to work fine:

void
newfunc(instring,outstring)
   char *instring
   char *outstring
   CODE:
   strcpy(outstring, instring);
   OUTPUT:
   outstring


My question however, is: how much space has been allocated for outstring?
How do I know how long a string I can put into it? How can I safely ensure
that enough space has been allocated for it? Thanks.


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

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


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