[19070] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1265 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 8 03:07:09 2001

Date: Sun, 8 Jul 2001 00:05:08 -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: <994575908-v10-i1265@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 8 Jul 2001     Volume: 10 Number: 1265

Today's topics:
        $key function in perl??? Code question peter@devries.tv
    Re: $key function in perl??? Code question <dbe@wgn.net>
    Re: $key function in perl??? Code question <dscarlett@optushome.com.au>
        automatic form submission <creafin1998@yahoo.com>
    Re: automatic form submission <tony_curtis32@yahoo.com>
    Re: automatic form submission <dbe@wgn.net>
    Re: automatic form submission (Smiley)
    Re: Command line script to FTP a file to server?? <james@zephyr.org.uk>
        FAQ: Can I do [task] in Perl? <faq@denver.pm.org>
        Filtering mail based on size <no_sp@m.for_me.org>
        grouping characters in variables in Regexps... <NOSPAMricharddmorey@yahoo.com>
    Re: grouping characters in variables in Regexps... <dbe@wgn.net>
    Re: grouping characters in variables in Regexps... <krahnj@acm.org>
    Re: grouping characters in variables in Regexps... <redsquirreldesign@yahoo.com>
    Re: how to read multipart/form-data <redsquirreldesign@yahoo.com>
        Perl 6 (None)
        Perl and PHP (None)
    Re: Perl and PHP (Logan Shaw)
    Re: Perl and PHP <mbudash@sonic.net>
    Re: Perl and PHP (Logan Shaw)
    Re: Perl and PHP (isterin)
    Re: Perl and PHP (isterin)
    Re: Perl Regular Expressions <james@zephyr.org.uk>
    Re: Perl Regular Expressions (Tim Hammerquist)
    Re: Posting HTML table from a file? <goldbb2@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 08 Jul 2001 05:13:31 GMT
From: peter@devries.tv
Subject: $key function in perl??? Code question
Message-Id: <20010708.012251.1789366143.10447@devries.tv>

could somebody tell me why the below program is functioning correctly.  I
have not defined $keys at any point. Well not until the while loop ends
anyway  I am trying to get a string to compare against
a list of hash keys and if it doesn't exist I want to create the hash key
with the zero value and if it does st the value should be increased by
one.   I haven't found $key listed as a perl function so I'm wondering why
I am getting the desired results from the program.

'Im new to perl so any insight would be helpful.

