[24822] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6973 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 8 06:06:20 2004

Date: Wed, 8 Sep 2004 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 8 Sep 2004     Volume: 10 Number: 6973

Today's topics:
        create connection from html form into insert MySQL data <gp@nospm.hr>
    Re: create connection from html form into insert MySQL  <noreply@gunnar.cc>
    Re: Execute Windows program from Perl script (??) (kevincar)
        Is it possible to set a content timeout in LWP::UserAge <leifwessman@hotmail.com>
    Re: list of numbers (Charles DeRykus)
    Re: list of numbers <bik.mido@tiscalinet.it>
    Re: LWP::UserAgent and 8bit characters (T Conti)
    Re: Network Scanner (Chad Brown)
    Re: Network Scanner (Chad Brown)
    Re: Object Oriented Perl : Query (Peter J. Acklam)
    Re: print Location to blank window? (krakle)
    Re: print Location to blank window? (krakle)
    Re: Shared memory for data structures <nospam@bigpond.com>
    Re: Shared memory for data structures (Walter Roberson)
    Re: splice or split an array <someone@example.com>
    Re: splice or split an array (Anno Siegel)
    Re: Taking a reference to a calculated value <someone@example.com>
    Re: Taking a reference to a calculated value <chris@cjx.com>
        Trying to replace unicode characters (James)
    Re: Xah Lee's Unixism <reynirhs@mi.is>
    Re: Xah Lee's Unixism <steveo@eircom.net>
    Re: Xah Lee's Unixism <Alain.Picard@memetrics.com>
    Re: Xah Lee's Unixism (Brian {Hamilton Kelly})
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 8 Sep 2004 01:58:40 +0200
From: "PHP2" <gp@nospm.hr>
Subject: create connection from html form into insert MySQL data script
Message-Id: <chlhsq$316$1@ls219.htnet.hr>



I am successful insert data in MySQL with code below:



#!/usr/bin/perl -w

use strict;

use DBI();

use CGI;

use HTML::Template;



# Connect to the database.

my $dbh = DBI->connect("DBI:mysql:database=MYDABASE;host=localhost",

"MYDBUSERNAME", "MYPASS",

{'RaiseError' => 1});

my $turistobjekt = "dadas";

my $adresa = "sdasdasdfADRESA";

my $brojgrada = "1";

my $grad = "1";

my $manjemjesto = "1";

my $otok = "1";

my $regija = "1";

my $ime = "1";

my $prezime = "1";

my $tel = "1";

my $mob = "1";

my $fax = "1";

my $email = "1";

my $username = "1";

my $password = "1";

my $status = "1";



$dbh->do("INSERT INTO portal (turistobjekt, adresa, brojgrada, grad,
manjemjesto, otok, regija, ime, prezime, tel, mob, fax, email, username,
password, status) VALUES ('$turistobjekt', '$adresa', '$brojgrada', $grad',
'$manjemjesto', '$otok', '$regija', '$ime', '$prezime', '$tel', '$mob',
'$fax', '$email', '$username', '$password', '$status')" or die
$dbh->errstr);



$dbh->disconnect();

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



MY QUESTION: How on much simpler way with CGI.pm and HTML::template, instead
variables my $turistobjekt , my $adresa, my $brojgrada etc. RECEIVE any data
from html form successful?

I am read documentation, but whole day have errors.. can someone add and
explain own code connected with my above insert data script..




















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

Date: Wed, 08 Sep 2004 03:14:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: create connection from html form into insert MySQL data script
Message-Id: <2q74iaFs23k7U1@uni-berlin.de>

PHP2 wrote:
> I am successful insert data in MySQL with code below:

You are multi-posting again!!!

(This question is already being answered at the beginners@perl.org list.)

Last time I noticed that rude behaviour from you:
http://groups.google.com/groups?selm=4126806E.8010106%40gunnar.cc

Do you really think that your time is so much more worth compared to 
everybody else's?

BUUHHHH!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 7 Sep 2004 15:39:38 -0700
From: kevindotcar@yahoo.com (kevincar)
Subject: Re: Execute Windows program from Perl script (??)
Message-Id: <60bf9d3f.0409071439.4d95100a@posting.google.com>

