[19893] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2088 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 7 21:05:41 2001

Date: Wed, 7 Nov 2001 18: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: <1005185107-v10-i2088@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 7 Nov 2001     Volume: 10 Number: 2088

Today's topics:
    Re: can you help? grabbing urls mixed in with other tex (Joe Smith)
        controling modem <rsobieck@netnet.net>
    Re: Help: simple perl question on Windows (Garry Williams)
        Impossible problem to crack? (Remy Sharp)
    Re: Impossible problem to crack? <joe+usenet@sunstarsys.com>
        map question <zak@mighty.co.za>
    Re: map question <wuerz@yahoo.com>
    Re: Opening/creating files <mgjv@tradingpost.com.au>
    Re: Opening/creating files <mbudash@sonic.net>
    Re: Opening/creating files <vze34thh@verizon.net>
    Re: Opening/creating files <vze34thh@verizon.net>
        Oracle DBI Question <turtle*no-spam*@iislands.com>
    Re: Oracle DBI Question (Douglas Wilson)
        Simulating shell wildcards in perl <bernie@fantasyfarm.com>
    Re: Simulating shell wildcards in perl (Joe Smith)
        stripping garbage from head of file <nick.alexander@verizon.net>
    Re: stripping garbage from head of file <konareddy@hotmail.com>
        Sucking in /etc/passwd <XSPAMmagicrob@newsguy.com>
    Re: too late for -T? <Juha.Laiho@iki.fi>
    Re: too late for -T? <nospam_artd@speakeasy.net>
    Re: too late for -T? <mgjv@tradingpost.com.au>
    Re: too late for -T? (Joe Smith)
    Re: URGENT!  Please help me with this! (Tad McClellan)
    Re: URGENT!  Please help me with this! (Tad McClellan)
    Re: URGENT!  Please help me with this! (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 08 Nov 2001 00:54:45 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: can you help? grabbing urls mixed in with other text
Message-Id: <pJkG7.3548$Le.86637@sea-read.news.verio.net>

In article <3be91551.2096578@news.freeserve.co.uk>,
Phil <phil@no-6.co.uk> wrote:
>Hi,
>
>I am fairly new to perl and have a text list of many urls mixed in
>with other regular text. Is there a way and can fish out just the urls
>and output the results? I have tried many different flavours if
>regular expressions, but most don't seem to do what I expect them to!

Regular expressions are not the appropriate tool for the job here.
You need a real parser.  The following was adapted from the examples
from the HTML::Parser docs.
	-Joe

#!/usr/bin/perl
  use HTML::Parser ();

# When the <A> tag is seen, define a handler to print out the text that
# follows.  When the </A> tag is seen, remove the text handler.  The
# text handler outputs <A HREF="">text</A> even if the <A> and </A>
# were on different lines in the input file.

  sub start_handler {
    return if shift ne "a";	# Tag name
    my $self = shift;		# Current object
    my $attr = shift;		# hash of attributes
    $self->{HREF} = $attr->{href};
    $self->handler(text => \&text_handler, "self,dtext");
    $self->handler(end  => \&end_handler,  "self,tagname");
  }

  sub text_handler {		# Ordinary text after <A HREF="">
    my ($self,$text) = @_;
    $text =~ s/\s+/ /g;		# Convert newline and tab to a single space
    my $href = $self->{HREF};	# Get saved value from most recent <A HREF="">
    print qq|<A HREF="$href">$text</A>\n|;
    $self->{HREF} = "...";	# In case another text chunk before </A>
  }    

  sub end_handler {
    my $self = shift;
    $self->handler(text => undef) if shift eq "a";
  }

  my $p = HTML::Parser->new(api_version => 3);
  $p->handler( start => \&start_handler, "tagname,self,attr");
  $p->parse_file(shift || die) || die $!;

1;	# End of program
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Wed, 07 Nov 2001 19:49:41 -0600
From: Bob <rsobieck@netnet.net>
Subject: controling modem
Message-Id: <3BE9E4B5.9178C8E4@netnet.net>

I would like to control my modem with a Perl script.  I am not a very
experienced programmer though.  Iam using Active State 5.6.1 for
windows.  I  am attempting to have my PC dial a cell phone and poll
remote data.  I
have down loaded  "Win32-SerialPort-0-19_tar".
I decompressed everything and ran the "Makefile.pl" - all seems well.

Now it blows up on me  when I run "perl test.pl COM2"  (my modem is at
COM2).  I am actually struggling with the command line of DOS again and
can't scroll up to get all the error messages - but the final report is
what I copied on the last complete page - listed below.  I tried
Install.pl to no avail - as expected.   Any advice you could offer a
rookie would be greatly appreciated.


If an existing program is out there I would also be glad to hack it for
my needs.  I would like to dial the same number repetatively, vary the
hold time and time between dialings.

Bob




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

Date: Thu, 08 Nov 2001 01:12:08 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Help: simple perl question on Windows
Message-Id: <slrn9ujmv9.qv.garry@zfw.zvolve.net>

On Wed, 07 Nov 2001 08:50:46 -0800, Jeff Zucker <jeff@vpservices.com>
wrote:

> Garry Williams wrote:
>> On Tue, 06 Nov 2001 21:04:02 -0800, Jeff Zucker <jeff@vpservices.com>
>> wrote:
>> > and/or look at the Windows section of the ActivePerl docs and
>> > some of the past postings on clpm re file globbing and redirection
>> > issues on windoze.
>> 
>> Yes and that will reveal the widely-known lameness of the Windows
>> shell.
> 
> That's exactly the attitude I object to -- Windows shell is lame so
> don't bother finding out how to use it.

The shell in question *cannot* accomplish what the OP wants to
accomplish.  Finding out how to use it won't change that.  

-- 
Garry Williams


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

Date: 7 Nov 2001 15:34:03 -0800
From: remy.sharp@gallio.com (Remy Sharp)
Subject: Impossible problem to crack?
Message-Id: <84e76a18.0111071534.68bc9d3@posting.google.com>

Hi,

Environment info:
Perl 5.005_03 built for i386-linux 
Red Hat Linux release 6.2 (Zoot) 
Kernel 2.2.16-RAID on an i686.
Apache/1.3.12 (Unix)
GATEWAY_INTERFACE = CGI-Perl/1.1


Problem:
I have a large collection of shared modules, one in particular that
contains all of web site configuration values (particular to each
site).

The module looks like the following (more to follow below):

******************************************************

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

package Shared::ServerConfig;
use Exporter;
require AutoLoader;
@ISA = qw(Exporter AutoLoader);
@EXPORT = qw($cgibindir $serverroot $site_config $debug &get_servers);
@EXPORT_OK = qw(&get_site_var);

# used to get current working directory
use Cwd;

# automatically export these two variables
$cgibindir = "";
$serverroot = "";
$sitedir = "";
get_site_config();

sub get_site_config
{

    # check to see what type of variable contains the full path to our
file
    if (-f $ENV{'SCRIPT_FILENAME'})
    {
        $serverroot = $ENV{'SCRIPT_FILENAME'};
    }
    elsif (-e "/$0")
    {
        $serverroot = "$0";
    }
    elsif (-e (getcwd() . "/$0"))
    {
        # getcwd - returns to current working directory without the
        # trailing slash (/)
        $serverroot = (getcwd() . "/$0");
    }

    #######  and so on, asigning all of the variables from the
environment
}

******************************************************

However, when I create two test.cgi files in different directories and
hence, web sites, and I do:

use Shared::ServerConfig;

The $serverroot variable has not been initialised in both cases. 
Although in some other non-related places this they variables have the
correct values.

I'm sure this has something to do with the fact I am expecting the
module to execute when it is being loaded into the perl process, but
using mod_perl and having a start up script, I suspect that this is
preloaded in memory, and is overlooked.

I have also tried putting a 'warn' in the middle of this script, and I
can refresh the page that uses this module and the warn does not
appear in the apache error log.

This is very frustrating and I would be grateful for any imaginative
ideas.

Thanks in advance,

Remy.


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

Date: 07 Nov 2001 18:57:17 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Impossible problem to crack?
Message-Id: <m3lmhinnhe.fsf@mumonkan.sunstarsys.com>

remy.sharp@gallio.com (Remy Sharp) writes:

> sub get_site_config
> {

[...]

>     #######  and so on, asigning all of the variables from the
> environment
> }

[...]

> However, when I create two test.cgi files in different directories 
> and hence, web sites, and I do:
> 
> use Shared::ServerConfig;
> 
> The $serverroot variable has not been initialised in both cases. 

You might try adding a custom import() sub to Shared::ServerConfig; 
something like (untested)

  sub import {
    get_site_config();
    Shared::ServerConfig -> export_to_level(1, @_);
  }

See the manpage for Exporter for more details on how to do this.
Otherwise I think you must call get_site_config() in your scripts,
not in the module itself.

HTH
-- 
sub TIESCALAR {bless \$_[1]} sub STORE {${$_[0]}=$_[1]}$,=" ";$\=$/;$#Just=1;
tie $left,'main',-4; sub FETCH{${$_[0]}<0?${$_[0]}:$#[${$_[0]}++%4]}$Just[0]=
sub{$left,"\l$#[-++$_[0]]",$left&&$left.","}; @#=qw/Just Another Perl hacker/
;print ++$left, @{++$left} [$left++] -> ($left++)        # some words on play



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

Date: Thu, 08 Nov 2001 03:35:35 +0200
From: "Zak McGregor" <zak@mighty.co.za>
Subject: map question
Message-Id: <20011108.033531.1067854538.3319@mighty.co.za>

Greetings all



Please could someone tell  me what am I missing here?

This statement:

@array=map { reverse($_)."" } reverse split(/\./, reverse($filename), 2) ;

does exactly what I expect, but this one:

@array=map { reverse($_) } reverse split(/\./, reverse($filename), 2) ;

doesn't. By "exactly what I expect", the elements returned from the first
example are in fact reversed, while the elements returned from the secon
are not.

If used in a loop through ('abcd.efg.xyz.x','123.jpg','axdfg.1.jpg') (for
example) gives
the following for the second example:

abcd.efg.xyz.x: zyx.gfe.dcba, x
123.jpg: 321, gpj
axdfg.1.jpg: 1.gfdxa, gpj

and this for the first:

abcd.efg.xyz.x: abcd.efg.xyz, x
123.jpg: 123, jpg
axdfg.1.jpg: axdfg.1, jpg

Why would oncatenating an empty string to the reverse($_) command change
anything?

Thanks

Cheers

Zak


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

Date: 07 Nov 2001 20:51:36 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: map question
Message-Id: <m34ro6av2v.fsf@DCCMBX01.njitdm.campus.njit.edu>

"Zak McGregor" <zak@mighty.co.za> writes:

> This statement:
> 
> @array=map { reverse($_)."" } reverse split(/\./, reverse($filename), 2) ;
> 
> does exactly what I expect, but this one:
> 
> @array=map { reverse($_) } reverse split(/\./, reverse($filename), 2) ;
> 
> doesn't. By "exactly what I expect", the elements returned from the first
> example are in fact reversed, while the elements returned from the secon
> are not.

> Why would oncatenating an empty string to the reverse($_) command change
> anything?

It changes context. Appending "" has the same effect as:

@array=map { scalar reverse($_) } reverse split(/\./, reverse($filename), 2) ;

In list context, reverse returns the arguments in reverse order:

~ $ perl -wle '$,=$"; print reverse qw/one two three/'
three two one

In scalar context, it returns the reversed scalars that you expected.

-- 
$_="\n,rekcah egnufeB rehtona tsuJ";#v1<?>g\:pv-<5<
s s\S+(?:B)sunpack'u',q q$;')E4qsee;#>60#^<(v!<)g6<
print scalar reverse,$@ unless m,[+;#]55,;m:_,:#^1<


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

Date: Thu, 08 Nov 2001 00:40:29 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Opening/creating files
Message-Id: <slrn9ujl4c.1on.mgjv@verbruggen.comdyn.com.au>

On Wed, 07 Nov 2001 22:02:50 GMT,
	Michael Budash <mbudash@sonic.net> wrote:
> In article <slrn9ujb1p.1on.mgjv@verbruggen.comdyn.com.au>, 
> mgjv@tradingpost.com.au wrote:
> 
>> On Wed, 07 Nov 2001 18:10:39 GMT,
>> 	Tad McClellan <tadmc@augustmail.com> wrote:
>> > G Harper <g.vox@verizon.net> wrote:
>> > 
>> >>How can I open a file to read from, without truncating it, and creating 
>> >>it
>> >>if necessary?
>> > 
>> > 
>> > What would be the point of creating an empty file to read from?
>> > 
>> > You're not going to read much from an empty file.
>> > 
>> > Anyway (untested):
>> > 
>> >    unless ( -e $file ) {  # doesn't exist, need to create it...
>> >       open FILE, ">$file" or die "could not create '$file' $!";
>> >    }
>> >    open FILE, $file or die "could not open '$file' for reading  $!";
>> 
>> Which maybe needs the warning that this contains a race condition, if
>> multiple processes could be doing this same thing.
>> 
>> I'd rather like to see some more explanation on the why of this before
>> commetning any further.
> 
> good point. i think i would've gone this route:

I actually cancelled the post you're replying to[1], since I was wrong.
The OP states that they only want to _read_ from the file in question.
Even if multiple processes create and clobber the file, nothing will
go wrong, since it will never be anything else but an empty file.

If, however, there is another process that creates the file, then
there is a race condition. The OP never mentioned this. If the OP
states a bit more clearly what is to be achieved, maybe we can give
better advice :)

> open FILE, "+>>$file"
> 
> and then repositioned the file cursor using seek...

But that would leave the file in a writeable state.

Martien

[1] Pity large numbers of Usenet servers don't honour cancels anymore
-- 
                                | 
Martien Verbruggen              | 
Trading Post Australia Pty Ltd  | Curiouser and curiouser, said Alice.
                                | 


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

Date: Thu, 08 Nov 2001 01:44:18 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Opening/creating files
Message-Id: <mbudash-2D8733.17442107112001@news.sonic.net>

In article <slrn9ujl4c.1on.mgjv@verbruggen.comdyn.com.au>, 
mgjv@tradingpost.com.au wrote:

> On Wed, 07 Nov 2001 22:02:50 GMT,
> 	Michael Budash <mbudash@sonic.net> wrote:
> > In article <slrn9ujb1p.1on.mgjv@verbruggen.comdyn.com.au>, 
> > mgjv@tradingpost.com.au wrote:
> > 
> >> On Wed, 07 Nov 2001 18:10:39 GMT,
> >> 	Tad McClellan <tadmc@augustmail.com> wrote:
> >> > G Harper <g.vox@verizon.net> wrote:
> >> > 
> >> >> How can I open a file to read from, without truncating it, and 
> >> >> creating it if necessary?
> >> > 
> >> > What would be the point of creating an empty file to read from?
> >> > 
> >> > You're not going to read much from an empty file.
> >> > 
> >> > Anyway (untested):
> >> > 
> >> >    unless ( -e $file ) {  # doesn't exist, need to create it...
> >> >       open FILE, ">$file" or die "could not create '$file' $!";
> >> >    }
> >> >    open FILE, $file or die "could not open '$file' for reading  $!";
> >> 
> >> Which maybe needs the warning that this contains a race condition, if
> >> multiple processes could be doing this same thing.
> >> 
> >> I'd rather like to see some more explanation on the why of this before
> >> commetning any further.
> > 
> > good point. i think i would've gone this route:
> 
> I actually cancelled the post you're replying to[1], since I was wrong.
> The OP states that they only want to _read_ from the file in question.
> Even if multiple processes create and clobber the file, nothing will
> go wrong, since it will never be anything else but an empty file.
> 
> If, however, there is another process that creates the file, then
> there is a race condition. The OP never mentioned this. If the OP
> states a bit more clearly what is to be achieved, maybe we can give
> better advice :)
> 
> > open FILE, "+>>$file"
> > 
> > and then repositioned the file cursor using seek...
> 
> But that would leave the file in a writeable state.
> 

true. good point.

anyway, as someone asked up front, what would be the point of his 
creating an empty file to read from??
 
strange...
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Thu, 08 Nov 2001 02:00:51 GMT
From: "G Harper" <vze34thh@verizon.net>
Subject: Re: Opening/creating files
Message-Id: <nHlG7.1355$o16.94434@typhoon2.gnilink.net>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
>
> What would be the point of creating an empty file to read from?
>

I guess this could use some clarification...

I'm making a page hit log based on visitor's IP.  If nobody has viewed the
page yet, the IP log .txt file must be created.  The first access to the
file in my program reads its contents.

Now I'm thinking a conditional might be the most efficient way, because I
obviously won't be reading the file if it's not there.  This is something
that I've wondered about before though...

I'll include the whole script below so you can just see what's going on.

Thanks for the advice..


#!c:\perl\bin\perl -w    # Yeah, I know.
### Unique hit counter (by IP)
use Strict;
$| = 1;

my $ip = $ENV{'REMOTE_ADDR'};
my @iplog;
my $exists = 0;
my $hits = 0;

print "Content-type: text/html\n\n";

open (IPLOG, "<iplog.txt") or die "Couldn't open IPLOG: $!";
flock ("iplog.txt", LOCK_EX);
@iplog = <IPLOG>;
flock ("iplog.txt", LOCK_UN);
close(IPLOG);

$hits = $#iplog + 1;

if (grep(m/$ip/, @iplog)) {
 print $hits;
 exit;
} else {
 open (IPLOG, ">>iplog.txt") or die "Couldn't open IPLOG: $!";
 flock ("iplog.txt", LOCK_EX);
 print IPLOG $ip . "\n";
 flock ("iplog.txt", LOCK_UN);
 close(IPLOG);
 $hits++;
 print $hits;
}







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

Date: Thu, 08 Nov 2001 02:01:22 GMT
From: "G Harper" <vze34thh@verizon.net>
Subject: Re: Opening/creating files
Message-Id: <SHlG7.1356$o16.95502@typhoon2.gnilink.net>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
>
> What would be the point of creating an empty file to read from?
>

"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> I actually cancelled the post you're replying to[1], since I was wrong.
> The OP states that they only want to _read_ from the file in question.
> Even if multiple processes create and clobber the file, nothing will
> go wrong, since it will never be anything else but an empty file.
>
> If, however, there is another process that creates the file, then
> there is a race condition. The OP never mentioned this. If the OP
> states a bit more clearly what is to be achieved, maybe we can give
> better advice :)

