[6826] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 451 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 8 13:17:41 1997

Date: Thu, 8 May 97 10:00:31 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 8 May 1997     Volume: 8 Number: 451

Today's topics:
     An question about CGI.pm (Cheng Tyh Lin)
     Re: clever coding required (Chipmunk)
     Re: clever coding required (Chipmunk)
     Re: clever coding required <friedman@uci.edu>
     Re: Complex Data Structure help: How can I do a push?? (Tony Bass)
     Re: Dates <merlyn@stonehenge.com>
     Drawing a graph? (Michael Schuerig)
     Re: Finding a pattern in a file (Chipmunk)
     FormMail & NT Server (EMWAC Internet Mail Services for  <merath@berlin.snafu.de>
     Re: GIF in Base64 encoding? (Kyzer)
     mount problem on install <geoff@opcom.ca>
     Re: need help w/forms and Perl (I R A Aggie)
     Re: Need help with PERL script! <dorman@s3i.com>
     Perl and setuid problem (Rick Greene)
     Re: PERL cross reference generator (Malcolm Beattie)
     Perl-Socket using in C ??? <kipar@informatik.uni-bonn.de>
     perl5.003 installing help <rcastill@icix.net>
     Re: perl5.003 installing help <a.aitken@unl.ac.uk>
     PerlScript & Active Server Pages jcoleman@alison.sbc.edu
     Re: Possible inclusion into FAQ <merlyn@stonehenge.com>
     possible typo warning <eglamkowski@hotmail.com>
     Re: program for perl? <rkd7949@ballard.ca.boeing.com>
     Programmin Perl on MacOS <george@9003inc.com>
     Re: replacing escape characters in a text file. (Chipmunk)
     Re: Request for simple text file handling program <a.aitken@unl.ac.uk>
     Require assistance with function stat ( Thomas Lachlan XMS x1893 )
     Re: Require assistance with function stat <fawcett@nynexst.com>
     Re: scalar holds compiled code (Chipmunk)
     Something I'm missing <abennett@stonehill.edu>
     Re: Something I'm missing (A. Deckers)
     Re: standards <merlyn@stonehenge.com>
     sybperl problem (Mr Simon Lee)
     Re: system () won't execute the called program. <a.aitken@unl.ac.uk>
     testing for non-existence in an associative array??? (Marshall Pierce)
     Re: testing for non-existence in an associative array?? <friedman@uci.edu>
     Re: testing for non-existence in an associative array?? <a.aitken@unl.ac.uk>
     Re: Trash can or wastebasket for Unix (Jason Kohles)
     url detection in a string (Sascha Kerschhofer)
     variable  names <eglamkowski@hotmail.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 8 May 1997 14:12:02 GMT
From: a00lcj00@elc010.nchc.gov.tw (Cheng Tyh Lin)
Subject: An question about CGI.pm
Message-Id: <5ksmvi$5lr@cyrene.nchc.gov.tw>

Could anybody tell me what's wrong about the program as belows? The default
value "a" and "c" cannot become "SELECTED" to the output! 
(my CGI.pm is version 2.24, perl is verson 5.003)

#!/usr/bin/perl5
use CGI qw(:standard);
$myname=param('MYNAME');        #<=== need a "MYNAME" paramater!
print header;
print start_html('TEST');
print startform(-name=>"FORM1");
%tmp = ('a'=>'1','b'=>'2','c'=>'3');
print textfield(-name=>'MYNAME', -default=>$myname),
	scrolling_list(-name=>'OPEN_LEVEL_1',
        -values=>['a','b','c'],
        -default=>['a','c'],     #<===== this line cannot work properly
        -size=>3,
	-multiple=>'true',
        -labels=>\%tmp),
        submit(-value=>'SUBMIT'), reset(-value=>'RESET'),
        end_html;



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

Date: 8 May 1997 15:37:21 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: clever coding required
Message-Id: <5ksrvh$pkb$2@dartvax.dartmouth.edu>

In article <33701CBD.71323816@gpu.srv.ualberta.ca>
Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:

> depending on the nature of your fields
> you could strip out your leading/trailing spaces
> from each field with something like:
> 
> $_="  a field  | another field   |   and again  ";
> s/(?:^\s*|(\w)\s*(?=\|)|(\|)\s*|\s*$)/$+/g;
> ($field1,$field2,$field3)=split /\|/;
> print "$field1:$field2:$field3";

Yes, you could, but I'm not sure why you'd want to...

Check out the other posts in this thread for a somewhat simpler regexp.

;-)

Chipmunk


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

Date: 8 May 1997 15:35:02 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: clever coding required
Message-Id: <5ksrr6$pkb$1@dartvax.dartmouth.edu>

In article <01bc5a20$bd8e3c80$a7078496@toshi>
"alex" <alex99@ozemail.com.au> writes:

> I've spend hours upon hours trying to cleverly deal with data of the form
> a field   |  some more stuff   | another field  | field4  | hello mum
> (dumped from a rdbms)
> 
> Field are separated by the pipe char |   Each field may have trailing and
> leading whitespace.     I need to "split" the fields  
> ($aField, $another, $foo)=split(/\|/),  but then I have to trim each field
> $aField =~ remove leading spaces
> $aField =~ remove trailing spaces
> FOR each field ..... blah blah blah   *too many lines*
> 
> If the leading and trailing whitespace can be consumed before the split, 
> the split would be nicer,  each field would be ready to go.
> I know (deep down in my bones) that there is a more eligant solution,  but
> I don't find it  ... grrrrh!!!
> I naively thought I coulde do a  s/xxx/yyy/g type sub *followed* by the
> split, hence get the job done on 2 lines.   But the "s///" is to hard to
> work out

s/ *\| */\|/g;
split(/\|/);

or

split(/ *\| */);

Chipmunk


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

Date: 8 May 1997 16:23:56 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: clever coding required
Message-Id: <5ksums$ab1@news.service.uci.edu>

In article <5ksrr6$pkb$1@dartvax.dartmouth.edu>,
Chipmunk <Ronald.J.Kimball@dartmouth.edu> wrote:

>s/ *\| */\|/g;
>or
>split(/ *\| */);

Not unless you're sure that tabs never get mixed in with those spaces.
Better, I think, to use \s* instead of ` *`, my furry little friend.

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: 8 May 1997 13:30:49 +0100
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: Complex Data Structure help: How can I do a push??
Message-Id: <5ksh1p$9js$1@brains.cartoon.bt.co.uk>

>From article <ratty.36.000BD39C@uclink2.berkeley.edu>, by ratty@uclink2.berkeley.edu (Ratty):
[...]
> The program reads an sgml file, extracts attribute information
> from selected tags, and uses this to print rows of small
> thumbnail gifs to a web page. The data structure I've chosen
> is an array of hashes of arrays of hashes:

> @thumbrows contains hashes called %row. Each %row contains (among
> other things) an array called @thumbs. @thumbs is an array
> containing a hashes called %img. What follows is first the test
> code that builds the struct, followed by a short loop to print
> out selected values. Can anyone tell me how to eliminate the
> subscripts and do all of this with push and foreach?
[...]


Here is something in fairly pure functional style.  I have slightly
simplified to construct only a 2-d array rather than with the extra
hashes described, but think this otherwise respects the spirit of the
original,

 #! /usr/local/bin/perl -w
 use strict;

 my $ThumbRowNum = 5;
 my $textdivs = "cover|div0|div1|div2|image";

 my @thumbline = map {
  my ($tag, $atts, $tail) = m/^<($textdivs)([^>]*)>(.*)$/is;
  +{
   map(('seqno' => $_), $atts =~ /seqno\s*=\s*"?(\d+)/i),
   map(('nativeno' => $_), $atts =~ /nativeno\s*=\s*"?([-_A-Za-z0-9.]*)/i),
   map(('entityref' => $_), $atts =~ /entityref\s*=\s*"?([-_A-Za-z0-9.]*)/i),
   map(('caption' => $_), $tail =~ /^\s*<caption[^>]*>([\w\W]*?)<\/caption>/i),
   };
  } (join '', <DATA>) =~
   m/<(?:$textdivs)[^>]*>(?:\s*<caption[^>]*>(?:[\w\W]*?)<\/caption>)?/gi;

 my $thumb2 = [map {
  my $p = $_ * $ThumbRowNum;
  my $q = $p + $ThumbRowNum - 1;
  +[@thumbline[$p..($q < $#thumbline ? $q : $#thumbline)]];
  } 0..int($#thumbline/$ThumbRowNum)];

where @thumbline is a 1-d array of the ref-to-hash images, and $thumb2
constructs the 2-d rectangular layout.  The regexps are mostly
unchanged from the original, of course.  Printing some data by

 grep {
  my $i = $_;
  grep {
   my $j = $_;
   my $t = $thumb2->[$i]->[$j];
   print "image $i $j\n";
   defined($t->{'seqno'}) and print " seqno ", $t->{'seqno'}, "\n";
   defined($t->{'nativeno'}) and print " nativeno ", $t->{'nativeno'}, "\n";
   defined($t->{'entityref'}) and print " entityref ", $t->{'entityref'}, "\n";
   defined($t->{'caption'}) and print " caption ", $t->{'caption'}, "\n";
   } 0..$#{$thumb2->[$i]};
  } 0..$#$thumb2;

 exit 0;

 __DATA__
 <page><image entityref="I0018236" seqno="2">
 <caption>Friday Nov. 20th 1846</caption></page>
 <page><image entityref="I0018237" seqno="3">
 <caption>Sat. 21st-Monday 23rd</caption></page>
 <page><image entityref="I0018238" seqno="4">
 <caption>Tuesday 24th-Sunday 29th</caption></page>
 <page><image entityref="I0018239" seqno="5">
 <caption>Monday 30th-Wedns. 2nd</caption></page>
 <page><image entityref="I0018240" seqno="6">
 <page>

yields

 calf$ thumb
 image 0 0
  seqno 2
  entityref I0018236
  caption Friday Nov. 20th 1846
 image 0 1
  seqno 3
  entityref I0018237
  caption Sat. 21st-Monday 23rd
 image 0 2
  seqno 4
  entityref I0018238
  caption Tuesday 24th-Sunday 29th
 image 1 0
  seqno 5
  entityref I0018239
  caption Monday 30th-Wedns. 2nd
 image 1 1
  seqno 6
  entityref I0018240
 calf$


This illustrates a style rather different from the original imperative

> while ($SgmlText =~ /<($textdivs)([^>]*)>/gi) {
>    $tag = $1;
>    $atts = $2;
>    $tail = $';
>    if ($tag =~ /image/i) {
>       my $img = {};
>       $atts =~ /seqno\s*=\s*"?(\d+)/i
>          && ($img->{seqno} = $1);
>       $atts =~ /nativeno\s*=\s*"?([-_A-Za-z0-9.]*)/i
>          && ($img->{nativeno} = $1);
>       $atts =~ /entityref\s*=\s*"?([-_A-Za-z0-9.]*)/i
>          && ($img->{entityref} = $1);
>       $tail =~ /^\s*<caption[^>]*>([\w\W]*?)<\/caption>/i
>          && ($img->{caption} = $1);
>       $thumbrows[$i]->{thumbs}[$j] = $img;
>       if ($j < $ThumbRowNum) {
>          $j++;
>       } else {
>          $j = 0;
>          $i++;
>       }
>    }
> }


    Tony Bass

-- 
# A E Bass                                      Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


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

Date: 08 May 1997 07:12:02 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Dipti V. Sonak" <dsonak@us.oracle.com>
Subject: Re: Dates
Message-Id: <8cbu6mm4st.fsf@gadget.cscaper.com>

>>>>> "Dipti" == Dipti V Sonak <dsonak@us.oracle.com> writes:

Dipti> Robert Saunders wrote:
>> 
>> I am trying to use the date function. but I don't need all the
>> information that it returns.. I would like to parse the information so
>> I could get just the Month and the Day out of the date function.

Dipti> #!/usr/local/bin/perl -w
Dipti> $month = `date +'%m'`;
Dipti> $day   = `date +'%d'`;
Dipti> $year  = `date +'%y'`;
 
Dipti> printf "Month : $month\n";
Dipti> printf "Day   : $day \n";
Dipti> printf "Year  : $year \n";

Well, that's unnecessarily expensive, and unportable (some systems
don't have date +%x, and some systems don't even have date!).

Instead, let Perl do the whole thing:

	my ($month,$day,$year) = (localtime)[4,3,5];
	$month++; # convert 0-11 into 1-12
	$year += 1900; # convert 1-199 into 1901-2099
	print "it's now month $month day $day year $year\n";

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 481 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 8 May 1997 18:12:51 +0200
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Drawing a graph?
Message-Id: <19970508181251317638@rhrz-ts3-p4.rhrz.uni-bonn.de>


I'm looking for a module that draws a graph for me. I only want to input
nodes (with labels) and edges (with labels) and have the module do
everything else. Is there such a thing?

Michael

---
Michael Schuerig           Contests between male toads over females are
mailto:uzs90z@uni-bonn.de      often settled by the depth of the croak.
http://www.uni-bonn.de/~uzs90z/                     -John Maynard Smith


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

Date: 8 May 1997 15:45:46 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Finding a pattern in a file
Message-Id: <5kssfa$pkb$4@dartvax.dartmouth.edu>

In article <5kpb0u$lnt@triton.np.ac.sg>
Query??? writes:

>        I would like to find if a pattern exist in a certain file.
>        If it does output the finding into another file.
>        Both input and output file name is in a variable.
> 
>         e.ga:-
>         $infile="/tmp/abc";
>         $outfile="/tmp/out";
> 
>         grep $pat $infile > $outfile;

That's a pretty simple problem.  Do you have any Perl references
(manpages or books)?  They should explain how grep works.

Something like this might work:

open(INFILE, "$infile") || die "Could not open $infile: $!\n";
open(OUTFILE, ">$outfile") || die "Could not open $outfile: $!\n";
@infile = <INFILE>;
@matches = grep(/$pat/, @infile);
print OUTFILE "Matching lines:\n", join("\n", @matches), "\n";
close(INFILE);
close(OUTFILE);

Chipmunk


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

Date: Thu, 08 May 1997 17:10:35 +0200
From: Stefan Merath <merath@berlin.snafu.de>
Subject: FormMail & NT Server (EMWAC Internet Mail Services for Windows NT Version 0.8x)
Message-Id: <3371ECEB.5D9A@berlin.snafu.de>

Hi,

anybody knows a FormMail-Port for the above named Mailserver? Or maybe
something else with the function to send formated mail with a cgi-call?

Please reply to my e-mail-adress too

Thanx

Stefan
-- 
Stefan Merath ******************************************* Blue Orange
GbR
Reichenberger Str. 59 ------------------------------------- 10 999
Berlin
Fon: 030/ 618 56 70 --------------------------------- Fax: 030/ 618 56
70
Mail: merath@berlin.snafu.de ********** Home:
http://www.snafu.de/~merath


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

Date: 8 May 1997 15:40:50 GMT
From: junkmail@sysc.abdn.ac.uk (Kyzer)
Subject: Re: GIF in Base64 encoding?
Message-Id: <5kss62$ki4@info.abdn.ac.uk>

Otis Gospodnetic, while smelling of fish, wrote:
: Hi,

: I was wondering if anyone knows how I can Base64 encode a GIF?

I think you yourself know!

: I have no clue about image formats, so I don't even fully understand what
: I'm saying here (don't laugh :)), but I know that I have to use Base64
: encoding on a GIF file.

: I looked at MIME::Base64, but the pod says that the module is for encoding
: strings (as opposed to images).  But, can I simply open() the GIF and use
: this MIME::Base64 to encode the data I read after open()ing ?

Yes, I guess so!

The following test works fine (shows my horrible face!):
cat kyzer.gif |\
perl -p -mMIME::Base64 -e '$_=MIME::Base64::encode_base64($_)' |\
perl -p -mMIME::Base64 -e '$_=MIME::Base64::decode_base64($_)' | xv -

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
BONUS: Present this .sig at Tesco for a 15% discount.


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

Date: Thu, 8 May 1997 12:18:53 -0400
From: "Geoff Fry" <geoff@opcom.ca>
Subject: mount problem on install
Message-Id: <5ksub7$3452@news.ott.opcom.ca>

I'm installing Redhat off CD-ROM.  The CD gets detected and everything runs
smooth during install(setup) until it trys to mount the file system.  Here
is the error:

 -   mount.  wrong fs type or bad superblock on /dev/hda2
-   mount -t ext2 /dev/hda2/mnt/
-   exited with code 1

I re-partitioned my drive because I thought there was a problem having the
second partition as a linix partition.  I had a 250 meg, type 83 partition
and a 30 meg, type 82 swap partition.  No other file system was present the
second time I tried this.
My CD-Rom is the second device on IDE interface #1, with the HD as the
first one.  My system is a Cyrix 150+ with 32 megs of RAM.  
I'm pretty sure the file types are not the problem, what is this
superblock?
Geoff Fry




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

Date: Thu, 08 May 1997 09:44:36 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: need help w/forms and Perl
Message-Id: <fl_aggie-ya02408000R0805970944360001@news.fsu.edu>

In article <Pine.A41.3.95a.970508113252.100960E-100000@sp058>, "Alan J.
Flavell" <flavell@mail.cern.ch> wrote:

+ On Thu, 8 May 1997, Geoffrey Hebert wrote:
+ > Check out the Perl site!
+ > http://www.microserve.net/~soccer/

+ _THAT's_ "the" Perl site???  
+ Who are you trying to fool??

Well, as ol' PT Barnum put it: there's a sucker born every minute.

The real one is at <url:http://www.perl.com/perl/>.

+ > Geat tool for Developers>
+   ^^^^
+ Really?  It'll be interesting to hear what the Perl regulars have to
+ say about this.

I'd have to say Mr. Hebert's post is thinly disguised spam. I didn't
see anything remotely useful to a perl developer.

The only good thing I can say is that he explains why he chooses to set
a cookie, and what gets into it...

James

-- 
Consulting Minister for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 08 May 1997 10:15:30 -0400
From: Clark Dorman <dorman@s3i.com>
Subject: Re: Need help with PERL script!
Message-Id: <d207im4n1.fsf@s3i.com>


brian@accesschicago.net (Brian Locascio) writes:
> I am looking for some ideas/help on how to take information from a
> space delimited text file that looks like this (see below) and imput
> each line to the BSDI "adduser" program.  This script will save me the
> trouble of entering account information manually for 1000+ users!
> 
> {username} {password} {First Name} {Last Name} {shell}
> 
> The script will need to read the information from this text file and
> imput it to the "adduser" program with a few switches.  
> 
> Example of  BSDI "adduser" command line:
> 
> adduser -g {groupname} -h {user home directory} -P {password}
> 
> 
> At this point I am not looking for anyone to write the script for me
> (of course I would pay).  However, if you could give me ideas or setup
> the framework for the small script, I would be in debt to you!
> 
> Thanks for your help!!!

well, this actually sounds like a pretty trivial script.  It should look
somehting like the following.  I have _not_ tested it: 

#!/usr/bin/perl -w

$namefile = "/dir/dir/dir/namefile";

open ( NAME_FILE, "$namefile") or die "cant open ($!)";
while (<NAME_FILE>) {
	$dataline = $_;	
	($uname, $passwrd, $fname, $lname, $shll, $extra) = split(' ',$dataline);

	if ($extra ne "") {
		print "Gack! problem on line ($.) \n";
		print "Entry:  ($dataline)\n";	
		next;
	}
	
        # do similar checks on each of the fields to make sure
	# they are ok
	
	$groupname = "whatevergroup";

	$add_user_result = "";
	$add_user_result = `adduser -g $groupname -h /home/$uname -P $passwrd`;

	# Check the result of add_user_result;
	if ( $add_user_result ne "") {
		print " got this from adduser: ($add_user_result)";
		print "Entry:  ($dataline)\n";	
	}
}
close (NAME_FILE);


Best of luck.  If you have problems, play with it for a while and email me.
I'm still a beginning perl person, but I can probably handle the easy
questions.  

-- 
Clark Dorman				"Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick


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

Date: 8 May 1997 14:43:49 GMT
From: rickg@hyperion.dynanet.com (Rick Greene)
Subject: Perl and setuid problem
Message-Id: <5ksor5$gsa$1@thea.dynanet.com>
Keywords: setuid taint

I'm trying to develop a Perl script to allow non-root users to create
user accounts under Unix.  I've pretty much got everything in the script
I need, checks to make sure the user doesn't already exists, the UID
selected isn't already used, they're not trying to make a superuser,
etc.  Works fine when I run it as root (as would be expected).

I've used the the "wrapsuid" program in the eg directory of my Perl5.003
distribution, and most things seem to work ok.  There are two (so far)
exceptions:

1) I create a directory /etc/ptmp from within the script to "lock" the
functionality so only one user can run this at a time.  Inside that
directory I create a file called "user" that contains the real name of
the person running this script (the second user to attempt it gets the
message "Adduser is being run by Fred Foobar, please try later").  The
last thing the script tries to do on any exit condition is to do a
system("rm -fr /etc/ptmp").  I get a permission denied error from rm.
I've looked at the directory (rwx-r-xr-x) and file (rw-r--r--), both
are owned by root.  Any ideas why the script can't delete that which
it created?

2) Being that this is an interactive script, I need the user to be able
to enter in the username, UID, group(s), and real name of the account to
create.  However, according to the docs, any input is flagged as tainted.
How can I untaint this type of input, when I know that it is only going
to get used as the search text in grep statements or part of a print
statement?

Thanks for any/all help,

Rick Greene
Mid-Range Systems Support
Wyeth-Ayerst Laboratories


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

Date: 8 May 1997 13:13:42 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: PERL cross reference generator
Message-Id: <5ksji6$3rl@news.ox.ac.uk>

In article <3370C35F.1F39@interactive.ibm.com>,
John Call  <johnc@interactive.ibm.com> wrote:
>I need a cross reference generator for PERL. Anybody know where I can
>get one?

There's a poor but sometimes useful one included in the compiler kit.
    perl -MO=Xref foo.pl

Applying the following will fix one of the main bugs.

------------------------------ cut here ------------------------------
--- ../Compiler-a3/B/Xref.pm	Fri Aug 30 14:20:00 1996
+++ B/Xref.pm	Mon Mar 24 18:14:48 1997
@@ -85,7 +85,7 @@
 =cut
 
 use strict;
-use B qw(peekop class ad comppadlist main_start svref_2object walksymtable);
+use B qw(peekop class comppadlist main_start svref_2object walksymtable);
 
 # Constants (should probably be elsewhere)
 sub OPpLVAL_INTRO () { 128 }
@@ -143,7 +143,9 @@
     for ($ix = 1; $ix < @namelist; $ix++) {
 	my $namesv = $namelist[$ix];
 	next if class($namesv) eq "SPECIAL";
-	my ($type, $name) = $namesv->PV =~ /^(.)(.*)$/;
+	my $namepv = $namesv->PV;
+	my ($type, $name) = $namepv =~ /^(.)(.*)$/
+	    or warn "funny lexical name for $namesv: $namepv\n";
 	$pad[$ix] = ["(lexical)", $type, $name];
     }
 }
@@ -214,7 +216,7 @@
 
 sub pp_padsv {
     my $op = shift;
-    $top = $pad[$op->targ];
+    $top = [@{$pad[$op->targ]}];
     process($top, $op->private & OPpLVAL_INTRO ? "intro" : "used");
 }
 
@@ -275,7 +277,7 @@
 sub B::GV::xref {
     my $gv = shift;
     my $cv = $gv->CV;
-    if (ad($cv)) {
+    if ($$cv) {
 	#return if $done{$$cv}++;
 	$file = $gv->FILEGV->SV->PV;
 	$line = $gv->LINE;
@@ -283,7 +285,7 @@
 	push(@todo, $cv);
     }
     my $form = $gv->FORM;
-    if (ad($form)) {
+    if ($$form) {
 	return if $done{$$form}++;
 	$file = $gv->FILEGV->SV->PV;
 	$line = $gv->LINE;
------------------------------ cut here ------------------------------

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee


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

Date: 8 May 1997 13:30:32 GMT
From: Thomas Kipar <kipar@informatik.uni-bonn.de>
Subject: Perl-Socket using in C ???
Message-Id: <5kskho$7be@news.rhrz.uni-bonn.de>

How can I get an interger socket handle within a C program 
for a socket created in a perl script which calls this C program 
via 'system' ??

Please Help me ... ;)
Send EMail !

Thanks
~tk


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

Date: Thu, 08 May 1997 08:52:56 -0400
From: Ramon Castillo <rcastill@icix.net>
Subject: perl5.003 installing help
Message-Id: <3371CCA8.17A3@icix.net>

I'm having a problem installing perl5.003 I'm soryy if I did something
stupid but I have not experience installing software in Unix.
Here is my scenario:
I download and untar the distibution file now I have all the files in 
/usr/local/bin/perl5.003/ I followed the instuctions in the
documentation:

sh Configure
I'm getting this error
Your C compiler "gcc" doesn't seem to be working

If I do "which gcc" aswer = /usr/share/bin/gcc

My workstation is a ultra 1 with solaris 2.5 and perl and gcc are in
other server with Solaris 2.4 and are mounted in my  machine, what I
wish is install in my local machine perl5.003 and in the other keep
perl5.001, I guess the problem is in the fact that gcc is not local but
I don't know how to go around this problem or where perl look for it and
then to install it locally I've already gcc-2.7.2.tar in my machine, I
don't know if is the latest and where to install it.

Thanks in advance for any help or any clue about it.

RC 


You can reply to this group or
ray@icix.net
rcastill@icix.net


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

Date: Thu, 08 May 1997 16:19:27 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: perl5.003 installing help
Message-Id: <3371EEFF.38E1@unl.ac.uk>

Ramon Castillo wrote:
> 
> I'm having a problem installing perl5.003 I'm soryy if I did something
> stupid but I have not experience installing software in Unix.
> Here is my scenario:
> I download and untar the distibution file now I have all the files in
> /usr/local/bin/perl5.003/ I followed the instuctions in the
> documentation:
> 
> sh Configure
> I'm getting this error
> Your C compiler "gcc" doesn't seem to be working
> 
> If I do "which gcc" aswer = /usr/share/bin/gcc
> 
> My workstation is a ultra 1 with solaris 2.5 and perl and gcc are in
> other server with Solaris 2.4 and are mounted in my  machine, what I
> wish is install in my local machine perl5.003 and in the other keep
> perl5.001, I guess the problem is in the fact that gcc is not local but
> I don't know how to go around this problem or where perl look for it and
> then to install it locally I've already gcc-2.7.2.tar in my machine, I
> don't know if is the latest and where to install it.
> 
> Thanks in advance for any help or any clue about it.

This is a gcc problem - not perl!

Anyway, it sounds like the compiler (gcc) is only partially mounted -
i.e: the libraries and include files are not all mounted to your
workstation as well.  Have you compiled anything else successfully on
your workstation?  You have two options:

1) mount all the libraries etc onto your workstation

2) compile on the server - it won't overwrite the existing 5.001
(upgrading is *recommended*) and then do make install on your
workstation.

Alastair.


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

Date: 8 May 97 11:17:43 EDT
From: jcoleman@alison.sbc.edu
Subject: PerlScript & Active Server Pages
Message-Id: <1997May8.111743.282@alison.sbc.edu>

Can anyone tell me a nice comprehensive page where I might learn a bit about
PerlScript (ie with Active Server Pages)?  I've got a good handle on Perl
itself, but I'm wondering some differences between PerlScript and Perl.

Also, I'm concerned about multithreading issues...are these even a problem with
asp's?

John Coleman
jcoleman@sbc.edu


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

Date: 08 May 1997 07:00:40 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Vipul M. Shah" <vipul@xcaliber.com>
Subject: Re: Possible inclusion into FAQ
Message-Id: <8cenbim5br.fsf@gadget.cscaper.com>

>>>>> "Vipul" == Vipul M Shah <vipul@xcaliber.com> writes:

Vipul> For us C/C++ lovers, what is the equivalent of the subscript operator for
Vipul> strings in Perl. I.e;
Vipul>  how do I write
Vipul>    int n = strlen(s);
Vipul> int t = 0;
Vipul> for (int i = 0; i < n; i++)
Vipul>     {
Vipul> t += (int)s[i];
Vipul> }

Vipul> in Perl.  Please CC responses to mailto:vipul@xcaliber.com.

For sufficiently small values of n (where the sum does not exceed 2**31):

	$t = unpack "%32C*", $s;

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 481 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 08 May 1997 11:25:41 -0400
From: the count <eglamkowski@hotmail.com>
Subject: possible typo warning
Message-Id: <3371F075.167B@hotmail.com>

this may be a newbie-ish question, but i am getting a possible typo 
warning and have no idea what is causing it.  it has the unfortunate
result of leaving the variables in question with a value of undef.

i have never seen this warning before, and there is nothing in the 
"Programming Perl" book about it (chapter 9 is a whole chapter on
nothing
but diagnostic messages, and this one isn't in there).

% perl -w tickler.pl
Possible typo: "caseID" at tickler.pl line 75
Possible typo: "endOfWindow" at tickler.pl line 77
[lots of 'Use of uninitialized variable' warnings deleted]

while (<CASELIST>) {
    chop;
    @caselist_tmp__fields = split;

    $caseID = $caselist_tmp__fields[0];          <-- line 75
    $startOfWindow = $caselist_tmp__fields[1];
    $endOfWindow = $caselist_tmp__fields[2];     <-- line 77


i am not getting the warning on line 76, which is the same format.
any idea why lines 75 & 77 are a problem?

-- 
   "The gods themselves struggle in vain against stupidity." - Schiller


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

Date: Thu, 8 May 1997 14:12:42 GMT
From: "Richard K. Downer" <rkd7949@ballard.ca.boeing.com>
Subject: Re: program for perl?
Message-Id: <3371DF5A.3B4C@ballard.ca.boeing.com>

Kyzer wrote:
> 
> Michael J Gebis, while smelling of fish, wrote:
> : junkmail@sysa.abdn.ac.uk (Kyzer) writes:
> 
> : }: Suzanne L. wrote:
> : }: >
> : }: > Is there a program that is needed to write in perl or can they be
> : }: > written in any text editor?
> 
> : }Ah, yes, there IS a program needed to write in perl.
> : }It's called "perl" :)
> 
> : Technically, that's the program needed to run perl.  You can write in
> : perl using almost anything, from emacs to antelope blood on a cave wall.
> 
> But the $64000 question is, if you write it in antelope blood on a cave wall,
> can you get perl to execute it afterwards? :)
> 
No. Now how do I collect the $64000?
-- 
Rick Downer
rkd7949@ballard.ca.boeing.com

