[18024] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 184 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 31 14:10:53 2001

Date: Wed, 31 Jan 2001 11:10:26 -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: <980968226-v10-i184@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 31 Jan 2001     Volume: 10 Number: 184

Today's topics:
    Re: Net::Telnet, How do i 'print' Arrow Keys? (Garry Williams)
    Re: Net::Telnet, How do i 'print' Arrow Keys? <stefan.bach@web.de>
    Re: Newbie Problem with setting environment variables a scottpa@my-deja.com
    Re: Newbie Problem with setting environment variables a nobull@mail.com
        open(), quoting, and Win32 woes allandclarke@my-deja.com
    Re: printf and leading zeros <russ_jones@rac.ray.com>
    Re: printf and leading zeros <mischief@velma.motion.net>
    Re: printing array of hashes <mjcarman@home.com>
    Re: qr and backreferences <joe+usenet@sunstarsys.com>
    Re: qr and backreferences <uri@sysarch.com>
        question about sort k9boy@my-deja.com
    Re: question about sort tigra@sky.deep.ru
    Re: question about sort nobull@mail.com
    Re: question about sort <mjcarman@home.com>
    Re: Referencing module functions query. <ddunham@redwood.taos.com>
        RegExp: Find anything except... <vezerid@ac.anatolia.edu.gr>
        Script to Retrieve UK TV listings. <unformat@my-deja.com>
    Re: secure server <mischief@velma.motion.net>
    Re: Securely tarring a directory on the web server nobull@mail.com
    Re: Sorting in NT like in Unix <bowman@montana.com>
        sorting IP addresses mike_solomon@lineone.net
        Turn off Content (Jimtaylor5)
    Re: Turn off Content tigra@sky.deep.ru
    Re: Using global var in subroutine <steve@teamITS.com>
        while loop to print list of tags? <davidwaters@bigfoot.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 31 Jan 2001 14:33:26 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Net::Telnet, How do i 'print' Arrow Keys?
Message-Id: <WmVd6.17$Sn3.1968@eagle.america.net>

On Wed, 31 Jan 2001 14:30:06 +0100, Stefan Bach <stefan.bach@web.de>
wrote:
>I'm connecting to a Switch via Telnet.
>Unfortunately the Switch has a menu-based user interface.
>How can I send ($obj->print();) Keys like the arrow Keys?
>Are there ESC-Codes or how can it be done?

What does the program at the other end expect?  

This doesn't seem to be a Perl issue at all, does it?  

[off topic]

Even so, you might want to look at snoop(1) or its equivalent on your
client machine.  That would enable you to "see" what is being sent to
the server when you type it on the client.  

-- 
Garry Williams


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

Date: Wed, 31 Jan 2001 15:47:44 +0100
From: "Stefan Bach" <stefan.bach@web.de>
Subject: Re: Net::Telnet, How do i 'print' Arrow Keys?
Message-Id: <9598il$g72mn$1@ID-65368.news.dfncis.de>

"Garry Williams" <garry@zvolve.com> schrieb im Newsbeitrag
news:WmVd6.17$Sn3.1968@eagle.america.net...
> On Wed, 31 Jan 2001 14:30:06 +0100, Stefan Bach <stefan.bach@web.de>
> wrote:
> >I'm connecting to a Switch via Telnet.
> >Unfortunately the Switch has a menu-based user interface.
> >How can I send ($obj->print();) Keys like the arrow Keys?
> >Are there ESC-Codes or how can it be done?
>
> What does the program at the other end expect?

I want to disable ports at the switch, using a script. Though there is only
a menu-based interface I have to tell the telnet server the down key was
pressed to select the right port.

> This doesn't seem to be a Perl issue at all, does it?

Well... I use Perl (net::telnet) to communicate with the server.
And I don't think there is a
comp.telnet.whichcodedoihavetosendtotellthedownarrowwaspressed newsgroup.
A simple link to a Webpage with a list of all codes would be enough.
Perhabs somebody experienced the same problem and can help me.

