[18790] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 958 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 22 14:06:09 2001

Date: Tue, 22 May 2001 11:05:24 -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: <990554723-v10-i958@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 22 May 2001     Volume: 10 Number: 958

Today's topics:
        [ANNOUNCE] Proc::Queue 0.08 (salva)
        Apostrophes and ODBC <rick.tammy.nospam@nf.sympatico.ca>
    Re: Apostrophes and ODBC <Jenda@Krynicky.cz>
    Re: Array slice: how about the remainder? (Mark Jason Dominus)
    Re: Array slice: how about the remainder? (Greg Bacon)
        Curious about this I found on the web! <davsoming@lineone.net>
    Re: delete() from array (Mark Jason Dominus)
    Re: delete() from array <pne-news-20010522@newton.digitalspace.net>
    Re: delete() from array <bart.lateur@skynet.be>
    Re: delete() from array <bart.lateur@skynet.be>
    Re: delete() from array <uri@sysarch.com>
    Re: delete() from array (Anno Siegel)
    Re: delete() from array (Anno Siegel)
    Re: delete() from array <ren@tivoli.com>
        Good source for Perl contracts ? <snakedjip@nospamyahoo.com>
    Re: Handling JPEGs without modules (Honza Pazdziora)
        hash reference <smrtalec@nospam.earthlink.net>
    Re: Help with script to modify the content of a text fi <godzilla@stomp.stomp.tokyo>
    Re: Help with script to modify the content of a text fi <EUSWMCL@am1.ericsson.se>
        Help with script to modify the content of a text file a <stpham@qwest.net>
    Re: Help: Can't use correctly File:Find in perl (Mark Jason Dominus)
        How free is your RPM-based GNU/Linux distribution? <kenneth@kebes.com>
    Re: image_button and onClick??? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 May 2001 09:21:07 -0700
From: salvador@my-deja.com (salva)
Subject: [ANNOUNCE] Proc::Queue 0.08
Message-Id: <tgl5c9cqcch680@corp.supernews.com>

Hi,

Version 0.08 of Proc::Queue is now available from CPAN.

------------------------------------------------------------------------
NAME
    Proc::Queue - Perl extension to limit the number of concurrent child
    process running

SYNOPSIS
      use Proc::Queue size => 4, debug => 1;

      package other;

      # this loop will create new childs, but Proc::Queue will make it
      # wait when the limit (4) is reached until some of the old childs
      # exit.
      foreach (1..10) {
        my $f=fork;
        if(defined ($f) and $f==0) {
          print "-- I'm a forked process $$\n";
          sleep rand 5;
          print "-- I'm tired, going away $$\n";
          exit(0)
        }
      }

      Proc::Queue::size(10); # changing limit to 10 concurrent processes
      Proc::Queue::trace(1); # trace mode on
      Proc::Queue::debug(0); # debug is off
      Proc::Queue::delay(0.2); # set 200 miliseconds as minimum
                               # delay between fork calls

      package other; # just to test it works in any package

      print "going again!\n";

      # another loop with different settings for Proc::Queue
      foreach (1..20) {
        my $f=fork;
        if(defined ($f) and $f==0) {
          print "-- I'm a forked process $$\n";
          sleep rand 5;
          print "-- I'm tired, going away $$\n";
          exit(0)
        }
      }

      1 while wait != -1;

