[19678] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1873 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 4 21:05:37 2001

Date: Thu, 4 Oct 2001 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002243910-v10-i1873@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Oct 2001     Volume: 10 Number: 1873

Today's topics:
        Help on 'perl -lne' <maheshasolkar@yahoo.com>
    Re: Help on 'perl -lne' <skuo@mtwhitney.nsc.com>
    Re: Help on 'perl -lne' <maheshasolkar@yahoo.com>
    Re: Help on 'perl -lne' <skuo@mtwhitney.nsc.com>
    Re: Help on 'perl -lne' <maheshasolkar@yahoo.com>
    Re: How to add date stamp to a log file (Venkatesh Babu Sira)
    Re: How to add date stamp to a log file <mbudash@sonic.net>
    Re: HTTP::Request::Common <mbudash@sonic.net>
    Re: mode date from dir <maheshasolkar@yahoo.com>
        Multiplexing strings (Dimitri)
    Re: Multiplexing strings <ronh@iainc.com>
        new to perl (anirban chakraborti)
        Newbie: ASP: JScript -> PerlScript -> JScript by sessio <ReplyVia_contact.asp@URLinSig>
    Re: Newbie: ASP: JScript -> PerlScript -> JScript by se <ReplyVia_contact.asp@URLinSig>
        NT Script, Accessing network drives under scheduler <akennel@rwsc.com>
    Re: pattern matching between range <goldbb2@earthlink.net>
    Re: Perl and Solaris Version Upgrade <tintin@snowy.calculus>
    Re: Perl Guru needed for this extremely frustrating sea <dtweed@acm.org>
    Re: Perl Guru needed for this extremely frustrating sea <mbudash@sonic.net>
    Re: Perl Regex (Abigail)
        robot in perl <adustipujo1@mediaone.net>
    Re: Skipping following lines if the same <tintin@snowy.calculus>
    Re: Something wrong with this? (Martien Verbruggen)
    Re: Whither Palm Perl? (Martien Verbruggen)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 4 Oct 2001 15:51:05 -0700
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Help on 'perl -lne'
Message-Id: <trppqrb94cj52e@corp.supernews.com>

Hi,

I am using a perl command-line in one of my shell scripts for post
processing a log file.

The post processing criteria is, to check if first 30 characters of any line
in the log file contains the word 'error'. If a line matches this criterion
print that line and increment a counter. When this counter hits its maximum,
exit with error status.

This perl command should exit with 0 status only if it finds no trace of
'error' in the log file. Otherwise, it should return the error count (which
would be non-zero).

Currently this is the command I am using:
-------------------
% perl -lne '{if (/^.{0,25}?error/i) {$ec++;exit$ec if ($ec>3);print}}'
temp.log ; echo $status
-------------------
Where temp.log contains:
-------------------
error
error
                                                    error
error
error
        error
              error
error
-------------------

The problem with this is that it returns 0 if the number or 'error's in the
log file are <= 3. Because it never hits the exit statement.

I unsuccessfully tried the use of END{} to overcome this problem.

Ended up using a while(<>){...} loop (not using the -n option) which yields
correct results.

Any help would be most helpful.

Thanks,
M




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

Date: Thu, 4 Oct 2001 16:34:46 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Help on 'perl -lne'
Message-Id: <Pine.GSO.4.21.0110041631520.12796-100000@mtwhitney.nsc.com>

On Thu, 4 Oct 2001, Mahesh A wrote:

> Hi,
> 
> I am using a perl command-line in one of my shell scripts for post
> processing a log file.
> 
> The post processing criteria is, to check if first 30 characters of any line
> in the log file contains the word 'error'. If a line matches this criterion
> print that line and increment a counter. When this counter hits its maximum,
> exit with error status.
> 
> This perl command should exit with 0 status only if it finds no trace of
> 'error' in the log file. Otherwise, it should return the error count (which
> would be non-zero).
> 
> Currently this is the command I am using:
> -------------------
> % perl -lne '{if (/^.{0,25}?error/i) {$ec++;exit$ec if ($ec>3);print}}'
> temp.log ; echo $status
> -------------------
> Where temp.log contains:
> -------------------
> error
> error
>                                                     error
> error
> error
>         error
>               error
> error
> -------------------
> 
> The problem with this is that it returns 0 if the number or 'error's in the
> log file are <= 3. Because it never hits the exit statement.
> 
> I unsuccessfully tried the use of END{} to overcome this problem.
> 
> Ended up using a while(<>){...} loop (not using the -n option) which yields
> correct results.
> 
> Any help would be most helpful.


I think you want to use the "last" operator to exit the loop:

% perl -lne '++$ec if (/^.{0,25}error/); last if ($ec > 3); END { print
$ec}' temp.log