> [off topic]
>
> Even so, you might want to look at snoop(1) or its equivalent on your
> client machine.  That would enable you to "see" what is being sent to
> the server when you type it on the client.

Currently I'm using a Win2k machine. I don't think it is available here.

> Garry Williams
         Stefan Bach




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

Date: Wed, 31 Jan 2001 15:36:31 GMT
From: scottpa@my-deja.com
Subject: Re: Newbie Problem with setting environment variables and hashes
Message-Id: <959bdt$f78$1@nnrp1.deja.com>


>
>     I expected to see something like
>
>     $ENV{SSDIR} = "\\\\GCHE1
\\DEVLPMNT\\SourceSafeDatabases\\Renaissance
> Apps";
>
Thanks for that. This works. I had copied the path from an attempt
using system().


> > D:\MyDocuments\perl>perl x
> > Can't use subscript on hash deref at x line 1, near "{SSDIR}"
> > (Did you mean $ or @ instead of %?)
>
>     and did you follow this hint?
>
I copied the syntax from a previous post and it had %ENV and in the
absence of more information, I assumed that it was right.

Thankyou for your help.

Regards,
Alan


Sent via Deja.com
http://www.deja.com/


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

Date: 31 Jan 2001 18:00:34 +0000
From: nobull@mail.com
Subject: Re: Newbie Problem with setting environment variables and hashes
Message-Id: <u9zog7ob3x.fsf@wcl-l.bham.ac.uk>

scottpa@my-deja.com writes:

> Subject: Newbie Problem with setting environment variables and hashes

Omit the words "Newbie Problem" - they only serve to antagonise us.

Always distill your problem to purest essense before posting.

Since your problem applies to the hash %ENV but also equally to all
other hashes there is no point mentioning "environment variables"
since they not clearly part of the essense of the problem.

> Can't use subscript on hash deref at x line 1, near "{SSDIR}"
> (Did you mean $ or @ instead of %?)

Well _did_ you?  (Hint: yes you did).

Further information on what errors mean and the likely fixes are to be
found in perldiag.  In this case the error message itself already
contains a correct guess at what you've done wrong.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 31 Jan 2001 16:54:10 GMT
From: allandclarke@my-deja.com
Subject: open(), quoting, and Win32 woes
Message-Id: <959fvc$jqf$1@nnrp1.deja.com>

I have looked at about 1000 news messages, looked in FAQs,
and in the Perl docs. For my purposes, I'm assuming that
`` and open() are equivalent, as I don't see any difference
for what I'm doing.

I'm stuck. This seems like it should be such an easy thing
to do:

I have a perl program that needs to do this:

my $results = `"/path/myprog.exe" "/otherpath/arg1"`;

I naively put quotes around both items because the
path components may contain spaces. As written, I can
get it to work if either but NOT BOTH of them are
quoted.

If I run the command as is, I get the "this is not a
known command, batch file, ..." error message.

Please advise me before I pull the rest of my hair out.


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 10:14:00 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: printf and leading zeros
Message-Id: <3A7839C8.3BA06B4C@rac.ray.com>

John Lin wrote:
> 
> "Russ Jones" wrote
> > I have a number that looks like this:
> > $num = 0.33;
> > and I want to print it as
> > .33
> 
> > Never mind, I think I've found an answer.
> 

Well, it looks to me like you can't do it with printf. The Camel and
the man page for the C printf function both look like you get that
zero whether you want it or not. You have to strip it with something
else. It makes some kind of sense to me, I guess, because 0.33
intuitively looks more like a number than .33 does.



---
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Cacatne ursus in sylvis? - Ovid


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

Date: Wed, 31 Jan 2001 19:01:12 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: printf and leading zeros
Message-Id: <t7go7oms60ui6e@corp.supernews.com>

Russ Jones <russ_jones@rac.ray.com> wrote:
> Russ Jones wrote:
>> 
>> I have a number that looks like this:
>> 
>>         $num = 0.33;
>> 

> Never mind, I think I've found an answer.

Does your answer look anything like this?


