[11619] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5219 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 24 18:07:26 1999

Date: Wed, 24 Mar 99 15:00:19 -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, 24 Mar 1999     Volume: 8 Number: 5219

Today's topics:
    Re: ANNOUNCE: Boston.pm Social Meeting, Thurs Mar 25 <elaine@cts.wustl.edu>
    Re: array question (Larry Rosler)
        Can you use a hash slice reference? <burton.not.spam@lucent.com>
    Re: choping off whitespace (Steve Lamb)
        How to interpolate subroutines in here-documents? <jsjensen@Paramin.COM>
    Re: initialization <aqumsieh@matrox.com>
    Re: initialization (Larry Rosler)
    Re: initialization (Larry Rosler)
    Re: Limiting database results <fty@utk.edu>
        never mind... <kwoody@citytel.net>
        New Bee Alert <grichard@uci.edu>
    Re: New Bee Alert <eric.schwartz@acm.org>
    Re: Perl Detecting Browser Version <matt@cartnetwork.com.spammenot>
        Perl, Oracle, and SQL <jwarner@tivoli.com>
        Perls remove directory function doesn't work. <support@counter.w-dt.com>
    Re: Perls remove directory function doesn't work. <jhi@alpha.hut.fi>
    Re: randomizing an array order (Tad McClellan)
    Re: RegExp problem, can't see wood for trees <renfro@i-55.com>
    Re: RegExp problem, can't see wood for trees (Tad McClellan)
    Re: RegExp problem, can't see wood for trees (Bart Lateur)
    Re: Remove HTML codes <tavi367@ibm.net>
    Re: Resizing File <aqumsieh@matrox.com>
        Undefined error on a scalar... <kwoody@citytel.net>
        Using a Web Proxy in Perl <javierrubio@interlink.es>
    Re: utime issue (Larry Rosler)
    Re: Values of 'true' and 'false'? (Tad McClellan)
    Re: why my sub returns nothing? <ty@cnr.colostate.edu>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 24 Mar 1999 17:37:35 -0500
From: Elaine Ashton <elaine@cts.wustl.edu>
Subject: Re: ANNOUNCE: Boston.pm Social Meeting, Thurs Mar 25
Message-Id: <36F9692F.4E445C20@cts.wustl.edu>

brian d foy wrote:

> > This should be quite fun to ponder and plot but I am still left
> > wondering where ORAs support for the Monger YAPC conference is. Where is
> > the quid pro quo? Addison-Wesley is supporting YAPC.
> 
> not everything you see if everything there is.  O'Reilly is supporting
> Perl Mongers at the tutorials because Perl Mongers would do it without
> O'Reilly's support just like we did at the Perl Conference.  that, along
> with my politicking behind the scenes is making this happen.  there is
> actually a lot of work that goes into this.

No big whoop brian but when I get a ream of Tutorial booklets in the
mail where #9 on the top 10 reasons to attend them is "Party with the
Perl Mongers" I get a little thoughtful and think hmmm... Sure, at least
we beat out the free t-shirt on the list. 

My point is this...the mongers and ora are both promoting perl, open
source, selling books, etc. When a monger is organising a conference for
the fun of it and for those who cannot afford exhorbitant fees and
considering that we are helping promote their tutorials they should be
there without asking. See, it's a quid pro quo thing. Someone still has
an itchy back.

> someone for YAPC simply needs to ask O'Reilly to do something.  They
> have already committed to doing *something*, but you don't get something
> without asking for it.  O'Reilly is ready to help.  Not everyone wants
> O'Reilly's help, though, and that is not their fault.

Support takes on many forms and ORA seems to know what to do at every
other conference why is YAPC any different? Forgive me, but I am not
convinced.

> my guess is that Kevin is swamped with arranging all of the details,
> and that he would greatly appreciate help.  send him some mail at
> <lenzo@cs.cmu.edu> to volunteer. :)

I believe that he emailed them a while back and received no response.
And I've already volunteered :)


And Larry, if you read c.l.p.m. anymore...many thanks for showing your
support for YAPC.

e.


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