tony@paradoxcommunity.com (Tony McGuire) wrote in message news:<f896a829.0408290616.31b184ef@posting.google.com>...
> Well, I'm going to take the easy way out.
> 
> I'll just write something to a file with perl, and have the scheduler
> watch for that file to be modified.
> 
> Then the scheduler program can start the external program.
> 
> Thank you to everyone who participated.  I really do appreciate the
> feedback, regardless of whether it helped or not.

Hi all,
 Lucky me, I just ran into this problem this morning, so I thought 
 I'd  chime in on how I got mine to work ...  It's really more of 
 an Apache config question, but what the hey; Perl is the most used
 CGI program anyway (AFAIK).

My Simple problem description;  I have a VB program that I wanted 
a user to be able to run on my Apache/Perl equipped server - 
I tried this originally with a 1-liner Perl CGI script; 
  
  #!c:/Perl/perl.exe -w
  system("m:/bah/blah/vbrunprogram.exe");

 ...obviously, it was installed under cgi-bin and it was a 
UNIX-style ascii file and all that stuff - It worked when I 
called it from a command window but my Apache logs always
said "Access Denied" when called from a brower.


There were two things going on;  
First, it was a file on a networked drive and apache didn't 
know the first thing about what to do with it-

Second;  Apache doesn't use your logon account; It *could*, but 
it DEFINITELY is not very adviseable!!!  

I solved the problem by having the cgi "1-liner" script call
a DOS bat file with a "net use" wrapper around it; 

C:\cat script.bat
NET USE M: \\machine\mtpoint
m:/bah/blah/vbrunprogram.exe
NET USE M: /DELETE

 ...and change the script to call the bat file;
#!c:/Perl/perl.exe -w
system("script.bat");

Be warned;  the "system" call will dump everything from the 
BAT file onto the user's brower- don't put any embarassing
comments in it!

Hope this helps,
K.c


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

Date: 8 Sep 2004 02:40:08 -0700
From: "Leif Wessman" <leifwessman@hotmail.com>
Subject: Is it possible to set a content timeout in LWP::UserAgent?
Message-Id: <chmk1o$46b@odah37.prod.google.com>


Hi!

I know it's possible to set a connection timeout using $ua->timeout()
function. But how do I set a content timeout? If I connect to a dynamic
webpage that has an programming error and doesn't send any content I
would like to abort. I can't see anything about this in the docs.
Thanks for any input!

Leif



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

Date: Wed, 8 Sep 2004 04:29:46 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: list of numbers
Message-Id: <I3pGHM.H53@news.boeing.com>

In article <chkg25$ajd$1@aspen.sucs.soton.ac.uk>,
Andrew Moffat <ajmoffat@soton.ac.uk> wrote:
>Hi,
>
>I have lots of files with three columns of numbers e.g.
>
>1    2    3
>4.1   5    6
>7    8    9
>.....etc
>
>I want to extract the third column e.g.
>
>3
>6
>9
>....etc
>
>The problem is that I can't just use a colrm type function because the 
>numbers in the first 2 columns aren't always the same number of figures (as 
>above). Each number is seperated by a tab. Can anybody think of a way around 
>this please. TIA.
>

Unix: perl -F\\t -lane 'print $F[2]'  file1 file2...

W2K: perl -F\t -lane "print $F[2]" file1 ...

hth,
--
Charles DeRykus


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

Date: Wed, 08 Sep 2004 08:54:51 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: list of numbers
Message-Id: <lh9tj0t2t23q9m4ojdk658nuq026n533bd@4ax.com>

On Wed, 8 Sep 2004 04:29:46 GMT, ced@bcstec.ca.boeing.com (Charles
DeRykus) wrote:

>>1    2    3
>>4.1   5    6
>>7    8    9
>>.....etc
>>
>>I want to extract the third column e.g.
[snip]
>Unix: perl -F\\t -lane 'print $F[2]'  file1 file2...
>
>W2K: perl -F\t -lane "print $F[2]" file1 ...

Going down the golfing route, I'd suggest

  perl -lape'$_=pop@F'

(-a defaults split()ting on whitespace and "\t" *is* whitespace.)
Without the need of being so drastic, though, it is amazing to see
what kind of clumsy solutions have been posted to this simple
problem...