DESCRIPTION
    This module lets you parallelice one program using the "fork", "exit",
    "wait" and "waitpid" calls as usual and without the need to take care of
    creating too much processes and overloading the machine.

    It works redefining "fork", "exit", "wait" and "waitpid" functions so
    old programs do not have to be modified to use this module (only the
    "use Proc::Queue" sentence is needed).

    Additionally, the module have two debugging modes (debug and trace) that
    can be activated and that seem too be very useful when developing
    parallel aplications.

    Debug mode when activated dumps lots of information about processes
    being created, exiting, being caught be parent, etc.

    Trace mode just prints a line every time one of the "fork", "exit",
    "wait" or "waitpid" functions is called.

    It is also possible to set a minimun delay time between calls to fork to
    stop consecutive processes for starting in a short time interval.

    Childs processes continue to use the modified functions, but its queues
    are reset and the maximun process number for them is set to 1. Althought
    childs can change it to any other value if needed.

  EXPORT

    This module redefines the "fork", "wait", "waitpid" and "exit" calls.

  EXPORT_OK

    Functions "fork_now", "waitpids", "run_back", "run_back_now",
    "all_exit_ok" and "running_now" can be imported. Tag ":all" is defined
    to import all of them.

  FUNCTIONS

    There are several not exported functions that can be used to configure
    the module:

    size(), size($number)
        If an argument is given the maximun number of concurrent processes
        is set to it and the number of maximun processes that were allowed
        before is returned.

        If no argument is given, the number of processes allowed is
        returned.

    delay(), delay($time)
        delay lets you set a minimun time in seconds to elapse between every
        consecutive calls to fork. This is usefull for not creating to much
        processes in a very short time.

        If the Time::HiRes module is available it will be used and delays
        shorted that 1 second could be used.

        If no arg is given, the current delay is returned.

        To clear it use "Proc::Queue::delay(0)".

    fork_now()
        Sometimes you would need to fork a new child without waiting for
        other child to exit if the queue is full, "fork_now" does that. It
        is exportable so you can do...

          use Proc::Queue size => 5, qw(fork_now), debug =>1;

          $f=fork_now;
          if(defined $f and $f == 0) {
              print "I'm the child\n"; exit;
          }

    waitpids(@pid)
        Will wait for all the processes in @pid to exit. It returns an array
        with pairs pid and exit values (pid1, exit1, pid2, exit2, pid3,
        exit3,...) as returned by individual waitpid calls.

    run_back(\&code), run_back { code }
        Runs the argument subrutine in a forked child process and returns
        the pid number for the new process.

    run_back_now(\&code), run_back_now { code }
        A mix between run_back and fork_now.

    all_exit_ok(@pid)
        Do a waitpids call and test that all the processes exit with code 0.

    running_now()
        Returns the number of child processes currently running.

    debug(), debug($boolean), trace(), trace($boolean)
        Change or return the status for the debug and trace modes.

    import(pkg,opt,val,opt,val,...,fnt_name,fnt_name,...)
        The import function is not usually explicitally called but by the
        "use Proc::Queue" statement. The options allowed are "size", "debug"
        and "trace" and they let you configure the module instead of using
        the "size", "debug" or "trace" module functions as in...

          use Proc::Queue size=>10, debug=>1;

        Anything that is not "size", "debug" or "trace" is expected to be a
        function name to be imported.

          use Proc::Queue size=>10, ':all';

  BUGS

        None that I know, but this is just version 0.08!

        The module has only been tested under Solaris 2.6

        Child (forking) behaviour althought deterministic could be changed
        to something better. I would accept any suggestions on it.

INSTALL
        As usual, unpack de module distribution and from the newly created
        directory run:

          $ perl Makefile.PL
          $ make
          $ make test
          $ make install

AUTHOR
        Salvador Fandino <sfandino@yahoo.com>

SEE ALSO
        the perlfunc(1) manpage, the perlipc(1) manpage, the POSIX manpage,
        the perlfork(1) manpage, the Time::HiRes manpage, the
        Parallel::ForkManager manpage. The "example.pl" script contained in
        the module distribution.




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

Date: Tue, 22 May 2001 10:46:08 -0230
From: "Rick Bennett" <rick.tammy.nospam@nf.sympatico.ca>
Subject: Apostrophes and ODBC
Message-Id: <3b0a660f.0@209.128.1.3>