Date: Wed, 24 Mar 1999 13:15:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: array question
Message-Id: <MPG.1162f5ba39bacaf59897ba@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7dbi62$ou4$1@nnrp1.dejanews.com> on Wed, 24 Mar 1999 
20:33:06 GMT, gwebb@reedtech.com <gwebb@reedtech.com> says...
 ...
>        I think what you really meant was to leave only the extension in
> $file_extension like this:
> 
> $file_extension =~ s/[^.]\.//g;

  $file_extension =~ s/[^.]*\.//g;

But to deal with 'foo.bar.txt' properly, you want:

  $file_extension =~ s/.*\.//g;

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 24 Mar 1999 15:01:08 -0600
From: Burton Kent <burton.not.spam@lucent.com>
Subject: Can you use a hash slice reference?
Message-Id: <36F95294.C3160DF6@lucent.com>

I'm trying to assign several values to a hash slice.  I 
want to use a hash reference to get the slice.  Code
follows:

# @list contains 6 copies of the same string.  
# $wo_info is a hash reference (\%):
@{$wo_info}->{path_name, src_name, proc_title, pt, doc_ppss, chapter} =
   @list;


I check this by seeing if anything was assigned to the second
element of the hash slice:

die "This did not work" unless $wo_info->{src_name};


It dies every time.  I've tried MANY variations to try
getting the reference and hash slice just right.  Does 
anyone know the correct one, or is this just not doable?

Thanks,

Burton


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

Date: 24 Mar 1999 13:41:54 +0800
From: morpheus@no-spam.calweb.com (Steve Lamb)
Subject: Re: choping off whitespace
Message-Id: <slrn7fin11.ebj.morpheus@teleute.rpglink.com>

On 24 Mar 1999 14:53:30 GMT, Greg Bacon <gbacon@itsc.uah.edu> wrote:
>What?  You don't read the FAQ?  Even Tom and Randal read the FAQ.  Do
>you know Perl better than they?

    Surely you jest!  Nono, I do not know Perl better than Tom or Randal.  I
just don't read this newsgroup but once every few months, saw a post that I
figured I could answer and answered.  :P

-- 
             Steve C. Lamb             | Opinions expressed by me are not my
    http://www.calweb.com/~morpheus    | employer's.  They hired me for my
             ICQ: 5107343              | skills and labor, not my opinions!
---------------------------------------+-------------------------------------


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

Date: Wed, 24 Mar 1999 15:23:06 -0700
From: "J. S. Jensen" <jsjensen@Paramin.COM>
Subject: How to interpolate subroutines in here-documents?
Message-Id: <36F965CA.4C1C0B10@Paramin.COM>

How do I interpolate subroutine references within a here-document?

$a = "I";
print <<EOF;
hello, it is $a talking.
EOF

will appropriately substitute "me" where $a is.  Now how do I
interpolate (substitute subroutines/functions into the here-doc?)

sub aa {
    print "I";
}
$aaref = \&aa();
print <<EOF;
hello, it is $aaref talking.
EOF

will actually print:

Ihello,it is SCALAR(0x80b6020) talking.

Which kind of makes sense that perl is dumping the physical scalar
reference.

So:  How do I do this?  And how do I provide arguments to the
subroutine?  use the {} somehow?

Thanks...


--
J. S. Jensen
mailto:jsjensen@Paramin.COM
http://www.Paramin.COM




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

Date: Wed, 24 Mar 1999 12:56:28 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: initialization
Message-Id: <x3ybthi7ovn.fsf@tigre.matrox.com>


Zhiliang Hu <zlhu@iastate.edu> writes:

> Thanks to all who took time to solve my confusion!
> Here is another confusion, probably a better one :)

So now, you are confused in a better way? Is that better?

> I have a few working CGI scripts.  They are working, but I always
> observe complains in the error log:
> 
> "Use of uninitialized value at" lines such as:

This means that you are trying to access some variables with undefined
values. They will be interpreted as "" or 0, but it's probably a
mistake in your part. Checkout perldiag for more info. Do you 'use
strict' in your script?

> 1. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