Michele
-- 
#!/usr/bin/perl -lp
BEGIN{*ARGV=do{open $_,q,<,,\$/;$_}}s z^z seek DATA,11,$[;($,
=ucfirst<DATA>)=~s x .*x q^~ZEX69l^^q,^2$;][@,xe.$, zex,s e1e
q 1~BEER XX1^q~4761rA67thb ~eex ,s aba m,P..,,substr$&,$.,age
__END__


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

Date: 7 Sep 2004 20:44:17 -0700
From: tconti@hotmail.com (T Conti)
Subject: Re: LWP::UserAgent and 8bit characters
Message-Id: <5e0d3eda.0409071944.5828dfb3@posting.google.com>

I have been digging further and I found that the result from
LWP::UserAgent is not the issue.  The issue is further along the
process after the return XML is parsed.  It looks like the encoding
gets all screwed up.  I also found that I can write umlates to an html
file, but the get slammed when they are rendered.

tconti@hotmail.com (T Conti) wrote in message news:<5e0d3eda.0409071307.772957c1@posting.google.com>...
> Hello:
> 
> I am using LWP::UserAgent to make a vanilla request to a web service. 
> The return value is an XML file that may contain utf-8 characters. 
> However when I debug my module I see that the return test is getting
> mangled.  I can call the web service from IE and everything works
> fine.  Here is the code I am using to make the HTTP call:
> 
> my $ua = new LWP::UserAgent;
> my $request = new HTTP::Request('GET', $queryURL);
> my $response = $ua->request($request);
> my $string = $response->content;
> 
> The resulting string slams umlates among other things.  Here is a
> sample of the garbled return data:
> 
> <Location>DE-Baden W&#9500;&#9565;rttemberg-76137 Karlsruhe</Location>
> 
> The proper return data should be:
>  <Location>DE-Baden Württemberg-Obersontheim</Location>
> 
> The return XML is utf-8 encoded. The headers of the response object
> seem to reflect this:
> 
> $VAR1 = bless( {
>                  'client-response-num' => '1',
>                  'x-aspnet-version' => '1.1.4322',
>                  'content-type' => 'text/xml; charset=utf-8',
>                  'connection' => 'close',
>                  'date' => 'Tue, 07 Sep 2004 20:54:00 GMT',
>                  'server' => 'Microsoft-IIS/5.0',
>                  'client-date' => 'Tue, 07 Sep 2004 20:54:00 GMT',
>                  'content-length' => '18835',
>                  'cache-control' => 'private',
>                  'x-powered-by' => 'ASP.NET'
>                }, 'HTTP::Headers' );
> 
> 
> Any thoughts on how to handle this?
> 
> Thanks,
> T


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

Date: 7 Sep 2004 20:21:50 -0700
From: chad@wononline.net (Chad Brown)
Subject: Re: Network Scanner
Message-Id: <ea150da0.0409071921.76db05a2@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote in message news:<x7k6v6sp2m.fsf@mail.sysarch.com>...
> >>>>> "CB" == Chad Brown <chad@wononline.net> writes:
> 
>   CB> I put together a script for scaning a network. Features are DNS
>   CB> resolution, selective port scan, scanning of multiple addresses at one
>   CB> time, and ping sweep. Ports can be customized depending on what is
>   CB> being sought on a network. If anyone decides to add more ideas to this
>   CB> please send me a copy. Im very interested in input. (:
> 
>   CB> http://onager.guild.net/~vrai/
>   CB> chad@wononline.net
> 
> 
> 
>   CB> #!/usr/bin/perl
> 
>   CB> #usage--> netsweep 20.0.0.1
> 
>   CB> use Socket;
>   CB> use Net::Ping;
> 
> no strict or warnings. fix that first and then i will comment on the
> rest.
> 
> <snip of unstrict/unwarned code>
> 
> uri

Im an ace at VB but im new to Perl... yea I know the code looks like a
bucket of bolts slapped up there hehe (:


$ perlcc -o netsweep netsweep.pl
Signal 11
/usr/bin/perlcc: netsweep.pl did not compile, which can't happen:
Starting compile
 Walking tree
 Prescan
 Saving methods
 No definition for sub main::Socket
 No definition for sub main::Socket (unable to autoload)
 No definition for sub main::Net::Ping
 No definition for sub main::Net::Ping (unable to autoload)


this script works very smoothly under interpretation but I wouldnt
have too many ideas of how to fix the no definitions problem...


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

Date: 7 Sep 2004 22:00:48 -0700
From: chad@wononline.net (Chad Brown)
Subject: Re: Network Scanner
Message-Id: <ea150da0.0409072100.4fc460df@posting.google.com>

I fixed the code... but I ran it with the strict and warnings
commented out and . It would not iterate right its sticking to the
first ip (like 21.211.1.0) and the next iterations of the forks run at
the same IP...

I got most of the warnings out but still got one left that im puzzeled
with...

G:\PHASIC\PROJECTS\NETSCAN>netsweep.pl
Bareword "EAGAIN" not allowed while "strict subs" in use at
G:\PHASIC\PROJECTS\NETSCAN\netsweep.pl line 43.
Execution of G:\PHASIC\PROJECTS\NETSCAN\netsweep.pl aborted due to
compilation errors.


here is the recorrected code...


#!/usr/bin/perl

#usage--> netsweep 20.0.0.1

use strict;
use warnings;

use Socket;
use Net::Ping;

my @ports = (21,22,23,80,110,119,1080,8080);
my $Max_Processes = 20;

my $Target_IP = $ARGV[0];

#---Startup

if ( $Target_IP eq "" ) {
 die "need target ip...\n";
}

my @Target_IP_Sep = IP_Seperate($Target_IP);

my $TA = $Target_IP_Sep[0];
my $TB = $Target_IP_Sep[1];
my $TC = $Target_IP_Sep[2];

my $Start_Addy = $TA.".".$TB.".".$TC.".0";
my $End_Addy = $TA.".".$TB.".".$TC.".255";

my $Current_Long = Dot2Long_IP($Start_Addy);
my $End_Long = Dot2Long_IP($End_Addy);


#---Main workload control routines
my $stp = 0;
my $npids = 0;

while () {

 #forker
 FORK: {  
  if (my $pid=fork) {
   #return $pids;
  }
  elsif (defined $pid) {
   Connect_IP(Long2Dot_IP($Current_Long));
  }
  elsif ($! == EAGAIN) {
   sleep 3;
   redo FORK;
  }
  else {
   die "cant fork!\n";
  }
 }

 #fork control
 $npids++;
 if($npids>=$Max_Processes){
   my $wait_ret=wait();
   if($wait_ret>0){
    $npids--;
   }
 }

 #iterate to next IP
 $Current_Long++;

 #look for end IP 
 if ($Current_Long eq $End_Long+1) {
  sleep(2);
  exit(0);
 };

}

#---Sub Functions

sub Dot2Long_IP {
 return unpack('N', inet_aton(shift));
}

sub Long2Dot_IP {
 return inet_ntoa(pack('N', shift));
}

sub IP_Seperate {
 my ($IP_Address) = @_ ;
 my @IP_SepArr = split(/\./,$IP_Address);
 return @IP_SepArr;
}

sub Connect_IP {
 my ($tghost) = @_ ;

 my $connect_list = ""; 

 $connect_list = $tghost;

 #getting host name
 my $host_ipaddr = inet_aton($tghost); 
 my $host_name = gethostbyaddr($host_ipaddr, AF_INET);
 if (my $host_name eq "") {
  my $host_name = "NR";
 }
 $connect_list = $connect_list." $host_name";

 #pinging target
 my $p = Net::Ping->new("icmp");

 if ($p->ping($tghost)) {
  my $connect_list = $connect_list." TG_A"; #for returns
 }
 else {
  my $connect_list = $connect_list." TG_N"; #for negatives
 }

 $p->close();

 #start scan on ports
 foreach my $port (@ports) {

  my $AF_INET=2; 
  my $SOCK_STREAM=1; 
  my $sockaddr='S n a4 x8';   

  my ($name,$aliases,$proto)=getprotobyname('tcp');  

  ($name,$aliases,my $type,my $len,my
$thataddr)=gethostbyname($tghost);
  my $this=pack($sockaddr,$AF_INET,0,my $thisaddr); 
  my $that=pack($sockaddr,$AF_INET,$port,$thataddr); 

  die "unknown host $tghost\n" if($thataddr eq ""); 

  socket(S,$AF_INET,$SOCK_STREAM,$proto) or die $!; 
  bind(S,$this) or die $!; 

  if(connect(S,$that)) {   
   $connect_list = $connect_list." ".$port;
   close(S)
  } 
  else { 
   close(S); 
  }
 
 }

 print "$connect_list\n";

 $connect_list = "";
 exit();
}


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

Date: 08 Sep 2004 08:10:08 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Object Oriented Perl : Query
Message-Id: <656pe1fj.fsf@online.no>

merlyn@stonehenge.com (Randal L. Schwartz) wrote:

> >>>>> "Thens" == Thens  <thens@NOSPAMti.com> writes:
> 
> Thens> sub new {
> Thens>   my ( $self ) = @_;
> Thens>   my $class = ref($self) || $self;
> Thens>   return  bless {  }, $class;
> Thens> }
> 
> Please see <http://www.stonehenge.com/merlyn/UnixReview/col52.html>
> about why that ref($self) thing is bad.

You recommend not using ref($self) because some people might guess
incorrectly what new() does when it is used as an instance method.

How about this:  If people guess method behaviour rather than
reading the docs their votes don't count.  Allow $object->new(),
document the behaviour, and expect people to read it.

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: 7 Sep 2004 22:48:28 -0700
From: krakle@visto.com (krakle)
Subject: Re: print Location to blank window?
Message-Id: <237aaff8.0409072148.231d64a@posting.google.com>

"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<tFl_c.2682$5Y6.2026@trnddc07>...
> Scott Bryce wrote:
> > krakle wrote:
> 
> Oh, krakle is still around?
> 
> >> For the morons of this thread
> >
> > Morons? His question had nothing to do with Perl!
> 
> I guess it's just perfect that he's still a honor guest in my killfile
> 
> jue

You never killfiled me buddy... and you will get this too...


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

Date: 7 Sep 2004 22:49:22 -0700
From: krakle@visto.com (krakle)
Subject: Re: print Location to blank window?
Message-Id: <237aaff8.0409072149.1cdf6936@posting.google.com>

Gregory Toomey <nospam@bigpond.com> wrote in message news:<2pvb6aFortv3U1@uni-berlin.de>...
> krakle wrote:
> 
> > 
> > For the morons of this thread what Travis is asking: Is there away to
> > use the Location header to target a new browser window or an existing
> > one or a frame...
> > And the answer is, surprisingly to most, yes. Use:
> 
> If that is what HE was asking,  why do YOU need to paraphrasew it?
> 
> gtoomey

Well, I gave an answer... which is what everyone else neglected to provide... :)


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

Date: Wed, 08 Sep 2004 09:41:25 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Shared memory for data structures
Message-Id: <2q6v6pFrl6ohU2@uni-berlin.de>

Yash wrote:

> In our Active Perl 5.8 script on Windows 2000, we cache a number of
> database tables in memory in hashes, and use them for lookups to be
> performed on records being read from a number of files. To make use of
> a multiprocessor environment, we spawn multiple processes using fork.
> This causes multiple copies of the cache being maintained. We have to
> update the cache during the processing in certain cases and hence
> would like to keep a single copy so that all processes see the same
> lookup data.
> Is there a way to let Perl keep some of the hash tables in shared
> memory? Can somebody provide relevant pointers/suggestions?
> 
> Thanks
> Yash

If you want shared data you can use System 5 shared memory, which is
available on just about all unixes/linux. Not sure if there is a Perl
module that supports it though.

gtoomey


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

Date: 8 Sep 2004 00:31:44 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Shared memory for data structures
Message-Id: <chljtg$iqj$1@canopus.cc.umanitoba.ca>

In article <2q6v6pFrl6ohU2@uni-berlin.de>,
Gregory Toomey  <nospam@bigpond.com> wrote:
:Yash wrote:

:> In our Active Perl 5.8 script on Windows 2000, we cache a number of
:> database tables in memory in hashes,

:If you want shared data you can use System 5 shared memory, which is
:available on just about all unixes/linux.

Gregory, is the OP's Windows 2000 system unix or linux, or even
System V compatible?


To be fair, though, as of Windows 2000 (not earlier), Windows impliments
the POSIX shared memory primitives.

http://www.microsoft.com/technet/itsolutions/interop/sfu/sfuposix.mspx#XSLTsection152121120120
-- 
'ignorandus (Latin): "deserving not to be known"'
   -- Journal of Self-Referentialism


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

Date: Tue, 07 Sep 2004 23:36:12 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: splice or split an array
Message-Id: <MBr%c.155446$X12.102852@edtnps84>

Scott Bryce wrote:
> Peter wrote:
> 
>> @list =
>> ("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17" 
>> ,"18");
> 
> Double quotes are neither necessary, nore desireable here.
> 
> my @list = qw(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18);
> 
> or
> 
> my @list = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18);
> 
> or
> 
> my @list = (1 .. 18);

Speaking of unnecessary, the parentheses are not required in the last example. 
  :-)

