[10507] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4099 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 29 00:06:55 1998

Date: Wed, 28 Oct 98 21:00:16 -0800
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, 28 Oct 1998     Volume: 8 Number: 4099

Today's topics:
    Re: Another regexp help? <J.D.Gilbey@qmw.ac.uk>
    Re: Another regexp help? (Tad McClellan)
    Re: Checking Input for Exactly 2 numbers (I R A Aggie)
        do vs eval `` - perl book wrong? (Thomas Andrews)
    Re: do vs eval `` - perl book wrong? (Martien Verbruggen)
        Dumbass newbie needs help (James Barton)
    Re: Dumbass newbie needs help (Martien Verbruggen)
    Re: leading spaces and pipes (Tad McClellan)
    Re: Looking for a shopping cart kmcarthur@my-dejanews.com
        Need simple solution on 'formatting' data printed from  <jhawk39@idt.net>
    Re: new version of perldb.pl <mpersico@erols.com>
    Re: Not to start a language war but.. (Abigail)
    Re: Not to start a language war but.. (Abigail)
    Re: Perl & Y2K - booby trap code (Joergen W. Lang)
    Re: Perl how-to question (Martien Verbruggen)
        Perl Setup: (Why 'use' statement gives =>not found) devonc1061@my-dejanews.com
        perldoc -i switch/perldoc documentation <ltl@rgsun40.viasystems.com>
    Re: The point of curly braces (Abigail)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 29 Oct 1998 03:27:27 +0000
From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
Subject: Re: Another regexp help?
Message-Id: <3637E09F.1C4A5D2E@qmw.ac.uk>