#!/usr/bin/perl
while (<>) {
        @fields = split;
                if ($fields[1] != $key) {
                        %sendhost = (%sendhost, @fields[1], "1");
                #       print $fields[1]," ",$sendhost{$fields[1]},"\n"; }
                else {
                        $sendhost{$fields[1]} = $sendhost{$fields[1]} + 1;
                #       print $fields[1]," ",($sendhost{$fields[1]},"\n");
                }
        }
foreach $key(keys(%sendhost)) { print $key," ", $sendhost{$key},"\n"; }


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

Date: Sat, 07 Jul 2001 22:46:20 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: $key function in perl??? Code question
Message-Id: <3B47F3AC.D4E847A4@wgn.net>

peter@devries.tv wrote:
> 
> could somebody tell me why the below program is functioning correctly.  I
> have not defined $keys at any point. Well not until the while loop ends
> anyway  I am trying to get a string to compare against
> a list of hash keys and if it doesn't exist I want to create the hash key
> with the zero value and if it does st the value should be increased by
> one.   I haven't found $key listed as a perl function so I'm wondering why
> I am getting the desired results from the program.
> 
> 'Im new to perl so any insight would be helpful.
> 
> #!/usr/bin/perl
> while (<>) {
>         @fields = split;
>                 if ($fields[1] != $key) {
>                         %sendhost = (%sendhost, @fields[1], "1");
>                 #       print $fields[1]," ",$sendhost{$fields[1]},"\n"; }
>                 else {
>                         $sendhost{$fields[1]} = $sendhost{$fields[1]} + 1;
>                 #       print $fields[1]," ",($sendhost{$fields[1]},"\n");
>                 }
>         }
> foreach $key(keys(%sendhost)) { print $key," ", $sendhost{$key},"\n"; }

Try more like (untested):

my %sendhost;
while (<>) {
	my @fields = split;
	$sendhost{$fields[1]}++;
}
foreach my $key (keys %sendhost) {
	print "$key=$sendhost{$key}\n";
}

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


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

Date: Sun, 08 Jul 2001 06:14:33 GMT
From: "David Scarlett" <dscarlett@optushome.com.au>
Subject: Re: $key function in perl??? Code question
Message-Id: <dTS17.4914$A5.12159@news1.eburwd1.vic.optushome.com.au>

<peter@devries.tv> wrote in message
news:20010708.012251.1789366143.10447@devries.tv...
> could somebody tell me why the below program is functioning correctly.  I
> have not defined $keys at any point. Well not until the while loop ends
> anyway  I am trying to get a string to compare against
> a list of hash keys and if it doesn't exist I want to create the hash key
> with the zero value and if it does st the value should be increased by
> one.   I haven't found $key listed as a perl function so I'm wondering why
> I am getting the desired results from the program.
>
> 'Im new to perl so any insight would be helpful.

By the looks of it, the $key scalar is undefined. Since you're comparing it
to the second element of the array, @fields, it checks if it is defined...

ie. if $fields[1] is defined, it will execute the first block (ie %sendhost
= ......), otherwise it will execute the second (else) block.

It's just like having "if (defined($fields[1])) {"


>
> #!/usr/bin/perl
> while (<>) {
>         @fields = split;
>                 if ($fields[1] != $key) {
>                         %sendhost = (%sendhost, @fields[1], "1");
>                 #       print $fields[1]," ",$sendhost{$fields[1]},"\n"; }
>                 else {
>                         $sendhost{$fields[1]} = $sendhost{$fields[1]} + 1;
>                 #       print $fields[1]," ",($sendhost{$fields[1]},"\n");
>                 }
>         }
> foreach $key(keys(%sendhost)) { print $key," ", $sendhost{$key},"\n"; }




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

Date: Sat, 7 Jul 2001 22:05:35 -0500
From: "John Smith" <creafin1998@yahoo.com>
Subject: automatic form submission
Message-Id: <tkfj2l2l6pe45f@corp.supernews.com>

Does anyone know how to submit a form automatically (cannot require buttons
or user interaction) within a perl script?  I've tried the following with a
few variations:

print "
<FORM NAME =\"Somescript\" METHOD=\"POST\" ACTION=\"script.pl\"> <input
type=\"hidden\" name=\"config\" value=\"$configvar\">   <input
type=\"hidden\" name=\"myvar\" value=\"$myvar\"
onChange=\"Somescript.submit()\"> </FORM>";

Please help.

Thanks in advance.







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

Date: 07 Jul 2001 21:59:10 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: automatic form submission
Message-Id: <87ae2gw2gx.fsf@limey.hpcc.uh.edu>

>> On Sat, 7 Jul 2001 22:05:35 -0500,
>> "John Smith" <creafin1998@yahoo.com> said:

> Does anyone know how to submit a form automatically
> (cannot require buttons or user interaction) within a
> perl script?

perldoc lwpcook

hth
t
-- 
Beep beep!  Out of my way, I'm a motorist!


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

Date: Sat, 07 Jul 2001 20:15:12 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: automatic form submission
Message-Id: <3B47D040.E34A44FA@wgn.net>

John Smith wrote:
> 
> Does anyone know how to submit a form automatically (cannot require buttons
> or user interaction) within a perl script?  I've tried the following with a
> few variations:
> 
> print "
> <FORM NAME =\"Somescript\" METHOD=\"POST\" ACTION=\"script.pl\"> <input
> type=\"hidden\" name=\"config\" value=\"$configvar\">   <input
> type=\"hidden\" name=\"myvar\" value=\"$myvar\"
> onChange=\"Somescript.submit()\"> </FORM>";

1) This is an HTML/JS question, not Perl

2) If your fields are hidden how can the user change them ?

3) Use a here-doc and get rid of all those \'s in there.

print <<EOD;
<FORM NAME="Somescript" METHOD="POST" ACTION="script.pl">
 ...etc..
EOD

4) Try a Javascript site

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


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

Date: Sun, 08 Jul 2001 06:38:08 GMT
From: gurm@intrasof.com (Smiley)
Subject: Re: automatic form submission
Message-Id: <3b47fd6f.16654147@news1.on.sympatico.ca>

John,

I'm not sure I understand what you're getting at here - but if you
want to send form data to a script without actually getting the data
from the user, it's pretty easy to do.  You'd just refer to the script
something like this :