Does $ENV{'CONTENT_LENGTH'} exists? Does it contain a defined value?
you can check with:

if (exists $ENV{'CONTENT_LENGTH'} && defined $ENV{'CONTENT_LENGTH'}) {
	print "It is fine.\n";
} else {
	print "No good.\n";
}

> 2. $ENV{REMOTE_HOST};

Check for it .. same as above.

> 3. ($name,$value)=split(/:/,$pair);

What is the value of $pair just before this statement?

print defined $pair ? "Pair is fine\n" : "Pair is no good.\n";

> 4. ($term1, $term2, $term3, $term4, $term5) = split(/\s+/,
> $FORM{terms});

Again, check for the value of $FORM{'terms'}

> and so on.  I wonder is it a standard requirement in perl to
> "initialize" them such as:
> 
> $buffer = $buffer;
> $ENV{'CONTENT_LENGTH'} = $ENV{'CONTENT_LENGTH'};
> $ENV{REMOTE_HOST} =$ENV{REMOTE_HOST};
> ... ...
> ?

No. That is useless because you are setting a value to itself. So, if
the value was previously undefined, it will stay so.

> Well, then how should I initialize "$name", $value", "term1 .... term5"
> in the above example?

>From what I see, those are not the variables that are giving you the
troubles. Check the variables I specify above and let us know.

HTH,
Ala



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

Date: Wed, 24 Mar 1999 13:10:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: initialization
Message-Id: <MPG.1162f49f1d997d639897b9@nntp.hpl.hp.com>

In article <akqad7.943.ln@magna.metronet.com> on Wed, 24 Mar 1999 
08:51:06 -0500, Tad McClellan <tadmc@metronet.com> says...
 ... 
> : 1. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> 
>    print "\$buffer '$buffer'\n";  # can't be this one though, because
>                                   # its value is not being used, it
>                                   # is being _set_

Note that in perl 5.003 or earlier, it did draw a diagnostic!  So, for 
my programs (which have to run on perl 5.002 or later), I have to 
preface this with:

  my $buffer = "";

Ugh...

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 24 Mar 1999 14:00:42 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: initialization
Message-Id: <MPG.11630063a6adc7f09897bc@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x3ybthi7ovn.fsf@tigre.matrox.com> on Wed, 24 Mar 1999 
12:56:28 -0500, Ala Qumsieh <aqumsieh@matrox.com> says...
> Zhiliang Hu <zlhu@iastate.edu> writes:
 ...