-- 
Cheers,
Steve



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

Date: Thu, 4 Oct 2001 16:49:21 -0700
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Re: Help on 'perl -lne'
Message-Id: <trpt835eg2jpbe@corp.supernews.com>


"Steven Kuo" <skuo@mtwhitney.nsc.com> wrote in message
news:Pine.GSO.4.21.0110041631520.12796-100000@mtwhitney.nsc.com...
> On Thu, 4 Oct 2001, Mahesh A wrote:
>
> > Hi,
> >
> > I am using a perl command-line in one of my shell scripts for post
> > processing a log file.
> >
> > The post processing criteria is, to check if first 30 characters of any
line
> > in the log file contains the word 'error'. If a line matches this
criterion
> > print that line and increment a counter. When this counter hits its
maximum,
> > exit with error status.
> >
> > This perl command should exit with 0 status only if it finds no trace of
> > 'error' in the log file. Otherwise, it should return the error count
(which
> > would be non-zero).
> >
> > Currently this is the command I am using:
> > -------------------
> > % perl -lne '{if (/^.{0,25}?error/i) {$ec++;exit$ec if ($ec>3);print}}'
> > temp.log ; echo $status
> > -------------------
> > Where temp.log contains:
> > -------------------
> > error
> > error
> >                                                     error
> > error
> > error
> >         error
> >               error
> > error
> > -------------------
> >
> > The problem with this is that it returns 0 if the number or 'error's in
the
> > log file are <= 3. Because it never hits the exit statement.
> >
> > I unsuccessfully tried the use of END{} to overcome this problem.
> >
> > Ended up using a while(<>){...} loop (not using the -n option) which
yields
> > correct results.
> >
> > Any help would be most helpful.
>
>
> I think you want to use the "last" operator to exit the loop:
>
> % perl -lne '++$ec if (/^.{0,25}error/); last if ($ec > 3); END { print
> $ec}' temp.log
>
Exactly, but I want the command to set the '$status' shell variable
accordingly. So I do...

% perl -lne '{if (/^.{0,25}?error/i) {$ec++;last if ($ec>3);print}} END
{exit $ec}' temp.log ; echo $status

Which gives me this output
------------
error
         error
 error
Callback called exit, <> chunk 8.
END failed--cleanup aborted, <> chunk 8.
255
------------

The exit status is always 255 (-1)

Thanks,
M





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

Date: Thu, 4 Oct 2001 17:09:57 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Help on 'perl -lne'
Message-Id: <Pine.GSO.4.21.0110041706340.13362-100000@mtwhitney.nsc.com>

On Thu, 4 Oct 2001, Mahesh A wrote:

> "Steven Kuo" <skuo@mtwhitney.nsc.com> wrote in message
> >
> >
> > I think you want to use the "last" operator to exit the loop:
> >
> > % perl -lne '++$ec if (/^.{0,25}error/); last if ($ec > 3); END { print
> > $ec}' temp.log
 
> Exactly, but I want the command to set the '$status' shell variable
> accordingly. So I do...
> 
> % perl -lne '{if (/^.{0,25}?error/i) {$ec++;last if ($ec>3);print}} END
> {exit $ec}' temp.log ; echo $status
> 
> Which gives me this output
> ------------
> error
>          error
>  error
> Callback called exit, <> chunk 8.
> END failed--cleanup aborted, <> chunk 8.
> 255
> ------------
> 
> The exit status is always 255 (-1)


See 
% perldoc -f exit
% perdoc perlmod

Try 

% perl -lne '++$ec if (/^.{0,25}error/); last && exit if ($ec >
3); END { $?= $ec; print $ec}' erf ; echo $status
4
4

-- 
Cheers,
Steve



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

Date: Thu, 4 Oct 2001 17:34:40 -0700
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Re: Help on 'perl -lne'
Message-Id: <trpvt1svpe1cd6@corp.supernews.com>


"Steven Kuo" <skuo@mtwhitney.nsc.com> wrote in message
news:Pine.GSO.4.21.0110041706340.13362-100000@mtwhitney.nsc.com...
> On Thu, 4 Oct 2001, Mahesh A wrote:
>
> > "Steven Kuo" <skuo@mtwhitney.nsc.com> wrote in message
> > >
> > >
> > > I think you want to use the "last" operator to exit the loop:
> > >
> > > % perl -lne '++$ec if (/^.{0,25}error/); last if ($ec > 3); END {
print
> > > $ec}' temp.log
>
> > Exactly, but I want the command to set the '$status' shell variable
> > accordingly. So I do...
> >
> > % perl -lne '{if (/^.{0,25}?error/i) {$ec++;last if ($ec>3);print}} END
> > {exit $ec}' temp.log ; echo $status
> >
> > Which gives me this output
> > ------------
> > error
> >          error
> >  error
> > Callback called exit, <> chunk 8.
> > END failed--cleanup aborted, <> chunk 8.
> > 255
> > ------------
> >
> > The exit status is always 255 (-1)
>
>
> See
> % perldoc -f exit
> % perdoc perlmod
>
> Try
>
> % perl -lne '++$ec if (/^.{0,25}error/); last && exit if ($ec >
> 3); END { $?= $ec; print $ec}' erf ; echo $status
> 4
> 4
>
Excellent.