http://www.yourserver.com/cgi-bin/yourscript.cgi?item1="Hello"&item2="There"

Your form data are item1 and item2, and their values respectively are
Hello and There.  Doing this you don't have to submit the data from a
form when you call the script.

Is that what you wanted to know?  If not, could you be a little more
specific?

On Sat, 7 Jul 2001 22:05:35 -0500, "John Smith"
<creafin1998@yahoo.com> wrote:

>Does anyone know how to submit a form automatically (cannot require buttons
>or user interaction) within a perl script?  I've tried the following with a
>few variations:
>
>print "
><FORM NAME =\"Somescript\" METHOD=\"POST\" ACTION=\"script.pl\"> <input
>type=\"hidden\" name=\"config\" value=\"$configvar\">   <input
>type=\"hidden\" name=\"myvar\" value=\"$myvar\"
>onChange=\"Somescript.submit()\"> </FORM>";
>
>Please help.
>
>Thanks in advance.



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

Date: Sun, 8 Jul 2001 02:19:11 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: Command line script to FTP a file to server??
Message-Id: <p+6aSBhPU7R7Ewr8@gratiano.zephyr.org.uk>

In message <MPG.15b147074ec0704298969b@news.edmonton.telusplanet.net>,
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> writes
>In article <igM41wVWT4R7Ew6S@gratiano.zephyr.org.uk>, james@zephyr.org.uk
>says...
>
>Thanks James.  I will look that module up.  By the way I am curious I
>have seen numerous posts where there is some kind of PGP stuff at the
>bottom like in yours.

Taken to e-mail.  Follow-ups set.

-- 
James Coupe                                                PGP Key: 0x5D623D5D
                                                                 EBD690ECD7A1F
It's me Nono small robot you know - friend of Ulysses            B457CA213D7E6
It's me Nono small robot you know - friend of Ulysses           68C3695D623D5D


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

Date: Sun, 08 Jul 2001 06:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Can I do [task] in Perl?
Message-Id: <wVS17.56$T3.171022848@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  Can I do [task] in Perl?

    Perl is flexible and extensible enough for you to use on virtually any
    task, from one-line file-processing tasks to large, elaborate systems.
    For many people, Perl serves as a great replacement for shell scripting.
    For others, it serves as a convenient, high-level replacement for most
    of what they'd program in low-level languages like C or C++. It's
    ultimately up to you (and possibly your management) which tasks you'll
    use Perl for and which you won't.

    If you have a library that provides an API, you can make any component
    of it available as just another Perl function or variable using a Perl
    extension written in C or C++ and dynamically linked into your main perl
    interpreter. You can also go the other direction, and write your main
    program in C or C++, and then link in some Perl code on the fly, to
    create a powerful application. See the perlembed manpage.

    That said, there will always be small, focused, special-purpose
    languages dedicated to a specific problem domain that are simply more
    convenient for certain kinds of problems. Perl tries to be all things to
    all people, but nothing special to anyone. Examples of specialized
    languages that come to mind include prolog and matlab.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           01.09
-- 
    This space intentionally left blank


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

Date: Sun, 08 Jul 2001 04:52:20 GMT
From: mike hardy <no_sp@m.for_me.org>
Subject: Filtering mail based on size
Message-Id: <jb4rsorq4x.fsf@analog.net>


I'm betting this is real simple but I don't know how to do it.  I've been
searching Usenet, etc., got a couple modules (probably before I should
have) and still can't figure out how to do what I want:

    Have my .forward invoke a Perl script which determines if the message
    is greater than N bytes (or lines or whatever).  If it is, only
    forward the Sender/Subject info; if it isn't send the whole thing.

I can use Mail::Audit to do everything besides the most important part -
determining the size of the message.  If the incoming email was a file I'd
have no problem determining its size.  But I don't understand what's
passed by sendmail(?) when a piece of mail comes in and is routed due to a
 .forward file.  It would be nice if I didn't have to install the MIME
module(s) because it looks like it has a lot of dependencies I don't (yet)
have installed.  Can someone help me with using Perl to determine the size
of an incoming email message? 

Thanks...

Mike
-- 



------------------------
mhardy_mail@NO_SPAM@yahoo.com

Auntie Em: Hate you, hate Kansas; took the dog - Dorothy







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