#################################################
my $number = 0.33;
my $number_like_string = sprintf("%s", $number);
$number_like_string =~ s/0(?=\.)//;
print "$number_like_string\n";
#################################################


If you don't like the side effects of printing as a number,
then don't.

Chris

-- 
Christopher E. Stith

Try not. Do, or do not. The Force is binary. -- Yoda,
The Empire Strikes Back (paraphrased)



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

Date: Wed, 31 Jan 2001 08:57:13 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: printing array of hashes
Message-Id: <3A7827C9.C633E377@home.com>

B McDonald wrote:
> 
> "Peter Sundstrom" <peter.sundstrom@eds.com> wrote:
>>
>> "Jürgen Exner" <juex@deja.com> wrote:
>>>
>>> By its very definition a hash does not have an order (well, there 
>>> is an implementation-defined order but that is pretty much useless 
>>> for all practical purposes).

Furthermore, it could change without notice in future versions of Perl.

>>> Therefore it cannot preserve any order.
>>>
>>> If you want an order, then you must use an array (or pointer 
>>> lists or whatever).
>>
>> You can use the Tie::IxHash
>> http://search.cpan.org/search?mode=module&query=IXhash
>>
> 
> Thank you for the tip, Peter. This might be a naive question, but 
> what is the computational penalty of using such a module? I am 
> wondering if it is too expensive for my application.

It's significant -- observe:

#!/usr/local/bin/perl5 -w
use strict;
use Benchmark;
use Tie::IxHash;

my @keys = 'A' .. 'Z';
my (%hash, %tiedhash);

tie %tiedhash, 'Tie::IxHash';

timethese(10000, {
    'No_Tie'   => \&No_Tie,
    'With_Tie' => \&With_Tie,
    }
);

sub No_Tie {
    foreach (@keys) {
        $hash{$_} = $_;
    }

    foreach (keys %hash) {
        $hash{$_}++;
    }
}

sub With_Tie {
    foreach (@keys) {
        $tiedhash{$_} = $_;
    }
    
    foreach (keys %tiedhash) {
        $tiedhash{$_}++;
    }
}

__END__

Benchmark: timing 10000 iterations of No_Tie, With_Tie...
    No_Tie:  1 wallclock secs ( 0.72 usr +  0.00 sys =  0.72 CPU) @
13869.63/s (n=10000)
  With_Tie: 17 wallclock secs (17.00 usr +  0.00 sys = 17.00 CPU) @
588.10/s (n=10000)

Whether or not the performance hit is too big is up to you to decide. 
If you can get the order you want by sorting your keys, do it that way.
It will be much faster. Tie::IxHash is what you use when you *must*
maintain the insertion order.

-mjc


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

Date: 31 Jan 2001 10:00:42 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: qr and backreferences
Message-Id: <m3zog7936t.fsf@mumonkan.sunstarsys.com>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:

> I was shocked! How could Abigail <abigail@foad.org>
> say such a terrible thing:
> >That's not fixing the problem, it just avoids it in a specific case.
> >It won't work for instance for:
> >
> >    /$repeat$repeat/;
> >
> >which matches 'aaba' and not aabb.
> >
> >I strongly suggest that the original poster uses perlbug to report this.
> 
> I disagree. I think the current behaviour is correct (but then I'm
> weird). Someone suggested a solution that does the correct thing using
> the postponed regular subexpression thing in 5.6 which I like better.
> Maybe the problem is that the backreferences count up from the start of
> the pattern match but that sometimes you might like a way to count
> backwards and say "give me the n'th previous matched backref"?

I guess you're referring to the (??{$+}) thing I posted?  It was 
meant as a workaround, since it's only applicable for referencing
the last matched "bracket". If the qr regexp is more complicated,
this "fix" would prove to be a real mess.

Personally I believe it's a bug, since backreferences are meaningful 
to qr.  The first fix I tried was qr/(.)\2/, which gave
the compiler error:

        /(.)\2/: reference to nonexistent group at ./try.pl line 5.

