[19911] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2106 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 10 00:05:38 2001

Date: Fri, 9 Nov 2001 21:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005368708-v10-i2106@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Nov 2001     Volume: 10 Number: 2106

Today's topics:
    Re: apply chmod() to a symlink (Clinton A. Pierce)
    Re: date/time question: weekofyear, see my code <no_mto@hotmail.com>
    Re: date/time question: weekofyear, see my code <uri@stemsystems.com>
    Re: date/time question: weekofyear, see my code (John J. Trammell)
        Extracting a 3DES key from an IBM 4758 <israelrt@optushome.com.au>
        how to perl an OLE call? <noname@nospam.com>
        HTTPS Handshakes (Rand al'Thor)
    Re: Issues when developing on windows systems and runni <stuart@otenet.gr>
    Re: Issues when developing on windows systems and runni (F. Xavier Noria)
    Re: md5 and hashrefs <goldbb2@earthlink.net>
    Re: Need Some Help <mbudash@sonic.net>
    Re: Need Some Help <jeff@vpservices.com>
    Re: Newbie: Handline CSV files properly <jurgenex@hotmail.com>
    Re: Perl vs. Active Perl <bart.lateur@skynet.be>
    Re: Perl vs. Active Perl <tim@vegeta.ath.cx>
    Re: Perl vs. Active Perl <randy@theory.uwinnipeg.ca>
    Re: Please help beginner with using cookies! <goldbb2@earthlink.net>
        print problem HELP!!! (JOHN DOUGLAS SMITH)
        regular expresion <adustipujo1@mediaone.net>
    Re: regular expresion (Rand al'Thor)
    Re: regular expresion (Tad McClellan)
    Re: Regular Expressions (james)
    Re: Regular Expressions (Tad McClellan)
    Re: Software error with -T using sendmail <goldbb2@earthlink.net>
        which is faster? =1 or ++ (reader of news)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 10 Nov 2001 02:21:35 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: apply chmod() to a symlink
Message-Id: <Pa0H7.6400$RI2.3154756@news2>

[Posted and mailed]

In article <9sh9qt$jrn$1@holly.rdwarf.com>,
	Louis Erickson <wwonko@rdwarf.com> writes:
> Radu Muschevici <grinsefisch@gmx.ch> wrote:
>: apparently, if perl's chmod() is applied on a symbolic link, it 
>: changes the owner of the file which the link points to.
>: but how can I change the owner of the symlink itself??
> 
> Well, chmod changes the access permissions for a file, not the owner.
> You'd be able to change the owner with chown.  See perldoc -f chown
> 
> Most Unix systems don't have any access permissions for the symbolic
> link, anyway, so it must change the real file.  Symlinks do, however
> have owners, which can be changed independently.
> 
> I'm not quite sure which you mean to be changing here, but, if it's
> the permissions, you can't change those on a symlink, and if it's
> the owner, then you need to use chown().

It appears as though this behavior might vary depending on Unix systems.
The man pages for Linux, for example, indicate that there's a chown(2)
and a lchown(2) system call.  At one point the behavior of chown was 
to change the symlink, at another point it time it was to change the 
referent.

Now there's two syscalls so you can pick which behavior you're looking for.
If you call chown(2) now it changes the referent, and lchown(2) changes
the link.

Perl, FWIW, seems to go looking for an lchown(2) function and if you've 
got it, it's used.  So Perl _should_ be changing the link itself.

As far as mode, though, you're right.  Permissions don't really matter
on a symlink.  chmod(2) is always going to work on the referent.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sat, 10 Nov 2001 00:02:24 +0100
From: "MAGiC MANiAC^mTo" <no_mto@hotmail.com>
Subject: Re: date/time question: weekofyear, see my code
Message-Id: <9shnj6$16g1$1@news.kabelfoon.nl>


Okay, Thanks, I've change it in this...
I hope your all agree with this code... ;-)


sub getdate {
  ( $second , $minute , $hour , $day , $month , $year , $dayofweek ,
$dayofyear , $isdst ) = localtime( );
  $month ++;
  $year += 1900;
  $weekofyear = int( $dayofyear / 7 ) + 1;
  $dayofyear ++;
  $day = sprintf( "%02d" , $day );
  $month = sprintf( "%02d" , $month );
  $year = sprintf( "%04d" , $year );
  $hour= sprintf( "%02d" , $hour );
  $minute = sprintf( "%02d" , $minute );
  $second = sprintf( "%02d" , $second );
  $date = "$day-$month-$year";
  $time = "$hour:$minute:$second";
}

&getdate;

print "$date - $time\n\n";
print "date: $day / $month / $year - time: $hour hour, $minute minutes\n\n";
print "day of year: $dayofyear\n";
print "day of week: $dayofweek";





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

Date: Fri, 09 Nov 2001 23:34:09 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: date/time question: weekofyear, see my code
Message-Id: <x7ofmbr00n.fsf@home.sysarch.com>

>>>>> "MM" == MAGiC MANiAC^mTo <no_mto@hotmail.com> writes:

  MM> I hope your all agree with this code... ;-)