and others...

Yikes, I've been _trying to post but my news server has been entirely
impossible :(

I guess this could use some clarification...

I'm making a page hit log based on visitor's IP.  If nobody has viewed the
page yet, the IP log .txt file must be created.  The first access to the
file in my program reads its contents.

Now I'm thinking a conditional would be the most efficient way, because I
obviously won't be reading the file if it's not there.  The particular
question is something
that I've wondered about before though...

I'll include the whole script below so you can just see what's going on.

Thanks for the advice..


#!c:\perl\bin\perl -w    # Yeah, I know.
### Unique hit counter (by IP)
use Strict;
$| = 1;

my $ip = $ENV{'REMOTE_ADDR'};
my @iplog;
my $exists = 0;
my $hits = 0;

print "Content-type: text/html\n\n";

open (IPLOG, "<iplog.txt") or die "Couldn't open IPLOG: $!";
flock ("iplog.txt", LOCK_EX);
@iplog = <IPLOG>;
flock ("iplog.txt", LOCK_UN);
close(IPLOG);

$hits = $#iplog + 1;

if (grep(m/$ip/, @iplog)) {
 print $hits;
 exit;
} else {
 open (IPLOG, ">>iplog.txt") or die "Couldn't open IPLOG: $!";
 flock ("iplog.txt", LOCK_EX);
 print IPLOG $ip . "\n";
 flock ("iplog.txt", LOCK_UN);
 close(IPLOG);
 $hits++;
 print $hits;
}







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

Date: Wed, 07 Nov 2001 23:53:06 GMT
From: "Turtle" <turtle*no-spam*@iislands.com>
Subject: Oracle DBI Question
Message-Id: <CPjG7.429167$ME2.49009991@typhoon.kc.rr.com>

Hello Everyone,

I have used Perl and MySQL for years and have been very satisfied with them.
Recently I have been given a large project to build and thought I would load
Oracle up and see how it flies with Perl. I downloaded the Oracle module and
tried to install it but it seems to want Oracle mounted on my local machine.
The configuration for the project required a central server with the
database on it accessed from many remote clients. MySQL handles this with
ease so I thought it would be a no brainier for Oracle.


The question is what else do I need to load to get Oracle to do this. Anyone
worked through this type of situation before? I am using the latest version
of 8i and Perl.

Thanks

Turtle






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

Date: Thu, 08 Nov 2001 00:53:52 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: Oracle DBI Question
Message-Id: <3be9d95f.979222@news>

On Wed, 07 Nov 2001 23:53:06 GMT, "Turtle" <turtle*no-spam*@iislands.com> wrote:

>The configuration for the project required a central server with the
>database on it accessed from many remote clients. MySQL handles this with
>ease so I thought it would be a no brainier for Oracle.
>
>
>The question is what else do I need to load to get Oracle to do this. Anyone
>worked through this type of situation before? I am using the latest version
>of 8i and Perl.

If you want to use DBD::Oracle, you'll need some Oracle client software on the
local machine. If you use DBD::Proxy you won't, but DBD::Oracle would be
preferable I think.

Although setting up the  Oracle client software is OT for perl, I think its
been discussed on the DBI mailing list. Search the archives
at http://dbi.symbolstone.org



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

Date: Wed, 07 Nov 2001 18:29:30 -0500
From: Bernard Cosell <bernie@fantasyfarm.com>
Subject: Simulating shell wildcards in perl
Message-Id: <fmgjut0bkac23k3bem24rn9cp75h93thi6@4ax.com>

I have an odd problem: my app wants to take a wildcard on the command
line that Perl will evaluate [via =~], but it would be very nice if I
could have the pattern *ONLY* implement shell wildcard [=glob]
semantics.  Is there some trick/easy way to do this, or will it take
just a brute-force '\'ing of everything in sight plus changing the *=>
 .*, etc.  Seems like a bit of a mess, so I'd sure be happy to learn
that htere was some slick way to make it happen..   [And no, I really
don't want to mkdir a temp directory, take my list and make files in
the dir with the corresponding names, and then use 'glob' itself,
although it may turn out that that's the easiest way...]

Thanks!
  /Bernie\
-- 
Bernie Cosell                Fantasy Farm Fibers
bernie@fantasyfarm.com       Pearisburg, VA


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

Date: Thu, 08 Nov 2001 01:21:56 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Simulating shell wildcards in perl
Message-Id: <U6lG7.3555$Le.86661@sea-read.news.verio.net>

In article <fmgjut0bkac23k3bem24rn9cp75h93thi6@4ax.com>,
Bernard Cosell  <bernie@fantasyfarm.com> wrote:
>I have an odd problem: my app wants to take a wildcard on the command
>line that Perl will evaluate [via =~],

	use File::Glob ':glob';
	@list = glob('*.[ch]');

		-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Thu, 08 Nov 2001 01:48:06 GMT
From: "nick.alexander" <nick.alexander@verizon.net>
Subject: stripping garbage from head of file
Message-Id: <qvlG7.1250$vM6.79267@typhoon1.gnilink.net>

hi
i'm new to perl, and realize that i don't understand alot.  please help if
you can.

i have a text file that when created will always have a string of garbage at
its head.  i want to strip the garbage from the file.

i have the file open and am reading each line:

open ( FH, $newFile );
while ( <FH> ) {
    # the first line should have some garbage, then the <xml> tag.
    if ( grep { /<datafile>/ } $_ ) {
    . . .

the 'good' part of the file always starts with '<datafile>', so i thought if
i had the line, i could substitute the garbage with an empty string .  but i
can't figure out how to write it . . .

    $_ = s!/<xml>//;   #doesn't seem to work ???

any help?






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

Date: Wed, 7 Nov 2001 18:04:56 -0800
From: "Rangeshwara Reddy Kona" <konareddy@hotmail.com>
Subject: Re: stripping garbage from head of file
Message-Id: <3be9e83e$1@news.cadence.com>

open (FH, $newfile);
open(OUT, $outfile);
while(<FH>) {
# removed any line which is having <datafile> string in it
        if (/<datafile>/) { next; }
        print OUT $_;
}
close FH;
close OUT;
rename($outfile, $newfile);
exit;
"nick.alexander" <nick.alexander@verizon.net> wrote in message
news:qvlG7.1250$vM6.79267@typhoon1.gnilink.net...
> hi
> i'm new to perl, and realize that i don't understand alot.  please help if
> you can.
>
> i have a text file that when created will always have a string of garbage
at
> its head.  i want to strip the garbage from the file.
>
> i have the file open and am reading each line:
>
> open ( FH, $newFile );
> while ( <FH> ) {
>     # the first line should have some garbage, then the <xml> tag.
>     if ( grep { /<datafile>/ } $_ ) {
>     . . .
>
> the 'good' part of the file always starts with '<datafile>', so i thought
if
> i had the line, i could substitute the garbage with an empty string .  but
i
> can't figure out how to write it . . .
>
>     $_ = s!/<xml>//;   #doesn't seem to work ???
>
> any help?
>
>
>
>




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

Date: Wed, 07 Nov 2001 15:42:59 -0700
From: Rob <XSPAMmagicrob@newsguy.com>
Subject: Sucking in /etc/passwd
Message-Id: <pcdjut033ejo8rehtjggc03bs3sem7bi7d@4ax.com>

I've gone back through the past postings and seen plenty of examples
showing how to pull /etc/passwd in a single into a hash with a single
"map" statement, and most look about like my version:
	%pwFile = map { split(/:/, $_, 2) }  (<PW>);

This has the following two problems with my app:
  1) Lines aren't "chomp"ed.
  2) What I'd really like is a HOL (hash of lists)

For now I'm using a loop.  This is actually OK, and if I wasn't so
stubburn I'd leave it there.  This is one of those puzzle type things,
however, and I know I'm not going to be able to leave it alone until
I've figured it out.  

My current loop looks like this:
  for (<PASSWD>)
  {
      chomp($_);
      ($key, @pwInfo) = split(/:/, $_);
      $pwFile{$key} = [ @pwInfo ];
  }

Works, but it seems like there should be an easy way to get the same
thing with a single split.  Ideas?

Thanks,

	Rob
-- 
Rob
(magicrob@newsguy.com)


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

Date: 7 Nov 2001 17:15:15 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: too late for -T?
Message-Id: <9sbq73$b8q$1@ichaos.ichaos-int>

redsquirreldesign@yahoo.com (Dave Hoover) said:
>Nicholas wrote:
>I have received this error when trying to test a script from the
>command line by entering something like:
>
>% perl my_script.cgi
>
>If you have taint mode on, you need to specify that at the command
>line like this:
>
>% perl -T my_script.cgi

Why not just "./my_script.cgi"?
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
         !M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Wed, 7 Nov 2001 13:21:43 -0500
From: "speakeasy" <nospam_artd@speakeasy.net>
Subject: Re: too late for -T?
Message-Id: <tujks4ol92bh63@corp.supernews.com>

It's in IIS,
Go to your IIS web, properties, Home Directory tab, then Configuration,
scroll down to the .pl extension, it should read :
<path>\perl.exe -T "%s" %

the placement of the -T may be off as I'm writing this from memory...

Hope this helps.

"Nicholas R. Markham" <nickmarkham@mailandnews.com> wrote in message
news:9s8uun$uik$1@newsfeeds.rpi.edu...
> I have a Perl CGI (several, in fact) that I want to make more secure using
> taint mode.  The shebang line looks like
>
> #! /usr/bin/perl -T
>
> But when I try to run it, perl says 'Too late for "-T" option at
script.cgi
> line 1.'
> How can the first line of the script be too late?
>
>




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

Date: Thu, 08 Nov 2001 00:43:33 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: too late for -T?
Message-Id: <slrn9ujla5.1on.mgjv@verbruggen.comdyn.com.au>

On 7 Nov 2001 17:15:15 GMT,
	Juha Laiho <Juha.Laiho@iki.fi> wrote:
> redsquirreldesign@yahoo.com (Dave Hoover) said:
>>Nicholas wrote:
>>I have received this error when trying to test a script from the
>>command line by entering something like:
>>
>>% perl my_script.cgi
>>
>>If you have taint mode on, you need to specify that at the command
>>line like this:
>>
>>% perl -T my_script.cgi
> 
> Why not just "./my_script.cgi"?

Because that doesn't work on all platforms. The poster you reply to
may be on one of those platforms.

Martien
-- 
                                | 
Martien Verbruggen              | This matter is best disposed of from
Trading Post Australia Pty Ltd  | a great height, over water.
                                | 


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

Date: Thu, 08 Nov 2001 01:47:13 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: too late for -T?
Message-Id: <BulG7.3560$Le.86664@sea-read.news.verio.net>

In article <9s90mk$lma$1@pheidippides.axion.bt.co.uk>,
Kevin Brownhill <kevinbrownhill@yahoo.com> wrote:
>Have you got a space between !# -and- /usr/bin/perl

That is irrelevant.  The kernel ignores spaces in that position.

I believe the problem is this:

	unix% chmod +x temp.pl
	unix% perl temp.pl
	Too late for "-T" option at temp.pl line 1.
	unix% ./temp.pl
	OK
	unix% perl -T temp.pl
	OK

The solution is to use "./temp.pl" or "$PWD/temp.pl" instead of
manually invoking perl.
	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Wed, 07 Nov 2001 23:47:45 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: URGENT!  Please help me with this!
Message-Id: <slrn9ujef2.gag.tadmc@tadmc26.august.net>

Marianne Sisto <msisto@chat.carleton.ca> wrote:

>Hey thats not very fair, 


How so?


>I have spent hours working on this thing, I've been
>up all night doing it night after night and am getting no little to no from
>my school, 


Whatever trials _you_ have endured do not affect _us_.

How to post is how to post. You don't get to throw the rules
out the door because you have had a hard time.

Being able to disregard the practices that everyone else
follows, *that* would be unfair.



>"Tad McClellan" <tadmc@augustmail.com> wrote in message
>news:slrn9uj2li.fr0.tadmc@tadmc26.august.net...
>> Marianne Sisto <msisto@chat.carleton.ca> wrote:
>> >Hi, I have to get this working because it is for an assignment which is
>due
>> >on Fri!
>>
>>
>>    1) No subject in the Subject


You had a chance to *contribute* to our community, but you demured.
You seemed more interested in getting a good grade than in being
a part of our community.

If your Subject had contained a subject, then the next poor soul
with your problem might have been able to find the answer
(because the Subject would have mentioned what the problem
was about).

Your Subject is useless, as it does not contain a subject.


>>    2) "urgent" is a nonsense term in the context of Usenet


Because it can take hours/days for your post to reach someone,
and more hours/days for the answer to get back to you.

If it was truly urgent, you would probably be already dead
before the answer got to you.

If it was not urgent, then you used it just as a device to
gain attention. People don't like being tricked.


>>    3) and it's a homework problem
>>
>> You sure are testing the limits...


[snip upside-down quoted text including a .sig]


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


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

Date: Wed, 07 Nov 2001 23:47:47 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: URGENT!  Please help me with this!
Message-Id: <slrn9ujf3d.gag.tadmc@tadmc26.august.net>

Marianne Sisto <msisto@chat.carleton.ca> wrote:

>U have no right to say I am not skilled in
>logic for programming, 


You provided the evidence. Uri just commented on it.


>u do not know anything about me


Except that your reasoning is a bit off.


>You are obviously not skilled in the necessary fields of
>having a little patience and understanding when dealing with other people
>and thats a sad way to be.  


Uri has been here for years.

I have been here for years.

You just got here and you know How It Is Supposed To Be?

That is quite presumptuous.


>You obviously have not much going
>on in ur life. 


Golly. You have sure loaded up on the ad hominens.

Now it is looking like you lack intellect as well as logic.

Your followup makes it worse and worse, I suggest you stop.


> I did not post all of my code because I was not asking
>people to look over my entire assignment and like I said I isolated where
>the problem was 


But the problem is, you have *not* isolated where the problem is.

You are comparing to $STU_NUM yet you never showed the code
that put a value into $STU_NUM. There's that "logic thing" again...


>I do not believe I did anything wrong by posting my
>original method.


You no doubt base this on your extensive experience with
what is socially acceptable in this newsgroup?


>( Thank you to
>the person who did infact give me some advice)


You're welcome.


[snip upside-down quoted text including a .sig. Again!]


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


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

Date: Wed, 07 Nov 2001 23:47:48 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: URGENT!  Please help me with this!
Message-Id: <slrn9ujfdq.gag.tadmc@tadmc26.august.net>

Marianne Sisto <msisto@chat.carleton.ca> wrote:

>I wont post here again dont worry.


Thank you.


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


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

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


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