[8505] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2122 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 18 00:17:26 1998

Date: Tue, 17 Mar 98 21:00:35 -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           Tue, 17 Mar 1998     Volume: 8 Number: 2122

Today's topics:
    Re: "Getting data from another machine" <bholzman@mail.earthlink.net>
    Re: (Newbie to Perl) - can you improve my program? <zenin@archive.rhps.org>
    Re: [Q] MacPerl - How to use libraries? (John Moreno)
    Re: Calling all "Newbies" <chasecreek.systemhouse@usa.net>
    Re: Date function - yyyymmdd format (Mike Heins)
    Re: Date function - yyyymmdd format <sowmaster@juicepigs.com>
    Re: Date function - yyyymmdd format <bholzman@mail.earthlink.net>
    Re: Date function - yyyymmdd format (Scratchie)
    Re: Date function - yyyymmdd format <zenin@archive.rhps.org>
    Re: Extracting HTML <TITLE>...</TITLE> using Perl? <bholzman@mail.earthlink.net>
        grep on hashes <hold@cglis.com>
    Re: grep on hashes <zenin@archive.rhps.org>
    Re: grep on hashes <bholzman@mail.earthlink.net>
    Re: grep on hashes <uri@sysarch.com>
    Re: How to use "@" literally in perl scripts <bholzman@mail.earthlink.net>
    Re: Module for copying directories <chasecreek.systemhouse@usa.net>
        need help with syslog.pm (Maxine G.)
    Re: opendir and UNC's in NT <metcher@spider.herston.uq.edu.au>
        Parse HTML and rename file with string (Craig Raymond Knoll)
    Re: parsing perl <zenin@archive.rhps.org>
    Re: Perl Script Challange <chasecreek.systemhouse@usa.net>
    Re: Posting to UseNet groups from Perl? <chasecreek.systemhouse@usa.net>
        Problem of auto-increment in s///; (Wei Tang)
    Re: Q about printf (Stan Horwitz)
    Re: stripping "special" characters from string (David Oswald)
    Re: Tainted Data Problems <jbc@west.net>
    Re: ts: using "my" inside a loop? (Jason Gloudon)
    Re: Variable question <bholzman@mail.earthlink.net>
    Re: Variable question <kellysm@ix.netcom.com>
    Re: Wanted: email address gleaner <jbc@west.net>
    Re: Wanted: email address gleaner <chasecreek.systemhouse@usa.net>
    Re: Why this one doesn't work ? (Dave Brown)
        Win95 to Unix jbar@marineville.com
    Re: Win95 to Unix <zenin@archive.rhps.org>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Mar 1998 21:17:29 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Terry Michaels <74331.3261@CompuServe.COM>
Subject: Re: "Getting data from another machine"
Message-Id: <350F2EB9.4C84A64D@mail.earthlink.net>

Not a perl question.  man rsh

Terry Michaels wrote:
> 
> How can I get system information from another machine
> through my script.  I want to launch a script from "predator"
> which can look at other machines and read the results from
> "df -a" or "df -k" into an array for reporting.
> 
> Thanks in advance,
> 
> Terry Michaels
> Apache Corporation
> Houston, Texas
> terrence.michaels@apachecorp.com


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

Date: 18 Mar 1998 03:00:11 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: (Newbie to Perl) - can you improve my program?
Message-Id: <890190400.252210@thrush.omix.com>

Matthew Kennedy <q9522772@mail.connect.usq.edu.au> wrote:
	>snip<
: 	open(INPUT,$file);

	Always, always test your system calls...

	open INPUT, $file
	    or die "Can not open '$file': $!, stopped";

: 	# find a PostScript text label containing a number
: 	@labels = grep /^(\(\-?\d+(\.?\d+)?\) s)/, <INPUT>;

	I'd use a while(<INPUT>) loop myself, incase the file
	is huge.  No reason to pull in all into memory of you don't
	need to.

	I'd also recommend using -w and 'use strict' as well, even
	for a program this size.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Tue, 17 Mar 1998 23:22:06 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: [Q] MacPerl - How to use libraries?
Message-Id: <1d625pe.9cb0ox1qlxkbuN@roxboro0-019.dyn.interpath.net>