Date: Sun, 8 Jul 2001 01:58:01 -0400
From: "Richard Morey" <NOSPAMricharddmorey@yahoo.com>
Subject: grouping characters in variables in Regexps...
Message-Id: <9i8smd$4gt$1@news.fsu.edu>


Here are two similar chunks of code:

#This, with braces....
$test = "My name is {print this}";
$openp = "{";
$closep = "}";

$test=~/$openp(.*?)$closep/i;
print "$test\n";
print $1;

#This, with parentheses....
$test = "My name is (print this)";
$openp = "(";
$closep = ")";

$test=~/$openp(.*?)$closep/i;
print "$test\n";
print $1;

The first works as expected - it prints:

My name is {print this}
print this

The second, however, doesn't. It outputs:

My name is {print this}


What is wrong? Why can't I use the parentheses?
Thanks in advance for your help, or a direction to the part of the FAQ where
I can find it.

Richard Morey

***********************************
"The advancement and diffusion of knowledge is the only guardian of true
liberty." -James Madison
***********************************




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

Date: Sat, 07 Jul 2001 23:34:49 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: grouping characters in variables in Regexps...
Message-Id: <3B47FF09.D7790EC9@wgn.net>

Richard Morey wrote:
> 
> Here are two similar chunks of code:
> 
> #This, with braces....
> $test = "My name is {print this}";
> $openp = "{";
> $closep = "}";
> 
> $test=~/$openp(.*?)$closep/i;
> print "$test\n";
> print $1;
> 
> #This, with parentheses....
> $test = "My name is (print this)";
> $openp = "(";
> $closep = ")";
> 
> $test=~/$openp(.*?)$closep/i;
> print "$test\n";
> print $1;
> 
> The first works as expected - it prints:
> 
> My name is {print this}
> print this
> 
> The second, however, doesn't. It outputs:
> 
> My name is {print this}
> 
> What is wrong? Why can't I use the parentheses?
> Thanks in advance for your help, or a direction to the part of the FAQ where
> I can find it.

parens are used for grouping etc. in REs.
Try escaping them, eg: $openp = "\("; or use quotemeta on them or use \Q$var\E in RE.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


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

Date: Sun, 08 Jul 2001 06:50:39 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: grouping characters in variables in Regexps...
Message-Id: <3B4802BE.EAFE971@acm.org>

Richard Morey wrote:
> 
> Here are two similar chunks of code:
> 
> #This, with braces....
> $test = "My name is {print this}";
> $openp = "{";
> $closep = "}";
> 
> $test=~/$openp(.*?)$closep/i;
> print "$test\n";
> print $1;
> 
> #This, with parentheses....
> $test = "My name is (print this)";
> $openp = "(";
> $closep = ")";
> 
> $test=~/$openp(.*?)$closep/i;
> print "$test\n";
> print $1;
> 
> The first works as expected - it prints:
> 
> My name is {print this}
> print this
> 
> The second, however, doesn't. It outputs:
> 
> My name is {print this}
> 
> What is wrong? Why can't I use the parentheses?
> Thanks in advance for your help, or a direction to the part of the FAQ where
> I can find it.

The characters {, }, (, and ) are special in regular expressions and
have to be escaped to match the literal characters. Also the /i modifier
is not required and you should test whether the match succeeded so that
$1 will contain valid data.

#This, with braces....
$test = "My name is {print this}";
$openp = '\{';
$closep = '\}';
if ( $test =~ /$openp(.*?)$closep/ ) {
    print $1;
    }

# OR

#This, with braces....
$test = "My name is {print this}";
$openp = "{";
$closep = "}";
if ( $test =~ /\Q$openp\E(.*?)\Q$closep\E/ ) {
    print $1;
    }

# OR

#This, with braces....
$test = "My name is {print this}";
$openp = quotemeta "{";
$closep = quotemeta "}";
if ( $test =~ /$openp(.*?)$closep/ ) {
    print $1;
    }


perldoc perlre



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 08 Jul 2001 06:52:18 GMT
From: "Dave Hoover" <redsquirreldesign@yahoo.com>
Subject: Re: grouping characters in variables in Regexps...
Message-Id: <CqT17.117458$mG4.57770184@news1.mntp1.il.home.com>

Richard wrote:
[snip]
> $test = "My name is (print this)";
> $openp = "(";
> $closep = ")";
>
> $test=~/$openp(.*?)$closep/i;
> print "$test\n";
> print $1;
[snip]
> It outputs:
>
> My name is {print this}
>
>
> What is wrong? Why can't I use the parentheses?