> > 1. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> ...
> if (exists $ENV{'CONTENT_LENGTH'} && defined $ENV{'CONTENT_LENGTH'}) {

  if (defined $ENV{CONTENT_LENGTH}) {

is enough -- if it is defined, for sure it exists.  :-)

But in this case, one doesn't need to bother with the 'read' if the 
defined value is 0.  So simply:

  if ($ENV{CONTENT_LENGTH}) {

As is being discussed in another thread, no value of FALSE draws a 
warning in a Boolean test.

But what you can't say so simply is this:

  if ($ENV{CONTENT_LENGTH} > 0) {

The simplest way to say that is:

  if (($ENV{CONTENT_LENGTH} || 0) > 0) {

which I think is elegant; others may think it is bizarre.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 24 Mar 1999 16:01:47 -0500
From: Jay Flaherty <fty@utk.edu>
Subject: Re: Limiting database results
Message-Id: <36F952BB.E56C55F0@utk.edu>


> What I'm wondering is how I can get the system to display the first 10
> results and allow users to cycle through their search results in
> groups of 10. I've studied various programs that do this, but I just
> can't seem to figure this out

You need to keep track of which block of records your viewing (1..10,
11..20, etc...). You can do this by passing a parameter (lets call it
$low)
and then just add 10 to that variable. You can then run a for loop. For
instance:

sub printrecords {
    my $low = $INPUT{'low'};
    my $high = $low + 10;
    my $i;	
    for($i = $low; $i < $high; $1++) {
        print "$matches[$i]<br>\n";
    }
    print qq(<a href="/cgi-bin/myscript?low=$high">Click Here to view
the next              10 records<br>);
}
__END__

You also need to check and make sure you don't exceed $count. I would
also pass @matches as function parameter to printrecords()

Good luck...jay


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

Date: Wed, 24 Mar 1999 14:33:08 -0800
From: Keith Woodworth <kwoody@citytel.net>
Subject: never mind...
Message-Id: <Pine.BSI.3.95.990324143003.3916C-100000@rosencrantz.citytel.net>


as is the case just about every time I post to this group or some other
because after much fscking about trying to figure something out I figured
it out...

if (not defined $var) {
   do something
} else {
     do someting else
} 
is right, not

if not (defined $var) 

is wrong. arg..



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

Date: Wed, 24 Mar 1999 14:01:07 -0800
From: "Gabriel Richards" <grichard@uci.edu>
Subject: New Bee Alert
Message-Id: <7dbn5v$h60@news.service.uci.edu>

Be gentle with me, please...

I'm reading in a text file which contains blank lines. I would like Perl to
print the file's contents literally, but Perl seems to ignore blank lines.
Is that right? Why? I assume I must add something like: if ($_ eq \n) {print
"\n"}  ?

Gabe




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

Date: 24 Mar 1999 15:46:46 -0700
From: Eric The Read <eric.schwartz@acm.org>
Subject: Re: New Bee Alert
Message-Id: <xkfiubqjyjt.fsf@valdemar.col.hp.com>

"Gabriel Richards" <grichard@uci.edu> writes:
> I'm reading in a text file which contains blank lines. I would like Perl to
> print the file's contents literally, but Perl seems to ignore blank lines.
> Is that right? Why? I assume I must add something like: if ($_ eq \n) {print
> "\n"}  ?

You shouldn't have to do anything of the sort.  If you want help on code
that doesn't work, it's best to post the code that doesn't work, explain
what you want to happen, and what actually happens.  Otherwise, it's like 
the four blind men and the elephant, and not much fun for anyone.

-=Eric


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

Date: Wed, 24 Mar 1999 22:45:12 GMT
From: "MMK" <matt@cartnetwork.com.spammenot>
Subject: Re: Perl Detecting Browser Version
Message-Id: <YVdK2.11$O4.10@cabot.ops.attcanada.net>

If it is there, it is $ENV{HTTP_USER_AGENT}.

M




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

Date: Wed, 24 Mar 1999 15:05:07 -0600
From: John Warner <jwarner@tivoli.com>
Subject: Perl, Oracle, and SQL
Message-Id: <36F95382.2345F36C@tivoli.com>

I'm trying to write a Perl script to query an Oracle db.  The Perl
portion works fine but I seem to be having a problem with performing
substring searches in SQL.  (I know, I know it's a little off topic but
please bear with me.)  The SQL string Perl is building is:

SELECT SOLUTION_ID,SOLUTION,DESCRIPTION FROM EXAV.SOLUTIONS WHERE
DESCRIPTION = some_portion_of_text;

_The SQL Guide to Oracle_ hasn't been much help in how I should be going
about searching for, say *FAQ*.  Where are there any decent on-line
references for SQL that can help me?

--

John Warner                      Tivoli Systems Inc.
Sales Support Engineer           9442 Capital Of Texas Hwy North
Sales Infrastructure Group       Austin, TX 78759
john_warner@tivoli.com




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

Date: Wed, 24 Mar 1999 15:29:09 -0600
From: Mike <support@counter.w-dt.com>
Subject: Perls remove directory function doesn't work.
Message-Id: <36F95925.5FFFA2F2@counter.w-dt.com>

How come this fails all the time? rmdir
"$ads_dir/$INPUT{'accountnumber'}/ads";
it is a directory with nothing in it. It was created using perls make
directory function, and chmodded to 0777. Does by chance it have to be
deleted within the same perl program that created it? Or what else could
be wrong?



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

Date: 25 Mar 1999 00:07:28 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Perls remove directory function doesn't work.
Message-Id: <oeeg16ua6e7.fsf@alpha.hut.fi>


Mike <support@counter.w-dt.com> writes:

> How come this fails all the time? rmdir
> "$ads_dir/$INPUT{'accountnumber'}/ads";
> it is a directory with nothing in it. It was created using perls make

Why don't you check why it fails?  Learn this Perl idiom:

try() or die "I did try() but then: $!";

Study perlvar to learn more about $!.

> directory function, and chmodded to 0777. Does by chance it have to be

The permission bits on a directory don't mean a bit (okay, a lame pun)
for removing the directory.  Only the remove (aka, write) permission
on the directory your directory is in matters.  All this assuming we
are talking about a filesystem with UNIX-like semantics.

> deleted within the same perl program that created it? Or what else could

No.

Umm, well, to split hairs, that is in a fuzzy kinda way possible, but
highly unlikely.  If your program is set-uid to some uid that no other
program is, only that uid (and root) can do the removal.

> be wrong?
> 

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Wed, 24 Mar 1999 11:06:48 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: randomizing an array order
Message-Id: <oi2bd7.a63.ln@magna.metronet.com>

=?iso-8859-1?Q?d=E1na?= watanabe (dwatanab@uci.edu) wrote:

: if i could shuffle the deck, i could just pop the cards, which would be preferred)


   If you could check the Perl FAQ before posting your Perl question,
   you would have had the answer in about 30 seconds, and avoided
   annoying folks who have seen your questions hundreds of 
   times already...


   Perl FAQ, part 4:

      "How do I shuffle an array randomly?"


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


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

Date: Wed, 24 Mar 1999 15:28:37 -0600
From: "Tom Renfro" <renfro@i-55.com>
Subject: Re: RegExp problem, can't see wood for trees
Message-Id: <7dbkv8$kq1$1@nntp.gulfsouth.verio.net>

> $name =~ /name="?([^"]+)/i;
> $fn   = $1;

>
>What I am after is the file name between the optional double quotes. What
>makes it difficult is that it can be at the end of a line (with or without
>a \n) and could have a ; after the second double quote. It could also be
>in the middle of a line, in which case the ; would no longer be optional.
>
>Probably some examples would help
>
>any old stuff; name="file.doc"
>any old stuff; name=file.xls
>any old stuff; name="file.exe";
>any old stuff; name=file;
>


Try breaking it in 2:

$name =~ /name=(.*)[\;\n]/i;
$fn = $1;
$fn =~ s/"//g;

First one grabs whatever is between name= and either a semi-colon or
newline, the second
graps that substring, and the third removes the quotes, if they are there.

My regexps are rusty, so don't trust my syntax, but the method is sound...

TOM.




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

Date: Wed, 24 Mar 1999 11:01:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: RegExp problem, can't see wood for trees
Message-Id: <m92bd7.a63.ln@magna.metronet.com>

I.J. Garlick (ijg@csc.liv.ac.uk) wrote:

: I am bashing my head against a brick wall, 


   It will feel very nice when you stop  :-)