no.

  MM> sub getdate {
  MM>   ( $second , $minute , $hour , $day , $month , $year , $dayofweek ,
  MM> $dayofyear , $isdst ) = localtime( );
  MM>   $month ++;
  MM>   $year += 1900;
  MM>   $weekofyear = int( $dayofyear / 7 ) + 1;
  MM>   $dayofyear ++;
  MM>   $day = sprintf( "%02d" , $day );
  MM>   $month = sprintf( "%02d" , $month );
  MM>   $year = sprintf( "%04d" , $year );
  MM>   $hour= sprintf( "%02d" , $hour );
  MM>   $minute = sprintf( "%02d" , $minute );
  MM>   $second = sprintf( "%02d" , $second );
  MM>   $date = "$day-$month-$year";
  MM>   $time = "$hour:$minute:$second";
  MM> }

just do this:

use POSIX ;

and call strftime already. looking at that code is ruining my eyesight.

it doesn't use strict. it returns with globals. it calls sprintf way to
many times. you can just do one call and get the date like:

	$date = sprintf '%02d-%02d-$year', $day, $month + 1 ;

please listen to what you are being told. your code breaks so many rules
(even if it finally seems to print the correct date).

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 9 Nov 2001 17:51:13 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: date/time question: weekofyear, see my code
Message-Id: <slrn9uor10.oia.trammell@haqq.el-swifto.com>

On Sat, 10 Nov 2001 00:02:24 +0100, MAGiC MANiAC^mTo <no_mto@hotmail.com> wrote:
> 
> Okay, Thanks, I've change it in this...
> I hope your all agree with this code... ;-)
[snip]

Sweet Jesus, no.  :-)



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

Date: Sat, 10 Nov 2001 12:25:27 +1100
From: IsraelRT <israelrt@optushome.com.au>
Subject: Extracting a 3DES key from an IBM 4758
Message-Id: <tf0putos6f22l03bj6i5qt5dg1bbnqkgi7@4ax.com>

An amusing article , well worth reading:



http://www.cl.cam.ac.uk/~rnc1/descrack/
"The IBM 4758 is an extremely secure crytographic co-processor. It is
used by banking systems and in other security conscious applications
to hold keying material. It is designed to make it impossible to
extract this keying material unless you have the correct permissions
and can involve others in a conspiracy.

Until IBM fix the CCA software to prevent our attack, banks are
vulnerable to a dishonest branch manager whose teenager has $995 and a
few hours to spend in duplicating our work.

We are able, by a mixture of sleight-of-hand and raw processing power,
to persuade an IBM 4758 running IBM's ATM (cash machine) support
software called the "Common Cryptographic Architecture" (CCA)
to export any and all its DES and 3DES keys to us. All we need is:
about 20 minutes uninterrupted access to the device one person's
ability to use the Combine_Key_Parts permission a standard
off-the-shelf $995 FPGA evaluation board from Altera
about two days of "cracking" time"


If your bank manager suddenly flies off to the south of France, this
might explain it !



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