Doug O'Leary wrote:
> 
> Hi;
> 
> I'm close, but I just can't seem to bust that \n barrier.  To make a long story
> short, HPUX has a command that will display all the disks on the system with
> the following format:
> 
> Class     I  H/W Path   Driver S/W State H/W Type Description
> ===============================================================
> disk      5  0/4.2.0    disc3  NO_HW     DEVICE    TOSHIBA CD-ROM XM-5401TA
>                        /dev/dsk/c0t2d0      /dev/rdsk/c0t2d0
>                        /dev/floppy/c0t2d0   /dev/rfloppy/c0t2d0
> [...]
> The short snippet of the code that I'm working with follows:
> 
> open (Scan,"ioscan -fun -C disk|") || die "Can't execute ioscan - $!";
> 
> while (<Scan>)
> { if (
> m#(\w+\s+){2}(\d+/\d+\.\d+\.\d+)\s+(\w+\s+){3}(\w+)\s+\w+\n*(/\w+/\w+/\w+)#s)
>    {  $Hw=$2;
>       $Manu = $4;
>       $Disk=$5;
>       printf ("%-15s\t%-10s%s\n",$Hw,$Manu,$Disk);
>    }
> }

The first problem is surely that <Scan> reads in only one line at a
time.
So you'll have to find some way of reading in all of the data for an
item
in one go, or doing the reading in two goes.

How about, assuming that entries are always at least two lines long, and
that
a new entry always begins with a non-space character:

while (<Scan>) {
   continue unless /^\w/;
   m#(\w+\s+){2}([\d\./]+)\s+(\w+\s+){3}(\w+)#;
   $Hw=$2;
   $Manu=$4;

   # Now find out the disk name
   $_=<Scan>;
   m#\s+(\S+)#;
   $Disk=$1;
   printf ("%-15s\t%-10s%s\n",$Hw,$Manu,$Disk);
}

HTH,

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


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

Date: Wed, 28 Oct 1998 22:59:00 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Another regexp help?
Message-Id: <kms817.01n.ln@flash.net>


[ please follow usual Usenet custom and limit your lines to
  70-72 characters.
]


Doug O'Leary (dkoleary@wwa.com) wrote:


: What I'm looking for is a hash with the h/w path as the key - eg:

: $Hw{0/4.2.0} => /dev/dsk/c0t2d0.  


   I'll leave it to you to build the hash.


: I can get this by running through the HPUX command twice - first time to get 
: the hw paths, second time to get the disk names; however, I *know* there's a 
: way to get them both with one run of the ioscan command.  


   I'll leave it to you to change 'DATA' to 'Scan'.

  
: open (Scan,"ioscan -fun -C disk|") || die "Can't execute ioscan - $!";


   You might want to have a look at this Frequently Asked Question too:

   Perl FAQ, part 8:

      "Why doesn't open() return an error when a pipe open fails?"


: m#(\w+\s+){2}(\d+/\d+\.\d+\.\d+)\s+(\w+\s+){3}(\w+)\s+\w+\n*(/\w+/\w+/\w+)#s)


   Whew! There's some write-only code.

   Have pity on the poor fool that has to maintain your code. Break
   up that match with m##x.


: I've also tried switching the #s to #m's with no luck.


   m//s changes the interpretation of the dot metacharacter.

   Your regex has no dot metacharacters.

   m//s has no effect for your regex.



   m//m changes the interpretation of anchors ( ^ and $ ).

   Your regex has no anchors.

   m//m has no effect for your regex.



: I've been pounding my head against this wall for about five hours now.  Any 
: help/tips would be greatly appreciated.


   This should get you started:


-------------------------------------------------
#!/usr/bin/perl -w

while (<DATA>) {
   if ( (/^disk/ || eof) && $record) {   # got a record

      ($hw, $manu) = (split /\s+/, $record)[2,6];

      $disk = $record =~ /^\s+(\S+)/m ? $1 : 'no disk found';

      printf ("%-15s\t%-10s%s\n", $hw, $manu, $disk);

      $record=$_;                        # start building the next record
   }
   else {
      $record .= $_;                     # continue building the next record
   }

}


__DATA__
disk      5  0/4.2.0    disc3  NO_HW     DEVICE    TOSHIBA CD-ROM XM-5401TA
                       /dev/dsk/c0t2d0      /dev/rdsk/c0t2d0
                       /dev/floppy/c0t2d0   /dev/rfloppy/c0t2d0
disk    162  0/52.1.0   disc3  CLAIMED   DEVICE    SEAGATE ST32550W
                       /dev/dsk/c6t1d0      /dev/rdsk/c6t1d0
                       /dev/floppy/c6t1d0   /dev/rfloppy/c6t1d0
-------------------------------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 28 Oct 1998 21:24:49 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Checking Input for Exactly 2 numbers
Message-Id: <fl_aggie-2810982124490001@aggie.coaps.fsu.edu>

In article <comdog-ya02408000R2810981646400001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:

+ two numbers or one number with two digits?  if the latter, which base?

D0H!

James - base 60, any one?? ;)


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

Date: 28 Oct 1998 19:49:20 -0800
From: thomaso@best.com (Thomas Andrews)
Subject: do vs eval `` - perl book wrong?
Message-Id: <718ok0$nes$1@shell3.ba.best.com>

It appears that the blue camel book has made an error in stating
that:

	do './foo.pl';

is the same runtime behavior as:

	eval `cat ./foo.pl`;

In particular, if I do:

sub test {
	my ($foo,$bar)=qw(a b);
	do './test2.pl';
}

the variables $foo and $bar are unset in test2.pl, while if I do:

sub test {
	my ($foo,$bar)=qw(a b);
	eval `cat ./test2.pl`;
}

the variables $foo and $bar are set.
-- 
Thomas Andrews         thomasoa@yahoo.com         http://www.best.com/~thomaso/
    "Show me somebody who is always smiling, always cheerful, always
    optimistic, and I will show you somebody who hasn't the faintest
    idea what the heck is really going on." - Mike Royko


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

Date: Thu, 29 Oct 1998 04:19:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: do vs eval `` - perl book wrong?
Message-Id: <W0SZ1.36$Ci5.115430@nsw.nnrp.telstra.net>

In article <718ok0$nes$1@shell3.ba.best.com>,
	thomaso@best.com (Thomas Andrews) writes:
> It appears that the blue camel book has made an error in stating
> that:
> 
> 	do './foo.pl';
> 
> is the same runtime behavior as:
> 
> 	eval `cat ./foo.pl`;
> 
> In particular, if I do:
> 
> sub test {
> 	my ($foo,$bar)=qw(a b);
> 	do './test2.pl';
> }
> 
> the variables $foo and $bar are unset in test2.pl, while if I do:
> 
> sub test {
> 	my ($foo,$bar)=qw(a b);
> 	eval `cat ./test2.pl`;
> }
> 
> the variables $foo and $bar are set.

Only if you declare them with my. Otherwise they'll be set in both
examples. The reason for that is obviously the scope that my
introduces there.

It still means, however, that the two situations are not identical, as
the documentation for do suggests. Maybe you should submit a bug
report (stating that the documentation is incomplete, and needs to be
changed in the following way.....).

You might also want to write to the authors of the blue camel.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Thu, 29 Oct 1998 01:54:48 GMT
From: jamesbarton@mail.ndirect.co.uk (James Barton)
Subject: Dumbass newbie needs help
Message-Id: <3637c9ff.46779578@news.netdirect.net.uk>

Briefly, and hopefully not too off topic

cgi scripts not requiring cgi-lib.pl will run over the network and
from the command line
cgi scripts requiring cgi-lib.pl will not run over the network, but
will run from the command line

cgi-lib.pl is in the same directory as the cgi scripts, and the server
is apache

Please reply directly to jbarton@wavenet.co.uk
Thanks in advance,
James


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

Date: Thu, 29 Oct 1998 04:40:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Dumbass newbie needs help
Message-Id: <EkSZ1.39$Ci5.115430@nsw.nnrp.telstra.net>

In article <3637c9ff.46779578@news.netdirect.net.uk>,
	jamesbarton@mail.ndirect.co.uk (James Barton) writes:

> cgi scripts requiring cgi-lib.pl will not run over the network, but
> will run from the command line

# perldoc perlfaq9
First question:
     My CGI script runs from the command line but not the
     browser.  Can you help me fix it?

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 28 Oct 1998 22:07:52 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: leading spaces and pipes
Message-Id: <omp817.5lm.ln@flash.net>

Tk Soh (r28629@email.sps.mot.com) wrote:

: try this:

: ($junk, @field2) = split(/\|/,$prefix);

: Of course you can always undef $junk, if you even bother;


   try this (with a recent perl):

   (undef, @field2) = split(/\|/,$prefix);  # no temp variables


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Oct 1998 03:47:36 GMT
From: kmcarthur@my-dejanews.com
Subject: Re: Looking for a shopping cart
Message-Id: <718ogo$gjd$1@nnrp1.dejanews.com>

You might be interested in a survey that we are taking of actual costs paid
for shopping cart websites.  The information is at http://www.mbsinternet.com

Kenneth A. McArthur
MBS Internet
Internet Services for Business
www.mbsinternet.com
mailto:kmcarthur@mbsinternet.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 28 Oct 1998 22:07:08 -0600
From: "AgentJ" <jhawk39@idt.net>
Subject: Need simple solution on 'formatting' data printed from a file
Message-Id: <718pli$qrk@nnrp2.farm.idt.net>

OK, I'm a total quack trying to write a somewhat legitimate snippet of Perl.
I've achieved virtual success...but am stuck in one place. I'm trying to
simple read specific lines from a text file. I'm to the point where I'm able
to read and print the proper lines...but there's no 'carriage return'. I'm
assuming I need a '/n' in there somewhere...but I've been unsuccessful in
finding the right place.

Here's the snippet of active code:

   open (EVENTFILE, "oct.txt");
 until ( $currentDay == $dayOfMonth ) {
 $currentDay = <EVENTFILE>;
   }

 until ($currentDay =~ /<\/ul>/)  {
 $currentLine = <EVENTFILE>;
 print $currentDay;
   }

   close (EVENTFILE);

It just spits out all the lines in one continuous stream without any
'carriage returns'. I'd love to have it print each line to the browser
separately just as it is in the text file. I'd rather learn how to do this
than put a <br> or paragraph tags on each line of the text file.

If anyone can help...I'd be eternally grateful and believe that there is
more to the internet than porn and chatrooms. Course..."Not that there's
anything wrong with that."

-John




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