It seems to me that's indicative of a problem somewhere.  Either
the compiler errors are dropped, and backreferences in qr become
meaningless until they're "bound", or else backreferences should
work as OP would like.  IMHO, they should work like OP suggests:
IMHO qr/(.)\1/ should match repeating characters within any larger
regexp.

Either way, I think he should report it.

-- 
Joe Schaefer


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

Date: Wed, 31 Jan 2001 18:27:10 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: qr and backreferences
Message-Id: <x7k87bshky.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@foad.org> writes:

  A> Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote on MMDCCX September MCMXCIII
  A> in <URL:news:slrn97fm0t.747.tjla@thislove.dyndns.org>:

  A> %% I disagree. I think the current behaviour is correct (but then I'm
  A> %% weird). Someone suggested a solution that does the correct thing using
  A> %% the postponed regular subexpression thing in 5.6 which I like better.
  A> %% Maybe the problem is that the backreferences count up from the start of
  A> %% the pattern match but that sometimes you might like a way to count
  A> %% backwards and say "give me the n'th previous matched backref"?


  A> You mean, as in $qr = /(.)\2/;?

i think he means something like (bogus syntax):

	$qr = /(.)\-1/ ;

the concept is that you are doing a relative count to the wanted
backref. this can work inside the qr or in the larger regex as well.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 31 Jan 2001 16:07:23 GMT
From: k9boy@my-deja.com
Subject: question about sort
Message-Id: <959d7i$h16$1@nnrp1.deja.com>

I intend to have a list with elements like so:

a[0] = {
NAME => "Joe",
AGE => "25"
};

Is it possible to use the perl's sort to sort the list by NAME, AGE,
etc? Meaning, the entire element a[0] is moved to its proper position,
not just a[0]->{NAME}. If it can be done, what would it look like?
Otherwise, I have to write my own quicksort.

While I'm at it, is there a round, ceil, floor function for perl?


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 17:11:58 GMT
From: tigra@sky.deep.ru
Subject: Re: question about sort
Message-Id: <959h0j$knn$1@nnrp1.deja.com>

In article <959d7i$h16$1@nnrp1.deja.com>,
  k9boy@my-deja.com wrote:
> I intend to have a list with elements like so:
>
> a[0] = {
> NAME => "Joe",
> AGE => "25"
> };
>
> Is it possible to use the perl's sort to sort the list by NAME, AGE,
> etc? Meaning, the entire element a[0] is moved to its proper position,
> not just a[0]->{NAME}. If it can be done, what would it look like?
> Otherwise, I have to write my own quicksort.

No need for own quicksorts. Just use:
(@array is your @a, just for clarity)

sort {$array[$a]{'AGE'} <=> $array[$b]{'AGE'}} @array; # Sort @array by
in ascending order
sort {$array[$b]{'AGE'} <=> $array[$b]{'AGE'}} @array; # The same, but
in descending order

sort {$array[$a]{'NAME'} cmp $array[$b]{'NAME'}} @aaray; # by name
alphabetically ascending

> While I'm at it, is there a round, ceil, floor function for perl?

Very frequently all you need is 'int'. If you really want ceil, etc.
then 'use POSIX'.


Sergey
PS. AFAIK all this stuff is well described in "Perl Cookbook".


Sent via Deja.com
http://www.deja.com/


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

Date: 31 Jan 2001 17:51:40 +0000
From: nobull@mail.com
Subject: Re: question about sort
Message-Id: <u93ddzpq37.fsf@wcl-l.bham.ac.uk>

k9boy@my-deja.com writes:

> I intend to have a list with elements like so:
> 
> a[0] = {
> NAME => "Joe",
> AGE => "25"
> };
> 
> Is it possible to use the perl's sort to sort the list by NAME, AGE,
> etc? Meaning, the entire element a[0] is moved to its proper position,
> not just a[0]->{NAME}. If it can be done, what would it look like?

FAQ: "How do I sort an array by (anything)?"

> While I'm at it, is there a round, ceil, floor function for perl?