Paul J. Schinder <schinder@leprss.gsfc.nasa.gov> wrote:

> phenix@interpath.com (John Moreno) wrote:
> 
> }  I've looked in Shuck, I've looked in the MacPerl FAQ (which needs to be
> }  updated) I've read the standard perl docs, and I still can't figure out
> }  why:
-snip problem-
> }  This is obviously some stupid thing that I'm overlooking and will kick
> }  myself in the ass for missing, but I just can't figure it out and can't
> }  think of anywhere else to look!
> 
> Run this and see what it says:
> 
> print join("\n",@INC)."\n";
> 
> Is the folder ":MacPerl :lib:" one of the entries?  If not, discard your
> MacPerl preferences and start over.

See?  I TOLD you it was something stupid I was overlooking!


Thanks.

-- 
John Moreno


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

Date: Wed, 18 Mar 1998 02:27:19 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Calling all "Newbies"
Message-Id: <350F2FB1.FFCC5EB@usa.net>

Super :-)

(I just keep code fragments that make me go 'Duh!  I should have known
that!' :-)

C'Ya,
Sneex

Mark Stackhouse wrote:

> Every time I read a good post that has an exceptionally well
> worded response, I cut and paste it into a text file that I





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

Date: 18 Mar 98 02:14:31 GMT
From: mikeh@minivend.com (Mike Heins)
Subject: Re: Date function - yyyymmdd format
Message-Id: <350f2e07.0@news.one.net>

jmohr@grizzly.ccsd.k12.wy.us wrote:
> I've been searching for a couple hours.  Is there a perl function that returns
> a date in yyyymmdd format?  I can write my own but why re-invent the wheel?
> It's the principal of the thing, you know.

In UNIX:

use POSIX qw/strftime/;

$now = time;
print strftime "%Y%m%d\n", localtime($now);

On Windows you will need a strftime function -- I have a fake POSIX.pm
module at ftp://ftp.minivend.com/pub/POSIX.pm if you need one. It has
strftime and ceil with stubs for some locale functions.

-- 
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
Just because something is           131 Willow Lane, Floor 2  | ||  _ \
obviously happening doesn't         Oxford, OH  45056         | || |_) |
mean something obvious is           <mikeh@minivend.com>     |___|  _ <
happening. --Larry Wall             513.523.7621 FAX 7501        |_| \_\


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

Date: Tue, 17 Mar 1998 21:31:10 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: jmohr@grizzly.ccsd.k12.wy.us
Subject: Re: Date function - yyyymmdd format
Message-Id: <350F31EE.422C@juicepigs.com>

jmohr@grizzly.ccsd.k12.wy.us wrote:
> 
> I've been searching for a couple hours.  Is there a perl function that returns
> a date in yyyymmdd format?  I can write my own but why re-invent the wheel?
> It's the principal of the thing, you know.
> 

you can find

 Date::DateCalc & Date::DateManip 

at your friendly neighborhood CPAN

If you are using Gurusamy Sarathy's port of Perl32 they are included.



HTH
Bob Trieger
sowmaster@juicepigs.com


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

Date: Tue, 17 Mar 1998 21:34:27 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: jmohr@grizzly.ccsd.k12.wy.us
Subject: Re: Date function - yyyymmdd format
Message-Id: <350F32B3.F086CA92@mail.earthlink.net>

my($mday, $mon, $year) = (localtime)[3..5];
$mon++; $year += 1900;
my $date = sprintf("%04d%02d%02d", $year, $mon, $mday);

Not everyone needs the same shape wheel all the time; better to provide
a basic model along with some useful tools.

HTH,

Benjamin Holzman

jmohr@grizzly.ccsd.k12.wy.us wrote:
> 
> I've been searching for a couple hours.  Is there a perl function that returns
> a date in yyyymmdd format?  I can write my own but why re-invent the wheel?
> It's the principal of the thing, you know.
> 
> --
> John Mohr
> Communications Specialist/Analyst
> Campbell County School District
> Gillette, Wyoming
> jmohr@grizzly.ccsd.k12.wy.us
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 17 Mar 1998 22:39:08 -0500
From: upsetter@ziplink.net (Scratchie)
Subject: Re: Date function - yyyymmdd format
Message-Id: <upsetter-1703982239080001@mfs-01-168.port.shore.net>

In article <350F32B3.F086CA92@mail.earthlink.net>, Benjamin Holzman
<bholzman@mail.earthlink.net> wrote:

: my($mday, $mon, $year) = (localtime)[3..5];
: $mon++; $year += 1900;
: my $date = sprintf("%04d%02d%02d", $year, $mon, $mday);
: 
: Not everyone needs the same shape wheel all the time; better to provide
: a basic model along with some useful tools.

An excellent answer... I always thought that the "principle" of the thing
was to get the job done as quickly as possible. 

--Art

: 
: HTH,
: 
: Benjamin Holzman
: 
: jmohr@grizzly.ccsd.k12.wy.us wrote:
: > 
: > I've been searching for a couple hours.  Is there a perl function that
returns
: > a date in yyyymmdd format?  I can write my own but why re-invent the wheel?
: > It's the principal of the thing, you know.
: > 
: > --
: > John Mohr
: > Communications Specialist/Analyst
: > Campbell County School District
: > Gillette, Wyoming
: > jmohr@grizzly.ccsd.k12.wy.us
: > 
: > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
: > http://www.dejanews.com/   Now offering spam-free web-based newsreading

---------------------------------------------------------------------
                     National Ska & Reggae Calendar
            http://www.ziplink.net/~upsetter/ska/calendar.html
---------------------------------------------------------------------


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

Date: 18 Mar 1998 03:58:51 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Date function - yyyymmdd format
Message-Id: <890193920.138797@thrush.omix.com>

Scratchie <upsetter@ziplink.net> wrote:
	>snip<
: An excellent answer... I always thought that the "principle" of the thing
: was to get the job done as quickly as possible. 

	Fast, Cheap, Good.

	...Pick any two.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Tue, 17 Mar 1998 21:53:23 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Matt Sephton <u5ms@csc.liv.ac.uk>
Subject: Re: Extracting HTML <TITLE>...</TITLE> using Perl?
Message-Id: <350F3723.FFF1D31E@mail.earthlink.net>

Probably.  If you have your html document in a scalar $html, you can do
this:

$html =~ m#<TITLE>(.*?)</TITLE>#is;

At which point the title of the html document will be in $1.  Depending
on what you're doing, there's probably modules on CPAN which will help. 
Like, for instance, HTML::Parse.

HTH,

Benjamin Holzman

Matt Sephton wrote:
> 
> How would I go about extracting the HTML tag <TITLE>...</TITLE> using
> Perl? Would a regular expression suffice?
> 
> Any help appreciated,
> Matt Sephton
> --
> u5ms@csc.liv.ac.uk
> http://www.csc.liv.ac.uk/~u5ms/


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

Date: 18 Mar 1998 03:18:14 GMT
From: "Christopher Lambrou" <hold@cglis.com>
Subject: grep on hashes
Message-Id: <01bd521c$c7fde8b0$a66f6420@akis>

Hello,
I want to count the number of keys in a hash array
that are equal to a value, say 'foo'.

So I said, assuming %a to be the hash in question:

@count = grep {$_ eq 'foo'} %a;
$count = $#count + 1;

This works(?) but is this the best way to do this?
The Camel book does not mention anything
about using hashes with 'grep'.

Any suggestions?


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

Date: 18 Mar 1998 04:04:01 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: grep on hashes
Message-Id: <890194229.989813@thrush.omix.com>

[posted & mailed]

Christopher Lambrou <hold@cglis.com> wrote:
: So I said, assuming %a to be the hash in question:
: @count = grep {$_ eq 'foo'} %a;

	Vary close:

	$count = scalar grep { $_ eq 'foo' } keys %a;

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Tue, 17 Mar 1998 22:33:04 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Christopher Lambrou <hold@cglis.com>
Subject: Re: grep on hashes
Message-Id: <350F4070.5E0EB57E@mail.earthlink.net>

Christopher Lambrou wrote:
> 
> Hello,
> I want to count the number of keys in a hash array
> that are equal to a value, say 'foo'.

I think you mean value.  There can only be one key with the value 'foo'.
> 
> So I said, assuming %a to be the hash in question:
> 
> @count = grep {$_ eq 'foo'} %a;
Assuming you meant value, you might want to do
@count = grep {$_ eq 'foo'} values %a;
This is pretty inefficient.  This is somewhat better:
foreach (values %a) {
  $count++ if $_ eq 'foo';
}
If %a is at all large, this is much better:
while (my($k,$v) = each %a) {
  $count++ if $v eq 'foo';
}

> $count = $#count + 1;
You don't need to do this.  Just use @count in a scalar context.

You may want to rethink your data structure if you need this information
repeatedly for different values of 'foo', or if %a is large.  I often
find a hash-of-lists to be a useful data structure.
> 
> This works(?) but is this the best way to do this?
> The Camel book does not mention anything
> about using hashes with 'grep'.
> 
> Any suggestions?


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

Date: 17 Mar 1998 23:30:17 -0500
From: Uri Guttman <uri@sysarch.com>
To: "Christopher Lambrou" <hold@cglis.com>
Subject: Re: grep on hashes
Message-Id: <x7vhtcipt2.fsf@sysarch.com>

"Christopher Lambrou" <hold@cglis.com> writes:

> I want to count the number of keys in a hash array

hash, not hash array

> that are equal to a value, say 'foo'.

1 or 0.

keys are unique. so only one key or none can equal foo.

> So I said, assuming %a to be the hash in question:
> 
> @count = grep {$_ eq 'foo'} %a;

this will count the number of VALUES which equal foo plus one if a key
equals foo. a hash in a list context returns a list of its key/value pairs

> $count = $#count + 1;

use
$count = @count ;


> This works(?) but is this the best way to do this?

no and no! and you don't have a good explanation of 'this'.

> The Camel book does not mention anything
> about using hashes with 'grep'.

why should it? it is not a very useful idiom. unless you use a regex to
match multiple keys, you could just do an exists to see if a key is in
the hash. or a grep on the values might be useful. but a grep on a hash
makes little sense.

hth,

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 years of Perl experience, Available Immediately
uri@sysarch.com              Resume and Sample code at http://www.sysarch.com
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: Tue, 17 Mar 1998 21:06:54 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Hiren Shah <hiren@clam.rutgers.edu>
Subject: Re: How to use "@" literally in perl scripts
Message-Id: <350F2C3E.EFBC49F5@mail.earthlink.net>

"Escape" it by using a backslash: \@

Hiren Shah wrote:
> 
> Hello,
> 
> I've been trying to write a program that would autorespond on completion
> of a web-based form. I would like to put my email address in the
> auto-response message. How do I include "@" sign in the message ?
> 
> Thanks.
> 
> Hiren


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

Date: Wed, 18 Mar 1998 02:24:28 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Module for copying directories
Message-Id: <350F2F06.B11BC6A6@usa.net>

A possibilty -

    find2perl . -print | cpio -pudvm /wherever |perl


HTH,
Sneex :-)



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