I have a Perl script that, from a web form, updates a MS Access database,
with two pieces of information using Win32::ODBC.  They are 'street' and
'area' respectively.  I am now experiencing a problem when a user enters a
street name that contains an apostrophe in to the web form.  The apostrophe
is being converted to a `, and subsequently things are not being ordered
properly when queryed.  My code is below.

######################### Start of Add areas Data subsection ###############
sub add_eve_data {
&open_database;
$db->Sql("INSERT INTO areas (street, area) VALUES ('$FORM{street}',
'$FORM{area}')");
$db->Sql("COMMIT");
&close_database;
&display_mainpage;
}
######################### End of Add areas Data subsection ###############

Can anynone shed any light as to why this is happening?




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

Date: Tue, 22 May 2001 15:54:02 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: Apostrophes and ODBC
Message-Id: <1103_990546842@JENDA>

On Tue, 22 May 2001 10:46:08 -0230, "Rick Bennett" <rick.tammy.nospam@nf.sympatico.ca> wrote:
> I have a Perl script that, from a web form, updates a MS Access database,
> with two pieces of information using Win32::ODBC.  They are 'street' and
> 'area' respectively.  I am now experiencing a problem when a user enters a
> street name that contains an apostrophe in to the web form.  The apostrophe
> is being converted to a `, and subsequently things are not being ordered
> properly when queryed.  

This should not happen. Are you sure you do not fiddle with $FORM{area} yourself?
It is true that it's necessary to take care of single quotes in data to be inserted into database, 
but the quotes should be doubled, not converted to backticks. 
(doubling means replacing by TWO SINGLEQUOTES, not ONE DOUBLEQUOTE!)

You could do it like this :

{
 my $street = $FORM{street};
 $street =~ s/'/''/g;
 my $area = $FORM{area};
 $area =~ s/'/''/g;
 $db->Sql("INSERT INTO areas (street, area) VALUES ('$street', '$area')");
}

Or if you use such things a lot and want to be cool you may use :

 use Interpolation "'" => sub {$_ = $_[0]; s/'/''/g; "'".$_}; 
  # please copy&paste this. Don't try to retype. All those double and single quotes ...
 ...
 $db->Sql("SELECT * FROM People WHERE LastName = $'{$lastname}'");

You may find Interpolation.pm at http://jenda.krynicky.cz

Jenda




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

Date: Tue, 22 May 2001 13:12:36 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Array slice: how about the remainder?
Message-Id: <3b0a65c3.2f50$258@news.op.net>

In article <tgjpjv9ac9lg2a@corp.supernews.com>,
Chris Stith  <mischief@velma.motion.net> wrote:
>> However, I did not benchmark.
>
>Sometimes your intuition speaks volumes to you that a benchmark
>would only confirm. ;-)

Yeah, but sometimes it doesn't.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Tue, 22 May 2001 14:37:49 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Array slice: how about the remainder?
Message-Id: <tgkudtdmc0gc39@corp.supernews.com>

In article <3b0a65c3.2f50$258@news.op.net>,
    Mark Jason Dominus <mjd@plover.com> wrote:

: In article <tgjpjv9ac9lg2a@corp.supernews.com>,
: Chris Stith  <mischief@velma.motion.net> wrote:
:
: >Sometimes your intuition speaks volumes to you that a benchmark
: >would only confirm. ;-)
: 
: Yeah, but sometimes it doesn't.

A tautology is a thing that is tautological.

Greg
-- 
It takes a lot of time to be a genius, you have to sit around so much doing
nothing, really doing nothing. 
    -- Gertrude Stein


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

Date: Tue, 22 May 2001 19:11:00 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Curious about this I found on the web!
Message-Id: <tglai97gs0uc00@corp.supernews.co.uk>

Hi,
I found this somewhere on the web and wondered what it is/does practical
use?
Its far too advanced for me... just curious really, anyone?

#!/usr/bin/perl
if(@ARGV){$w=int(shift(@ARGV)/2)*2+1;$h=int(shift(@ARGV)/2)*2+1;}else{$w=81
;$h=25;}$m=' 'x$w.(' '.'#'x($w-2)." ")x($h-2).' 'x$w;main:for(substr($m,$p=
2*$w+2,1)=4;$v!=4;){$o=$v=int(rand(4));do{substr($m,$p+$d,1)=' ',substr($m,
$p+=2*$d,1)=$v,next main if(substr($m,$p+2*($d=((($v&2)?1:-1)*(($v&1)?1:$w)
)),1)eq'#')}while($o!=($v=($v+1)%4));$v=substr($m,$p,1);substr($m,$p,1)=' '
;$p-=2*((($v&2)?1:-1)*(($v&1)?1:$w)) if ($v<4);}for($i=0;$i<$w*($h-2);print
substr($m,1+($i+=$w),$w-1),"\n"){}






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