Date: Fri, 9 Nov 2001 18:23:20 -0800
From: "A" <noname@nospam.com>
Subject: how to perl an OLE call?
Message-Id: <3bec8f86$0$79558$8eec23a@newsreader.tycho.net>

trying to script some functions for the Wise for Windows Installer ("wfwi")
tool's OLE automation interface, I'm stuck because i don't know enough perl
to get the parameters right ... please would some kind person suggest what
might work?

The function prototype is documented thus:

BSTR AddRegistryValue(short sKeyRoot, BSTR szKey, BSTR szValueName, BSTR
szData, short sDataType, short sOperation, BSTR szFeatureComponent, short
iType, BSTR *szComponentKey)

I suspect the last parameter is the one going wrong.  There's a variant of
the function (Add...Ex) which has the last parameter as VARIANT
*pvComponentKey "for VBScript compatibility".

My futile attempt at coding this is:

$Win32::OLE::WiseObj->AddRegistryValue(2, "SOFTWARE\\MyTest", "testValue",
"testData", 0, 1, "gview_report.reg", 1, \$ComponentKey)

What will work?

(I really really don't want to have to use VBS)

many thanks
alan





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

Date: Sat, 10 Nov 2001 00:09:36 GMT
From: sconfusion1@removethistext.home.com (Rand al'Thor)
Subject: HTTPS Handshakes
Message-Id: <3bec6da1.34480425@news>

Hey,

I was wondering if you could explain to me how the opening handshake
works when making a connection to a secure web site?  From what I
understand, the client sends an initial request:

OPTIONS * HTTP/1.1
Host: www.example.com
Upgrade: TLS/1.0
Connection: Upgrade

but then what?  The RFC says to send a ClientHello message, but never
defines what exactly that is.

Can anyone offer any help?

Thanks,

-Steven


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

Date: Sat, 10 Nov 2001 01:19:33 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <9shpte$6m8$1@usenet.otenet.gr>

"John J. Trammell" <trammell@haqq.hypersloth.invalid> wrote in message
news:slrn9uojnu.n7r.trammell@haqq.el-swifto.com...
> On Fri, 9 Nov 2001 22:15:57 +0100, Bob Rock wrote:
> > Hello,
> > I'm new to perl and was wondering if developing on win32 systems and
then
> > running code on linux systems can cause certain issues to arise. I was
> > thinking specifically to newlines where on win32 systems they are
composed
> > of two characters (a carriage return and a newline) while on linux
machines
> > they are just made up by a single newline character. Thank you.
> >
> Yes, that situation can cause problems, if people are careless.
>

But not with the code surely? Wont the perl interpreter take ^M to be
whitespace in unix?
I keep meaning to try it.

Data yes, can cause problems obviously.

--

Stuart Gall
------------------------------------------------
This message is not provable.



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

Date: 10 Nov 2001 00:00:19 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <9shqmj$3inc71@news1s.iddeo2.es>

On Fri, 9 Nov 2001 22:15:57 +0100, Bob Rock <no_spam.yet_another_apprentice@hotmail.com> wrote:

: I'm new to perl and was wondering if developing on win32 systems and then
: running code on linux systems can cause certain issues to arise. I was
: thinking specifically to newlines where on win32 systems they are composed
: of two characters (a carriage return and a newline) while on linux machines
: they are just made up by a single newline character. Thank you.

Perl code is portable in general.

However, there are some issues one needs to take into account to
program that way (which is The Way(tm) IMO). For instance, normal
line-oriented code assumes lines are written following the convention
of the platform perl is running. Filenames are portably dealt with
using packages of the standard distribution. Obviously, system() and
friends are not too much portable....

perldoc perlport explains it in detail.

-- fxn


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

Date: Fri, 09 Nov 2001 21:59:50 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: md5 and hashrefs
Message-Id: <3BEC9826.8FB38B77@earthlink.net>

Jens Luedicke wrote:
> 
> hi ...
> 
> I have an algorithm that creates a threaded Gtk::CTree
> based on the Message-ID and the In-Reply-To: Header parts.
> I store each node in an hashref and each node is identified
> by the Message-ID
> 
> Sometimes those Message-ID's and In-Reply-To's vary in their
> length, so would it make sense to create md5 digests to 'waste'
> the same amout of space to identify each node?
> 
> Or is this idea too strange to be useful at all? ;-)

It's not strange at all -- however, it *is* unnecessary.  Unless the
amount of data used by your program is gargantuan, the speed savings
[and decreased complexity of code] of using the actual message-ids
instead of md5s of them significantly outweighs the "waste" of having
the mids used both as keys and as values.

By the way, have you seen: http://www.jwz.org/doc/threading.html
If not, you really really really should.

-- 
Klein bottle for rent - inquire within.


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

Date: Fri, 09 Nov 2001 23:10:18 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Need Some Help
Message-Id: <mbudash-1E191A.15102009112001@news.sonic.net>

In article <3BEC5884.5147CD48@vpservices.com>, Jeff Zucker 
<jeff@vpservices.com> wrote:

> Michael Budash wrote:
> > 
> > In article <9sg7o4$36e$1@slb7.atl.mindspring.net>, "Sophie Anderson"
> > <saUSAFirst@yahoo.com> wrote:
> > 
> > > I need to read all files so that when I type "Enter the borrower
> > > number: " all fields from all 3 fields are displayed.
> > 
> > (i hope jeff zucker is reading this)
> 
> I wasn't (because "Need Some Help" didn't catch my eye as a database
> problem :-), but thanks for the email pointer.
> 
> > DBD::AnyData::db prepare failed: Parse error near .bNumber, bName,
> > bPhone, l.ISBN, title, author, returnDate FROM lends l, borrowers b,
> > ISBNs i WHERE l.bNumber=b.bNumber and i.ISBN=l.ISBN at
> > /usr/lib/perl5/site_perl/5.6.0/DBD/AnyData.pm line 126.
> > 
> > what am i missing? or does this module (or perhaps SQL::Statement) not
> > support sql aliasing?
> 
> The current SQL::Statement doesn't support either aliasing or
> multi-table joins.  The new SQL::Statement (I should have it out in the
> next few weeks) does support multi-table joins. 