my @list = 1 .. 18;


John
-- 
use Perl;
program
fulfillment


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

Date: 8 Sep 2004 09:31:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: splice or split an array
Message-Id: <chmjhg$3lj$1@mamenchi.zrz.TU-Berlin.DE>

Peter <clandos@yahoo.com> wrote in comp.lang.perl.misc:
> Hello,
> I try to split an array into a couple of arrays the same size.
> 
> This is my code and I think its very ugly ;-)
> 
> Does anoyone has a better idea?
> 
> @list =
> ("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"
> ,"18");
> 
> $pack =5;
> 
> $avg = $#list / $pack + 1;
> 
> for(1..$pack+1)
> {
>  @newlist = splice(@list,0,$avg) if @list;
> 
>  print "@newlist\n";
> }

Your loop runs one time too many.  It will print the last partial
list twice.  You seem to want $pack sublists, so the loop should
run over 1 .. $pack.

Equal sizes are, of course, only possible if $pack divides the length
of the original list.  Your solution, like Brian's proposition, leaves
the last sublist short.  If it matters, the sublist can be made more
equal than that:

    my @list = 1 .. 18;
    my $pack = 5;

    my @sizes = ( int @list/$pack) x $pack;
    $_ ++ for @sizes[ 0 .. @list % $pack - 1];
    print "@$_\n" for map [ splice @list, 0, $_], @sizes;