Date: Tue, 17 Mar 98 22:47:08 GMT
From: *nospam*mg*nospam*@pcg*nospam*.net (Maxine G.)
Subject: need help with syslog.pm
Message-Id: <6emuhm$4e9@examiner.concentric.net>

I am receiving the following error message when I invoke the syslog module:

Undefined subroutine &Sys::Syslog::hostname called at 
/usr/local/perl5/lib/Sys/Syslog.pm line 92.
BEGIN failed--compilation aborted at myprog.pl line 99

Here's the code from myprog.pl, line 99:
use Sys::Syslog ;

The contents of /usr/local/perl5/lib/Sys are 
Hostname.pm     
Syslog.pm

Does anyone have any idea what the problem is here? I do not know much about 
how the system is configured, and frankly, neither doesn my current system 
administrator. 
One interesting thing that I see is that in the error message, hostname isn't 
capitalized, but the file name in Sys does begin with a capital H. Is that 
relevant? 
Thanks in advance for any light you can shed on this problem!

 
*********************************************************
return address changed to prevent spamming
Remove "NOSPAM" in the return address
Maxine Gerber
PCG Systems
*********************************************************


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

Date: Wed, 18 Mar 1998 13:52:35 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: opendir and UNC's in NT
Message-Id: <350F4503.C751A7AC@spider.herston.uq.edu.au>