but not aliasing?
 
> In the meantime, the
> non-SQL AnyData.pm is the easiest way to do it.  The script below uses
> data from the DATA section of the script itself but data from files (in
> almost any format) could also be used just by changing the one line
> where @db is defined):
> 
> #!/usr/local/binperl -w
> use strict;
> use AnyData;
> my @db = split /\n\n/, join('',<DATA>);
> my @table = map { adTie( 'CSV', [$_] ) } @db;
> while (my $row0 = each %{$table[0]}) {
>     my $row1 = $table[1]->{ $row0->{bNumber} };
>     my $row2 = $table[2]->{ $row1->{ISBN}    };
>     print join( ', ', (
>         $row0->{bNumber}, $row0->{bName}, $row0->{bPhone},
>         $row1->{ISBN}, $row1->{returnDate},
>         $row2->{Author}, $row2->{Title}, $row2->{Publisher},
>         $row2->{Cost}, $row2->{Year},
>     )),"\n";
> }
> __DATA__
> bNumber,bName,bPhone
> 1,Hamlet,666-6666
> 
> bNumber,ISBN,returnDate
> 1,000-000,2001-11-09
> 
> ISBN,Author,Title,Publisher,Cost,Year
> 000-000,Shakespeare,Hamlet,McGraw,$12,1608
> 
> Note that the joins literally use the foreign key as the *key* to the
> tied hash for the joined table.
>
> Also note that if this was coming from
> files rather than the DATA section, none of the three tables would be
> slurped into memory -- only a row at a time for the first table and only
> the relevant rows (one row at a time) from the joined tables.
>
> Also note
> that this script assumes a one-to-one relationship between the tables
> but slight adjustments would allow it to do many-to-many or other kinds
> of relationships as well.  The script is a little longer than it needs
> to be for clarity :-).

well, due to all those notes as well as my desire to standardize my data 
access solutions, rather than learning/perfecting another one, i will 
wait for the new SQL::Statement. in case you missed my embedded question 
above: will it support aliasing?
 