This produces sublists whose sizes differ by at most one.  The first
few (@list % $pack) are longer.

A similar result, but with the longer lists last, can be obtained
like this:

    while ( @list ) {
        my @newlist = splice @list, 0, @list/$pack--;
        print "@newlist\n";
    }

but that one is a little hard to verify.  Will it ever divide by zero?
Also, it destroys not only @list, but also $pack.

Anno


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

Date: Tue, 07 Sep 2004 23:41:32 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Taking a reference to a calculated value
Message-Id: <MGr%c.155448$X12.92779@edtnps84>

Chris Allen wrote:
> I'm really stuck on the syntax for this one. 
> 
> I want to do the equivalent of:
> 
> %a=('a'=>1,'b'=>2,'c'=>3);
> @temp=keys %a;
> $b=\@temp;
> 
> But I can't find a single statement that will
> do it. I've tried:
> 
> $b= \(keys %a); 
> @$b = keys %a;
> $b=\@{keys %a};
> 
> They don't do the above - and actually I don't understand
> why they do what they do...
> 
> Can anybody help?

I am assuming from the subject line that you want this:

$b = \scalar @temp;


John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 08 Sep 2004 06:06:10 +0100
From: Chris Allen <chris@cjx.com>
Subject: Re: Taking a reference to a calculated value
Message-Id: <pan.2004.09.08.05.06.09.939221@cjx.com>