The parentheses need to be escaped.  Here are two ways that worked for me:

$test = "My name is (print this)";
$openp = "(";
$closep = ")";

$test=~/\Q$openp\E(.*?)\Q$closep\E/i;
print "$test\n";
print $1;

AND

$test = "My name is (print this)";
$openp = '\(';
$closep = '\)';

$test=~/$openp(.*?)$closep/i;
print "$test\n";
print $1;
print "\n\n";

Notice in the second example that I used single quotes when assigning $openp
and $closep.  With double-quotes, you would have to put two backslashes
because of interpolation.  For more info on this, see: perldoc perlre.

=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave




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

Date: Sun, 08 Jul 2001 03:12:52 GMT
From: "Dave Hoover" <redsquirreldesign@yahoo.com>
Subject: Re: how to read multipart/form-data
Message-Id: <UcQ17.117219$mG4.57495078@news1.mntp1.il.home.com>

Enrico wrote:
> I got my script to work but what is stored isnt right.
> I think it is because I split the entire buffer via "\n" first to
> identify the file part.

I don't understand why you would be splitting the buffer, everything in
there is "the file part."

> I want to try not using CGI.pm and cgi-lib.

Why?

> also, it "read($file, my $buffer, 1024)", what is in $file.

$file holds the the value of the HTML form field:
<input type="file" name="file">

Typically, the input would look something like this:
C:\WINDOWS\Desktop\foo.html

> also, I am forced to run my scripts in TAINT mode, so I have to detaint
> the filename.

Good...taint mode is a good thing.  It makes you think about what you're
doing with insecure input.

> the problem is that, it endsup filtering everything out eventhough its
> just I just have "file_name.jpg"
>
> I use
> $filename=~ /^(\w+)$/;

This will never match "file_name.jpg" because of the period between
"file_name" and "jpg".

HTH,

=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave




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

Date: 7 Jul 2001 20:37:04 -0700
From: pohanl@aol.com (None)
Subject: Perl 6
Message-Id: <12124e47.0107071937.4b6870c4@posting.google.com>

Is it true Perl 6 will allow your scripts to run on the Java virtual machine?


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

Date: 7 Jul 2001 19:56:37 -0700
From: pohanl@aol.com (None)
Subject: Perl and PHP
Message-Id: <12124e47.0107071856.6b63b373@posting.google.com>

Since PHP evolved from Perl, what are the major differences between
the languages?  From my examination they look very similar and
I have had success changing minor things in php scripts to work
under Perl.  Other than that the syntax looks exactly the same.

What is so good about PHP (different from perl) that makes it so popular?


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

Date: 7 Jul 2001 22:38:36 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perl and PHP
Message-Id: <9i8kjs$b1b$1@charity.cs.utexas.edu>

In article <12124e47.0107071856.6b63b373@posting.google.com>,
None <pohanl@aol.com> wrote:
>What is so good about PHP (different from perl) that makes it so popular?

PHP executes fast.  Perl can execute fast on a web server if
you use mod_perl, but this makes the programming a little more
difficult.  That makes mod_perl less popular because it's
harder to find a team of developers who can do it right.

PHP makes it really easy to access databases -- no typing "use
DBI" and all that; database support is built-in.  Although
it's by no means *hard* to access a database in Perl, the fact
that it's easier in PHP makes it more popular.

PHP isn't as complex as Perl, so it's easier to
learn.  See above about finding developers.

I think if you study PHP and Perl in detail, you'll find
that although there are many surface similarities (which can
help in learning one if you know the other), the more you
look at the more they look different.  I can't give specific
examples since it's been years since I touched PHP, but I do
remember reaching that conclusion at once point.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Sun, 08 Jul 2001 04:56:38 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl and PHP
Message-Id: <mbudash-614A05.21564107072001@news.sonic.net>

In article <9i8kjs$b1b$1@charity.cs.utexas.edu>, logan@cs.utexas.edu 
(Logan Shaw) wrote:

> In article <12124e47.0107071856.6b63b373@posting.google.com>,
> None <pohanl@aol.com> wrote:
> >What is so good about PHP (different from perl) that makes it so popular?
> 
[snip]
> PHP makes it really easy to access databases -- no typing "use
> DBI" and all that; database support is built-in.