: this reg exp should be easy but
: can't for the life of me get it right.

: Any way here goes, have tried the following
: 	$name =~ /name="?([^"]+)/i;
: 	$fn   = $1;
: and
: 	($fn = $name) =~ /^.*name="?(.+)"?.*$/$1/i;

: with the first I get a " on the end of $1 sometimes, but not others.


   I don't believe you there.

   Please post a bit of code that does that.


: The second one works sometimes 


   I don't believe you there either, since it doesn't even compile...

   You should never try and type code into a posting, use cut/paste,
   else you'll just get a bunch of comments about the typos instead
   of about your real problem.


: What I am after is the file name between the optional double quotes. What
: makes it difficult is that it can be at the end of a line (with or without
                                                     ^^^^^^          ^^^^^^^
: a \n) 
    ^^


   If there is no \n, then it is not a line.

   Maybe you meant 'string' instead of 'line' ?


: and could have a ; after the second double quote. 


   I see that you have an example of that in your sample data. Good.


: It could also be
: in the middle of a line, in which case the ; would no longer be optional.


   But you don't have an example like that. Bad.


: Probably some examples would help

: any old stuff; name="file.doc"
: any old stuff; name=file.xls
: any old stuff; name="file.exe";
: any old stuff; name=file;

: The last 2 may also be followed by more unwanted characters as well.