On Tue, 07 Sep 2004 18:21:34 +0000, Paul Lalli wrote:

> "Chris Allen" <chris@cjx.com> wrote in message
> news:pan.2004.09.07.18.00.06.390361@cjx.com...
>>
>> I want to do the equivalent of:
>>
>> %a=('a'=>1,'b'=>2,'c'=>3);
>> @temp=keys %a;
>> $b=\@temp;
> 
> $b = [ keys %a ];

Thanks to you and everyone else who pointed this out. 

> 
>> @$b = keys %a;
> 
> This should work, but is a bit ugly.  You're telling Perl $b is an array
> reference, and then assigning the list of values returned by keys to the
> array referenced by $b.   How did this "not work" for you?

Ah - my fault entirely on this one - I had been trying things in the
debugger, and had done:

$b=\keys %a; (one of many failed attempts)

@$b = keys %a; 

which printed "Not an ARRAY reference".

That'll teach me to be more careful!




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

Date: 7 Sep 2004 19:33:47 -0700
From: purserj@winnsw.com.au (James)
Subject: Trying to replace unicode characters
Message-Id: <432f26d0.0409071833.243ec5ae@posting.google.com>

I am writing a script that takes an Excel spreadsheet and using
SpreadSheet::ProcessExcel converts the data into a MySQL db.
Everything goes along fine until I hit the horizontal-ellipses unicode
character. I am trying to find out the best way to search for Unicode
characters in an ASCI string.