Date: Wed, 28 Oct 1998 21:47:36 -0500
From: "Matthew O. Persico" <mpersico@erols.com>
To: bobmorgan@my-dejanews.com
Subject: Re: new version of perldb.pl
Message-Id: <3637D748.97D2F4D@erols.com>

[ with courtesy CC to poster: ]

If you have PerlTk installed, why not try a graphical deebugger:

http://world.std.com/~aep/ptkdb/

bobmorgan@my-dejanews.com wrote:
> 
> Hi,
> 
>   Does anyone know where I can get a new version of perldb.pl - debugging
> library for perl. The current version I have is patch level 0.94 for Unix/AIX
>  4.1.4.
> 
>   I have not been able to find any new references to it on CPAN. Has it been
>   updated or not ? Any tips appreciated.
> 
>   Also: If anyone uses the perl debugger, do you have any clues why I would
> be getting a message about 100 levels deep in recursion ? Can this be fixed ?
> 
>   Thanks,
> 
>   Bob Morgan
>   bob.morgan@computer.org
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

-- 
Matthew O. Persico
Nothing even remotely clever at the moment.


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

Date: 29 Oct 1998 04:20:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Not to start a language war but..
Message-Id: <718qep$4ka$1@client3.news.psi.net>

Dirk Heise (dheise@metronet.de) wrote on MDCCCLXXXIV September MCMXCIII
in <URL:news:01be02bf$c70a4260$LocalHost@dreadzone>:
++ Abigail wrote:
++ > Klaus Schilling (Klaus.Schilling@home.ivm.de) wrote on MDCCCLXXXIII
++ > September MCMXCIII in <URL:news:87vhl671tf.fsf@ivm.de>:
++ > ++ 
++ > ++ 
++ > ++ Would python or perl change severely if one replaced ref-counting with
++ a real
++ > ++ gc like Boehm's?
++ > 
++ > 
++ > No.
++ 
++ Wrong. It would change severely as the destructors of Python
++ objects would be called at moments you can't manipulate
++ directly. Maybe you can when you have much knowledge
++ about the gc strategy, but usually, such strategies should
++ be hidden from the programmer and not be part of a 
++ public interface.
++ 
++ It can be worked around, but it would change the
++ behaviour of existing code, maybe severely.


It might change the behaviour of some existing code severly, it will
not change Perl severely. And that was what Klaus asked.



Abigail
-- 
perl -wlpe '}{$_=$.' file  # Count the number of lines.


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

Date: 29 Oct 1998 04:45:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Not to start a language war but..
Message-Id: <718rsc$ctn$1@client3.news.psi.net>

Zenin (zenin@bawdycaste.org) wrote on MDCCCLXXXV September MCMXCIII in
<URL:news:909623452.948196@thrush.omix.com>:
++ Dave Kirby <dkirby@bigfoot.com> wrote:
++ 	>snip<
++ : Yes python is OO, and so is perl. However creating a class in perl is
++ : frankly a pain in the ass,
++ 
++ 	Huh?  What ya been smoking?
++ 
++ 		package Foo;
++ 		sub new { bless {}, shift }
++ 
++ 	Or even shorter:
++ 
++ 		sub Foo::new { bless {}, shift }

Or even shorter:
bless {} => 'Foo';

One can even say that in Perl, one doesn't even have to create classes.

++ 	Name a platform Python supports that Perl doesn't, I dare you.
++ 	However I'd be surprised if I couldn't name a few that Perl
++ 	supports but Python doesn't.

Well, arguebly, the Mac. While Python was developped on the Mac, no
official version of Perl ran on the Mac. There have been separate ports to
the Mac, but that's all. I'd be surprised to see a Mac version of 5.005.

++ : * Exceptions. These make error handling far easier and greatly
++ : simplify the code.
++ 
++ 	Perl has had exceptions for dog years, before it even had
++ 	OO.  We just call try, throw, and catch "eval", "if", and "die"
++ 	respectively:

If you claim Perl has had exceptions for dog years, don't come with
a spiffy OO example which has only been there since 5.005 - and then
as an undocumented experimental feature.