Thanks,
M




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

Date: 4 Oct 2001 16:22:32 -0700
From: vsira@hotmail.com (Venkatesh Babu Sira)
Subject: Re: How to add date stamp to a log file
Message-Id: <d5b8dfd2.0110041522.4a958ff5@posting.google.com>

Michael Budash <mbudash@sonic.net> wrote in message news:<mbudash-5266EF.12472303102001@news.sonic.net>...
> In article <d5b8dfd2.0110031103.2500563@posting.google.com>, 
> vsira@hotmail.com (Venkatesh Babu Sira) wrote:
> 
> > Michael Budash <mbudash@sonic.net> wrote in message 
> > news:<mbudash-CAB4B9.13105302102001@news.sonic.net>...
> > > In article <d5b8dfd2.0110021136.3c5c31e7@posting.google.com>, 
> > > vsira@hotmail.com (Venkatesh Babu Sira) wrote:
> > > 
> > > > I have code like,
> > > > $LOGFILENAME = "logfile.txt";
> > > > I want to add time stamp like
> > > > $LOGFILENAME = "logfile.txt.$time";
> > > > ex: that it may look like logfile.txt.2oct2001 .
> > > > Tx
> > > > -B
> > > 
> > > this does it with a format you probly _oughta_ use, if you ever wanna 
> > > sort (or view a dir listing of) these files:
> > > 
> > > NOTE: beware of word wrap below!
> > >  
> > > use POSIX;
> > > $LOGFILENAME = 'logfile.txt.' . POSIX::strftime("%Y%m%d", 0, 0, 0, 
> > > (localtime)[3..5]);
> > >  
> > > the above (currently) yields;
> > > 
> > >    logfile.txt.20011002 
> > > 
> > > this version does it exactly as you requested:
> > > 
> > > use POSIX;
> > > my @t = localtime;
> > > $LOGFILENAME = 'logfile.txt.' . $t[3], lc(POSIX::strftime("%b%Y\n", 0, 
> > > 0, 0, @t[3..5]));
> > >  
> > > the above (currently) yields;
> > > 
> > >    logfile.txt.2oct2001 
> > > 
> > > hth-
> > 
> > Tx a lot Michael,second one i had to remove $t[3],other wise it will
> > create logfile.txt.3 .
> > -B
> 
> that actually looks like a typo to me. replace the comma after $t[3] 
> with a space-dot. i.e., should be:
> 
> $LOGFILENAME = 'logfile.txt.' . $t[3] . lc(POSIX::strftime("%b%Y\n", 0, 
> 0, 0, @t[3..5]));
> 
> (tested)
>  
> hth-

Excellent,
It works ,i have one more ? ,
What this means @t[3..5] ,also how can add time stamp to the above 
ex 04oct2001:12:00:00
I am novice to perl :)
Tx in advance
-V


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

Date: Thu, 04 Oct 2001 23:48:47 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: How to add date stamp to a log file
Message-Id: <mbudash-23BBBB.16484704102001@news.sonic.net>

In article <d5b8dfd2.0110041522.4a958ff5@posting.google.com>, 
vsira@hotmail.com (Venkatesh Babu Sira) wrote:

> Michael Budash <mbudash@sonic.net> wrote in message 
> news:<mbudash-5266EF.12472303102001@news.sonic.net>...
> > In article <d5b8dfd2.0110031103.2500563@posting.google.com>, 
> > vsira@hotmail.com (Venkatesh Babu Sira) wrote:
> > 
> > > Michael Budash <mbudash@sonic.net> wrote in message 
> > > news:<mbudash-CAB4B9.13105302102001@news.sonic.net>...
> > > > In article <d5b8dfd2.0110021136.3c5c31e7@posting.google.com>, 
> > > > vsira@hotmail.com (Venkatesh Babu Sira) wrote:
> > > > 
> > > > > I have code like,
> > > > > $LOGFILENAME = "logfile.txt";
> > > > > I want to add time stamp like
> > > > > $LOGFILENAME = "logfile.txt.$time";
> > > > > ex: that it may look like logfile.txt.2oct2001 .
> > > > > Tx
> > > > > -B
> > > > 
> > > > this does it with a format you probly _oughta_ use, if you ever 
> > > > wanna 
> > > > sort (or view a dir listing of) these files:
> > > > 
> > > > NOTE: beware of word wrap below!
> > > >  
> > > > use POSIX;
> > > > $LOGFILENAME = 'logfile.txt.' . POSIX::strftime("%Y%m%d", 0, 0, 0, 
> > > > (localtime)[3..5]);
> > > >  
> > > > the above (currently) yields;
> > > > 
> > > >    logfile.txt.20011002 
> > > > 
> > > > this version does it exactly as you requested:
> > > > 
> > > > use POSIX;
> > > > my @t = localtime;
> > > > $LOGFILENAME = 'logfile.txt.' . $t[3], lc(POSIX::strftime("%b%Y\n", 
> > > > 0, 
> > > > 0, 0, @t[3..5]));
> > > >  
> > > > the above (currently) yields;
> > > > 
> > > >    logfile.txt.2oct2001 
> > > > 
> > > > hth-
> > > 
> > > Tx a lot Michael,second one i had to remove $t[3],other wise it will
> > > create logfile.txt.3 .
> > > -B
> > 
> > that actually looks like a typo to me. replace the comma after $t[3] 
> > with a space-dot. i.e., should be:
> > 
> > $LOGFILENAME = 'logfile.txt.' . $t[3] . lc(POSIX::strftime("%b%Y\n", 0, 
> > 0, 0, @t[3..5]));
> > 
> > (tested)
> >  
> > hth-
> 
> Excellent,
> It works,
 
good
 
>i have one more ? ,
> What this means @t[3..5]
 
it's called an array slice:

http://www.perldoc.com/perl5.6/pod/perldata.html#Slices

> also how can add time stamp to the above 
> ex 04oct2001:12:00:00
> I am novice to perl :)
 
the documentation you need to read is on your unix box:

perldoc POSIX
man strftime
 
> Tx in advance

no prob,
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Thu, 04 Oct 2001 23:37:46 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: HTTP::Request::Common
Message-Id: <mbudash-C2C810.16374704102001@news.sonic.net>

In article <x7ofnn85ti.fsf@home.sysarch.com>, Uri Guttman 
<uri@sysarch.com> wrote:

> >>>>> "MB" == Michael Budash <mbudash@sonic.net> writes:
> 
>   >> If I create my request staticly, like so:
>   >> 
>   >> my $req = POST 'http://somesite', [ var1 => 'x', var2 => 'y' ];
> 
> 
> and that is an anon array of the vars.
> 
>   >> 
>   >> The code works fine and everything is happy.
>   >> 
>   >> If I do the following, however, it does not work:
>   >> 
>   >> my $variables = "var1 => 'x', var2 => 'y'";
> 
> and that is a quoted string. why would you think that could replace the
> array ref used above?
> 
>   >> my $req = POST 'http://somesite', [ $variables ];
> 
>   MB> some quick testing suggests that this will work for you:
> 
>   MB> my $req = POST 'http://somesite', [ eval($variables) ];
> 
> and that solution is silly. why even have the string to eval?
> 
 
yup, it's silly... however, based on the OP's requirements (which you 
did not quote), it still is one solution...

> you should have just assigned the anon array to the var and used it:
> 
> 	my $variables = [ var1 => 'x', var2 => 'y' ];
> 
> 	my $req = POST 'http://somesite', $variables ;
> 
> that is the proper equivilent of the original version.
> 
> uri
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Thu, 4 Oct 2001 16:41:06 -0700
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Re: mode date from dir
Message-Id: <trpsom1lssso74@corp.supernews.com>

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87pu83i3kr.fsf@limey.hpcc.uh.edu...
> >> On Thu, 04 Oct 2001 19:47:38 GMT,
> >> "Jessica Bull" <jessica.bull@broadwing.com> said:
>
> > Maybe you can help me. I am reading in all files in a
> > directory. I want the modified time for each file. What
> > I have below is not returning any value at all. Do you
> > know why that would be or how I could get it to do that?
>
> > while (defined($file = readdir(DIR))) {
> > my $mod = (stat($file))[9];
> > print "$mod\n";
> > }
>
> The entries read from the directory return the *names* of
> the files, not the path to them.  If you want to do
> something to one of these directory entries in its own
> right, you have to construct the appropriate path from the
> directory's location, plus the entry name.
>
> Note also there's no error checking in your stat() call;
> you just try to access the appropriate part of the
> return value regardless.
>
> The File::stat module provides a cleaner and more readable
> interface.