tia-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Fri, 09 Nov 2001 15:46:42 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Need Some Help
Message-Id: <3BEC6AE2.37A27E93@vpservices.com>

[posted and mailed]

Michael Budash wrote:

> In article <3BEC5884.5147CD48@vpservices.com>, Jeff Zucker
> <jeff@vpservices.com> wrote:
> >
> > The current SQL::Statement doesn't support either aliasing or
> > multi-table joins.  The new SQL::Statement (I should have it out in the
> > next few weeks) does support multi-table joins.
> 
> but not aliasing?

Oh heck. My craftily worded statement was supposed to leave that
ambiguous.  Yes, for sure it will support aliasing eventually.  Will it
in the next release?  Depends on whether I can squeeze 29 hours into the
days ahead rather than the normal 27.  It isn't that big of a thing to
do but right now I am a bit tied up with testing all of the various
combinations of explicit, implicit, natural, inner, and outer joins so
my work's cut out for me.  If aliasing doesn't make it into the coming
release, patches will be welcome. 

> my desire to standardize my data access solutions, 

Totallly understandable and certainly the route I take also.

> rather than learning/perfecting another one

Well a tied hash probably isn't a new data structure for you :-) but
point taken.  This tied hash thing is an interface for those for whom
SQL would mean learning/perfecting something they don't already know.  I
see it as a stepping stone sort of process of learning: 1) a tied hash
interface to flatfiles 2) a DBI/SQL interface to flatfiles 3) a DBI/SQL
interface to a full rdbms.  My modules are intended to bridge the three
steps but are also intended to be useful to those like yourself who
don't need the first one.

-- 
Jeff



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

Date: Fri, 9 Nov 2001 18:31:59 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie: Handline CSV files properly
Message-Id: <3bec91bb@news.microsoft.com>

"Paul Johnson" <aeropaul@sbcglobal.net> wrote in message
news:cd6muts2hc4ud3ot3febsrfmb3j204a1nb@4ax.com...

Did you check http://search.cpan.org/search?mode=module&query=csv already?

jue




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

Date: Fri, 09 Nov 2001 23:12:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl vs. Active Perl
Message-Id: <gdooutcfmq0eufem420r52903olfrrbr5p@4ax.com>

Malcolm Dew-Jones wrote:

>By "Active Perl" you probably mean "ActiveState Perl"  which is just the
>version of perl that runs on windows.  It is provided by ActiveState (a
>company).  It is exactly the same as any other perl, except that they have
>to make various small changes to get the unix version to compile and run
>on windows.

Not exactly... there are ActivePerl's for Solaris and Linux too. But
they are precompiled binaries. They come with the module installer
program (script), PPM. See
<http://www.activestate.com/Products/ActivePerl/>.

You can find out what Activestate modified to the sources to make it
compile (mainl for Windows) from the diff that is available from their
website:


<http://downloads.activestate.com/ActivePerl/src/5.6/AP630_diff.txt>

-- 
	Bart.


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

Date: Sat, 10 Nov 2001 00:38:13 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: Perl vs. Active Perl
Message-Id: <slrn9uou69.d45.tim@vegeta.ath.cx>

Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> graced us by uttering:
> bjohnsto@whiledefined.net wrote:
> : I was wondering what the difference if there is any between these two.  
> : Reason I ask is I would like to be able to monitor/admin some of my more
> : mundane functions from a linux workstation, like account creation across
> : multiple platorms for one. I was looking at the libwin32 modules but it 
> : states that it needs Active Perl.  They have the packages I need, but 
> : wanted to know the difference between the two before I rip out my current 
> : version and install another one.  Also, am I correct in thinking that 
> : these modules will not run on a linux system but have to be run from 
> : a windows box?  Thanks for the help folks.
> 
> 
> By "Active Perl" you probably mean "ActiveState Perl"  which is just the
> version of perl that runs on windows.  It is provided by ActiveState (a
> company).  It is exactly the same as any other perl, except that they have
> to make various small changes to get the unix version to compile and run
> on windows.