yeah, and if you wanna change databases, you have to go thru all your 
php code and change each of the db calls... fun...

> Although
> it's by no means *hard* to access a database in Perl, the fact
> that it's easier in PHP makes it more popular.

PHP more popular than perl? huh?
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 8 Jul 2001 00:05:53 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perl and PHP
Message-Id: <9i8pnh$kov$1@charity.cs.utexas.edu>

In article <mbudash-614A05.21564107072001@news.sonic.net>,
Michael Budash  <mbudash@sonic.net> wrote:
>In article <9i8kjs$b1b$1@charity.cs.utexas.edu>, logan@cs.utexas.edu 
>(Logan Shaw) wrote:

>> PHP makes it really easy to access databases -- no typing "use
>> DBI" and all that; database support is built-in.
>
>yeah, and if you wanna change databases, you have to go thru all your 
>php code and change each of the db calls... fun...

Hey, I didn't say it made it easy to write good, maintainable code,
just easy to access databases.  :-)

>> Although
>> it's by no means *hard* to access a database in Perl, the fact
>> that it's easier in PHP makes it more popular.
>
>PHP more popular than perl? huh?

Sorry, I meant more popular than it would otherwise be.  Or maybe more
popular than it would otherwise be relative to how popular Perl is.

Maybe it would have been better to say "more appealing to some people"
rather than "more popular".

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: 7 Jul 2001 22:37:32 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Perl and PHP
Message-Id: <db67a7f3.0107072137.21e9da46@posting.google.com>

pohanl@aol.com (None) wrote in message news:<12124e47.0107071856.6b63b373@posting.google.com>...
> Since PHP evolved from Perl, what are the major differences between
> the languages?  From my examination they look very similar and

Some syntax differences, though PHP is strictly for web programming
where Perl is all purpose.



> I have had success changing minor things in php scripts to work
> under Perl.  Other than that the syntax looks exactly the same.
> 
> What is so good about PHP (different from perl) that makes it so popular?

Nothing other than it can be easily embeded in HTML, which you can
also accomplish with Perl with embperl.  Though I prefer
HTML::Template so that my code and template HTML code are two separate
implementations.

Ilya


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

Date: 7 Jul 2001 22:39:26 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Perl and PHP
Message-Id: <db67a7f3.0107072139.39fc1607@posting.google.com>

pohanl@aol.com (None) wrote in message news:<12124e47.0107071856.6b63b373@posting.google.com>...
> Since PHP evolved from Perl, what are the major differences between
> the languages?  From my examination they look very similar and
> I have had success changing minor things in php scripts to work
> under Perl.  Other than that the syntax looks exactly the same.
> 
> What is so good about PHP (different from perl) that makes it so popular?

Also if you want someone to convince you to use PHP, you might want to
try a PHP group, since everyone here will most likely convince you
otherwise.  I think PHP is fine for lightweight web programming,
though heard of powerfull web apps were written in it too.  Perl is of
course more powerfull and mature.

Ilya


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

Date: Sun, 8 Jul 2001 02:51:44 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: Perl Regular Expressions
Message-Id: <+PFPuGmwy7R7EwrS@gratiano.zephyr.org.uk>

In message <slrn9kf28m.qbi.tadmc@tadmc26.august.net>, Tad McClellan
<tadmc@augustmail.com> writes
>>says one can find a string in which the first word is the same
>>as the last word by:
>>
>>/^(\S+)/s.*\1$/
>        ^
>        ^ slanting the wrong way. Do not retype code. Use cut/paste.
>
>I don't think you need the \s at all anyway.

I can see what it's intended to do.  Frex:

        $_ = "Patricia had always got her clothes from Chez Pat"

The first and last "words" aren't identical, and you presumably wouldn't
want that to match.  \b would probably be a better choice than \s of
course.

However, if you start getting technical about words in that manner, you
probably don't want to use \S anyway - since I've never considered
"855w00tdongleI;Love@Larry!Wall~kerplunk$$!" to be a word.

-- 
James Coupe                                                PGP Key: 0x5D623D5D
                                                                 EBD690ECD7A1F
It's me Nono small robot you know - friend of Ulysses            B457CA213D7E6
It's me Nono small robot you know - friend of Ulysses           68C3695D623D5D


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