And don't use // style comments. They don't work that well in Perl.

++ 	sub MyException::new { bless {}, shift() }
++ 	eval {
++ 	    trySomething()
++ 	        or die new MyException ();
++ 	};
++ 	if ($@) {
++ 	    if (ref $@ eq 'MyException') {
++ 	        cleanUp();
++ 	    }
++ 	    else {
++ 	        die; // propagate the exception
++ 	    }
++ 	}
++ 
++ : * Easy embeding and extending. I can easily write extensions in C, C++
++ : or other languages and they become a part of python. I can also embed
++ : the interpreter in a C or C++ (or java with jpython) application to
++ : give it scripting capabilities.  These are possible in perl, but are
++ : far more complex.
++ 
++ 	I was writing C extensions in Perl 20 minutes from the moment I
++ 	started reading the perlxstut man page, and I'm far from the C
++ 	expert.  Perl has also been embedable for likely longer then
++ 	Python has existed.

You must be an exception, and you don't hear people often claim XS
is easy. Perhaps you are the person who could write a good tutorial
about XS then?

++ : - you have to be careful not to mix indentation
++ : by tabs with indentation by spaces.

Now that makes for interesting bugs because your code was maintained
by someone else with different editor settings.

++ 
++ 	From my current (blagh) Java project:
++ 
++     public StringBuffer append (boolean bool)   { _extractStringBuffer().append (bool); type = STRING; return string; }
++     public StringBuffer append (char	ch)	{ _extractStringBuffer().append (ch);   type = STRING; return string; }
++     public StringBuffer append (int     num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
++     public StringBuffer append (long    num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
++     public StringBuffer append (float   num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
++     public StringBuffer append (double  num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
++     public StringBuffer append (Object  obj)    { _extractStringBuffer().append (obj);  type = STRING; return string; }
++     public StringBuffer append (String  str)    { _extractStringBuffer().append (str);  type = STRING; return string; }
++     public StringBuffer append (char[]  data)   { _extractStringBuffer().append (data); type = STRING; return string; }
++ 
++ 	Please show me how the readability of this code would be helped	by
++ 	either indent style blocks or max 80 column text.  Give me a couple
++ 	minutes and I'm sure I could dig up a couple dozen Perl and C
++ 	examples as well.

Oh, that's easy:

     public StringBuffer append (boolean bool) {
         _extractStringBuffer().append (bool);
         type = STRING;
         return string;
     }

Code with lines over 80 chars always lose when it comes to readability.

++ 
++ 	>snip<
++ : The bottom line is that both languages are freely available - it just
++ : costs some of your time to try them both and make up your own mind.
++ 
++ 	Yep, and a bit of time to wade through the BS each side dish
++ 	out to see what is really there.
++ 
++ : dkirby@   <-figure this out, spambots!
++ : bigfoot.   My opinions are my own,
++ : com        but I'm willing to share.
++ 
++ -- 
++ -Zenin (zenin@archive.rhps.org)
++  My opinions are mine, and you can't have them, so there.
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Wed, 28 Oct 1998 16:39:33 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <1dhm71c.1p5xsprd65328N@[194.97.197.4]>

Russ Allbery <rra@stanford.edu> wrote:

> Matt Knecht <hex@voicenet.com> writes:
> > Uri Guttman <uri@fastengines.com> wrote:
> 
> >> and strftime is the best way but rarely mentioned. everyone seems to
> >> use localtime.
> 
> > Why is strftime better than localtime?  Note: I'm not flaming ... I
> > really want to know!
> 
> localtime is faster.  strftime means that you don't have to do all the
> grungy number formatting yourself, you don't have to store arrays of month
> and week names, and you automatically get the benefit of system locales
> and generate names in the right language.  But it means you have to load
> POSIX.

Here's an example someone came up with after a discussion in
de.comp.lang.perl. This uses localtime to get a 4-digit year without
having to do number formatting.
I'm not sure if it meets the requirements of the original poster, which
a glance at dejanews did not bring up but I like it as a quick
workaround.

my $four_digit_year = ((split / /, localtime)[4]);      

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Thu, 29 Oct 1998 02:09:39 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl how-to question
Message-Id: <D7QZ1.11$Ci5.35901@nsw.nnrp.telstra.net>

In article <718grq$elf$1@supernews.com>,
	"Alistair Calder" <webmaster@topproducer.com> writes:
> I am creating an online survey for the company I work for.  I have
> programmed in perl before, but this question has flummoxed me.
> 
> I want to create a single file that will store all the survey values,
> including the survey Question, the possible responses and the number of
> respondants.  The catch is that the surveys will have a varying number of
> responses and I don't know how to tell perl to read that in.
> 
> Here is what the file will look like:
> 
> Survey_Date|Survey_Question|Number_Of_Responses|Response_A|Total_A|Response_
> B|Total_B
> 
> So a real life example would be:
> 
> 01/01/98|Do you think that Clinton should be impeached?|3|Yes, I think
> so|301|Not Really|268|Couldn't care less|65
> 
> I know how to do a split on a file I have read in, but only if I know the
> number of responses that I have.  How can I do this properly?

Do the split, in such a way:

($date, $question, $n, @f) = split(/\|/, $line);

$n will contain the number of responses, @f will contain the responses
and the numbers. of course, you don't need $n, because @f in a scalar
context will give you that same number doubled (if $n is correct). Or
$#f + 1 will also give you that number. Now all you need to do is loop
over @f to get each response and their number in turn. You might want
to check that @f actually contains an even number of elements.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Thu, 29 Oct 1998 04:09:30 GMT
From: devonc1061@my-dejanews.com
Subject: Perl Setup: (Why 'use' statement gives =>not found)
Message-Id: <718ppq$i97$1@nnrp1.dejanews.com>

Hi Guys,
I've just installed perl on an AIX box and everything seemed fine until I
included the 'use strict' or 'use <anything>' statement.
At runtime I get a
use: not found

A 'perl -V' shows that the appropriate directories are there :-
@INC:
    /usr/local/lib/perl5/aix/5.00404
    /usr/local/lib/perl5
    /usr/local/lib/perl5/site_perl/aix
    /usr/local/lib/perl5/site_perl

Your ideas would be helpful here.

Thanks
Devon_C

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 29 Oct 1998 02:31:41 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: perldoc -i switch/perldoc documentation
Message-Id: <718k2d$857$1@rguxd.viasystems.com>

"perldoc perldoc" does not tell me about the "-i" switch for case
insensitive matching.  Neither does the manual page.  Is it a
relatively new feature that just hasn't made it into the documenation
yet?

perldoc -h does describe the -i switch.

Also,

This paragraph from perldoc -h (and the similar ones from "perldoc
perldoc" and "man perldoc") describes partial matching of a module
name:

PageName|ModuleName...
	 is the name of a piece of documentation that you want to
	 look at. You may either give a descriptive name of the page
	 (as in the case of `perlfunc') the name of a module, either
	 like `Term::Info', `Term/Info', the partial name of a
                                     ^^^^^^^^^^^^^^^^
	 module, like `info', or `makemaker', or the name of a
	 program, like `perldoc'.

But I can't seem to make that work.  Example:

n5{ltl}ksh: perldoc Tk::Table

   [works --displays documentation]

n5{ltl}ksh: perldoc Table
No documentation found for "Table".

Am I not installed correctly or is this a feature that doesn't work
as described?  Do I have to build the "index" to make this work?

-- 
// Lee.Lindley@Viasystems.com



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

Date: 29 Oct 1998 04:51:09 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: The point of curly braces
Message-Id: <718s7t$ctn$2@client3.news.psi.net>

Jason Orendorff (jorendorff@ixl.com) wrote on MDCCCLXXXV September
++ 
++ Anyway, the practice is almost as rare in Python.  Typically, if you're
++ writing something long enough to need multiple lines, it's already got
++ some parentheses or brackets somewhere.


Unless you are like me, and write functions that can accept a
myriad of named arguments.


$result = some_function  parameter1 => value1,
                         parameter2 => value2,
                         parameter3 => value3,
                         parameter4 => value4;


That's certainly not uncommon in my code.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4099
**************************************

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