Um, not really.  He could very well have meant "ActivePerl", which is
what ActiveState calls its Perl distro. To quote from the site:

http://www.activeperl.com/Products/ActivePerl/ :
    ActivePerl is ActiveState's quality-assured binary build of Perl,
    available for Linux, Solaris, and Windows. As part of
    ActiveState's support for Perl, we provide the ActivePerl binary
    packages free to the community.

Among the mere "compatibility" modifications, ActiveState also modified
the _license_ under which their versions may be distributed.  It's still
free (beer) for non-commercial use, but its license is more restrictive
and you should really read it before you do anything work-related using
ActivePerl.

http://www.activeperl.com/Products/ActivePerl/license_agreement.plex

[ snip ]
> The bottom line is that if you wish to use the functions in libwin32 you
> probably need to run perl on a windows PC (which is normally done by
> installing the perl distribution provided by ActiveState). 

I would venture to guess that the *majority* of Win32 Perl installations
are from ActiveState.  OTOH, I feel it's important for the OP to know
that ActivePerl is _not_ the only Win32 perl distro, it's _not_ the only
one that uses libwin32, and it _might_ not be the best one for you.

CPAN has some win32 perl binaries that remain under the Artistic
License, and IndigoPerl <http://indigostar.com/indigoperl.htm>, quote,
"comes without a restrictive license - you can do whatever you want to
do with it."

So, in the spirit of capitalism (that evil institution that it is =),
shop around and decide what you need for yourself.

HTH
Tim Hammerquist
-- 
People don't buy our products because they want a 1/2 inch drill,
they buy our products because they want a 1/2 inch hole.
    -- reportedly, some exec at Black and Decker


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

Date: Fri, 9 Nov 2001 22:41:27 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: Perl vs. Active Perl
Message-Id: <9sibpv$jve$1@canopus.cc.umanitoba.ca>

"Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
    news:slrn9uou69.d45.tim@vegeta.ath.cx...

> CPAN has some win32 perl binaries that remain under the Artistic
> License, and IndigoPerl <http://indigostar.com/indigoperl.htm>, quote,
> "comes without a restrictive license - you can do whatever you want to
> do with it."

Actually, this seems to have changed somewhat regarding
bundling IndigoPerl with a commercial product - see
http://indigostar.com/indigoperl.htm#License.

best regards,
randy kobes





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

Date: Fri, 09 Nov 2001 23:21:52 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Please help beginner with using cookies!
Message-Id: <3BECAB60.CDE8CA85@earthlink.net>

Marianne Sisto wrote:
> 
> Yes I know, but its for an assignment!  I am not allowed to use
> somebody else code!

Does using perl itself count as 'somebody else's code' ?
After all, you didn't invent perl, Larry Wall did.
For that matter, you can't use any programming language, or even your
operating system... it was all written by other folks than you.

Your teacher almost certainly meant, don't copy code from other
students.  [S]he did *not* mean, don't use modules.

Besides, using modules is a fundamental part of using perl; learning to
do this is, I'm sure, an import part of the class you're in.  It's not
"cheating" to use them.

-- 
Klein bottle for rent - inquire within.


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

Date: 9 Nov 2001 23:09:59 GMT
From: jdsmith@ouray.cudenver.edu (JOHN DOUGLAS SMITH)
Subject: print problem HELP!!!
Message-Id: <9shno7$h56$1@news.cudenver.edu>

HELP!!!!

I have written a perl script to execute a command on each of the routers
on my network and parse the output. Basically the script gets the version
number of router code we are running on all our routers. The script
is invoked on a unix box by entering the <scritp name> <textfile containing
list of ip addresses> <managers password>:

% getimg.pl routers.txt password

The script then reads thru the text file called routers.txt and telnets to
the ipaddresses listed on each line of the text file and runs the 'stamp'
command and parses the output to something like:

Router 32.101.5.8  is running BayRS rev/14.00/1D12

Nothing fancy just your typical admin laziness.

BTW the routers.txt looks like this:

32.101.5.8
32.103.1.4
32.99.2.13