I think so too. But this might help if the requirement is not huge enough to
go for a module:
----------
while (defined($file = readdir(DIR))) {
  my $mod = (stat($file))[9];
  my ($sec,$min,$hr,$day,$mon,$yr,$wd,$yd,$isdt) = localtime($mod);
  print "$file -> $mon/$day/".(1900+$yr)." $hr:$min:$sec\n";
}
----------
I used this in one of my scripts. I am not aware of the caveats related.

regards,
M

>
> hth
> t
> --
> Whoops, I've said too much.  Smithers, use the amnesia ray...




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

Date: 4 Oct 2001 15:46:21 -0700
From: mauroid@csi.forth.gr (Dimitri)
Subject: Multiplexing strings
Message-Id: <a3ebf7b8.0110041446.6f0a9673@posting.google.com>

I have N=3 strings of equal length, and I want to multiplex them by taking
M=2 characters from each string (the length of each string is divisible by
M). Example :

Input:

$str1 = "aabbccddeeff";
$str2 = "AABBCCDDEEFF";
$str3 = "001122334455";

Output :

$out = "aaAA00bbBB11ccCC22ddDD33eeEE44ffFF55";

Besides the obvious for loop :

$out = ""; $len = length($str1);

for ($i = 0; $i < $len; $i += 2) {
 $out .= substr($str1, $i, 2) . substr($str2, $i, 2) . substr($str3, $i, 2);
}

Is there a more elegant (faster) way?

Thanks!
-Dimitri


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

Date: Fri, 05 Oct 2001 00:24:44 GMT
From: "Ron Hartikka" <ronh@iainc.com>
Subject: Re: Multiplexing strings
Message-Id: <g57v7.31767$kH1.271244@typhoon.mw.mediaone.net>

Don't know if this is faster or more elegant.

@str1= split '',$str1;
@str2= split '',$str2;
@str3= split '',$str3;

push @ans,
 shift @str1, shift @str1,
 shift @str2, shift @str2,
 shift @str3, shift @str3
while @str3;

$ans = join'', @ans;



"Dimitri" <mauroid@csi.forth.gr> wrote in message
news:a3ebf7b8.0110041446.6f0a9673@posting.google.com...
> I have N=3 strings of equal length, and I want to multiplex them by taking
> M=2 characters from each string (the length of each string is divisible by
> M). Example :
>
> Input:
>
> $str1 = "aabbccddeeff";
> $str2 = "AABBCCDDEEFF";
> $str3 = "001122334455";
>
> Output :
>
> $out = "aaAA00bbBB11ccCC22ddDD33eeEE44ffFF55";
>
> Besides the obvious for loop :
>
> $out = ""; $len = length($str1);
>
> for ($i = 0; $i < $len; $i += 2) {
>  $out .= substr($str1, $i, 2) . substr($str2, $i, 2) . substr($str3, $i,
2);
> }
>
> Is there a more elegant (faster) way?
>
> Thanks!
> -Dimitri




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

Date: 4 Oct 2001 16:38:34 -0700
From: anirbanchakraborti@hotmail.com (anirban chakraborti)
Subject: new to perl
Message-Id: <c3b9937a.0110041538.6263087b@posting.google.com>

hi guys,
        I am very new to perl.I have some specific needs like i need
to be able to ftp files from server ,store them in a database, make
c/c++ calls ,and use embedded sql .My platform is windows 98.
                                   Please Advice,
                                            Anirban


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

Date: Thu, 4 Oct 2001 23:04:31 +0100
From: "Andrew U" <ReplyVia_contact.asp@URLinSig>
Subject: Newbie: ASP: JScript -> PerlScript -> JScript by session variables in the same page, urgh.
Message-Id: <825v7.6233$jE3.762067@news6-win.server.ntlworld.com>

This is my first attempt at any flavour of Perl at all. Unsurprisingly I'm
also stuck.

I want a variable from a JScript code lump to be used by a PerlScript, the
PerlScript then returns the value to a further lump of JScript. Since I
couldn't fathom a way of sharing variables between the two languages I
decided that Session variables would be a way of getting round this variable
sharing issue. My JScript creates a session variable, the PerlScript reads
it, uses it, creates a new Session variable and then a subsequent block of
JScript reads the new Session variable and does some processing on the data.
OK, here's the problem, the PerlScript isn't retrieving the JScript created
Session variable, but the later JScript does retrieve the PerlScript created
Session variable. Here's the dual-language code:

<%@ LANGUAGE = "JScript" %>
<%
 // Assign data to session variable with JScript
 Session("nslookupIPAddress") = "62.254.64.4";
>%