FAQ: "Does Perl have a round() function?  What about ceil() and
floor()? ..."

Two unrelated questions.  Both from the FAQ.  The second lifted almost
verbatim from the FAQ.

Do I smell a homework exercise?  

If so, then I suspect the purpose of the exercise was to test your
ability to use the documentation.  Were you expressly asked to do this
without reading the FAQ?  If so I suspect your teacher also didn't
want you to come here and ask someone else to read the FAQ to you.  I
think the idea was probably that you should work it out for yourself.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 31 Jan 2001 11:43:00 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: question about sort
Message-Id: <3A784EA4.28BD7BA5@home.com>

k9boy@my-deja.com wrote:
> 
> I intend to have a list with elements like so:
> 
> a[0] = {
> NAME => "Joe",
> AGE => "25"
> };
> 
> Is it possible to use the perl's sort to sort the list by NAME, AGE,
> etc? Meaning, the entire element a[0] is moved to its proper position,
> not just a[0]->{NAME}.

Certainly. Did you miss the FAQ entry "How do I sort an array by
(anything)?" You did check the FAQ before posting, didn't you?

BTW: please use proper syntax. It's '$a[0]' not 'a[0]'.

> If it can be done, what would it look like?

@a = sort {$a->{NAME} cmp $b->{NAME} ||
           $a->{AGE}  <=> $b->{AGE}    } @a;

> Otherwise, I have to write my own quicksort.

No, just your own sortsub.
 
> While I'm at it, is there a round, ceil, floor function for perl?

Not built-in, but you can easily write your own.

-mjc


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

Date: Wed, 31 Jan 2001 17:55:21 +0000 (GMT)
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Referencing module functions query.
Message-Id: <dkYd6.10$pz3.24886@news.pacbell.net>

In comp.lang.perl.moderated Trevor Phillips <phillips@central.murdoch.edu.au> wrote:
> I'm trying to figure out how to call a subroutine in a Perl module, where the
> name of the routine is arbitary and stored as a string in a scalar.

*completely* arbitrary?

If it were me, I'd keep a hash to map a string to a sub reference.

$routines{suba} = \&suba;
$routines{subb} = \&subb;
$routines{subc} = \&subc;
$routines{subd} = \&subd;

<get string...>
<validate string>
# call sub
$routines{$string}->($x, $y);  # call sub with args $x, $y

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
      < Please move on, ...nothing to see here,  please disperse >


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

Date: Wed, 31 Jan 2001 15:21:44 GMT
From: Costis Vezeridis <vezerid@ac.anatolia.edu.gr>
Subject: RegExp: Find anything except...
Message-Id: <959aht$e80$1@nnrp1.deja.com>

In a processing stage of a tagged text file I use two types of tags.
The first type is like <something>. The second is like %somethingelse%.
Most of the time, a RE like:
if (m/>[^<]*?</)
will safely detect patterns that are between tags of the first type.
Can I have a single RE that does the following:
"Find anything from the last % or >, until the next % or <, making sure
there is no % or < in between".
I need this because the ? for the non-greedy search does not always
seem to work reliably.

--
Costis Vezeridis


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 16:00:58 GMT
From: unformat <unformat@my-deja.com>
Subject: Script to Retrieve UK TV listings.
Message-Id: <959crj$giu$1@nnrp1.deja.com>

Comments/improvements(patches rather than suggestions) welcomed. Code follows
sig.

--
unformat@my-deja.com
http://www.bmeworld.com/unformat/  -- tattooed all over!
"Enough love to knock a rhino sideways" - SNUFF

#!perl -w
use strict;
use diagnostics;
use LWP::Simple;
use HTML::TableExtract;

# Some hot handles (not really needed)...
#select((select(STDOUT), $| = 1)[0]);
#select((select(STDERR), $| = 1)[0]);

# The URL components...
my $root='http://www.ananova.com/tv/listings';
my @allregions; # <-- other available regions - see below.
my $region='central'; # <-- My TV region.
my @allchannels; # <-- other available channels - see below.
# My chosen channels...
my @channels= qw/ bbc1mid bbc2mid central ch4 ch5/;