Date: Sun, 08 Jul 2001 06:26:10 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Perl Regular Expressions
Message-Id: <slrn9kfvtg.5mb.tim@vegeta.ath.cx>

Buck Turgidson <jc_va@spamisnotcool.hotmail.com> wrote:
> I am learning about Perl, and especially regular expressions.  I am a bit confused
> about what is a standard, generic, regular expression (i.e. one that I can use with
> grep), versus something "proprietary" to Perl.  For instance, in my Perl book it
> says one can find a string in which the first word is the same as the last word by:
> 
> /^(\S+)/s.*\1$/
> 
> But when I try somehing similar in grep, it doesn't work.  I am guession that the
> \1 is really a perl construct, not a regular expression.
> 
> grep -E "^(\S+)\s.*\1$" xx.txt
> 
> Can someone straighten me out?

Your version of grep(1) may not even support back-references (\1, $1,
etc.)  Most greps use a regex engine that doesn't support them (and then
again, some greps have _both_ engines!)  Check 'Mastering Regular
Expressions' that someone else has recommended in this thread.  It
covers the concepts of regex's, different implementations (Perl vs (old)
Python vs grep vs awk, etc.), different engine types, and oh so much
more.  If you're interested in regex's or just think that they _might_
be useful, check the book out. ;)

HTH
-- 
-Tim Hammerquist <timmy@cpan.org>

If Microsoft build cars, the Linux car owners would get expensive Microsoft
upgrades to their cars, which would make their cars run much slower.


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

Date: Sat, 07 Jul 2001 22:07:40 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Posting HTML table from a file?
Message-Id: <3B47C06C.8EE26975@earthlink.net>

Ted Weston wrote:
> 
> I'm reading a file into a table, but I intend
> to read it in line-by-line so I can alternate
> colors between line of the table. Thus far:
> 
> .
> .
> .
> open (INFILE, "/tmp/out.test");
> 
> print header(),
> start_html(-xbase=>'http://mysite/testpage
>         -head=>meta({-http_equiv=>'Refresh',
>         -content=>'600'})),

There's no need for a meta inside of the head when you can set the http
headers directly.
The html code:
	<meta http_equiv="Refresh" content="600">
Should have exactly the same effect as if you had in the http header:
	Refresh: 600

> font({-face => 'arial'},{-size=>3},

This should be
	font({-face => 'arial',-size=>3},

> table({-width=>'100%', -height=>'130',
>         -border=>'undef',-cellpadding=>'0',
>         -cellspacing=>'1'},
> while (<INFILE>) {
>   @line = split (/|/);
>   Tr(),
>     td({-width=>'6%', -align=>'center',
>       -height=>'45'},[@line[0, 1, 3, 4, 6, 7]])
>   }#end while
>   )),
> end_html();

You can't include a while or a for statement in an expression like this.
Perhaps what you want is map?

open (INFILE, "/tmp/out.test") or die "Couldn't open /tmp/out.test: $!";

my $td_params = {-width=>'6%', -align=>'center', -height=>'45'};
print header(-Refresh => 600),
	start_html(-xbase=>'http://mysite/testpage),
	font( {-face => 'arial',-size=>3},
	table( {-width=>'100%', -height=>130, -border=>0,
		-cellpadding=>0, -cellspacing=>'1'},
	"<COL SPAN=6>\n",
	Tr [map {
		td $td_params, [(split /\|/)[0, 1, 3, 4, 6, 7]]
	} <INFILE>] )),
	end_html;

Another user suggested start_ and end_ for font and table.

use CGI qw(:standard *font *table);
open (INFILE, "/tmp/out.test") or die "Couldn't open /tmp/out.test: $!";

print header(-Refresh => 600),
	start_html(-xbase=>'http://mysite/testpage),
	start_font(-face => 'arial', -size => 3),
	start_table(-width=>'100%', -height=>130, -border=>0,
		-cellpadding=>0, -cellspacing=>'1'),
	"<COL SPAN=6>\n";
my $td_params = {-width=>'6%', -align=>'center', -height=>'45'};
while( <INFILE > ) {
	print Tr td $td_params, [(split /\|/)[0, 1, 3, 4, 6, 7]];
}
print end_table, end_font, end_html;

IMO, the second style is preferable to the first, since printing a line
at a time is better than doing a map, then printing a big huge list.

The purpose of the COL tag is to improve the speed of page loading in
html4 compliant browsers.

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1265
***************************************


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