<SCRIPT LANGUAGE="PerlScript" RUNAT="Server">
 # PerlScript reading the session variable
 # But Session->{'nslookupHostName'} is empty
 $Session->{'nslookupHostName'} = `nslookup
$Session->{"nslookupIPAddress"}`;
</SCRIPT>

<%
 // JScript retrieving the Session variable
 var bob = Session("nslookupHostName");
 // Variable 'bob' correctly equals $Session->{'nslookupHostName'}
%>


My final JScript recieves: "Default Server: ns0.bt.net Address: 194.72.6.51
> "

I would implement the page completely in PerlScript but I'm an absolute
beginner in PerlScript and was just looking for a quick and nasty solution.

Anything blatant that I've missed?
--
Andrew U
o-----------------------
http://www.andrewu.co.uk







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

Date: Thu, 4 Oct 2001 23:37:03 +0100
From: "Andrew U" <ReplyVia_contact.asp@URLinSig>
Subject: Re: Newbie: ASP: JScript -> PerlScript -> JScript by session variables in the same page, urgh.
Message-Id: <Cw5v7.6594$jE3.788646@news6-win.server.ntlworld.com>

BTW, I'm hoping I can win the coveted "Worst fudge of the year" award from
this.
--
Andrew U
o-----------------------
http://www.andrewu.co.uk







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

Date: 4 Oct 2001 15:07:57 -0700
From: Andrew Kennel <akennel@rwsc.com>
Subject: NT Script, Accessing network drives under scheduler
Message-Id: <12233277.0000fde0.030@drn.newsguy.com>

My apologies if this topic has been covered before, but I have been unable to
track down a solution.

I have been working with a script recently that needs to copy files from one NT
server to another on a scheduled basis for backups.  The schedule service on the
server runs under the system account.  I am aware that this can cause problems
with accessing network shares, but thought I had a work-around.

My script made a system call to map the network drive using a specific account. 
The pertinent line is pasted below:
system 'net use w: \\server2\d$ /user:useraccount password';
(Names have been changed to protect the innocent)

The script works fine when run manually on the server.  When run by the
scheduler, it fails.

I would like to keep the schedule service running under the system account if at
all possible.  Is there a way to do this?

Any help would be greatly appreciated.  



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

Date: Thu, 04 Oct 2001 19:29:37 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: pattern matching between range
Message-Id: <3BBCF0E1.780CE06D@earthlink.net>

I'm not sure if this is quite what you want, but:

#!/usr/bin/perl -w
use strict;
my $lastline = '';
MAINLOOP: while( <> ) {
    next if !/S01010101|S33333333/;
    print $lastline;
    /^H/ ? next MAINLOOP : print while( <> );
} continue { $lastline = $_ }

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Fri, 5 Oct 2001 08:26:14 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Perl and Solaris Version Upgrade
Message-Id: <en5v7.3$PC5.51251@news.interact.net.au>


"Abigail" <abigail@foad.org> wrote in message
news:slrn9rpmgu.ano.abigail@alexandra.xs4all.nl...
> Laurent Galster (laurent.galster@swisscom.com) wrote on MMCMLV September
> MCMXCIII in <URL:news:01c14c00$f29cfc50$8d4e310a@u45198>:
> "" Hello,
> "" We need to upgrade our solaris version from 2.5.1 to xx.
> "" The new version number will depend on all other tools that we use.
> ""
> "" Could you please send me a list of compatibilities between Perl
versions
> "" and Solaris versions. e.g.:
> "" Solaris 2.5.1 - Perl 5.005_02
> "" Solaris 2.6 - ??
> "" Solaris 7 - ??
> "" Solaris 8 - ??
> "" Solaris 9 (Beta) - ??
>
>
> The first Solaris version that shipped with Perl was Solaris 8.
> So the list would be:
>
>     Solaris 2.5.1       -  No perl.
>     Solaris 2.6         -  No perl.
>     Solaris 7           -  No perl.
>     Solaris 8           -  5.005.
>     Solaris 9           -  5.6.1.     (AFAIK)

The OP was asking what versions of Perl are *compatible* with the Solaris
version.  That being the case, they all are.




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

Date: Thu, 04 Oct 2001 23:40:55 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Perl Guru needed for this extremely frustrating search and replace  problem.
Message-Id: <3BBCF238.20219C7B@acm.org>

Don't top-post, it's a pain to fix up for follow-ups.