Other people that use the scripts and the routers.txt file want to add a 
comment in the routers.txt file, so I figured making the routers.txt file
work either way <ipaddress> # <comment> would be easy!  Well it doesn't 
seem to be working and I can't find what I am doing wrong. I want it to
parse the comment if its there and if its not just behave normally.

I have created a routers.txt file that looks like:

32.101.5.8 # hawaii router
32.103.1.4 # ny router
32.99.2.13 # denver router
32.199.5.2
32.87.5.131 

What I get when the script runs is this: 

Router 32.101.5.8  is running BayRS rev/15.00
Router 32.103.1.4  is running BayRS rev/14.00/1D12
Router 32.99.2.13  is running BayRS rev/14.00/1D12
is running BayRS rev/14.20
is running BayRS rev/13.00

Why is it not printing the string "Router " and the
ip address ($ip in the script)????

The script seems to work fine if the # and comment are there but if there is
no comment it doesn't print the ip address, however it still parses properly
accesses the router and gets the right version information.

If the wrong password is given or the router is not accessible it prints
the ip just fine.

I am really confused.

Any help would be greatly appreciated!


jds
jdsmith@ouray.cudenver.edu

The script is listed below:

#!/usr/bin/perl
# getimg.pl V2.0
# Written by Doug Smith 3/15/01
# Please feel free to use/modify and redistribute.
# Comments, suggestions, bugs e-mail me at 
# This program gets the router code image. Usefull for getting the code version
# on a whole group of routers at once.
# Usage: getimg.pl <iplist file> <Manager's password>