Date: Tue, 22 May 2001 13:14:22 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: delete() from array
Message-Id: <3b0a6620.2f55$8e@news.op.net>

In article <57jkgtscln272jhdnmj6pkfh0gctfun7sf@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>In recent perls (from 5.6 on, I believe), it is possible to remove items
>from an array using delete(). However, it doesn't work as *I* expected.
>What I did expect, is the same effect as when using splice(). 

It was foolishly put in there to help support objects based on pseudo-hashes.
So there's no reason for it to make any sense.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Tue, 22 May 2001 16:18:45 +0200
From: Philip Newton <pne-news-20010522@newton.digitalspace.net>
Subject: Re: delete() from array
Message-Id: <d3tkgtcindh11s099ehk7b7i51ei2vtnar@4ax.com>

On Tue, 22 May 2001 11:29:22 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

> In recent perls (from 5.6 on, I believe), it is possible to remove items
> from an array using delete(). However, it doesn't work as *I* expected.

But it works as the docs say:

:                                         In the case of an array, if
:      the array elements happen to be at the end, the size of the
:      array will shrink to the highest element that tests true for
:      exists() (or 0 if no such element exists).
[snip]
:      Note that deleting array elements in the middle of an array will
:      not shift the index of the ones after them down--use splice()
:      for that.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 22 May 2001 14:31:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: delete() from array
Message-Id: <q0ukgt4eo9u2qo74jvj607bg70vtiu90p6@4ax.com>

Philip Newton wrote:

>But it works as the docs say:

>:      Note that deleting array elements in the middle of an array will
>:      not shift the index of the ones after them down--use splice()
>:      for that.

Ah yes. But it's utterly useless. Imagine that delete() on a hash did
the same, that "deleted" hash keys still stuck around.

Has anybody *ever* use delete() on array elements in real code? Are you
planning to do so?

-- 
	Bart.


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

Date: Tue, 22 May 2001 14:33:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: delete() from array
Message-Id: <s5ukgtsrumdoucidt1trmgndhkk570gc5u@4ax.com>

Anno Siegel wrote:

> It does
>allow to remove multiple elements from an array at once (unlike undef,
>which is a unary operator), and the state of a delete()d element
>is slightly different from an undef()ed one:  exists() returns
>false for the former and true for the latter[1].  It is the same
>state $ary[0] has after "my @ary; $ary[1] = 123;".

But you can't really use it.

	@remain = grep { exists $_ } @ary;

doesn't even compile.

-- 
	Bart.


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

Date: Tue, 22 May 2001 15:04:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: delete() from array
Message-Id: <x77kz977dq.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Anno Siegel wrote:
  >> It does
  >> allow to remove multiple elements from an array at once (unlike undef,
  >> which is a unary operator), and the state of a delete()d element
  >> is slightly different from an undef()ed one:  exists() returns
  >> false for the former and true for the latter[1].  It is the same
  >> state $ary[0] has after "my @ary; $ary[1] = 123;".

  BL> But you can't really use it.

  BL> 	@remain = grep { exists $_ } @ary;

  BL> doesn't even compile.

well, exists needs to be given a real location and not a value. it tests
in both hashes and arrays whether the location has something regardless
of its (possibly undef) value. in an array there is a difference between
a slot which has nothing vs. a slot that has the value undef. exists can
test for that in 5.6.

perl5.6.0 -le '@a=qw( a b c d ); delete @a[0,3]; @b = map {exists $a[$_] ? $a[$_] : () } 0 .. $#a; print @b'

bc

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 22 May 2001 15:07:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: delete() from array
Message-Id: <9edvar$57f$1@mamenchi.zrz.TU-Berlin.DE>