Dan Boyce wrote:
> Michael Budash <mbudash@sonic.net> wrote in message > news:<mbudash-A0C5AE.14215903102001@news.sonic.net>...
> > In article <3fac67fd.0110031258.3cce7cd8@posting.google.com>,
> > dboyce@phoenixcolor.com (Dan Boyce) wrote:
> > > Some how I need to convert the script below to allow me to enter a
> > > directory structure (ie. /home/dan/).  Using a script that I have
> > > found in a book I can replace INSTALL_DIR with strings as long as they
> > > do not contain "/" in them.
> > >
> > > The following is the test script:
> > > #/bin/sh
> > > echo "Replace with: "
> > > read number_two
> > > cp test.conf test.conf.bak
> > > perl -p -i -e s/INSTALL_DIR/$number_two/ test.conf
> > > echo "test.conf"
> > > more test.conf
> > >
> > try this (untested) replacement line in the test script:
> >
> > perl -p -i -e 's{INSTALL_DIR}{$number_two}' test.conf
> 
> Thanks for the help, but still no luck.  I tried your line as is, and
> it just deleted INSTALL_DIR and put nothing in its place.  I tried
> modifying it a bit and again no luck.

You need both a perl guru and a shell guru, I guess.

The problem with your initial attempt was that any '/' in the replacement
string terminated the substitute command prematurely, creating the syntax
error.

Unfortunately, Michael introduced single-quotes around his solution, which
prevented the shell from doing the intended substitution for the replacement
pattern.

The trick is that you need to use some delimiter for the substitution other
than '/', but you need to make sure that the character you use isn't going
to be acted on by the shell.

Try this, using double-quotes and parens instead of single-quotes
and braces:

    perl -p -i -e "s(INSTALL_DIR)($number_two)" test.conf

-- Dave Tweed


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

Date: Thu, 04 Oct 2001 23:51:10 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl Guru needed for this extremely frustrating search and replace problem.
Message-Id: <mbudash-B196AA.16511104102001@news.sonic.net>

In article <3BBCF238.20219C7B@acm.org>, Dave Tweed <dtweed@acm.org> 
wrote:

> Don't top-post, it's a pain to fix up for follow-ups.
> 
> Dan Boyce wrote:
> > Michael Budash <mbudash@sonic.net> wrote in message > 
> > news:<mbudash-A0C5AE.14215903102001@news.sonic.net>...
> > > In article <3fac67fd.0110031258.3cce7cd8@posting.google.com>,
> > > dboyce@phoenixcolor.com (Dan Boyce) wrote:
> > > > Some how I need to convert the script below to allow me to enter a
> > > > directory structure (ie. /home/dan/).  Using a script that I have
> > > > found in a book I can replace INSTALL_DIR with strings as long as 
> > > > they
> > > > do not contain "/" in them.
> > > >
> > > > The following is the test script:
> > > > #/bin/sh
> > > > echo "Replace with: "
> > > > read number_two
> > > > cp test.conf test.conf.bak
> > > > perl -p -i -e s/INSTALL_DIR/$number_two/ test.conf
> > > > echo "test.conf"
> > > > more test.conf
> > > >
> > > try this (untested) replacement line in the test script:
> > >
> > > perl -p -i -e 's{INSTALL_DIR}{$number_two}' test.conf
> > 
> > Thanks for the help, but still no luck.  I tried your line as is, and
> > it just deleted INSTALL_DIR and put nothing in its place.  I tried
> > modifying it a bit and again no luck.
> 
> You need both a perl guru and a shell guru, I guess.
> 
> The problem with your initial attempt was that any '/' in the replacement
> string terminated the substitute command prematurely, creating the syntax
> error.
> 
> Unfortunately, Michael introduced single-quotes around his solution, 
> which
> prevented the shell from doing the intended substitution for the 
> replacement
> pattern.
> 
> The trick is that you need to use some delimiter for the substitution 
> other
> than '/', but you need to make sure that the character you use isn't 
> going
> to be acted on by the shell.
> 
> Try this, using double-quotes and parens instead of single-quotes
> and braces:
> 
>     perl -p -i -e "s(INSTALL_DIR)($number_two)" test.conf
> 
> -- Dave Tweed

thanks for correcting me, dave... just wasn't looking closely enuff...
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 4 Oct 2001 22:07:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl Regex
Message-Id: <slrn9rpn9n.ano.abigail@alexandra.xs4all.nl>

Keven Denen (kevend@nhrockford.com) wrote on MMCMLV September MCMXCIII in
<URL:news:b92b484e.0110022049.118428b1@posting.google.com>:
\\ This may seem like a very newbie type question, but I can't figure
\\ something out.  Flame me if necessary, but at least let me know what I
\\ am doing wrong.  Here's what I am trying to do:
\\ 
\\ I'm trying to get Perl to take input from the user and make sure it
\\ matches the right format for a social security number xxx-xx-xxxx.  So
\\ my regex is
\\ 
\\ /[\d]{3}-[\d]{2}-[\d]{4}/

Eh, what's with the character class inside a character class? \d{3} means
three digits.