Jason Gloudon wrote:
> 
> In article <350E1B13.CB29B1AC@bit.bucket.org>, David Boyce wrote:
> >Jaime Metcher wrote:
> >> opendir DH, "//server/share" || die "$!";
> >>
> >I'm not in a position to try this but how about:
> >
> >        opendir DH, "//server/share/" || die "$!";
> 

Same result.

> You'd be better off writing:
> 
> opendir (DH, "//server/share/") || die "$!";
> 
> or even
> 
> opendir (DH, "//server/share/") or die "$!";
> 

Of course.  Actually, that's the syntax I used (don't ask me why I
posted something different - I'll never know).  It still doesn't work,
though.

Other variations (that also don't work):

opendir (DH, "//server/share/.") || die "$!";
opendir (DH, "//server/share/subdir/..") || die "$!";

-- 
Jaime Metcher


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

Date: 18 Mar 1998 01:50:26 GMT
From: crknoll@unity.ncsu.edu (Craig Raymond Knoll)
Subject: Parse HTML and rename file with string
Message-Id: <6en992$k7n$1@uni00nw.unity.ncsu.edu>

I am trying to parse several html files, extract strings between 
<h2> and </h2>, then rename the file with the string.

Example:

Html file reads:
 ...
<h2> System Configuration</h2>
 ...


After locating "System Configuration", I rename the file
SystemConfiguration. 

There is only one <h2></h2> pair per file.

Suggestions??

Thank you

Craig Knoll
-- 


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

Date: 18 Mar 1998 03:18:05 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: parsing perl
Message-Id: <890191473.82766@thrush.omix.com>

Rob Collins <rob@NOSPAMintr.net> wrote:
: By what you say below, do you mean there are no rules which, when applied to a
: block of text, can determine if the syntax is correct?

	Of course there is:

	if ( system ("perl -ce '$perlcode' > /dev/null 2>&1") == 0) {
	    print "Perl code syntax is ok\n";
	} else {
	    print "Perl code has syntax errors\n";
	}

	:-)