: Any help would be greatly appreciated, and please don't tell me I missed
: it in perlfaq6 or I'll cwt nad cwy.


   How's this?


while (<DATA>) {
   while ( /name=("[^"]+|[^; \n]+)/g ) {
      ($fn = $1) =~ s/^"//;
      print "found '$fn'\n";
   }
}


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


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

Date: Wed, 24 Mar 1999 22:40:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: RegExp problem, can't see wood for trees
Message-Id: <36fb685a.880722@news.skynet.be>

I.J. Garlick wrote:

>Any way here goes, have tried the following
>
>	$name =~ /name="?([^"]+)/i;
>	$fn   = $1;
>
>and
>
>	($fn = $name) =~ /^.*name="?(.+)"?.*$/$1/i;
>
>with the first I get a " on the end of $1 sometimes, but not others.
>The second one works sometimes as well if I put a ? mark after the + but
>otherwise just gives a single character (yes I can see why, but I was
>getting desperate)

You'd probably be better of replacing the "(.+)" with "[^"]*".

>What I am after is the file name between the optional double quotes.

Obviously.

>Probably some examples would help
>
>any old stuff; name="file.doc"
>any old stuff; name=file.xls
>any old stuff; name="file.exe";
>any old stuff; name=file;

I think a combined regex would be slightly better. You don't need the
semicolon, right?

	if (/name=("[^"]*"|[a-zA-Z0-9\-\.]+)/) {
		$file = $1;
		# get rid of quotes:
		$file =~ s/^"// and $file =~ s/"$//;
	} else {
		$file = '';
	}

   HTH,
   Bart.


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

Date: Wed, 24 Mar 1999 17:37:45 -0500
From: "tavi" <tavi367@ibm.net>
Subject: Re: Remove HTML codes
Message-Id: <36f968ac@news1.us.ibm.net>


Michael Rau wrote in message <7d03pe$as8$1@surz18.HRZ.Uni-Marburg.DE>...
>Rollo Chan Ka Chun schrieb in Nachricht ...
>>Sorry that I can't use the HTML::Filter. Any other method?...Thanks...
>
>
>Use STRIPHTML.PL (by t.christiansen).
>I can mail it to you. Just give me a sign if you want to.

I would love a copy




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

Date: Wed, 24 Mar 1999 12:43:48 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Resizing File
Message-Id: <x3yd81y7pgr.fsf@tigre.matrox.com>


David J Whalen-Robinson <davidrn@pobox.com> writes:

> I want to resize a file, preferably while it is open.

This is the third time you ask this question withing two days. What is
it in the docs that you don't understand?



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

Date: Wed, 24 Mar 1999 14:11:14 -0800
From: Keith Woodworth <kwoody@citytel.net>
Subject: Undefined error on a scalar...
Message-Id: <Pine.BSI.3.95.990324133056.3916A-100000@rosencrantz.citytel.net>


It might one day be a CGI but now its just something I toy with on
occasion. Right now it seems there is a small perl problem that I cant
get around.
Program works ok, but keep getting an undefined error on one part.

Its not pretty, its really really roughshod, its not production by any
stretch of the imagination its mostly for my own amusement. ( I made one
similiar for in house staff to use to get current time usage for users but
all they need is a username)
 
Code snippet:

sub check_user {
   my($pattern, $word) = @_;
   if ($pattern eq '' || $word eq '') {
       return $matched;
   }
          $user_pwd = (getpwnam($pattern))[1];
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         here is where the problem lies. $pattern is supposed to be a
username. if its not a valid username them $user_pwd is null so
consequently the lines below will try to work on nothing and use of an
uninitialzed var error is returned.Even if  $user_pwd is null the prgram
does do the right thing and say username not found or not exist.

Ive tried various uses of undef, defined, testing for a valid username by
pulling out the username in getpwnam($patter)[0,1] and comparing etc but
it either just errors out cause I dont quite know the syntax for undef, or
defined or it still gives use of an uninit'd var.

Can I do something like: 

if not (defined $user_pwd) {
	#do something
} else {
	do something 
  }

I tried various combo's of that and kept getting uninit'd var error, or
syntax error.			

          $salt = substr $user_pwd, 0, 2;
          if (crypt($word, $salt) ne $user_pwd) {
             return $matched;
          } 
          else {
               my $matched='';
      		open(IN, $time_file) || die "could not open '$file'  $!";
      			while (<IN>) {
	                  $matched = $_ if /\b($pattern)\s+(\w+)/i;
         		} #end while  
     		close(IN);
      		return $matched;
	  } #end else 
} #end sub Check_user