# Print a header...
print "<HTML><HEAD><TITLE>TV listings</TITLE></HEAD>\n<BODY>\n";


foreach my $daynum (1..7) {
   # Container table for the day...
   print "<TABLE>\n";
   print "<TR><TD><H1>Day $daynum.</H1></TD></TR>\n";

   # Start row for the channels...
   print "<TR>\n";

	foreach my $channel (@channels) {

      # Form URL...
      my $url = sprintf '%s/%s/day%d/%s.html',
         $root, $region, $daynum, $channel;

      # Get data from URL...
      my $content;
      unless (defined ($content = get $url)) {
          warn "could not get $url\n";
          next;
      }

      # Parse received data...
      my $te = new HTML::TableExtract(depth => 2, count => 2 );
      $te->parse($content);

      # Pull out table of interest and write channel into data...
      print "<TD VALIGN=TOP><TABLE BORDER=3>\n";

      foreach my $ts ($te->table_states) {
         my $coord = join(',', $ts->coords);
         next unless $coord =~ /2,2/; #<-- this is the tablestate we want.
         # print "OK: TV Listings found at $coord.\n";
         foreach my $row ($ts->rows) {
            my( $time, $prog ) = @$row;
            # Trim off leading and trailing whitespace...
            $time =~ s/^\s+//;
            $time =~ s/\s+$//;

            $prog =~ s/^\s+//;
            $prog =~ s/\s+$//;
            $prog =~ s/\n+/\n/g; #<-- Remove multi newlines.
            print "<TR><TD><B>$time</B><BR>\n$prog\n</TD></TR>\n";
         }
      }

      # Close channel table & data...
      print "</TABLE></TD>\n";


   }

   # End row for all channels in this day...
   print "</TR>\n";

   # End table for this day...
   print "</TABLE>\n";

}
# End listing...
print "</BODY></HTML>\n";

__END__

NB: for other channels/regions...

sub otherchoices
{
@allregions = qw/
anglia
border
carlton
central
channel
grampian
granada
htvwales
htvwest
meridian
scottish
tyne
ulster
westcountry
ytv
/;

@allchannels = qw/
bbc1mid
bbc2mid
central
ch4
ch5
radio1
radio2
radio3
radio4
radio5mw
worldsvc
atlantic252
classicfm
talkradiouk
virgin
computer
adult
animalplanet
asianet
bbcchoice
bbcchoiceirish
bbcchoicescot
bbcchoicewales
bbcknowledge
bbcnews24
bbcparliament
bbcprime
bbcworld
bloomberg
box
bravo
cnbc
cnn
carltoncinema
carltonfood
cartoon
family_channel
christian
discovery
discoverycivilisations
tlc
discoverykids
discoveryplus1
discoveryscitrek
discoverytravel
discoverywings
disney
e4
sky_eurosport
britisheurosport
fantasy
filmfour
fox
foxplus1
granada_breezeondigital
granada_men
granada_menondigital
granada_plus
granada_plusondigital
history
itv2
landscape
ukliving
m2
mtv
mtvbase
mtvextra
mutv
musicchoiceblues
musicchoiceclassical
musicchoicecountry
musicchoicedance
musicchoiceeasy
musicchoicegold
musicchoicehits
musicchoicejazz
musicchoicelove
musicchoicerock
nationalgeographic
nickelodeon
nickelodeonjr
nickelodeonreplay
paramount
performance
playboy
qvc
racing
s2
scificable
scifidigital
scifisat
shop
sky_boxofficedigital
sky_moviesgolddigital
sky_movies
sky_moviemaxondigital
sky_moviemax2
sky_moviemax3
sky_moviemax4
sky_moviemax5
sky_news
sky_channel
sky_oneondigital
bsb_movie
sky_premierondigital
sky_premierwidescreen
sky_premier2
sky_premier3
sky_premier4
sky_sportsnews
bsb_sports
sky_sports2
sky_sports3
sonytv
tara
tcm
tnt
traveldigital
trouble
tvtravelshop
udirect
ukarena
ukgold
ukgoldclassics
ukhorizons
ukplay
ukstyle
vh1
vh1classic
tvasia
/;
}


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 16:44:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: secure server
Message-Id: <t7gg7dm066p27e@corp.supernews.com>