Thanks

If this is a noob question then I apologise in advance.


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

Date: Wed, 08 Sep 2004 02:18:46 +0000
From: Reynir Stefánsson <reynirhs@mi.is>
Subject: Re: Xah Lee's Unixism
Message-Id: <ucpsj0pc4ckos04lhm055qtvjse6bts3o6@4ax.com>

So spake Alan J. Flavell:

>On Tue, 7 Sep 2004, John Thingstad wrote:
>
>> It was the realization of www (CERN) that spawned the movement toward the
>> Internet.
>
>Eh?

Could the 'movement' be the mass influx of muggles?
-- 
Reynir Stefánsson (reynirhs@mi.is)


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

Date: Tue, 7 Sep 2004 19:21:21 +0100
From: Steve O'Hara-Smith <steveo@eircom.net>
Subject: Re: Xah Lee's Unixism
Message-Id: <20040907192121.61dbf949.steveo@eircom.net>

On Tue, 07 Sep 2004 07:00:23 GMT
Morten Reistad <firstname@lastname.pr1v.n0> wrote:

> Since I am on a roll with timelines; just one off the top of my head : 
> 
> Project start     : 1964
> First link        : 1969
> Transatlantic     : 1972 (to Britain and Norway)
> Congested         : 1976
> TCP/IP            : 1983 (the effort started 1979) (sort of a 2.0 version)
> First ISP         : 1983 (uunet, EUnet followed next year)
> Nework Separation : 1983 (milnet broke out)
> Large-scale design: 1987 (NSFnet, but still only T3/T1's)
> Fully commercial  : 1991 (WIth the "CIX War")
> Web launced       : 1992
> Web got momentum  : 1994
> Dotcom bubble     : 1999 (but it provided enough bandwith for the first time)
> Dotcom burst      : 2001

	One thing I always found amusing is the amount of science *fiction*
written in the first half of this period about what would happen if the
worlds computers became linked together.

-- 
C:>WIN                                      |   Directable Mirror Arrays
The computer obeys and wins.                | A better way to focus the sun
You lose and Bill collects.                 |    licences available see
                                            |    http://www.sohara.org/


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

Date: Wed, 08 Sep 2004 17:13:46 +1000
From: Alain Picard <Alain.Picard@memetrics.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <87wtz5nsgl.fsf@memetrics.com>

Steve O'Hara-Smith <steveo@eircom.net> writes:

> 	One thing I always found amusing is the amount of science *fiction*
> written in the first half of this period about what would happen if the
> worlds computers became linked together.

Yeah, but unfortunately (fortunately?) nobody predicted that 99%
of them would be running such an incredibly stupid dumbed down
OS.  Maybe that's the only reason why we're still around.  :-)



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

Date: Tue, 07 Sep 2004 22:04:52 +0100 (BST)
From: bhk@dsl.co.uk (Brian {Hamilton Kelly})
Subject: Re: Xah Lee's Unixism
Message-Id: <20040907.2104.57722snz@dsl.co.uk>

On Tuesday, in article
     <qsdrj0dl4qi558bopev159fg4m7rn6mfoq@4ax.com>
     Brian.Inglis@SystematicSW.Invalid "Brian Inglis" wrote:

> I was never aware that DEC offered TCP/IP. 

You'll have seen my later post about "TCP/IP Services for Vax/VMS"
(which, a niggle tells me, had a different name, either before or after).
This was written by the Unix developers at DEC, and consequently was very
kuldgy and astonishingly badly-documented (for those of us used to the
high quality of VMS documentation).

Did you never see a 
    UCX>
prompt?

> Politics and not timing was why TCP/IP didn't get into VMS:
> d|i|g|i|t|a|l backed the European horse that never ran as it fitted
> better with their network hardware capabilities and DECnet plans.
> It also meant they did not have to deal with those BBN guys that had
> developed a competing OS and network. 
> They had whole suites of products layered on top of DECnet that were
> sold to European governments and contractors. 

Can you say "Colour Book Software"? :-(

(Mind you, unattended file transfer running overnight beats FTP hands
down.)

-- 
Brian {Hamilton Kelly}                                     bhk@dsl.co.uk
   "I don't use Linux. I prefer to use an OS supported by a large multi-
   national vendor, with a good office suite, excellent network/internet
   software and decent hardware support."


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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