Thanks for any info or help...
Keith



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

Date: Wed, 24 Mar 1999 22:19:37 +0100
From: "Javier Rubio" <javierrubio@interlink.es>
Subject: Using a Web Proxy in Perl
Message-Id: <7dbk8k$c9h$1@talia.mad.ttd.net>

Hi all,

Im making a perl program to get information from some webs, but my problem
is the conection, is too slow.
I have some web proxy that can accelerate the speed, but i dont know how to
use in Perl(in Netscape is easy :) )
Anyone can help me?

Greetings,

Miguel Angel




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

Date: Wed, 24 Mar 1999 13:35:29 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: utime issue
Message-Id: <MPG.1162fa786b9749519897bb@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36F92DD8.5824875@xilinx.com> on Wed, 24 Mar 1999 18:24:24 
+0000, Daniel O'Connell <danieloc@xilinx.com> says...

> I'm trying to *touch* a load of files at once. I've checked some references and
> don't understand why the following doesn't work ...
> 
> @vFiles = grep /\.v/, readdir X if (opendir X, "$main::XPATH");
> my $now = gmtime();
> utime $now, $now, @vFiles or die;     #always dies here ...

  utime $now, $now, map "$main::XPATH/$_", @vFiles or die $!;

(because the current directory probably isn't "$main::XPATH").

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 24 Mar 1999 10:38:11 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Values of 'true' and 'false'?
Message-Id: <3t0bd7.a63.ln@magna.metronet.com>

Philip Newton (Philip.Newton@datenrevision.de) wrote:

: What are the values returned by relational operators? 

    true or false


: perlop only say
: "returns true if ...", but not how true and false are represented. 


    But perlsyn says:

       ...as long as the expression is true (does not evaluate to 
       the null string ("") or 0 or "0"

    So, the null string, the number zero, or the one-character
    string '0' is false. Everything else is true.


    I like the explanation given by Randal in Learning Perl (p59).

       1) if the EXPR is not a string, convert it to a string

       2) '' and '0' are false, everything else is true

    Keeping in mind that undef converts to the empty string.


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


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

Date: Wed, 24 Mar 1999 14:18:55 -0700
From: "Ty! Boyack" <ty@cnr.colostate.edu>
Subject: Re: why my sub returns nothing?
Message-Id: <36F956BF.39B9EA89@cnr.colostate.edu>

dizhao@my-dejanews.com wrote:
> 
> My result is:
> i is: 2
> i is:

I get the same results on perl5.005_02 on Solaris (2.5.1-2.7),
regardless of how perl has been built.

The code snippet:

for $index (0..10)
  {
     return $index;
  }

(use foreach if you prefer)
doesn't seem to return anything, but this code snippet:

for $index (0..10)
  {
     $ret_val=$index;
     return $ret_val;
  }

works just fine.  So it appears to be related to the use of 
a loop index rather than a block scope/sub-scope problem.  

I'm trying to avoid fixing up lots of little scripts that may use
this method in them --- has anyone heard if this is an official
bug which will get fixed, or is this one of those cases where
an old mis-feature has been cleaned up?

-Ty!

-- 
|==========================||======================================|
| Ty! Boyack               || Colorado State University            |
| Unix Services Manager    || College of Natural Resources         |
| ty@cnr.colostate.edu     || A105B, Advanced Technology Lab, NESB |
| (970) 491-4966           ||                                      |
|==========================||======================================|


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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