: That is, are you saying
: that syntax cannot be determined correct or incorrect until after the
: text-block is converted to op-code?

	Umm, basically...but it's not that simple.  Without using perl,
	there is no reliable way to check syntax.

: That's really confusing because it suggests that any text block is
: independently legal as perl code.

	One could say the same thing for C code...

: It would seem that somehow syntax is really
: only relevant to whatever the text-block translates into,

	Ah...ya...this is normal though...

: and that those
: op-code syntax-rules cannot for whatever reason be translated upstream, to perl
: code/text.

	Once it's compiled into a parse tree (op-codes), the "text" is thrown
	out...I don't understand what you meen by "upstream"... "to perl
	code/text"?

	Again, it would *really* help if we knew *why* you wanted to parse
	perl code without using perl.  The only reasons I can see are:

	Syntax checker...but this is well covered by the -c option to perl:
		perl -wc myprogram
	or even better:
		perl -wc -Mstrict myprogram

	Loading new perl code at run time...but this is what eval() is for.

	Checking if that code will be ok, which again is what eval() and $@
	are for.

	Perl code editor...this is a noble, but hopeless cause.  Even if you
	write it in perl (best choice, I'd say), you'd have never ending
	problems parsing perl code correctly.  Yes, Emacs and others come
	close, but nothing is perfect.  This is because, "Nothing but perl
	can parse perl".

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Wed, 18 Mar 1998 02:43:17 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Perl Script Challange
Message-Id: <350F336F.725291E6@usa.net>

No need to accept your challenge - If you have an account the now you
can ftp in and see the premissions yourself :-)

They should read something like
    -rwxr-xr-x   1 root     other       2551 Mar 17 19:50 xtest.cgi

Should work great :-)  If your code is OK...

HTH,
Sneex :-)



Sporty wrote:

> I would like to know if someone would be willing to
> test a perl script. I have done my best to put it
> together and use it on my web page. It is a guestbook
> that will send me e-mail when someone leave a message.
>
> My ISP has given me a cgi-bin directory on their
> server and "swears" it has the proper permissions.
>





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

Date: Wed, 18 Mar 1998 02:19:05 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Posting to UseNet groups from Perl?
Message-Id: <350F2DC3.CC43C43B@usa.net>