ibjdt@my-deja.com wrote:
> i have a perl script which i run from a secure server.  this script
> needs to access a flatfile database (plain .txt file) which resides on
> the non-secure server.  i only need to read the file and post
> information from it, but i have been unable to make this happen.  is
> this legal??

Is the flat text file HTTP accessible?

> i have tried using the direct path, the url, you name it i feel i have
> tried it.  any other suggestions would be greatly appreciated.

You could FTP the file over (or rsync it over for better speed) via a
scheduled task (using cron or at or whatever your platform has).

> also, i can't simply move the txt file to the secure server because it
> is needed on the non-secure server by other scripts. this would create
> the same problem in the other direction.

FTP and rsync don't remove a file from the machine it is downloaded from -
at least not by downloading it (FTP can delete a file with a different
command and rsync can optionally delete files).

I have a couple of scripts that use data copied via rsync in a cron job.
It works rather well.

Chris

-- 
Christopher E. Stith

Parking for people we like only. All other vehicles will be vandalized.



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

Date: 31 Jan 2001 17:37:01 +0000
From: nobull@mail.com
Subject: Re: Securely tarring a directory on the web server
Message-Id: <u98znrpqrm.fsf@wcl-l.bham.ac.uk>

"Alexander Farber (EED)" <eedalf@eed.ericsson.se> writes:

>   system ("tar cfh - -C $TEMPDIR $short | gzip -c > $TEMPDIR/$short.tar.gz") and die $!
> 
> I am however concerned about the tmpfile attack (sp?) - if 
> someone would create a soft link from some system file to 
> the (to be created) tarball $TEMPDIR/$short.tar.gz - after 
> I create the temporary dir but before I call the tar command. 
> 
> Are my concerns reasonable

Yes, but not really Perl related.

> and how would you handle it?

Tell your shell that > redirection must create a new file.

system ("set -C; tar cfh - -C $TEMPDIR $short | gzip -c > $TEMPDIR/$short.tar.gz") and die $!

Note: I not sure if all POSIX compliant shells necessarily support
this.  For details go ask in a Unix group.

Alternatively open the file 0_EXCL in and perform the redirection in
Perl rather than Shell.

Note: not all operating systems O_EXCL and broken symlinks correctly.
For details go ask in a Unix group.	

use Fcntl;
open(SAVE_STDOUT,">&STDOUT") or die $!;
sysopen(STDOUT,"$TEMPDIR/$short.tar.gz",O_WRONLY|O_CREAT|O_EXCL) or die $!;
system ("tar cfh - -C $TEMPDIR $short | gzip -c") and die $!;
open(STDOUT,">&SAVE_STDOUT") or die $!;

You may also want to look into the Perl modules that implement tar and
gzip.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 31 Jan 2001 07:44:49 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: Sorting in NT like in Unix
Message-Id: <iwVd6.7778$Uo2.31113@newsfeed.slurp.net>


<donz30@my-deja.com> wrote in message news:958ksh$t5q$1@nnrp1.deja.com...
> Could somebody help me?
> I need to find a way to sort in NT like in Unix environment.
>
> The command line that i need to let work in NT is:
> sort -k 4

the cygwin distro includes the port of sort, or you could port it yourself.





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

Date: Wed, 31 Jan 2001 14:47:54 GMT
From: mike_solomon@lineone.net
Subject: sorting IP addresses
Message-Id: <9598im$cdh$1@nnrp1.deja.com>

I have written a script to sort a list of IP addresses that I take
from an Access database.

It is working properly but I wandered if there was any way I could
simplify it.

I include here the relevant code

I am using strict and have predeclared the variables.

#run sql
$cO->Sql("SELECT ipaddress FROM ip_address");

