[16888] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4300 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 12 18:05:44 2000

Date: Tue, 12 Sep 2000 15:05:26 -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: <968796326-v9-i4300@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 12 Sep 2000     Volume: 9 Number: 4300

Today's topics:
    Re: (HELP) Socket.pm script -- what am i doing wrong ?? nobull@mail.com
        @array <todd@mrnoitall.com>
    Re: @array <anders@wall.alweb.dk>
    Re: @variable_list <todd@mrnoitall.com>
    Re: @variable_list <vmurphy@Cisco.Com>
    Re: @variable_list2 <elephant@squirrelgroup.com>
        [Query] Any way to affect results of a match with an in (William C. Ray)
    Re: avoiding do {} while() <lr@hpl.hp.com>
    Re: Change Windows Desktop BG <hartleh1@westat.com>
    Re: Change Windows Desktop BG <elephant@squirrelgroup.com>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl <iltzu@sci.invalid>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl (brian d foy)
    Re: DBI/MySQL Question for the WISE desertedge@my-deja.com
    Re: DBI/MySQL Question for the WISE <anders@wall.alweb.dk>
    Re: DBI/MySQL Question for the WISE desertedge@my-deja.com
    Re: Eliminate Duplicates <flavell@mail.cern.ch>
    Re: Entering data from an HTML into a hash of hashes (Chris Fedde)
    Re: File Upload using a require .pm nobull@mail.com
    Re: File Upload using a require .pm nobull@mail.com
    Re: Get the MAC address from an IP (Malcolm Dew-Jones)
    Re: Getting started w/ Perl <mischief@motion.net>
    Re: hash arrays... <vmurphy@Cisco.Com>
    Re: hash arrays... <aqumsieh@hyperchip.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 12 Sep 2000 19:48:51 +0100
From: nobull@mail.com
Subject: Re: (HELP) Socket.pm script -- what am i doing wrong ???
Message-Id: <u9lmwx30q4.fsf@wcl-l.bham.ac.uk>

cyberlurker@my-deja.com writes:

> ( BTW,i have rewritten this to use IO:Socket, but i can't figure
> out how to catch the local_addr in an IO::Socket script... )

You seem to have overlooked the fact that IO::Socket objects are still
socket filehandles.  (Well references to blessed GLOBs that contain
filehandles actually).  All the old-fashioned stuff still works.

> my big problem is: i cant stand to not understand *why* this one
> doesn't work ( dumb programmer for sure...;o/ )............

A loop that reads from a filehande until an EOF condition is reached
will, when applied to a socket, read from the socket until the other
end closes the connection.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 12 Sep 2000 14:10:22 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: @array
Message-Id: <39BE8DA7.E29C3337@mrnoitall.com>

Dear Sirs and or Madam,
The script below isn't reading the lists. Any ideas?
Thanks in advance for your help.


my %underwritter1_companies = (

AL => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AK => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AZ => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AR => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CA => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CO => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CT => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, DE => [ 'Company1', 'Company2', 'Company3', 'Company4' ] );


my %underwritter2_companies = (

AL => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AK => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AZ => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AR => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CA => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CO => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CT => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, DE => [ 'Company1', 'Company2', 'Company3', 'Company4' ] );

print qq~<select name="company">~;
foreach my $co ( @{$underwritter1_companies{$form_data{'state'}}} ){
print qq~<option value="underwritter1">$co~;
}
foreach my $co ( @{$underwritter2_companies{$form_data{'state'}}} ){
print qq~<option value="underwritter2">$co~;
}
print qq~</select>~;






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

Date: Tue, 12 Sep 2000 20:14:53 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: @array
Message-Id: <19wv5.739$Tn3.15647@news010.worldonline.dk>

Todd Anderson wrote:

> Dear Sirs and or Madam,
> The script below isn't reading the lists. Any ideas?
> Thanks in advance for your help.
> 
> 
> my %underwritter1_companies = (
> 
> AL => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , AK => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , AZ => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , AR => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , CA => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , CO => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , CT => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , DE => [ 'Company1', 'Company2', 'Company3', 'Company4' ] );
> 
> 
> my %underwritter2_companies = (
> 
> AL => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , AK => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , AZ => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , AR => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , CA => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , CO => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , CT => [ 'Company1', 'Company2', 'Company3', 'Company4' ]
> 
> , DE => [ 'Company1', 'Company2', 'Company3', 'Company4' ] );
> 
> print qq~<select name="company">~;
> foreach my $co ( @{$underwritter1_companies{$form_data{'state'}}} ){
> print qq~<option value="underwritter1">$co~;
> }
> foreach my $co ( @{$underwritter2_companies{$form_data{'state'}}} ){
> print qq~<option value="underwritter2">$co~;
> }
> print qq~</select>~;
> 
> 
> 
> 
you need to read a bit on hashes...

foreach $co_name (keys %comanies) { do $stuff }

-anders
-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Tue, 12 Sep 2000 13:22:35 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: @variable_list
Message-Id: <39BE8278.EA43547B@mrnoitall.com>

Dear Sirs and or Madam,
Thanks for your help. But it still isn't reading the lists. Any ideas?
Thanks in advance for your help.


my %underwritter1_companies = (

AL => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AK => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AZ => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AR => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CA => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CO => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CT => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, DE => [ 'Company1', 'Company2', 'Company3', 'Company4' ] );


my %underwritter2_companies = (

AL => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AK => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AZ => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, AR => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CA => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CO => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, CT => [ 'Company1', 'Company2', 'Company3', 'Company4' ]

, DE => [ 'Company1', 'Company2', 'Company3', 'Company4' ] );

print qq~<select name="company">
<option  value="" selected>Choose 1~;
foreach my $co ( @{$underwritter1_companies{$form_data{'state'}}} ){
print qq~<option value="underwritter1">$co~;
}
foreach my $co ( @{$underwritter2_companies{$form_data{'state'}}} ){
print qq~<option value="underwritter2">$co~;
}
print qq~</select>





Todd Anderson wrote:

> Dear Sirs,
> I need to read names from a list based on the state chosen. (The name of
> the @list would vary depending on the state chosen) I need code like the
> example below but this does not work. Any ideas would be appreciated.
> Thanks in advance.
>
> foreach $item (@$form_data{'state'}_companies){



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

Date: 12 Sep 2000 15:51:22 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: @variable_list
Message-Id: <ug0n5bd8l.fsf@Cisco.Com>

>>>>> "Todd" == Todd Anderson <todd@mrnoitall.com> writes:

    Todd> Dear Sirs and or Madam, Thanks for your help. But it still
    Todd> isn't reading the lists. Any ideas?  Thanks in advance for
    Todd> your help.

I put this at the top of your code:
my %form_data = ( state => 'CO' );


This seems to work. What is the value of form_data that you are passing
in?  I got the following, after putting in newlines in the foreach
loops:


C:\BIN>test2.pl
<select name="company">
<option  value="" selected>Choose 1
<option value="underwritter1">Company1
<option value="underwritter1">Company2
<option value="underwritter1">Company3
<option value="underwritter1">Company4
<option value="underwritter2">Company1
<option value="underwritter2">Company2
<option value="underwritter2">Company3
<option value="underwritter2">Company4
</select>

-vjm



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

Date: Wed, 13 Sep 2000 08:44:24 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: @variable_list2
Message-Id: <MPG.142940ae46b7aa16989790@localhost>

Yanick Champoux <yanick@babyl.sympatico.ca> wrote ..
>May I recommend a perusal of the priceless jewels of Perl lore
>that the commands
>
>	perldoc perldata
>	perldoc perldsc
>	perldoc perllol
>
>will merely pour out on your terminal? 
>
>Or, if you already absorbed the wisdom infused in those
>ubiquitous but alas so painfulyl rarely consulted and are
>only looking at examples to jog your memory...

what about the originator's post do you think was incorrect ? .. 
certainly nothing that is solved by any of the above docs - or by your 
snipped examples

try not to post answers that don't actually answer the question being 
asked - it's misleading and confusing

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 12 Sep 2000 15:53:30 -0400
From: ray@soyokaze.biosci.ohio-state.edu (William C. Ray)
Subject: [Query] Any way to affect results of a match with an internal eval?
Message-Id: <200009121949.PAA02164@soyokaze.biosci.ohio-state.edu>


Ok, so this is either really hard, or really easy and I'm an 
idiot.  What I want to do is to be able to attach code to a
regex match such that the results of evaluation of the code
affect whether a particular match is valid.  Additionally, the
code portion needs to be able to work on values that are being
extracted by other portions of the regex.

Why would anyone want to do this?  Well, my problem is rather
esoteric, but a simple example would be something like a
"math problem grader".  If it were possible to attach code to
a regex such that it affected the match, one could write a
regex something like  /(.+)=(.+)(?{compare(\1,\2)})/
which (with a suitable implementation of "compare()" would
match only _correct_ mathematical expressions.

Yes, I know that to solve this particular example I could parse
out the LHS and RHS and handle them independently outside the
match, but unfortunately for my application that won't work, and
what I want to be able to do is use Perl's wonderful backtracking
engine to iterate over a _huge_ mess of non-tokenizable data
looking for the one (or the first hit - doesn't really matter to
me) combination of substrings for which the eval comes up true.
(and yes, I know, that's going to be amazingly inefficient, but
I believe it's provably so, so I might as well use the Perl engine
rather than re-write it, right?)

Basically, I'm looking for a way to make the validity of a potential
match depend on the result of calculations applied to candidate
sub-matches, such that Perl will iterate over all possible regex
submatches until it finds a candidate set that satisfies the calculation
as well.

So, where am I?  (?{compare(\1,\2)}) doesn't seem to work on three
counts - \1 and \2 don't seem to go in, which I assume is a result
of the "no interpolation" in the current definition of the (?{})
extension.  Also, since (?{}) always returns a zero-width match,
returning "False" or some such doen't prevent the match from
succeeding.  Finally, I could almost get around the "always true"
return using $^R, except that this doesn't seem to be set until
_after_ the outside match is completed, so the results of the (?{})
can't be used as a sub-pattern in the same match where it's being
evaluated.


Any thoughts?  I know the example given is sort of a silly one,
but it seems to me that this is a capability that either must
already exist in Perl, or _really_really_should_ exist in Perl.


If someone knows how to do this, I'd be eternally grateful for
a few hints.  If it can't currently be done, can someone tell me
whose ear to put a bug in regarding getting this capability added
to a future release?

Thanks in advance for any information,
Will Ray
ray@soyokaze.biosci.ohio-state.edu



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

Date: Tue, 12 Sep 2000 12:52:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: avoiding do {} while()
Message-Id: <MPG.142829719197a8ce98ad5a@nntp.hpl.hp.com>

In article <Pine.OSF.4.21.0009120920240.4893-100000@pearl.cs.sc.edu> on 
Tue, 12 Sep 2000 09:26:01 -0400, Gopi Sundaram <gopalan@cs.sc.edu> 
says...
> On Mon, 11 Sep 2000, Larry Rosler wrote:

 ...

> >   my @try = my @sigs = </path/to/files/*>;
> >   my $found;
> >   1 while @try && ! -T ($found = splice @try, rand @try, 1);
> >   @try or die "All files tried!\n";
> > 
> > The name of the desired file is in $found.
> 
> That was very educational. It took me a worthy while to understand
> that. Just one question: is @sigs necessary? It doesn't seem to be
> used anywhere.

It was in your original code, and retained its value to the end of the 
snippet, so I thought to keep it around during the destructive search.  
If it isn't used later, then obviously it isn't needed.  :-)

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


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

Date: Tue, 12 Sep 2000 16:17:13 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: Change Windows Desktop BG
Message-Id: <39BE8F49.30662D8F@westat.com>


"James M. Luongo" wrote:
> jason wrote:
> > James M. Luongo <jluongonospam@draper.com> wrote ..
> > > How would I use Perl for Windows to randomly change my windows desktop
> > > background each time I logged into my computer?

The color, color scheme, and wallpaper are stored in:
HKEY_CURRENT_USER/Colors/Background
HKEY_CURRENT_USER/Current/Color Schemes
HKEY_CURRENT_USER/Control Panel/Desktop/Wallpaper

> > Win32::TieRegistry
> > Win32API::Registry
> > see the standard documentation for how to use them
> Where can I find the standard documentation for those modules?

At the command prompt, type:

perldoc Win32::TieRegistry
perldoc Win32API::Registry

for the standard documentation.  I wrote a short script that rotated
through a collection of Wallpapers (on an NT machine and using the old
Win32::Registry module) but it only worked on a restart (or a re-login,
really) because updating the Registry is not the whole battle.  You have
to make the system reread the registry and I never figured out how to do
that from the script.  Is that possible with the newer modules?  If so,
it's not obvious from the docs.

-- 
Henry Hartley


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

Date: Wed, 13 Sep 2000 08:11:57 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Change Windows Desktop BG
Message-Id: <MPG.14293916bba986e798978e@localhost>

James M. Luongo <jluongonospam@draper.com> wrote ..
>jason wrote:
>> 
>> James M. Luongo <jluongonospam@draper.com> wrote ..
>> >How would I use Perl for Windows to randomly change my windows desktop
>> >background each time I logged into my computer?
>> 
>> (assuming that you've checked CPAN in case someone's actually written
>> this sort of functionality into a module - I have not checked it)
>> 
>> the windows background setting is stored in the Windows registry ..
>> there are two modules for adjusting the registry .. both are (now)
>> standard modules
>> 
>>   Win32::TieRegistry
>>   Win32API::Registry
>> 
>> see the standard documentation for how to use them
>> 
>> see some Windows resource for which setting it is
>
>Where can I find the standard documentation for those modules?

you are clearly unaware of the 'perldoc' utility .. type the following 
at the command prompt

  perldoc perldoc

and start reading about it .. or on a Win32 machine that has 
ActiveState's Perl port installed on it (the standard Win32 port) go to 
the Programs section of your State menu .. there's an entry for 
ActivePerl with documentation in it

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 12 Sep 2000 19:07:24 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <968784201.19632@itz.pp.sci.fi>

In article <8ph28a$csnku$12@ID-24002.news.cis.dfn.de>, Tina Mueller wrote:
>In comp.lang.perl.misc brian d foy <brian@smithrenaud.com> wrote:
>> persisting in this sort of explanation will only cause confusion.
>> try this code:
>>
>>    sub foo { return ( 1, 2, 4 ) }
>>    my $value = foo();
>>    print $value;
>>
>> now, try to explain that result in terms of what you just said.
>
>nice effect, just read about this in perldata.
>change that sub to
>sub foo {@a=(1,2,4); @a}
>that is what i meant.
>
>so what about
>"if the sub returns a copy of an array"?

No, that doesn't really help.  You're just digging yourself into a
deeper hole.

The best way to think about this is to realize is that in Perl there
*is no way to turn a list into a scalar*.  When perl wants a scalar,
it keeps on evaluating deeper into the expression until it encounters
something that can give it a scalar.  The language has been designed
so that this is always possible; every builtin has a scalar value.

This can lead to some rather unexpected results:

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

  sub foo { $_[0] .. $_[1] }

  print "State   : ", foo(0, 0) ? "true":"false";
  print "Flip on : ", foo(1, 0) ? "true":"false";
  print "List from a to g: ", foo('a', 'g');
  print "State   : ", foo(0, 0) ? "true":"false";
  print "Flip off: ", foo(0, 1) ? "true":"false";
  print "State   : ", foo(0, 0) ? "true":"false";
  print "List from t to z: ", foo('t', 'z');
  print "State   : ", foo(0, 0) ? "true":"false";

  __END__

  State   : false
  Flip on : true
  List from a to g: abcdefg
  State   : true
  Flip off: true
  State   : false
  List from t to z: tuvwxyz
  State   : false

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: Tue, 12 Sep 2000 16:43:40 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <brian-ya02408000R1209001643400001@news.panix.com>

In article <968784201.19632@itz.pp.sci.fi>, Ilmari Karonen <usenet11212@itz.pp.sci.fi> posted:

> something that can give it a scalar.  The language has been designed
> so that this is always possible; every builtin has a scalar value.

even sort()?  ;)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Tue, 12 Sep 2000 18:13:41 GMT
From: desertedge@my-deja.com
Subject: Re: DBI/MySQL Question for the WISE
Message-Id: <8plro0$2hk$1@nnrp1.deja.com>

The below addition to my code gives me this error:
"Can't call method "fetchrow" without a package or object reference"

I've substituted the proper names, and played around a little, but
can't get it to take.  Thanks again.

> $sql = $dbh->prepare("select auto_col from table_name sort by
auto_col desc
> limit 1");
> die "DB ERROR: $DBI::errstr\n" unless ($sth = $dbh->prepare($sql) &&
> $sth->execute);
> $new_rec_id = ($sth->fetchrow)[0];
> $sth->finish;


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


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

Date: Tue, 12 Sep 2000 20:52:17 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: DBI/MySQL Question for the WISE
Message-Id: <5Iwv5.815$Oh1.11057@news000.worldonline.dk>

Garry T. Williams wrote:

> On Tue, 12 Sep 2000, Anders Lund wrote:
> 
> > desertedge@my-deja.com wrote:
> > >       ######HERE IS WHERE I WOULD LIKE TO FETCH THE ID OF THE RECORD
> > >       ########
> > 
> > $sql = $dbh->prepare("select auto_col from table_name sort by auto_col
> > desc limit 1");
> > die "DB ERROR: $DBI::errstr\n" unless ($sth = $dbh->prepare($sql) &&
> > $sth->execute);
> > $new_rec_id = ($sth->fetchrow)[0];
> > $sth->finish;
> 
> So how is it that you *know* that the highest number in this table is the
> row just inserted by *you*?  Is it possible that another insert by another
> client is now the row you are retrieving?
> 
> I think the original poster wants an "atomic" operation that both
> instantiates a new row with an automatically incremented column *and*
> returns the value of that column.
> 
> Your suggestion creates a race condition.
> 
> Then, of course there is the problem of MySql not accepting the query.  It
> is syntactically incorrect and will raise an exception.  The word `sort'
> should be `order'.  But why would you go to all the trouble of saying it
> that way when you could say:
> 
> select max(auto_col) from table_name
> 
> instead.  (You still have created a race condition.)
> 
> -Garry Williams
> 

Thanks Gary, you are absolutely right!!

Mysql has means for letting you know if the query was accepted, and DBI I 
think knows that and returns an error if no rows was affected.

But the table should be locked while this operation runs, can be done with 
an SQL statement.

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Tue, 12 Sep 2000 20:50:26 GMT
From: desertedge@my-deja.com
Subject: Re: DBI/MySQL Question for the WISE
Message-Id: <8pm4u8$ehn$1@nnrp1.deja.com>

In article <Pine.SOL.4.21.0009121343001.26378-100000@ifr>,
  "Garry T. Williams" <garry@zvolve.com> wrote:
> I think the original poster wants an "atomic" operation that both
> instantiates a new row with an automatically incremented column *and*
> returns the value of that column.
>
> Your suggestion creates a race condition.
>
> -Garry Williams
>
>

GARY,

You have the original poster's (me) correct understanding of the
question...do you have the answer :)

Thanks,

Justin


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


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

Date: Tue, 12 Sep 2000 20:20:52 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Eliminate Duplicates
Message-Id: <Pine.GHP.4.21.0009122020000.8693-100000@hpplus03.cern.ch>

On Tue, 12 Sep 2000 shollins@my-deja.com blurted out:

> Thanks Tom for your sarcastic remarks.

And another entry gets added to the list.

bye-bye.



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

Date: Tue, 12 Sep 2000 18:27:49 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <FAuv5.110$W3.170897408@news.frii.net>

In article <Pine.GHP.4.21.0009110039230.24095-100000@hpplus03.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>On 10 Sep 2000, Tina Mueller wrote:
>> and in the end, be aware that the parameters passed
>> to the script don't reflect anything like checkboxes
>
>You make a good point, because in the final analysis, a malicious
>user can submit just any stuff that amuses them.
>

In fact this ability allows one to implement the kind of automatic
form filling that is becoming so popular in the credit card industry
of late.  At least one of these critters works by submitting several
"likely" names blindly.

chris
-- 
    This space intentionally left blank


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

Date: 12 Sep 2000 20:09:41 +0100
From: nobull@mail.com
Subject: Re: File Upload using a require .pm
Message-Id: <u9its12zre.fsf@wcl-l.bham.ac.uk>

grover_muppit@hotmail.com writes:

> I have an file upload quirk that is baffling me and I hope someone can
> help.

Older versions of CGI.pm use an ugly sybolic reference hack to
overload the return from CGI->param() so that it is both a string
containing a filename and a symbolic reference to a file handle.

Because it's a symbolic refernence if you attempt to dereference it in
another namespace (package) then it won't work.  There were also
several other problems with the above design.

Relatively recent versions of GCI.pm have CGI->upload() which returns
a proper hard reference. 

Really recent versions (which evidently you don't have) of CGI.pm use
a more cleaver but even more ugly hack so that CGI->param() returns
hard eeference to a filehandle that is overloaded to give the filename
in a string context.  This fixes the problems but creates new ones.

You should either start using the upload() method, or upgrade GCI.pm
(or, both).

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 12 Sep 2000 20:14:42 +0100
From: nobull@mail.com
Subject: Re: File Upload using a require .pm
Message-Id: <u9hf7l2zj1.fsf@wcl-l.bham.ac.uk>

Anders Lund <anders@wall.alweb.dk> writes:

> grover_muppit@hotmail.com wrote:

[ Anders unselectively qoutes all 78 lines of grover_muppit's post but
apparently didn't read it]
 
> Read the CGI documentation.
> CGI delivers the filename as a file handle, but by passing it to your 
> module, you turn it into a string.

No, if you'd read his code you'd observe that he doesn't stringify the
value.  He's using the old version of GCI.pm that uses symbolic refs.
Unqualified symbolic refs don't travel well between packages.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 12 Sep 2000 11:36:59 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Get the MAC address from an IP
Message-Id: <39be77cb@news.victoria.tc.ca>

Mike Mesarch (mmesarch@wcom.net) wrote:
: Is their a way to get a MAC address associated with an IP address?
: -Mike

arp - I have no idea if there's a perl module to do this.


--


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

Date: Tue, 12 Sep 2000 14:45:42 -0500
From: "Chris Stith" <mischief@motion.net>
Subject: Re: Getting started w/ Perl
Message-Id: <srt1sesrct6123@corp.supernews.com>


"Randy" <randy_734@my-deja.com> wrote in message
news:39bce6c3.2061765@207.126.101.100...
> Phil, if you need to set up Unix, it is quite simple to set up a
> multi-boot system, with Linux on a separate small partition.  That
> makes a good learning environment, as well as a great place for
> testing your Perl work.  Also, someone suggested learning some general
> programming in another language first.  I would strongly agree.  Perl
> is an extremely powerful and adaptable language, but its free form,
> unstructured nature probably makes it the absolute worst language to
> begin learning programming.

I would disagree that it's the absolute worst to use as a beginning
language. I think COBOL, Fortran, RPG, Forth, or JCL would be much worse as
a first language. Some people might say that C or C++ is worse as a first
language too.

I wouldn't say Perl is the absolute best first language, either. I'd be
partial to Perl as a first language, since I like the language so much. I
didn't start with Perl. I played with AtariBasic when I was young. I started
in school with *gasp* Borland's Turbo Pascal and Microsoft's QBASIC, since
that's what my high school taught. At least QBASIC has subroutines and
doesn't need line numbers for every line. I taught myself a little bit of C
and some x86 assembly, but not a lot. I then went to uni, where the CS
program was taught mostly around Ada.

I started using Perl when I took my first real computer-related job aside
from doing part-time PC tutoring and repair on my own. The boss heard I'd
done some programming in school, and he had a script that did almost what he
wanted it to do. I was handed the Llama and the Camel on Monday and was
given a deadline of Friday to have the script working as desired. Perl's
been one of my favorite languages since - probably my favorite.

I'd say that Perl, with a decent instructor, could be a good first language.
Learning just from books, I think Perl could be a potentially troublesome
first language. Special-purpose languages such as Salt (the embedded
scripting language for the Telemate comm. software on DOS) or Expect might
teach someone a few things before they use a real general-purpose language,
but these languages could lead someone to become accustomed to many details
being handled for them if they are used extensively without any experience
with other programming languages. Java or Python would be decent candidates
for first-time languages, too. I'd say Pascal is a very good learning
language, although some people have tried to make it into more than that.

Right now, I'm still trying to round out my knowledge of various languages.
I'd like to be much better at C than I currently am. I'd also like to learn
Java, Lisp, Scheme, and Prolog. I've toyed with each of these, but not
enough to become proficient. of course, I'm still working hard to become
better at Perl day by day, since I've only been using it for two years or so
and there's so much the language has to offer.

In short, though, to bring this back to something that vaguely resembles a
post meant for c.l.perl.misc instead of comp.programming (or
alt.lunatic.autobiography ), I'd say that Perl is far from the worst first
language with which to start, although it's probably not the best either.

Chris Stith
mischief@pikenet.net   mischief@motion.net
There's a Chinese proverb that translates to: "May you live in interesting
times". If you want a more concrete example, "There's nothing like a swift
kick in the groin to make you appreciate a boring day at work".





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

Date: 12 Sep 2000 15:29:59 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: hash arrays...
Message-Id: <uk8chbe88.fsf@Cisco.Com>

>>>>> "Scott" == Scott Yanoff <yanoff@yahoo.com> writes:

    Scott> "Alvaro Bahamondes V." wrote:
    >>  Hello all,
    >> 
    >> I need to create a big hash from a string, for example:
    >> 
    >> #this is the string and may be a big one (I can change the
    >> #format of the string without a problem).  $r="1, a, 2, b, 3, c";
    >> #and I create the hash like this: %t = split(",",$r);

    Scott> Can't you just create a hash as follows:

    Scott> %t = qw(1, a, 2, b, 3, c);

If you used warnings ( -w ), you would have recieved:

C:\>perl -we "%t = (1, a, 2, b, 3, c); print map qq/$_ = $t{$_}\n/ => keys %t;"
Unquoted string "a" may clash with future reserved word at -e line 1.
Unquoted string "b" may clash with future reserved word at -e line 1.
Unquoted string "c" may clash with future reserved word at -e line 1.
1 = a
2 = b
3 = c

See perldoc perlop, or perldoc -f qw for more details.


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

Date: Tue, 12 Sep 2000 21:30:11 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: hash arrays...
Message-Id: <7aya0xpaca.fsf@merlin.hyperchip.com>



Vinny Murphy <vmurphy@Cisco.Com> writes:

> >>>>> "Scott" == Scott Yanoff <yanoff@yahoo.com> writes:
> 
>     Scott> "Alvaro Bahamondes V." wrote:
>     >>  Hello all,
>     >> 
>     >> I need to create a big hash from a string, for example:
>     >> 
>     >> #this is the string and may be a big one (I can change the
>     >> #format of the string without a problem).  $r="1, a, 2, b, 3, c";
>     >> #and I create the hash like this: %t = split(",",$r);
> 
>     Scott> Can't you just create a hash as follows:
> 
>     Scott> %t = qw(1, a, 2, b, 3, c);
> 
> If you used warnings ( -w ), you would have recieved:
> 
> C:\>perl -we "%t = (1, a, 2, b, 3, c); print map qq/$_ = $t{$_}\n/ =>
> keys %t;" 
> Unquoted string "a" may clash with future reserved word at -e line 1.
> Unquoted string "b" may clash with future reserved word at -e line 1.
> Unquoted string "c" may clash with future reserved word at -e line 1.
> 1 = a
> 2 = b
> 3 = c
> 
> See perldoc perlop, or perldoc -f qw for more details.

Also, Ii you used:

	%t = qw(1, a, 2, b, 3, c);

as the OP did, you would get this warning:

	Possible attempt to separate words with commas at - line xx.


--Ala


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

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


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