With Perl, All Things Are Possible.

Mick Knutson wrote:

> Can This be done?
> --

--Perl reference: <URL:http://reference.perl.com/>
 Perl language: <URL:http://language.perl.com/>
  Perl archive: <URL:http://www.perl.com/CPAN/>
      Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>



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

Date: 18 Mar 1998 03:44:01 GMT
From: wtang@cs.ualberta.ca (Wei Tang)
Subject: Problem of auto-increment in s///;
Message-Id: <6enfu1$m7o$1@scapa.cs.ualberta.ca>

Hi,

I want to auto-increment a variable in s///. I got the following running
fine under Perl4. But I got an error when using Perl5:
 ...
Can't modify constant item in postincrement at count.pl line 6, near "cnt++"

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

$cnt = 0;
$str = "one two three four five";
print "$str \n";
$str =~ s/(\w+)/$1_${cnt++}/g;
print "$str \n";

The output should be:
one two three four five
one_0 two_1 three_2 four_3 five_4

Could somebody help?



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

Date: 18 Mar 1998 03:58:29 GMT
From: stan@thunder.temple.edu (Stan Horwitz)
Subject: Re: Q about printf
Message-Id: <6engp5$p1e$1@cronkite.ocis.temple.edu>

brian d foy (comdog@computerdog.com) wrote:
: perhaps this is just a typo that escaped your attention, but it should
: be
: 
:    printf OUTFILE ("%02d", $x);
: 
: the printf(3) man page might be illuminating if you don't have much
: experience with the function.

Thanks. I have read the printf man page. I tried what you typed, but
I get the same result "0003" instead of "03".



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

Date: Wed, 18 Mar 1998 02:10:28 GMT
From: doswald@xmission.com (David Oswald)
Subject: Re: stripping "special" characters from string
Message-Id: <350f2b41.187351479@news.xmission.com>

On Tue, 17 Mar 1998 15:24:18 -0500, mshavel@erols.com (Michael Shavel)
wrote:


>#THIS IS THE PROBLEM LINE
>#HOW DO I MATCH THE STRING  (+1)  ??
>$archive_name =~ s/[(+1)]//g;
>

$archive_name =~ s/\(\+1\)//g;

I *think* that's right.  You're backslashing the first paren. so that
it becomes a character rather than a metachar.  Then you're
backslashing the plus so that it doesn't try to accept one or more
left parenthesis.  You're accepting one in the match, and finally
you're backslashing the right paren.  That should create a situation
where any time (+1) appears in the string it is replaced with nada.

The example you gave above would match either one left-parenthesis, or
one plus, or one 1 or one right parenthesis.  You used the character
class metacharacters (the [ and ] ) which indicate that the match can
come from any one of the characters within the square brackets.
There's no need to use a character class, and indeed it wouldn't work
since you are looking for a particular order, a particular number of
characters, and a particular set of characters.  Your example would
only meet the third need; a particular set.


MRE is a great book, but I'm not all the way through it yet, so if I'm
mistaken in my post I beg for forgiveness.  Test it out to be certain 
that it works.

Dave


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

Date: Tue, 17 Mar 1998 19:06:56 -0800
From: John Callender <jbc@west.net>
To: curt@vphos.net
Subject: Re: Tainted Data Problems
Message-Id: <350F3A50.72F39F11@west.net>

Curt Cranfield wrote:
> 
> The problem lies in the fact that I need to create a new file on the
> server side if certain data is transmitted by the client.  Of course I
> get an error like:
> Insecure dependency in open while running with -T switch at
> /xx/xx/programname line 517, <STDIN> chunk 4.

Maybe I'm missing the point of the question, but as I understand it the
*only* way to untaint data is to launder it via a regular expression
match. Like:

if ($tainted =~ /(.+)/) {
	$untainted = $1;
}

That particular regular expression, btw, is frowned upon by those who
write documentation, since it effectively subverts the whole point of
the tainting mechanism by matching everything that might be in $tainted.
But Perl still lets you do stuff like that, which is one of the great
things about Perl.

You're expected to know enough about the data you expect to see in
$tainted (and the possible bogus things subversive types might put in
there) to craft a regular expression that keeps only the good stuff and
loses the bad. For example, if you only wanted to allow "word" chars
[a-zA-Z0-9_] while losing all shell metacharacters like ";" and "|", you
could do something like:

if ($tainted =~ /(\w+)/) {
	$untainted = $1;
}

And so forth.

All of this is covered in much more detail (and much more
authoritatively) in the perlsec man page, which is why I wonder if I'm
missing something obvious in your original message. But anyway, good
luck!

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Wed, 18 Mar 1998 03:51:54 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: ts: using "my" inside a loop?
Message-Id: <slrn6guh49.bl9.jgloudon@manitoba.bbn.com>

In article <350E9996.214305A0@shopcfn.com>, Dan Boorstein wrote:
>tsatan@hotmail.com wrote:
>> 
>> Here is a fragment of perl code. "a" is a large array:
>>    my($i, $j, $k);
>>    for (@a) { ($i, $j, $k) = split /:/; }
>> 
>> Is it any less efficient to code this as:
>>    for (@a) { my($i, $j, $k)= split /:/; }
>
>well let's 'use Benchmark' and find out:

>not enough difference to be worried about in my opinion. and i think
>that the more intensive the procedures in the loop the less of a
>difference you will see. i would consider the scoping issues to be more
>important.

There really should be no substantial difference as the work associated 
with the maintenance of the lexical variables is the same in both examples.
The lexical variables within a block are "created" only when execution enters 
that block.  The for(each) loop enters and exits the { my () = split  } block 
once, so the lexicals are still only "created" once.

Jason Gloudon


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

Date: Tue, 17 Mar 1998 21:13:59 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: "Shawn M. Kelly" <kellysm@ix.netcom.com>
Subject: Re: Variable question
Message-Id: <350F2DE7.C2A00F03@mail.earthlink.net>

Two ways: soft-references and eval

soft-references:

while (<>) {
  chomp;
  my($name, $value) = split;
  ${$name} = $value;
}

eval:

while (<>) {
  chomp;
  my($name, $value) = split;
  eval "\$$name = $value;"
}


Soft-references are far better; definitely use them.

Shawn M. Kelly wrote:
> 
> I have a data file that looks like this:
> 
> door1    5.0
> door2    2.0
> door3    7.0
> ....
> 
> I'd like to read the data file in and then dynamically assign a variable
> with the first field having the value of the second.  So after reading
> in this particular file I would have three variable like so:
> 
> door1 equals  5.0
> door2 equals 2.0
> door3 equals 7.0
> 
> Can this be done in Perl? If so, can someone either give me an example
> or refer me to a book, a web site or a person?
> 
> Thank you in advance,
> 
> Shawn M. Kelly
> Network Administrator
> Hydrocarbon Technologies Inc.


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

Date: Tue, 17 Mar 1998 23:03:46 -0500
From: "Shawn M. Kelly" <kellysm@ix.netcom.com>
Subject: Re: Variable question
Message-Id: <350F47A2.A9270CFD@ix.netcom.com>

Thanks all!! The information that I received will be very usefull. I'll
be using the variable suggestions rather than the hash method though. I
need to have the values as variables so that I can "auto-update" labels
on a Perl/Tk canvas that I have. I think the was the last peice of the
puzzle!



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

Date: Tue, 17 Mar 1998 19:20:22 -0800
From: John Callender <jbc@west.net>
Subject: Re: Wanted: email address gleaner
Message-Id: <350F3D76.6369BFE7@west.net>

Jeff Potter wrote:
> 
> I've heard there are programs that search webpages on the internet
> as well as newsgroup posts for email addresses. That's how spam
> is done, right? Well, there are obviously good uses for such progs,
> too.

Personally, I can't think of one. But maybe that's just because I'm so
damn tired of being spammed.

I got a first-time E-mail spam the other day. I could tell it was a
first-time spam because the person who sent it included an actual
working 800 number for use by people who had "questions" about the
product for sale. When I dialed it I found I got to leave a recorded
message.

Man, I had a *lot* of questions. :-> Like:

* Why do you think you should have the right to send me this junk?
* Wouldn't you rather produce something of value to your fellow human
beings, rather than just scamming your way though life?
* How do you sleep at night?
* Have you heard this really cool easy-listening CD I bought the other
day? No? Well, take a listen! :-)