According to Bart Lateur  <bart.lateur@skynet.be>:
> Anno Siegel wrote:
> 
> > It does
> >allow to remove multiple elements from an array at once (unlike undef,
> >which is a unary operator), and the state of a delete()d element
> >is slightly different from an undef()ed one:  exists() returns
> >false for the former and true for the latter[1].  It is the same
> >state $ary[0] has after "my @ary; $ary[1] = 123;".
> 
> But you can't really use it.
> 
> 	@remain = grep { exists $_ } @ary;
> 
> doesn't even compile.

It doesn't because exists() isn't applicable to plain scalar variables
any more than it was before the change.  Substituting %hash for @ary,
your example would be something like

        @remain = grep { exists $_ } values %hash;

which obviously isn't supported.  You'd have to feed exists an array
element and say

        @existing_indexes = grep exists $ary[ $_], 0 .. $#ary;
        @remain = @ary[ @existing_indexes];

or the similarly unattractive

        @remain =  @ary[ grep exists $ary[ $_], 0 .. $#ary];

In another branch MJD said it doesn't have to make sense.  I tend
to agree.  The "trimming" feature of delete() could occasionally be
useful.

Anno


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

Date: 22 May 2001 15:31:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: delete() from array
Message-Id: <9ee0oh$653$1@mamenchi.zrz.TU-Berlin.DE>

According to Bart Lateur  <bart.lateur@skynet.be>:
> Philip Newton wrote:
> 
> >But it works as the docs say:
> 
> >:      Note that deleting array elements in the middle of an array will
> >:      not shift the index of the ones after them down--use splice()
> >:      for that.
> 
> Ah yes. But it's utterly useless. Imagine that delete() on a hash did
> the same, that "deleted" hash keys still stuck around.
> 
> Has anybody *ever* use delete() on array elements in real code? Are you
> planning to do so?

In another post I mentioned the "trimming" property of delete().
Figure an application where an array is used to map integers to
a "universe" of words, so that a bit vector can be interpreted as
a set of words.  If we do deletions from the universe via delete()
(instead of undef()ing entries), we are guaranteed that the array is
never longer than it has to be, so a vector of scalar( @universe)
bits will accommodate all the words currently present.  Figure a *lot*
of vectors...

Of course, a well-placed

        pop @universe until defined $universe[ $#universe];

guarantees the same thing, so I'm not sure it's worth the fuss.

Anno


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

Date: 22 May 2001 10:55:55 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: delete() from array
Message-Id: <m3n185cr90.fsf@dhcp9-172.support.tivoli.com>

On Tue, 22 May 2001, bart.lateur@skynet.be wrote:

> Anno Siegel wrote:
> 
>> It does allow to remove multiple elements from an array at once
>> (unlike undef, which is a unary operator), and the state of a
>> delete()d element is slightly different from an undef()ed one:
>> exists() returns false for the former and true for the latter[1].
>> It is the same state $ary[0] has after "my @ary; $ary[1] = 123;".
> 
> But you can't really use it.
> 
> 	@remain = grep { exists $_ } @ary;
> 
> doesn't even compile.

There are a couple of alternatives:

1. Assuming you can just delete the undef elements (admittedly not a
safe assumption in general):

  @remain = grep defined, @ary;

2. This works even if there can be undef elements:

  @remain = @ary[grep exists $ary[$_], 0..$#ary];

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 22 May 2001 12:02:40 -0400
From: "Snakedjip" <snakedjip@nospamyahoo.com>
Subject: Good source for Perl contracts ?
Message-Id: <6fwO6.204$bb4.72245@wagner.videotron.net>

Lacking a better newsgroup here... don't know if it's the place to post
this...

I am looking for a good source (web site, head-hunter...) to help me find
contract work for the web with Perl/mod-Perl.  This would have to be
tele-commute work, as I have no intention whatsoever of moving and/or
commuting...  And since I'm in Canada, canadian programmers (cheap cheap
cheap) would have to be allowed...

Thanks for the info.

PS: If you wish to contact me via email, remove the nospam from my email
address...





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

Date: Tue, 22 May 2001 12:33:56 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Handling JPEGs without modules
Message-Id: <slrn9gkn6t.3be4.adelton@nemesis.fi.muni.cz>

On Tue, 22 May 2001 00:53:43 +0200, Michael A. Krehan <ebo_mike-antispam-remove-t@hottmail.com> wrote:
> 
> > I think an issue here is that all the JPEG handling code he has found
> > for perl requires compiling, and I suspect that the hosting site
> > wouldn't allow that...
> 
> This is precisely the situation. I only have FTP access to my personal
> /cgi-bin. imagick is not installed (apparently not even the ImageMagick
> rpm), GD 1.19 is installed. I cannot telnet. I have no superuser rights. I
> cannot install or compile anything, make system-wide changes, let alone
> "make" and "make install" a module. All I can do is put stuff into /cgi-bin.

Pardon? If you can upload a Perl script to cgi-bin and run it, the
from that script you can run any other application that is installed
in the system. Including make (provided it is installed).

If it isn't installed, you can still do the make && make test phases
on your local computer and only upload the resulting compiled files.

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


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

Date: Tue, 22 May 2001 17:30:40 GMT
From: "R" <smrtalec@nospam.earthlink.net>
Subject: hash reference
Message-Id: <4nxO6.22016$BN6.896314@newsread1.prod.itd.earthlink.net>



The following peice of code generates, the output below.  I am trying to
make a visiually clean reference to the data represented in the hash. any
ideas ?


<snip>
@job_info=($radd_name,$radd_address);
 $user{$user_number}=\@job_info;
 #################################
 print "test cycle -3 \n";
 print $user{$user_number}->[1]->{first};
</snip>

<output>
test cycle -3
Use of uninitialized value at ./aewest2.pl line 42, <STDIN> chunk 8.
rowan@linux-srv:~/pl >
</output>




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

Date: Tue, 22 May 2001 10:18:12 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with script to modify the content of a text file and save it to  different directory
Message-Id: <3B0A9F54.11A474E@stomp.stomp.tokyo>

Steve wrote:

(some snippage)

> Please help me a script that will open a text file, prompt for input, and
> add those input values onto certain line and save it to different directory.

Why would you open a file then prompt for input? Wouldn't you
agree this is backwards logic?

Your prompt, is this a command line prompt or other?

You indicate saving to a different directory. So do you want to
modify your original file as well? Why a different directory?

 
> For example: let say I have this text file and it looks like this when I
> open it using notepad. I only shown part of the content of the file,  other
> settings are the same for all machines. Now I want to be
> able to prompt for input and modify the values for: PCIBusNumber,
> PCIDeviceNumber, IP properties.
 
Which IP properties? You indicate three sets of data which could
be construed to be IP properties.

How tough can this be?

 if ($line =~ /some parameter/)
  { $line = "whatever input"; )



Consider rewriting your article in a manner which is coherent,
easy to read and easy to comprehend.

Godzilla!


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

Date: Tue, 22 May 2001 13:32:58 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Re: Help with script to modify the content of a text file and save it to  different directory
Message-Id: <3B0AA2CA.B30F54D3@am1.ericsson.se>



Steve wrote:
> 
> Hi all,
> 
> Please help me a script that will open a text file, prompt for input, and
> add those input values onto certain line and save it to different directory.
> 
> For example: let say I have this text file and it looks like this when I
> open it using notepad. I only shown part of the content of the file,  other
> settings are the same for all machines. Now I want to be
> able to prompt for input and modify the values for: PCIBusNumber,
> PCIDeviceNumber, IP properties.
> 
>             [Params.Adapter1]
>                 PCIBusNumber = 3
>                 PCIDeviceNumber = 6
> 
>             [Params.Adapter2]
>                 PCIBusNumber = 1
>                 PCIDeviceNumber = 2
> 
>             [Params.TCPIP.Adapter1]
>                 IPAddress = 10.10.10.2
>                 SubnetMask = 255.0.0.0
>                 DefaultGateway = 10.10.10.1
> 
>             [Params.TCPIP.Adapter2]
>                 IPAddress = 11.10.10.2
>                 SubnetMask = 255.0.0.0
>                 DefaultGateway = 11.10.10.1
>


Hears an approach of reading ea line and echoing it until you reach one
that
matches your input string like "PCIBu" and changing it, otherwise keep
reading
and echoing and writing unchanged...

open INFILE,  ........
open OUTFILE, .........
$parm=<STDIN>;
while (<INFILE>) {
  chomp;
  if (/^$parm/) { # if line begins with input parm string
    print $_;
    print "Is this it?\n";
    $ans=<STDIN>;
    if ($ans=~/^y/i) { # if yes
      print "Whatcha wanna change it to?\n";
      $ans=<STDIN>;
        ...etc.

      @lin=split /\=/,$_;
      print OUTFILE "$lin[0]= $ans\n";
    
    }  

  }else{
      print OUTFILE "$_\n"; # Writeout unchanged


  etc and so forth


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

Date: Tue, 22 May 2001 11:58:30 -0500
From: "Steve" <stpham@qwest.net>
Subject: Help with script to modify the content of a text file and save it to different directory
Message-Id: <LUwO6.105$jP4.212955@news.uswest.net>

Hi all,

Please help me a script that will open a text file, prompt for input, and
add those input values onto certain line and save it to different directory.

For example: let say I have this text file and it looks like this when I
open it using notepad. I only shown part of the content of the file,  other
settings are the same for all machines. Now I want to be
able to prompt for input and modify the values for: PCIBusNumber,
PCIDeviceNumber, IP properties.

            [Params.Adapter1]
                PCIBusNumber = 3
                PCIDeviceNumber = 6

            [Params.Adapter2]
                PCIBusNumber = 1
                PCIDeviceNumber = 2

            [Params.TCPIP.Adapter1]
                IPAddress = 10.10.10.2
                SubnetMask = 255.0.0.0
                DefaultGateway = 10.10.10.1

            [Params.TCPIP.Adapter2]
                IPAddress = 11.10.10.2
                SubnetMask = 255.0.0.0
                DefaultGateway = 11.10.10.1

Thanks,

Steve





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

Date: Tue, 22 May 2001 13:44:18 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Help: Can't use correctly File:Find in perl
Message-Id: <3b0a6d32.3013$11b@news.op.net>

In article <9d135994.0105210745.7c40c390@posting.google.com>,
E.Lalande <emmanuel.lalande@bluelineinternational.com> wrote:
>Hope someone out there can help me.  I'm trying to do the command
>"find /a_root_directory/* -prune -type d" under Perl with the
>File:find module 

Perl comes with a program called 'find2perl' that turns 'find'
commands into Perl programs.  If you run

  find2perl /a_root_directory/* -prune -type d

it will print out the equivalent File::Find usage.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Tue, 22 May 2001 18:18:26 +0200
From: "Kenneth Bernholm" <kenneth@kebes.com>
Subject: How free is your RPM-based GNU/Linux distribution?
Message-Id: <ggwO6.259$Zc4.9865@news.get2net.dk>

A little something for those concerned about licensing ...

#!/usr/bin/perl -w
# How free is your RPM-based GNU/Linux distribution?
# by Kenneth Bernholm (kebe@get2net.dk), may 2001
@rpmdump=`rpm -qa --queryformat '%{LICENSE}\n'`;
foreach(@rpmdump) {chomp; if($_) {$lc{$_}++} else {$lc{$_}=1}}
@keys=sort{$lc{$b}<=>$lc{$a}} keys %lc; 
foreach(@keys) {print "$lc{$_}\t$_\n"}
exit(0);


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

Date: 22 May 2001 13:25:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: image_button and onClick???
Message-Id: <9edpcf$q04$4@mamenchi.zrz.TU-Berlin.DE>

Bryan Coon  <bcoon@sequenom.com> top-posted in reply to Alan Flavell:

[...]

> coffee yet, and I do find it irritating having my posts policed and being
> told what is on topic and what is off topic for a perl question in the
> perl.MISC group.

You don't know whom you are talking to, you don't know what you
are talking about, and you don't know how to talk about it.  Follow
the group a bit to learn about all.

Anno


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

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


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