# Fetch the next rowset
while($cO->FetchRow()){
	undef %Data;
   my %Data = $cO->DataHash();

#split ip address
	($ip1,$ip2,$ip3,$ip4) = split(/\./,$Data{ipaddress});

	$ips = ($ip1*10000) + ($ip2 * 1000) + ($ip3 + 100) + $ip4 ;

	$new{$ips} = $Data{ipaddress};
}

foreach (sort keys %new) {
		print"$new{$_}\n";
};


Any suggestions will be gratefully received

Thanks

Regards

Mike Solomon


Sent via Deja.com
http://www.deja.com/


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

Date: 31 Jan 2001 16:47:36 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Turn off Content
Message-Id: <20010131114736.18894.00000008@ng-ca1.aol.com>

In my perl scripts I sometimes use content html to print something to screen.
The problem is, when I return to my script this causes errors.  I turn it on by
print "Content-type: text/html\n\n";

There has to be a way to turn it off. How do I counter this action, or change
content type back so my perl script will run. i.e., if I take the content tag
out, it works perfectly. can anyone help me with this?


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

Date: Wed, 31 Jan 2001 17:23:32 GMT
From: tigra@sky.deep.ru
Subject: Re: Turn off Content
Message-Id: <959hm6$lhu$1@nnrp1.deja.com>

In article <20010131114736.18894.00000008@ng-ca1.aol.com>,
  jimtaylor5@aol.com (Jimtaylor5) wrote:
> In my perl scripts I sometimes use content html to print something to
screen.
> The problem is, when I return to my script this causes errors.  I turn
it on by
> print "Content-type: text/html\n\n";
>
> There has to be a way to turn it off. How do I counter this action, or
change
> content type back so my perl script will run. i.e., if I take the
content tag
> out, it works perfectly. can anyone help me with this?
>

Unprint, huh? No way to turn off the stuff you've printed. Consider your
CGI script is writing to a file (or more precise - to a stream). So you
should decide what to print and only then print. Try using a global like
$content_type. Set it to whatever you wish as many times as you wish. At
the end of calculations just print "Content-type: $content_type\n\n";

If you want to handle a situation where content type shouldn't be
printed at all use this:
print "Content-type: $content_type\n\n" if defined $content_type;
But don't forget to undefine $content_type when needed.

Sergey


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 09:17:11 -0600
From: "Steve Yates" <steve@teamITS.com>
Subject: Re: Using global var in subroutine
Message-Id: <t7gb299u2futf9@corp.supernews.com>

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:aFnd6.11$gG5.2848@vic.nntp.telstra.net...
> What message are you getting from $! in the die?  c:/folder//file.txt is
> probably not a valid path (the double slash).

    Yes, and that's the message from the die.  That's the point...that
$userCode has no value in this subroutine for some reason.

Steve




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

Date: Wed, 31 Jan 2001 14:55:57 GMT
From: David Waters <davidwaters@bigfoot.com>
Subject: while loop to print list of tags?
Message-Id: <95991p$csq$1@nnrp1.deja.com>

I have the following text which is stored in $arg and I'm trying to
print each tag that occurs.

<appointee>
<cro_number></cro_number>
<appointment_type values='D(Director),C(Company Secretary),PD(Previous
Director),PC(Previous Company secretary),U(Unknown)'></appointment_type>
<name>
	<titles></titles>
	<surname></surname>
</name>
<monitor_ref></monitor_ref>
<disqualification>
	<act></act>
	<exclusion_company>
		<number></number>
		<name></name>
	</exclusion_company>
</disqualification>
</appointee>

while ($arg =~ /<(\w+)(\s*)(values=\'.+\')*>([\S\s]*)<\/\1>/gi) {
  my $tag = $1 ;
  print "$tag\n" ;
}

not all the tags are printed and I think it's going wrong when <name>
is encountered as it's matching against the last </name> found when I
want it to match against the first.

Any help?

Thanks

David


Sent via Deja.com
http://www.deja.com/


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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