It was really pretty fun. But again, that's probably just because I'm so
tired of being spammed.

> Do you want to succeed at dating, or you just need a little spark to
> your
> relationship or marriage?

[snip]
 
> If you have any questions or will like to order Sensations please call
> 1-800-409-8302 ext.1256

--
John Callender
jbc@west.net
http://www.west.net/~jbc/



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

Date: Wed, 18 Mar 1998 03:31:24 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Wanted: email address gleaner
Message-Id: <350F3EB5.CFA01074@usa.net>

Hmmmm  Or just leave my phone off the hook AFTER I dial it...

:-)  Phone-O-Spam...

John Callender wrote:

> > If you have any questions or will like to order Sensations please call
> > 1-800-409-8302 ext.1256
>
> --
> John Callender
> jbc@west.net
> http://www.west.net/~jbc/





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

Date: Wed, 18 Mar 1998 02:21:02 GMT
From: dagbrown@undergrad.math.uwaterloo.ca (Dave Brown)
Subject: Re: Why this one doesn't work ?
Message-Id: <Epzt73.1r3@undergrad.math.uwaterloo.ca>

In article <6ekd3v$7u2$1@nnrp1.dejanews.com>,  <indhiraa@hotmail.com> wrote:
: I have a PERL program whose first 3 lines are like this:
: 
: #!/bin/sh
: # this line will be comment for PERL \
: exec perl "$0" $@"
: 
: print "hello..\n";
: 
: My intention is to avoid hard-coding the path to the Perl interpreter.
: but this script continuously execs and never goes beyond that.

Try

    #!/bin/sh
    exec perl "$0" "$@"
        if $running_under_some_shell;

    print "Hello...\n";

--Dave
-- 
"Fluffy bunnies are cute. Not that I have any but they should be eaten more."
                                        --Debbie Wu
http://www.csclub.uwaterloo.ca/u/dagbrown/


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

Date: Tue, 17 Mar 1998 21:06:15 -0600
From: jbar@marineville.com
Subject: Win95 to Unix
Message-Id: <6endje$2vg$1@nnrp1.dejanews.com>

Forgive the elementary nature of this
question but it comes after searching
extensively through the Perl for Win32
faq and countless docs.

I've written a couple of  simple  cgi
scripts using the Perl for Win32 port,
which use no modules at all, let alone
Win mods, and they run fine on Omnicronhttpd's
server on my hard disk. If I want to use
these on a commercial webserver,
does it have to be a Windows based
server or will the Unix perl interpreter handle
 them fine?

The support team at the commercial
 webserver I contacted  tell me their Unix
machines "aren't configured for Perl for Win32
and that you must modify the scripts for Unix."
Is that real? If so, what does it entail?
I kind of thought that an ultra simple 'Hello world'
script would be interpretable, whatever the flavor.

Excuse me for being so ignorant,

Richard Collins

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 18 Mar 1998 03:26:50 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Win95 to Unix
Message-Id: <890191998.593114@thrush.omix.com>

jbar@marineville.com wrote:
: If I want to use
: these on a commercial webserver,
: does it have to be a Windows based
: server or will the Unix perl interpreter handle
:  them fine?
	>snip<

	This depends on what you do in the program, but more then
	likely you won't need to make many changes, if any.

: The support team at the commercial
:  webserver I contacted  tell me their Unix
: machines "aren't configured for Perl for Win32
: and that you must modify the scripts for Unix."

	Translated, "We hate MS and we don't want to bother having to
	deal with any questions about why "@files = `dir`" doesn't work."

: Is that real? If so, what does it entail?
: I kind of thought that an ultra simple 'Hello world'
: script would be interpretable, whatever the flavor.

	It should...but again it depends on exactly what you do.

	If you call any outside programs either using system() or backticks
	("'"), you'll probably have to change them or rewrite the call in
	pure perl (which is probably better anyway).  If you do any Win32
	only operations (like trying to open() something with "C:/foo/bar",
	or using forward slashes in file paths), you'll need to change them.

	Best advice, try it.  If it blows up, fix it.  Perl is the most
	portable language on the planet.

-- 
-Zenin
 zenin@archive.rhps.org


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

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

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