\\ Seems like it should be easy right???  That's what I thought.  It is
\\ almost right but it will take more than 3, 2, and 4 digits after each
\\ dash.  Doesn't the {x} limit the number of characters??  Am I missing
\\ something?  Any help would be appreciated.

After *each* dash? Are you sure? The regex *will* match something like

    1234-12-12345

but that is just because that string contains

     234-12-1234

which matches the regex. If you don't what that, you need to anchor your
regex. Perhaps with ^ and $, perhaps with \b or with negative lookahead/
lookbehind, depending on what you exactly need.

\\ Email me if you can tell what I am doing wrong.  I'm using Perl5 in
\\ RedHat.

No. If you cannot be bothered to read the group after you asked a question,
the answer cannot be important to you.


Abigail
-- 
$=-=4*++$|;{print$"x--$==>"\@\x7Fy~*kde~box*Zoxf*Bkiaox \r"
                            ^
$/x24if!select$,,$,,$,,join+q=.==>$^W=>$|;$=&&redo}sleep$|;


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

Date: Fri, 05 Oct 2001 00:44:19 GMT
From: "Pujo C A" <adustipujo1@mediaone.net>
Subject: robot in perl
Message-Id: <Dn7v7.31879$kH1.272430@typhoon.mw.mediaone.net>

anybody knows any good references to make robot in perl?

thanks

ojup




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

Date: Fri, 5 Oct 2001 08:29:42 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Skipping following lines if the same
Message-Id: <uq5v7.4$oS5.350351@news.interact.net.au>


"Walter Hafner" <hafner@augusta.de> wrote in message
news:qdf1ykjk1an.fsf@www.ibexnet.de...
> kenlaird@yahoo.com (Laird) writes:
>
> > aaa
> > aaa
> > bbbbb
> > cccc
> > cccc
> > c
> > ddd
> > ddd
> > fff
> > fff
> > fff
> > ffff
> > ffff
> >
> > and would like to transform it into this
> >
> > aaa
> > bbbbb
> > cccc
> > c
> > ddd
> > fff
> > ffff
>
> system("unique", "data")
>
> *duck and run* :-)

s/unique/uniq/




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

Date: Fri, 5 Oct 2001 09:39:50 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Something wrong with this?
Message-Id: <slrn9rpsq6.d6o.mgjv@martien.heliotrope.home>

On 03 Oct 2001 23:24:49 -0400,
	Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> 
>> On 03 Oct 2001 22:37:47 -0400,
>> 	Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>> > BCC <a@b.c> writes:
>> >>   
>> >>   if ($file ne '') {
>> >         ^^^^^^^^^^
>> > 
>> >     if ($file) {         # all false values are unacceptible here
>> 
>> Why isn't the file allowed to be called "0"?
> 
> It is, but that would be "$file".  $file is a ref to 
> a filehandle object (package Fh in the CGI.pm src)
> that has overloaded '""'.  

Ah, ok. The original line that set $file was:

  my $file = $query->param("upload");

I just assumed that that was whatever the user had typed into the upload
box, not realising there was some magic involved. Reading the
documentation for CGI.pm tells me that you're right :)

>   sub upload {
>     my($self,$param_name) = self_or_default(@_);
>     my $param = $self->param($param_name);
>     return unless $param;
>     return unless ref($param) && fileno($param);
>     return $param;
>   }

In version 2.78 that has become

sub upload {
    my($self,$param_name) = self_or_default(@_);
    my @param = grep(ref && fileno($_), $self->param($param_name));
    return unless @param;
    return wantarray ? @param : $param[0];
}

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd.   | Then things get worse.
NSW, Australia                  | 


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

Date: Fri, 5 Oct 2001 10:27:20 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Whither Palm Perl?
Message-Id: <slrn9rpvj8.d6o.mgjv@martien.heliotrope.home>

On 4 Oct 2001 19:52:33 GMT,
	Ilmari Karonen <iltzu@sci.invalid> wrote:
> In article <t4sort88or0ghbnse8ogmacqjnm2idp11d@4ax.com>, Bart Lateur wrote:
>>DrDebug wrote:
>>
>>>Is there some reason why Perl has not been ported to the PalmOS?
>>>Sure it's big, but couldn't something be done?
>>
>>Perl6 will most likely run on the Palm. A few months, or years, of
>>patience, please.
> 
> Mind you, "run" may still be the wrong verb.  I'm having a hard time
> imagining that anything resembling Perl could ever do anything but
> "crawl" on PalmOS, regardless of the underlying implementation.  Of
> course, I *could* be wrong...

Mind you, by the time that Perl 6 is finished, and a palmtop version
implemented, Moore's law will probably have caught up with the
requirements of the perl interpreter.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

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


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