use Net::Telnet ();
open(iplist,$ARGV[0])||die "Need input file of IP addresses. (errno: $!)\n";
if (length($ARGV[1])==0) {die "Need Manager's password. (errno: $!)\n";}
while (<iplist>)
{
        chop;
        ($ip,$comment) = split(/#/);
        $t=new Net::Telnet (Timeout=>10,Prompt=>'m/\]\$/',Errmode=>"return");
        if($t->open($ip))
        {
                if($t->login('Manager',$ARGV[1]))
                {
                        @o=$t->cmd("stamp");
                        print "Router ",$ip," is running BayRS ",split(/Image:     /,$o[1]);
                }
                else
                {
                        print $ip," Possible bad password\n";
                        next;
                }
        }
        else
        {
                print "Error accessing ",$ip,"\n";
                next;
        }
        close $t;
}



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

Date: Sat, 10 Nov 2001 00:29:05 GMT
From: "Pujo C A" <adustipujo1@mediaone.net>
Subject: regular expresion
Message-Id: <lx_G7.5586$4W.67640@typhoon.mw.mediaone.net>


Hi guys,

I couldn't find the effective way to subtitute this array
$t = "string \"Inside must\" still remain";
what I want to make is the array become only (Inside must)
I tried with this but I want this into one line......

$t=~s/.*?\"//;
$t=~s/\".*//;


Thank you in advance,
--
Pujo C Agustiyanto
http://www.geocities.com/pujoca
<!-- Veryly man is in loss if they  gain the same today and think not to be
better tomorrow -->




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

Date: Sat, 10 Nov 2001 01:03:20 GMT
From: sconfusion1@home.com (Rand al'Thor)
Subject: Re: regular expresion
Message-Id: <3bf07d62.38514172@news>

On Sat, 10 Nov 2001 00:29:05 GMT, in comp.lang.perl.misc you wrote:

>
>Hi guys,
>
>I couldn't find the effective way to subtitute this array
>$t = "string \"Inside must\" still remain";
>what I want to make is the array become only (Inside must)
>I tried with this but I want this into one line......
>
>$t=~s/.*?\"//;
>$t=~s/\".*//;
>
>
>Thank you in advance,

Try this:

$t =~ s/^.*\"([^\"]+)\".*/$1/;

-Steven



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

Date: Sat, 10 Nov 2001 04:10:25 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regular expresion
Message-Id: <slrn9up7hr.olf.tadmc@tadmc26.august.net>

Rand al'Thor <sconfusion1@home.com> wrote:

>$t =~ s/^.*\"([^\"]+)\".*/$1/;
            ^    ^    ^
            ^    ^    ^

None of those backslashes serve any purpose. So why are they there?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 9 Nov 2001 19:23:30 -0800
From: james@ryley.com (james)
Subject: Re: Regular Expressions
Message-Id: <79fd9c90.0111091923.5029edd7@posting.google.com>

Use this:  

$variable =~ tr/A-Z/a-z/;

tr is slightly different than s.

James

Uri Guttman <uri@stemsystems.com> wrote in message news:<x7eln7sueu.fsf@home.sysarch.com>...
> >>>>> "DH" == Dave Hull <dphull@ku.ed.nospam.u> writes:
> 
>   DH> "Anya Miretsky" <anyam_99@yahoo.com> wrote in message
>   DH> news:1e0c6f7a.0111090745.385e55b@posting.google.com...
>   >> I am new to Perl, so therefore the simple question..
>   >> 
>   >> How do I use a regular expression to make all uppercase letters in a
>   >> string into lowercase?
>   >> 
>   >> I've tried $x =~ s/[A-Z]/[a-z]/g; and this doesn't work. I've also
>   >> looked at the perlre man page and the Camel book, but can't find what
>   >> I need.
> 
>   DH> If you're not required to use a regular expression for this, look
>   DH> at the "uc" function which converts its argument to uppercase.
> 
> methinks you meant lc and lowercase. read the OP again.
> 
> :)
> 
> uri


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

Date: Sat, 10 Nov 2001 04:10:23 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular Expressions
Message-Id: <slrn9up78q.olf.tadmc@tadmc26.august.net>

james <james@ryley.com> wrote:

>tr is slightly different than s.


tr/// is _wildly_ different than s///


s/// is appropriate to the Subject: of this thread.

tr/// has nothing to do with regular expressions despite
its unfortunately similar appearance.


[ and neither one of them is the Right Tool for converting case.
  They do not respect locales, as lc() and friends do.
]
-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 09 Nov 2001 23:40:38 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Software error with -T using sendmail
Message-Id: <3BECAFC6.3DAB8B5D@earthlink.net>

spamfree wrote:
> 
> I wish to enable taint but get software error opening sendmail.
> Do I need to untaint path?
> If so, how to do that.
> 
> #!/usr/bin/perl -Tw
> #<code cut>
> open (MAIL, "|/usr/sbin/sendmail -t") || &ErrorMessage;
> # Insecure $ENV{PATH} while running with -T switch ?

There's one of two problems:

The simplest is, you ran the program by typing something like:
    perl -T somescript.pl
and perl is able to tell that "perl" was looked up in the PATH, not from
a full pathname.  To fix it, either start your program as:
    /usr/bin/perl -T somescript.pl
or:
    ./somescript.pl

Less simple is:
When you open to a pipe, it uses popen to create the new process...
popen, in turn, uses "sh -c" to parse the arguments.  It starts sh by
looking in your PATH.  If the PATH is tainted, sh could come from a
malicious location.  This would be bad.

The solution:
    use IPC::Open3;
    my $pid = open3( MAIL, ">&STDOUT", ">&STDERR",
        qw(/usr/sbin/sendmail -t) );
    print MAIL stuff....;
    close MAIL or die $!;
    if( waitpid $pid, 0 ) {
        my ($sig, $ret) = ($?&255, $?>>8);
        die "sendmail exited with code $ret" if $ret;
        die "sendmail killed by signal $sig" if $sig;
    } else {
        die "waitpid(sendmail pid $pid, 0) : $!";
    }

Sure, it's alot of code, but you have full control over what's
happening... when you use open2, there will not be an instance of 'sh'
started to parse the arguments.

-- 
Klein bottle for rent - inquire within.


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

Date: Sat, 10 Nov 2001 04:44:46 GMT
From: newsreader@mediaone.net (reader of news)
Subject: which is faster? =1 or ++
Message-Id: <slrn9upc96.uf0.newsreader@amd.universe>

I would like to know which of the following is faster


$|=1; 
	or 
$|++;


Thanks in advance




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 2106
***************************************


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