These opinions are not mine, they're Boeing's. Boeing paid me while I 
opined them, so Boeing owns them. But Boeing might not agree with them.


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

Date: 8 May 1997 16:26:22 GMT
From: "George Silva" <george@9003inc.com>
Subject: Programmin Perl on MacOS
Message-Id: <01bc5bcc$c9fba720$2a9235c6@jorge>

I have a question concerning MacPerl...ie) Perl on Mac OS

For some reason the "mkdir" function seems not to work.  Is there any other
way to create a directory?
If "mkdir" does not work on MacPerl, how does one create a directory?

Also I have heard that back ticks do not work either on MacPerl.  How do I
resolve this?




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

Date: 8 May 1997 15:53:46 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: replacing escape characters in a text file.
Message-Id: <5kssua$pkb$5@dartvax.dartmouth.edu>

In article <01bc5ac5$87121e60$5378238a@pc1.asia.compaq.com>
"cedric tio" <cedric=tio%design%eng=sin@bangate.compaq.com> writes:

>         I need to replace escape characters (^[)  in a text file with asterixs. I
> tried doing s/\^\[/*/g; but it doesn't work.

The escape character is a single character.  The two characters ^ and [
put together are a printable representation of the escape character.

Try this instead:

s/\x1B//g;

1B is the hexadecimal value of the Escape character.

Chipmunk


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

Date: Thu, 08 May 1997 14:42:14 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Request for simple text file handling program
Message-Id: <3371D836.6BE6@unl.ac.uk>

Cindy Rutherfurd wrote:
> 
> Hi.  I'm just learning perl.  I'd like to write a script to read a text
> file, glean some of the substrings from the file, then write them out as
> hyperlinks. Does anyone out there have such an example script?  Please
> e-mail.

#! /usr/local/bin/perl -w		# This routine was tested against itself.

require 5.003;
use strict;

my ($file,@lines,$pattern,$hit);

$pattern = 'line';			# very simple pattern indeed
open (OUT, "> /path/to/outfile") || die "Can't open outfile: $!";
$file = `cat /path/to/infile` || die "Can't open infile: $!";
@lines = split(/\n/,$file);
foreach (@lines) {
    if (($hit) = ($_ =~ /($pattern)/)) {
        print OUT "<a href=\"$hit\">$hit</a>\n";
    }
}

exit 0;

That makes an assumtion that each $hit is a fully qualified reference to
a resource with respect to the server and the server's dataroot.  It
doesn't build an html file, just a list of <a href ...>..</a>
references.

Alastair.


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

Date: 8 May 1997 13:05:03 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x1893 )
Subject: Require assistance with function stat
Message-Id: <5ksj1v$r4i@newstoo.ericsson.se>


ood day everybody,
		I'm using stat in a script I'm writing, however
		due to extreme ignorance on my part I'm having difficulty
		deciphering the significance of the 5 digit $mode field
		returned by the afore mentioned function.
												 
		 I would be most grateful if one of you groovy perl dudes
		 could enlighten me on this subject. I.e. I know that the 
		 number contains info pertaining to the mode and type of 
		 file but how do I interpret this to something useful.
																																  
																																						  Thankyou for taking your time to read the above.
																																							   
																																										   Yours Tom Lachlan
																																																		
																																									etltsln@etlxdmx.ericsson.se



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

Date: 08 May 1997 08:38:28 -0400
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: Require assistance with function stat
Message-Id: <8jlo5qf8aj.fsf@nynexst.com>

etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x1893 ) writes:
> Good day everybody,
>	I'm using stat in a script I'm writing, however
>	due to extreme ignorance on my part I'm having difficulty
>	deciphering the significance of the 5 digit $mode field
>	returned by the afore mentioned function.

The perl stat function is an interface to the stat() system call.  The
documentation of stat() on your system (eg, "man stat") should explain
how to interpret the bits of $mode.

On non-unix systems, I don't know where this information comes from.

-Tom


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

Date: 8 May 1997 15:40:00 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: scalar holds compiled code
Message-Id: <5kss4h$pkb$3@dartvax.dartmouth.edu>

In article <33704E48.63FA@unl.ac.uk>
Alastair Aitken <a.aitken@unl.ac.uk> writes:

> $stuff = 'mv cp al';
> `$stuff`;                      # note - this is not perl code, its a simple UNIX move
> command.
> 
> Which also worked.  Either you are not making your problem clear enough
> or you are not doing enough of your own testing.

It's still not what he wants to do.

I think he made his problem plenty clear enough.  You just haven't
grasped it yet.

He has some compiled C code in a scalar variable.  How does he execute
it?

It's not Perl code, it's not a shell command.  It is compiled C code.

Everybody got that?

Chipmunk


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

Date: Thu, 08 May 1997 11:56:36 +0100
From: Aaron Bennett <abennett@stonehill.edu>
Subject: Something I'm missing
Message-Id: <3371B156.3147@stonehill.edu>

I was hoping the program below would put <TR><TD></TR></TD> around every
line that has
no tab characters in it.  Instead is matches every line in the file.

The file is like this:

Summer Session I
name {tab} year {tab} {tab} time {tab} {tab} etc

created by an person unskilled with word processing.  I have to HTML'ize
it.

Instead of what I wanted, the program puts the characters around every
line, tab or no tab.

Does anyone have any ideas?

Thanks.

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

	$file="evediv.txt";
	$out="htmlout.html";


print "Opening $file for processing. \n";
print "Results will be stored in $out. \n";

open (INPUT, $file) or die("Can't open $file!\n");
open (OUTPUT, ">$out");

while ($textline=<INPUT>)	{
	$textline =~ s/(.+\t{0}.+)/<TR><TD>$1<\/TD><\/TR>/sg; 
	print OUTPUT $textline;
	}

-- 
|	Aaron Bennett
|	Internet Services Coordinator
|       Stonehill College Department of Academic Computing
| 		http://www.stonehill.edu                       
|			"The most precious things remain unseen."


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

Date: 8 May 1997 16:54:52 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Something I'm missing
Message-Id: <slrn5n41as.ssa.I-hate-cyber-promo@news.rediris.es>

In comp.lang.perl,comp.lang.perl.misc,
	abennett@stonehill.edu wrote:
>I was hoping the program below would put <TR><TD></TR></TD> around every
>line that has
>no tab characters in it.  Instead is matches every line in the file.
>
>The file is like this:
>
>Summer Session I
>name {tab} year {tab} {tab} time {tab} {tab} etc

>created by an person unskilled with word processing.  I have to HTML'ize
>it.
>
>Instead of what I wanted, the program puts the characters around every
>line, tab or no tab.

Because you're essentially asking it to match anything. You should use a
character class to specify "match anything except a tab", like so: [^\t].

>Does anyone have any ideas?
>
>Thanks.
>
>#!/usr/local/bin/perl -w
>
>	$file="evediv.txt";
>	$out="htmlout.html";
>
>
>print "Opening $file for processing. \n";
>print "Results will be stored in $out. \n";
>
>open (INPUT, $file) or die("Can't open $file!\n");
>open (OUTPUT, ">$out");

You really should also check the return code of this open statement.

>while ($textline=<INPUT>)	{
>	$textline =~ s/(.+\t{0}.+)/<TR><TD>$1<\/TD><\/TR>/sg; 
>	print OUTPUT $textline;

The fact that you use the /g option makes me think that you're actually
trying to make a table with the text _between_ tabs in separate cells.
I would use split to do this:

	chomp($textline);
	my @cells = split "\t", $textline;
	my $line = join '</TD><TD>', @cells;
	print OUTPUT '<TR><TD>', $line, '</TD></TR>\n";
}

The advantage is that you don't have two separate cases for lines that
do or don't contain tabs.

This would however output empty cells if there are spurious consecutive
tabs. To remove them (assuming that's what you want to do) you could do
$textline =~ s/(\t)\t+/$1/g to remove them (again, assuming that's what
you actually want to do).

You probably also want to skip blank lines, so that would be:

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

$file="test.txt";
$out="htmlout.html";

print "Opening $file for processing. \n";
print "Results will be stored in $out. \n";

open INPUT, $file or die "can't open $file: $!\n";    # use the diagnostic
open OUTPUT, ">$out" or die "can't write $out: $!\n"; # ditto

print OUTPUT "<TABLE>\n";
while ($textline=<INPUT>)	{
	next if ($textline !~ /^$/);       # skip blank lines
	chomp($textline);                  # remove trailing newline
	my @cells = split "\t", $textline;
	my $line = join '</TD><TD>', @cells;
	print OUTPUT '<TR><TD>', $line, "</TD></TR>\n";
}
print OUTPUT "</TABLE>\n";
__END__

using this input:

foo1
bar	baz	bat
foo2
fie	fee	foe

you get this output:

<TABLE>
<TR><TD>foo1</TD></TR>
<TR><TD>bar</TD><TD>baz</TD><TD>bat</TD></TR>
<TR><TD>foo2</TD></TR>
<TR><TD>fie</TD><TD>fee</TD><TD>foe</TD></TR>
</TABLE>

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: 08 May 1997 07:22:29 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: walkerjl@swbell.net
Subject: Re: standards
Message-Id: <8c911qm4be.fsf@gadget.cscaper.com>

>>>>> "jonnie" == jonnie walker <walkerjl@swbell.net> writes:

jonnie> Does anyone know of a source for programming standards in Perl?

"man perlstyle" in any sufficiently modern version of Perl.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 481 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 8 May 1997 15:39:43 GMT
From: silee@news.hk.super.net (Mr Simon Lee)
Subject: sybperl problem
Message-Id: <5kss3v$ro6$1@tst.hk.super.net>



Hi all,

	Sometime I have problem to  get the output from centain system 
	procedures via sybperl......

	For example, I can get all the output of sp_who via it, but
	can only get the first few lines of the 'sp_helpdb <dbase>'....
	(only the dboptions display but cannot get the info like device
	name, size of a segment, free kb of a segment etc)

	Does anyone know why ?


Thanks,
Simon


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

Date: Thu, 08 May 1997 16:11:25 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: system () won't execute the called program.
Message-Id: <3371ED1D.2A64@unl.ac.uk>

Otis Gospodnetic wrote:
> 
> are you sure you want to use && ?
> I think you want | in place of &&
> 
> Otis
> --
> POPULUS, the Intelligent People Locator -- http://www.POPULUS.net/
> 
>  Ken Anderson wrote in article ...
> 
> >I have a perl program which has to execute an external
> >c program, so i am using
> >
> >
> > system("cprog -p prog.par") && die "cprog failed. $!\n";
> >
> >It simply does nothing. cprog never starts. no error message.
> >What am i missing?

I thought this too when I saw it.  Someone (Randall?) has already posted
that system returns false for success and true for fail, open() returns
true for success and false for failure and backticks return the ouptut
of the command.  exec() does not return at all but closes the calling
script prior to execing.

Alastair.


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

Date: 8 May 1997 16:04:49 GMT
From: piercem@col.hp.com (Marshall Pierce)
Subject: testing for non-existence in an associative array???
Message-Id: <5kstj1$6i1$1@nonews.col.hp.com>

I have an associative array:  $TimeSpent{$Project} = $WeeklyTotal,$DailyTotal
If I search it for something, how can I tell if anything was found?

($SomeProjectsTotal,$SomeDailyTotal) = $TimeSpent{$SomeProject};

if ($SomeProjectsTotal =~  <FOUND>)
{
  do something
}
else
{
  intitial setup of project
} 

If I print $SomeProjectsTotal and nothing was found, nothing is printed
but ($SomeProjectsTotal =~ /\d/) is positive
    ($SomeProjectsTotal !=~ /\0/) is positive
    ($SomeProjectsTotal > 0) is positve
IOW, every test I try is a positive, despite the fact that NOTHING was found!


TIA
--
Marshall V Pierce            /_ __    TIS - WWUSP Technology Team
marshall_pierce@hp.com      / //_/    
USA (719) 590-3461            /       http://hpweb.cs.itc.hp.com/wwusp/piercem/


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

Date: 8 May 1997 16:20:22 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: testing for non-existence in an associative array???
Message-Id: <5ksug6$a8h@news.service.uci.edu>

[mailed, posted]

In article <5kstj1$6i1$1@nonews.col.hp.com>,
Marshall Pierce <piercem@col.hp.com> wrote:
>I have an associative array:  $TimeSpent{$Project} = $WeeklyTotal,$DailyTotal

What's with the comma?  If you're trying to store a list in your hashtable,
you'll need to put brackets around it so that it's treated as an
anonymous array. (Note that 'associative arrays' are now referred to as
hashes.)

$timespent{$project} = [$weeklytotal,$dailytotal];

More about that can be found in the very helpful perldsc man page.

>If I search it for something, how can I tell if anything was found?

could you possibly be looking for `exists'?  You use it to see if a
particular key exists (hence the name) in the hashtable.

if (exists $timespent{'someproject'})
  { 
    # do stuff
  }

But you'll want to read about that in the manpages too, because sometimes
you not only want to check whether something exists, but whether it's
defined as well.  

Before you can tackle that problem, however, you'd better figure out
how to store that list in a hash, because I'm 95% sure what you've got
won't work.

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: Thu, 08 May 1997 17:20:28 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: testing for non-existence in an associative array???
Message-Id: <3371FD4C.5F30@unl.ac.uk>

Marshall Pierce wrote:

[snip]

> ($SomeProjectsTotal,$SomeDailyTotal) = $TimeSpent{$SomeProject};

shouldn't that be:

($SomeProjectsTotal,$SomeDailyTotal) =
split(/$split_chars/,$TimeSpent{$SomeProject});

where $split_chars is the char(s) that separate the fields in the value
and not the key for the hashitem?

[snip]
 
> If I print $SomeProjectsTotal and nothing was found, nothing is printed
> but ($SomeProjectsTotal =~ /\d/) is positive
>     ($SomeProjectsTotal !=~ /\0/) is positive
>     ($SomeProjectsTotal > 0) is positve
> IOW, every test I try is a positive, despite the fact that NOTHING was found!

Have you tried:

if ($SomeProjectsTotal) {
    &do_something;
}

Alastair.


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

Date: 8 May 1997 09:47:28 -0600
From: robobob@xmission.xmission.com (Jason Kohles)
Subject: Re: Trash can or wastebasket for Unix
Message-Id: <5kssig$al5@xmission.xmission.com>

tfbiv@erols.com (Tom Bates) writes:


>I've been looking for a trashcan or wastebasket type of program for
>use on a Sun workstation network.  Being a new fan of perl, I thought
>I might write one in perl, but I wanted to see if it had been done
>already.  Has it?

It has now...

alias rm 'cp \!* ~/.wastebasket'
alias emptywastebasket '/usr/bin/rm -rf ~/.wastebasket/*'



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

Date: Thu, 08 May 1997 16:18:14 +0200
From: e9127005@stud1.tuwien.ac.at (Sascha Kerschhofer)
Subject: url detection in a string
Message-Id: <e9127005-0805971618140001@sozgr.htu.tuwien.ac.at>

i need a subroutine, which replaces found URLs in the HTML specific syntax
e.g.

$test = "look at http://info.com/mor.html for further information";
&findurl($test);

$test should now be: "look at <A
HREF="http://info.com/more.html">http://info.com/more.html</A> for further
information"

i tried with the following:

sub findurl {
  $_ =~ s/(.*)(\shttp://.*\s)(.*)/$1 <A HREF="$2">$2</A> $3/g
}

but this doesnt work.
what am i doing wrong ?
what would happen, if $test would include qoutes, or any other character
before the URL ($test = 'look at "http://info.com/mor.html" for further
information';) or cr characters?
what would happen if $test includes more than one URL?

Any help is greatly appreciated.

Sascha Kerschhofer, Vienna


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

Date: Thu, 08 May 1997 11:51:20 -0400
From: the count <eglamkowski@hotmail.com>
Subject: variable  names
Message-Id: <3371F678.1ED8@hotmail.com>

it is possible to create variable names on the fly?
for example, i want a series of variables a1, a2, a3... up to aX where
X is a user defined variable.
i.e. is there any way concatenate together two or more variables 
to create a new variable name?

i'd like to be able to do something like:
for ($i = 1; $i <= $X; $i++) {
  $a."$i" = some_expression;
}

and end up with:
$a1 = something
$a2 = something_else
$a3 = something_else_yet_again
etc.

is this legal?  if not, is there any other way to do this?

-- 
   "The gods themselves struggle in vain against stupidity." - Schiller


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 451
*************************************

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