[25440] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7685 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 24 06:05:46 2005

Date: Mon, 24 Jan 2005 03:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 24 Jan 2005     Volume: 10 Number: 7685

Today's topics:
        Email fate on server down ? <siliconmike@yahoo.com>
    Re: Email fate on server down ? <nospam@bigpond.com>
    Re: Email fate on server down ? <siliconmike@yahoo.com>
    Re: Email fate on server down ? <siliconmike@yahoo.com>
    Re: Email fate on server down ? <nospam@bigpond.com>
    Re: Email fate on server down ? <matternc@comcast.net>
    Re: Email fate on server down ? <matternc@comcast.net>
    Re: Email fate on server down ? chris-usenet@roaima.co.uk
    Re: Email fate on server down ? chris-usenet@roaima.co.uk
    Re: FAQ 3.19 How can I free an array or hash so my prog <dha@panix.com>
        globs, ref globs, and lexically scoped filehandles <alex_the_hart@yahoo.com>
        globs, ref globs, and lexically scoped filehandles <alex_the_hart@yahoo.com>
    Re: how to write a tutorial <wuwei23@gmail.com>
    Re: how to write a tutorial <matternc@comcast.net>
    Re: how to write a tutorial <jonathan.burd@REMOVEMEgmail.com>
        Perl Script Problems grant.september@vodafone.com
    Re: Preserve Timestamp chris-usenet@roaima.co.uk
    Re: Question? Alternative to loading modules!!! <ebohlman@omsdev.com>
        Regex problem <vito_corleone@godfather.com>
    Re: Regex problem <xthua111@sohu.com>
    Re: Regex problem <vito_corleone@godfather.com>
    Re: Regex problem ioneabu@yahoo.com
    Re: Regex problem <toreau@gmail.com>
        Regex: Progressive matching and replace <vito_corleone@godfather.com>
    Re: Regex: Progressive matching and replace <news@chaos-net.de>
        Sorting a hahs of hashes <me@nowehere.com>
    Re: Sorting a hahs of hashes <noreply@gunnar.cc>
        substitute \ with / <joericochuyt@msn.com>
    Re: substitute \ with / <matternc@comcast.net>
    Re: substitute \ with / <joericochuyt@msn.com>
    Re: substitute \ with / <see_sig@invalid>
    Re: substitute \ with / <tintin@invalid.invalid>
    Re: substitute \ with / <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 23 Jan 2005 18:27:28 -0800
From: "siliconmike" <siliconmike@yahoo.com>
Subject: Email fate on server down ?
Message-Id: <1106533648.716533.151890@c13g2000cwb.googlegroups.com>

Hi,

What happens to an email sent to a server if that server is down ? I
mean, does the sender get a failed to deliver message ? Or does it get
lost without the sender's knowledge?

(Apologies to post this question which is really not relevant to perl.
Unfortunately I searched through google groups but could not find a
relevant active group for this post.)]

Regards,
Mike



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

Date: Mon, 24 Jan 2005 12:36:30 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Email fate on server down ?
Message-Id: <35j59jF4kh2mcU1@individual.net>

siliconmike wrote:

> Hi,
> 
> What happens to an email sent to a server if that server is down ? I
> mean, does the sender get a failed to deliver message ? Or does it get
> lost without the sender's knowledge?
> 
> (Apologies to post this question which is really not relevant to perl.
> Unfortunately I searched through google groups but could not find a
> relevant active group for this post.)]
> 
> Regards,
> Mike

What happen when email is sent to you and you're not online? Its queued for
later retrieval.

With store-and-forward Mail Transfer Agents (postfix etc), they usually
retry sending for at least few days.
http://en.wikipedia.org/wiki/Store_and_forward

gtoomey


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

Date: 23 Jan 2005 18:43:49 -0800
From: "siliconmike" <siliconmike@yahoo.com>
Subject: Re: Email fate on server down ?
Message-Id: <1106534629.408784.111260@z14g2000cwz.googlegroups.com>

Yes, but say if hundreds of users are sending email to say
xyz@whatever.com and if say, the server hosting whatever.com is down at
those times, then do you assert that *all* of those users would get a
'failed delivery' message ?

Mike



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

Date: 23 Jan 2005 18:45:32 -0800
From: "siliconmike" <siliconmike@yahoo.com>
Subject: Re: Email fate on server down ?
Message-Id: <1106534732.802139.118840@z14g2000cwz.googlegroups.com>

add this to my previous question:

"failed delivery message ? (assuming that they're not using store & fwd
mail transfer agents)



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

Date: Mon, 24 Jan 2005 13:15:06 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Email fate on server down ?
Message-Id: <35j7hrF4o07vmU1@individual.net>

siliconmike wrote:

> Yes, but say if hundreds of users are sending email to say
> xyz@whatever.com and if say, the server hosting whatever.com is down at
> those times, then do you assert that *all* of those users would get a
> 'failed delivery' message ?
> 
> Mike

It depends (thats not much help).

Some may be lost, some may be requeued, depending on the config of the
sending mail delivery agent.

gtoomey


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

Date: Sun, 23 Jan 2005 22:58:09 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Email fate on server down ?
Message-Id: <yvCdnYXMCIjO72ncRVn-sw@comcast.com>

siliconmike wrote:

> Hi,
> 
> What happens to an email sent to a server if that server is down ? I 
> mean, does the sender get a failed to deliver message ? Or does it get
> lost without the sender's knowledge?
> 
> (Apologies to post this question which is really not relevant to perl.
> Unfortunately I searched through google groups but could not find a
> relevant active group for this post.)]

comp.mail.misc seems to fit the bill to me...

However, since you did make the effort, I will say the normal action
is that that your MTA (mail transfer agent) keeps trying.  You'll
generally get a mail message every few hours saying that your mail
couldn't be delivered but it's still trying.  After some defined
period (usually several days) it gives up, and you get an email message
saying it gave up.


-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Sun, 23 Jan 2005 23:00:29 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Email fate on server down ?
Message-Id: <yvCdnYTMCIhA72ncRVn-sw@comcast.com>

siliconmike wrote:

> Yes, but say if hundreds of users are sending email to say
> xyz@whatever.com and if say, the server hosting whatever.com is down at
> those times, then do you assert that *all* of those users would get a
> 'failed delivery' message ?
> 
Well, yes.  Because it's not the server giving out those messages.
The server isn't doing *anything*, remember--that's the problem!  All
those users get messages *from their own machines* saying they couldn't
get in but are still trying (or have given up, if that's the case).

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Mon, 24 Jan 2005 09:04:16 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Email fate on server down ?
Message-Id: <g9qec2-2jc.ln1@moldev.cmagroup.co.uk>

siliconmike <siliconmike@yahoo.com> wrote:
> (Apologies to post this question which is really not relevant to perl.
> Unfortunately I searched through google groups but could not find a
> relevant active group for this post.)]

comp.mail.misc is pretty active.


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

Date: Mon, 24 Jan 2005 09:13:34 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Email fate on server down ?
Message-Id: <uqqec2-2jc.ln1@moldev.cmagroup.co.uk>

> Yes, but say if hundreds of users are sending email to say
> xyz@whatever.com and if say, the server hosting whatever.com is down at
> those times, then do you assert that *all* of those users would get a
> 'failed delivery' message ?

Gregory Toomey <nospam@bigpond.com> wrote:
> Some may be lost, some may be requeued, depending on the config of the
> sending mail delivery agent.

The whole point of SMTP was supposed to guarantee that no email would
ever be lost. Provided the mail headers were correct, then unless you got
a delivery error you could assume it had been delivered. Unfortunately
anti-spam and anti-virus systems (well, the reasons for their existence)
have put paid to that guarantee.

Note that I'm excluding mail user agents (Outlook, Thunderbird, Eudora,
et al) from this "guarantee". They can reasonably assume that a mail
host is always available.

Mail transport agents go to great lengths to ensure that a piece of email
is not considered as "accepted" until it has been written to non-volatile
storage (i.e. disk).

If a mail delivery host is unavailable then the sending host will
queue the traffic for a number of hours or days. Usually a four hour
delay will cause a response to be sent to the sender warning about the
delivery delay.

In order to help load-balance mail delivery systems, alternate systems
can be configured to accept email for a host on its behalf. You can
find out about such mail exchangers by looking in the DNS for "MX"
records. The lower numbered systems are higher priority acceptors.

Follow-ups set to comp.mail.misc this definitely does not belong in
comp.lang.perl.misc.

Chris


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

Date: Mon, 24 Jan 2005 04:00:02 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: FAQ 3.19 How can I free an array or hash so my program shrinks?
Message-Id: <slrncv8sm2.10s.dha@panix2.panix.com>

On 2005-01-24, brian d foy <comdog@panix.com> wrote:
> In article <slrncv7s85.s21.dha@panix2.panix.com>, David H. Adler
><dha@panix.com> wrote:
>
>> On 2005-01-23, brian d foy <comdog@panix.com> wrote:
>> > In article <neGdnfSTgJKCxW7cRVn-gA@adelphia.com>, DJO <d@adelphia.net>
>> > wrote:
>
>> >>  Posting patches here 
>> >> in comp.lang.perl.misc is not how it's handled.
>
>> > Other than a response to one of these autoposts, the correct place to
>> > post a correction or addition is perlfaq-workers@perl.org, not p5p.
>
>> A cursory glance at where I'd assume this info would be (perldoc -q
>> (patch|submit), perlbug) doesn't provide it. Maybe this should be a faq.
>
> well, it does mention all this stuff in perlfaq.pod. :)

You know, I forgot that was even there, as I usually figure 'perldoc -q'
searches the faq for me. Perhaps that page should be renamed
'perlmetafaq'. :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
_Day of Wrath_ is probably Dreyer's most popular film, which already
indicates something of the problems it poses.
        - David Bordwell, The Films of Carl-Theodor Dreyer


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

Date: 24 Jan 2005 00:21:27 -0800
From: "Alex Hart" <alex_the_hart@yahoo.com>
Subject: globs, ref globs, and lexically scoped filehandles
Message-Id: <1106554887.183266.231980@c13g2000cwb.googlegroups.com>

2 questions, but somewhat related.

What is the rule for when it's possible to use a glob, and when it's
possible to use a ref glob. Can they always be used interchangably? The
docs seem a little vague on this. Is this a property of the glob, or of
the function being called?

Also, concerning lexically scoped filehandles (which is really a ref
glob, right?), can these be used anywhere a filehandle would be used
(i.e. will they be auto-vivicated anywhere a file handle is expected?).
I always see the example with open, but what about sysopen, or accept,
or bind, or anything else. Can I always use a undefined scalar in these
functions?

Thanks.

- Alex Hart



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

Date: 24 Jan 2005 00:35:52 -0800
From: "Alex Hart" <alex_the_hart@yahoo.com>
Subject: globs, ref globs, and lexically scoped filehandles
Message-Id: <1106555752.481620.284120@c13g2000cwb.googlegroups.com>

2 questions, but somewhat related.

What is the rule for when it's possible to use a glob, and when it's
possible to use a ref glob. Can they always be used interchangably? The
docs seem a little vague on this. Is this a property of the glob, or of
the function being called?

Also, concerning lexically scoped filehandles (which is really a ref
glob, right?), can these be used anywhere a filehandle would be used
(i.e. will they be auto-vivicated anywhere a file handle is expected?).
I always see the example with open, but what about sysopen, or accept,
or bind, or anything else. Can I always use a undefined scalar in these
functions?

Thanks.

- Alex Hart



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

Date: 23 Jan 2005 17:57:04 -0800
From: "alex23" <wuwei23@gmail.com>
Subject: Re: how to write a tutorial
Message-Id: <1106531824.833549.28720@c13g2000cwb.googlegroups.com>

> the first paragraph of 9.1 "A Word About Terminology" is
> epitome of masturbation.

I'm tempted to concede this point to you given the sheer overwhelming
testament to onanism that is your website but this is just nonsense.
Defining terms is *always* necessary, it ensures that participants in
whatever dialogue are at least partially using the terms with the same
intent

> For 99% of readers, it is incomprehensible and irrelevant.

You're not 99% of the readers, so I find that remark difficult to
swallow. Having read your comments on women, the whole idea that you
have a superior insight into would-be python coders is just obscenely
ludicrous.

- alex23



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

Date: Sun, 23 Jan 2005 22:48:53 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: how to write a tutorial
Message-Id: <x5adnUOn5Ku77WncRVn-og@comcast.com>

alex23 wrote:

> Having read your comments on women, 

I hadn't looked at that part of his site until now.  I can only say:
gah.  Haven't seen something like that since Dave Sim's infamous
"Tangent" essay.

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Mon, 24 Jan 2005 16:04:23 +0530
From: Jonathan Burd <jonathan.burd@REMOVEMEgmail.com>
Subject: Re: how to write a tutorial
Message-Id: <35k13gF4nvosaU1@individual.net>

Xah Lee wrote:
> adding to my previosu comment...

<snip>

*plonk*

-- 
"Women should come with documentation." - Dave


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

Date: 24 Jan 2005 02:46:53 -0800
From: grant.september@vodafone.com
Subject: Perl Script Problems
Message-Id: <1106563613.708743.50220@z14g2000cwz.googlegroups.com>

Hi All, I'm a total newbie to perl but I found a script form the web
that would automate the cloning of Oracle DB's on NT so I thought i'd
give it a go, the problem is whenever i run it i get a badfile error, (
found in the section that backs up Db files - think )which i'm assuming
is becuase my path of some of my db files have a space in them, i'd
appreciate it if anybody can give me a workaround to this

TIA
Grant
=========================================================================
#!/usr/bin/perl

#
------------------------------------------------------------------------
# coldarch -- cold backup for Microsoft
#             G. Patterson, June 2002

# WARNING  ** This script SHUTS DOWN THE DATABASE! ********
#             This is the only warning!

# Set the common parameters (contained in common.pl)
use File::Basename;
# extract the path from $0
$MyPath = dirname($0);
# This file contains important site definitions
require "$MyPath\\common.pl";
# This determines how the database will be re-opened
$OPEN_TYPE = 0;         # 0 = Don't open, 1 = oradim, 2 = svrmgrl, 3 =
both

#
------------------------------------------------------------------------

# Write a log message to the logfile
sub LogMsg{
my @t = localtime(time);
printf LOG "%04d-%02d-%02d %02d:%02d %s\n",
$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$_[0];
}

#
------------------------------------------------------------------------

# We have a problem ... cleanup and exit
sub problem{
LogMsg "ERROR: $_[0]";
unlink "$lockfile";
unlink "$stopfile";
# hopefully we can start the database
opendb();
die "$_[0]\n";
}

# -------------------------------------------------------------------
# Run the given SQL and spool to temp.LST, because we
# cannot redirect output from version 7 sqlplus in NT
sub run_sql {
# first,  write the given SQL to a temp file
open SQL,">$sqltmp" || die "cannot open $sqltmp";
print SQL "set term off\n";
print SQL "set echo off\n";
print SQL "set trimspool on\n";
print SQL "set pages 0\n";
print SQL "set feedback off\n";
print SQL "set verify off\n";
print SQL "set lines 1024\n";
print SQL "spool $tmpdir\\temp\n";
print SQL "$_[0]\n";
print SQL "exit\n";
close SQL || die "$!";
# now run it with the SQLPLUS utility
system "$sqlplus -s $userid/$passwd\@$orasid \@$sqltmp";
# read back the spool file and return the contents in list
context
open (TMP,"$tmpdir\\temp.LST") || problem "opening temp.LST";
my @t = (<TMP>);
close TMP || problem "closing temp.LST";
return( @t);
}

#
------------------------------------------------------------------------

# Run the given SQL in svrmgrl
sub run_svrmgr {
# construct an SQL file
open SQL,">$sqltmp" || die "cannot open $sqltmp";
print SQL "connect internal/$passwd\n";
print SQL "$_[0]\n";
print SQL "exit\n";
close SQL || die "$!";
# EXEC as a backticks block and return the output in list
context
my @t = `$svrmgrl \@$sqltmp`;
return( @t);
}
#
------------------------------------------------------------------------

# get list of redo logs from v_$logfile
sub get_redo_info{
# this should return a list of the redo logs
my @t = run_sql "select member from v_\$logfile;";
foreach $x (@t){
# remove any crud from the end of the lines
$x =~ s/\s+$//;
push (@REDOLIST,$x) if (length($x) )
}
}

#
------------------------------------------------------------------------

# shutdown the database and get a copy of SQL to create control file
sub shutdb{
my $t; my $f; my $x; my $a;
# run a BACKUP TO TRACE command
my $backup_ctrl = "$coldarc\\" . uc($orasid) .
"_CTRL.FILE.trc";
my @t = run_svrmgr "alter system switch logfile;
alter database backup controlfile to trace resetlogs;";
@t = run_svrmgr "shutdown immediate;";
LogMsg $t = `$oradim -shutdown -sid $orasid -usrpwd $passwd
-shuttype inst,srvc -shutmode i`;
# examine the files in USER_DUMP_DEST
opendir (TRACE,$ORAPARM{user_dump_dest}) ||
problem "Cannot open $ORAPARM{user_dump_dest}";
$a = 99;
# we want the most recent trace file ...
while ($t = readdir TRACE){
$x = $ORAPARM{user_dump_dest} . "\\" . $t;
next unless ( -f $x);
next unless ( (-M $x ) < $a);
$f = $x;
$a = ( -M $x )
}
# save the trace file for later (the coldclone procedure)
rename $f,$backup_ctrl || problem "Cannot move $f to
$backup_ctrl";
}

#
-----------------------------------------------------------------------
# retrieve parameter values from v$parameter
sub get_oraparm{
# extract the parameters from v$parameter
my @t = run_sql "col name format a40 trunc\ncol value format
a512 trunc
select name,value from v\$parameter;";
for my $i ( 0 .. $#t){
$t[$i] =~ s/\s+$//;
# parse them into %ORAPARM (using parameter as a hash
key)
if ( $t[$i] =~ /^(\w+)/){
$ORAPARM{$1} = $';
$ORAPARM{$1} =~ s/^\s+//;
}
}
}

#
------------------------------------------------------------------------

# Get the list of datafiles to be backed up
sub get_datafiles{
my @t = run_sql "select tablespace_name, file_name, blocks+1
from dba_data_files where status = 'AVAILABLE'
order by tablespace_name, file_name;";
my $j = 0;
for my $i ( 0 .. $#t){
chomp($t[$i]);
my @s = split ' ',$t[$i];
if (@s == 3){
$DATAFILE[$j] = \@s;
my @b = split /\\/,$DATAFILE[$j][1];
$DATAFILE[$j++][3] = $b[$#b];
}
elsif (@s > 3){
# spit the dummy if filename contains embedded
spaces
problem "bad file: $s[1] $s[2]";
}
}
problem "no data files available" unless (@DATAFILE > 0);
LogMsg sprintf "$MyName found %d data files to
backup",@DATAFILE+0;
}
# Create a header file.
# This is a text file that contains information about the cold archive
# which can be used by scripts that restore from the cold archive.
sub write_header{
my $x;
# gather all the necessary information
get_redo_info();
get_datafiles();
@CTRLFILES=split /, /,$ORAPARM{control_files};
# clobber previous backup
unlink glob "$coldarc\\*";
open (HDR,">$coldarc\\0header") || die "Cannot open
$coldarc\\0header\n";
# store the information in the header file
print HDR "$MyName started at $start_str
ORACLE_SID: $orasid
ORACLE_HOME: $ENV{ORACLE_HOME}
BLOCK_SIZE: $ORAPARM{db_block_size}
PARAM_FILE: $pfile{$orasid}\n";
if ($ORAPARM{ifile}){
print HDR "    I FILES:\n";
foreach $x(split (/, /,$ORAPARM{ifile})){
print HDR "\t$x\n";
}
}
print HDR " CTRL FILES:\n";
foreach $x (@CTRLFILES){
print HDR "\t$x\n";
}
}

#
------------------------------------------------------------------------

# create SQL for a backup control (backup to trace)
sub backup_control_file{
my $backup_ctrl = "$coldarc\\" . uc($orasid) . "_CTRL.FILE";
# clobber any old versions of this file
unlink "$backup_ctrl";
my @t = run_sql "set feedback on
alter database backup controlfile to '$backup_ctrl';";
problem "Cannot backup controlfile"
unless ( grep(/Database altered$/i,@t) );
# use the $zipview command to verify that the backup is successful
# this reads through the contents of the zip archive and checks
# that the sizes match specified system size.
# NB: This may vary from site to site. If you have actually created
# a data file that is larger than the allocated size in the database
# this check should be disabled.
sub verify_backup{
$blksz = $ORAPARM{db_block_size};
for my $i ( 0 .. $#DATAFILE){
my @t = `$zipview $coldarc\\$DATAFILE[$i][3].zip`;
foreach my $x (@t){
$x =~ s/\s+$//;
if ($x =~ /$DATAFILE[$i][3]$/){
$size = (split ' ',$x)[0];
problem "suspect backup
$DATAFILE[$i][3].zip"
unless ($size == $DATAFILE[$i][2] *
$blksz);
}
}
}
}

#
------------------------------------------------------------------------

#make the output from the zipadd more pretty
sub pretty {
my $t = $_[0];
$t =~ s/Deflating     .*%\), done./Deflated/;
return($t);
}

#
------------------------------------------------------------------------

# backup the control_file, redo logs, pfiles and ifiles
sub backup_config(){
my $x; my $b;
my $dest = "$coldarc\\config.$orasid.zip";
# first copy the pfile to the archive directory
my $t = `copy $pfile{$orasid} $coldarc`;
$t =~ s/\s+$//;
problem "pfile: $t" unless ($t =~ /1 file\(s\) copied/);
# add the control_file to the zip archive
LogMsg pretty $t = `$zipadd $dest $CTRLFILES[0]`;
foreach my $x (@REDOLIST){
LogMsg pretty $t = `$zipadd $dest $x`;
}
# copy each of the ifiles to the archive directory
foreach $x(split (/, /,$ORAPARM{ifile})){
$b = basename( $x);
problem "Duplicate ifile: $b" if ( -f "$coldarc\\$b");
$t = `copy $x $coldarc`;
$t =~ s/\s+$//;
problem "ifile: $t" unless ($t =~ /1 file\(s\)
copied/);
}
}

#
------------------------------------------------------------------------

# reopen database -- called from problem(), so we must not call
problem()
sub opendb{
LogMsg "WARNING: Database is shutdown!" unless $OPEN_TYPE;
LogMsg $t =
`$oradim -startup -sid $orasid -usrpwd $passwd -starttype
srvc,inst`
if ( $OPEN_TYPE & 1);
run_svrmgr "startup" if ( $OPEN_TYPE & 2);
}

#
------------------------------------------------------------------------

# Main ... start here:
# which program am I?
$MyName = basename $0,"\.pl";
# sanity check for command line
die "usage: $MyName intrnl_passwd db_name\n" unless (@ARGV == 2);
$userid = "sys";
$passwd = $ARGV[0];
$orasid = $ARGV[1];
# check the environment
chk_env();
# init strings for logfile
@start = localtime(time);
$start_str = sprintf "%04d-%02d-%02d %02d:%02d:%02d",$start[5]+1900,
$start[4]+1,$start[3],$start[2],$start[1],$start[0];
$logfile = sprintf
"%s\\%s_%s_%02d%02d%02d.log",$logdir,$orasid,$MyName,
$start[5]%100,$start[4]+1,$start[3];
$lockfile = "$logdir\\coldarch.$orasid.lock";
$stopfile = "$logdir\\coldarch.$orasid.stop";
die "$MyName is already running\n" if ((-f $lockfile) && (-M $lockfile
< 1));
# create the lockfile
open (LOCK,">$lockfile") || die "Cannot write to $lockfile";
print LOCK "$MyName started $start_str\n";
close (LOCK) || die "$!";
open(LOG,">>$logfile") || die "error opening $logfile\n";
get_oraparm();
problem "$ORAPARM{db_name} does not match $orasid"
unless (uc($ORAPARM{db_name}) eq uc($orasid));
$coldarc = "$coldarc\\$ORAPARM{db_name}";
# setup the header
write_header();
# shutdown the database, backup control_file, pfile, ifiles
shutdb();
# write information about datafiles to the HEADER
print HDR "\n DATA FILES:\n";
for my $i ( 0 .. $#DATAFILE){
# loop through the datafiles
problem "$MyName Stopped!" if ( -f $stopfile);
sleep(10);
LogMsg "copying $DATAFILE[$i][1], $DATAFILE[$i][2] blocks";
print HDR "\t$DATAFILE[$i][1] $DATAFILE[$i][2] blocks\n";
LogMsg pretty $t = `$zipadd $coldarc\\$DATAFILE[$i][3].zip
$DATAFILE[$i][1]`;
}
backup_config();
opendb();
LogMsg "$MyName completed normal";
unlink "$lockfile";



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

Date: Mon, 24 Jan 2005 09:01:59 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Preserve Timestamp
Message-Id: <75qec2-2jc.ln1@moldev.cmagroup.co.uk>

pulsar4f@hotmail.com wrote:
> I'm try to search and replace a string in some files, but I don't want
> the file's timestamp to change if it doesn't contain the string I'm
> searching for.  Any ideas?

Uh, change your algorithm to avoid rewriting the files unless they
contain your matching string.

(The "easy" way of doing this is to continue to write the temporary
file and leave the decision of whether to replace the existing file
with the new modified one or leave the original one intact until the
last moment. At least then you only need to pass through each file once.)

Chris


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

Date: 24 Jan 2005 10:28:02 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <Xns95E82EB05A5EAebohlmanomsdevcom@130.133.1.4>

Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote in 
news:87brbjl2oy.fsf@mithril.chromatico.net:

> This is basic technical sales.  "You need to host this site at a host
> that allows Perl module installations.  They generally run $30 a
> month, which *is* more than the cut-rate web host you want to use.
> However, if the host doesn't allow module installations, and the
> cut-rate web host you want to use doesn't, then I need to rewrite a
> lot of code instead of using standard well-tested modules, and that
> will add between 8 and 12 hours to the development time for this
> script.  I'm happy to go either way, but the requirement that I not
> use any external modules will add between $480 and $720 to the
> estimate I gave you, and will save only $240 a year.  The decision is
> up to you."  Doesn't seem like a tough sales job to me, especially as
> it's one I've made several times quite successfully.

That argument presumes that the decision of which host to use is in the 
same hands as the decision to contract with a programmer.  If it is, then 
there are no flaws to your argument, but in even a fairly small company 
the two decisions may be in different hands; in a larger company the two 
decision-makers may even be under different VPs.  Under such 
circumstances, office politics dictate that Joe isn't going to be very 
willing to spend extra money so that Jack can spend less money, even when 
the money Jack saves is more than Joe spends and so results in a net cost 
reduction to the company as a whole.  Joe's performance evaluation is 
going to depend on whether or not he cuts *his* department's costs, *not* 
on whether or not he cuts *the company's* costs.

So it's not really a tough sales job *if* you're making the sale to 
someone sufficiently high up in the client, but in many cases you don't 
have access to someone that high up.

Once again, this isn't to say that your economics don't make sense; they 
do.  But businesses often act in particularly irrational ways.


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

Date: Mon, 24 Jan 2005 11:57:09 +0900
From: Vito Corleone <vito_corleone@godfather.com>
Subject: Regex problem
Message-Id: <20050124115709.0d51360d.vito_corleone@godfather.com>

Hi,

How can I change every: 
<photo src=111:123:456> to 
<img src=img/111/123/456>? 

I tried:
$html =~ s#<photo src=($d+):($d+):($d+)>#<img src=img/$1/$2/$3>#g;

But there is a possibility that there is a newline in it. Is there any
better way to change this?


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

Date: Mon, 24 Jan 2005 11:27:08 +0800
From: kenneth <xthua111@sohu.com>
Subject: Re: Regex problem
Message-Id: <ct1q6c$2r01$1@mail.cn99.com>

Vito Corleone wrote:
> Hi,
> 
> How can I change every: 
> <photo src=111:123:456> to 
> <img src=img/111/123/456>? 
> 
> I tried:
> $html =~ s#<photo src=($d+):($d+):($d+)>#<img src=img/$1/$2/$3>#g;
> 
> But there is a possibility that there is a newline in it. Is there any
> better way to change this?
are you sure where did the newline would appear?


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

Date: Mon, 24 Jan 2005 12:47:56 +0900
From: Vito Corleone <vito_corleone@godfather.com>
Subject: Re: Regex problem
Message-Id: <20050124124756.587c73f5.vito_corleone@godfather.com>

Hi Kenneth,

> > I tried:
> > $html =~ s#<photo src=($d+):($d+):($d+)>#<img src=img/$1/$2/$3>#g;
> > 
> > But there is a possibility that there is a newline in it. Is there
> > any better way to change this?
> are you sure where did the newline would appear?

No it could be anywhere. Actually I make this for online BBS, where user
can choose an icon, click on it, and the javascript will put <photo
src=12:13:14> on the text. I would be easier if I put <img
src=img/12/13/14.gif> on the first place, but some user has different
directories, so I have to get_user_id, and then change <photo src> to
appropiate <img src>.


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

Date: 23 Jan 2005 22:07:07 -0800
From: ioneabu@yahoo.com
Subject: Re: Regex problem
Message-Id: <1106544574.067393.226620@c13g2000cwb.googlegroups.com>


Vito Corleone wrote:
> Hi Kenneth,
>
> > > I tried:
> > > $html =~ s#<photo src=($d+):($d+):($d+)>#<img
src=img/$1/$2/$3>#g;
> > >
> > > But there is a possibility that there is a newline in it. Is
there
> > > any better way to change this?
> > are you sure where did the newline would appear?
>
> No it could be anywhere. Actually I make this for online BBS, where
user
> can choose an icon, click on it, and the javascript will put <photo
> src=12:13:14> on the text. I would be easier if I put <img
> src=img/12/13/14.gif> on the first place, but some user has different
> directories, so I have to get_user_id, and then change <photo src> to
> appropiate <img src>.

try this first:

$html =~ s/\n//g;

then your thing:

$html =~ s#<photo src=($d+):($d+):($d+)>#<img src=img/$1/$2/$3>#g;
maybe that will help with the newlines.



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

Date: Mon, 24 Jan 2005 09:07:48 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Regex problem
Message-Id: <i12Jd.5743$IW4.118029@news2.e.nsc.no>

Vito Corleone wrote:
> How can I change every: 
> <photo src=111:123:456> to 
> <img src=img/111/123/456>? 
> 
> I tried:
> $html =~ s#<photo src=($d+):($d+):($d+)>#<img src=img/$1/$2/$3>#g;
> 
> But there is a possibility that there is a newline in it. Is there any
> better way to change this?

Get rid of the newline(s) first;

   $html =~ s,\n,,g;
   $html =~ s,<photo src=(\d+):(\d+):(\d+)>,<img src=img/$1/$2/$3>,g;


-- 
Tore Aursand <tore@aursand.no>
"Those people who think they know everything are a great annoyance to
  those of us who do." (Isaac Asimov)


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

Date: Mon, 24 Jan 2005 17:34:16 +0900
From: Vito Corleone <vito_corleone@godfather.com>
Subject: Regex: Progressive matching and replace
Message-Id: <20050124173416.1ce6b241.vito_corleone@godfather.com>

Hi,

How can I do progressive progressive matching and replace? For example I
want to change this text:
##--- before ---##
adfdf <photo src=12> dasfd Fdfdsfdf <photo 
src=14> adsfdf dsf dsf dsf asdfdsa ds <phot
o> dsafd adsf

to:

##--- after ---##
adfdf <img src=12.gif> dasfd Fdfdsfdf <img 
src=14.gif> adsfdf dsf dsf dsf asdfdsa ds <phot
o> dsafd adsf

And also I want to check if each user has access to the image they are
trying to link to. Here is what I tried:

##----- start sample.pl -----##
my $test =<< "BLOCK";  ## User input this from web interface, textarea
adfdf <photo src=12> dasfd Fdfdsfdf <photo 
src=14> adsfdf dsf dsf dsf asdfdsa ds <phot
o> dsafd adsf
BLOCK
;

$test =~ s/\n//g; 
while ($test =~ /<photo src=(\d+)>/g) {
    if (!check_access($1)) { ## See if user have access to this photo
       die "Use your own photo";
    }

    ## Here I don't know how to change 
    ## from <photo src=XX> to <img src=XX.gif>
}
##----- end sample.pl -----##

But I have some problems here:
1. I can do progressive matching, but I don't know how to replace it.
2. Even if I can, I don't know how can I restore the newline that I
deleted.

Any better way to do this? Thank you very much. 

--Vito


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

Date: 24 Jan 2005 10:47:20 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Regex: Progressive matching and replace
Message-Id: <slrncv9khp.g94.news@maki.homeunix.net>

Vito Corleone wrote :
> Hi,
>
> How can I do progressive progressive matching and replace? For example I
> want to change this text:
> ##--- before ---##
> adfdf <photo src=12> dasfd Fdfdsfdf <photo 
> src=14> adsfdf dsf dsf dsf asdfdsa ds <phot
> o> dsafd adsf
>
> to:
>
> ##--- after ---##
> adfdf <img src=12.gif> dasfd Fdfdsfdf <img 
> src=14.gif> adsfdf dsf dsf dsf asdfdsa ds <phot
> o> dsafd adsf

  #!/usr/bin/perl
  
  use strict;
  use warnings;

  my $string ="adfdf <photo src=12> dasfd Fdfdsfdf <photo src=14> adsfdf
  dsf dsf dsf asdfdsa ds <photo> dsafd adsf";

  $string =~ s/photo src=(\d*)/img src=$1.gif/g;

  print "$string\n";

Output:
  iadfdf <img src=12.gif> dasfd Fdfdsfdf <img src=14.gif> adsfdf dsf dsf
  dsf asdfdsa ds <photo> dsafd adsf

HTH
Martin

-- 
Epur Si Muove (Gallileo Gallilei)


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

Date: Mon, 24 Jan 2005 10:19:50 +0200
From: Me <me@nowehere.com>
Subject: Sorting a hahs of hashes
Message-Id: <fcOdnQSMR9A9MmncRVn-qA@is.co.za>

  I have a hash (of a hashes) that has data like this
    table1->table_name
	->table_size
    table2->table_name
	->table_size
    .
    .
    .
    table_n->table_name
	  ->table_size


I need to sort the hash by table_size (numeric). How can I do this.


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

Date: Mon, 24 Jan 2005 11:39:29 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Sorting a hahs of hashes
Message-Id: <35k262F4n9bopU1@individual.net>

Me wrote:
>  I have a hash (of a hashes) that has data like this
>    table1->table_name
>     ->table_size
>    table2->table_name
>     ->table_size
>    .
>    .
>    .
>    table_n->table_name
>       ->table_size
> 
> 
> I need to sort the hash by table_size (numeric). How can I do this.

     perldoc -q "sort a hash"

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 23 Jan 2005 15:17:25 -0500
From: "yusufdestina" <joericochuyt@msn.com>
Subject: substitute \ with /
Message-Id: <1ba932ade530811d20fa4fa568939e1b@localhost.talkaboutprogramming.com>

newbie question... How do I subtitute all '\' with '/'?
I've tried ~s/\\\///;
But didn't work very wel.



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

Date: Sun, 23 Jan 2005 15:41:00 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: substitute \ with /
Message-Id: <tZSdncmeS8lDlmncRVn-1g@comcast.com>

yusufdestina wrote:

> newbie question... How do I subtitute all '\' with '/'?
> I've tried ~s/\\\///;
> But didn't work very wel.

Well, no.  That breaks down to making your first term
"\\\/", which only matches "\/" and your second term
a null string.  So this says 'replace "\/" with nothing'.

You *could* say:

s/\\/\//

But that's ugly.  Instead, you use the fact that you
are not required to use "/" as your separator.  Now
you don't have to escape "/" anymore:

s#\\#/#

Oh, and you said *all*--this only subs the first one.
For all, you want to use the g(lobal) modifier:

s#\\#/#g
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Sun, 23 Jan 2005 16:59:34 -0500
From: "yusufdestina" <joericochuyt@msn.com>
Subject: Re: substitute \ with /
Message-Id: <3f64d1704b15f336c131f78d94ce0af5@localhost.talkaboutprogramming.com>

tnx m8



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

Date: Sun, 23 Jan 2005 18:35:31 -0500
From: Bob Walton <see_sig@invalid>
Subject: Re: substitute \ with /
Message-Id: <41f4354d_1@127.0.0.1>

yusufdestina wrote:
> newbie question... How do I subtitute all '\' with '/'?
> I've tried ~s/\\\///;
> But didn't work very wel.
> 

To do just character substitutions, use the tr/// operator:

use warnings;
use strict;
my $s='blah\\blah\\blah';
print "incoming>$s<\n";
$s=~tr{\\}{/};
print "outgoing>$s<\n";

Generates:

d:\junk>perl junk514.pl
incoming>blah\blah\blah<
outgoing>blah/blah/blah<

d:\junk>

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Mon, 24 Jan 2005 13:27:18 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: substitute \ with /
Message-Id: <35itjoF4m3hgnU1@individual.net>


"yusufdestina" <joericochuyt@msn.com> wrote in message 
news:1ba932ade530811d20fa4fa568939e1b@localhost.talkaboutprogramming.com...
> newbie question... How do I subtitute all '\' with '/'?
> I've tried ~s/\\\///;
> But didn't work very wel.

A better question would be to know why you want to do this. 




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

Date: Sun, 23 Jan 2005 22:48:53 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: substitute \ with /
Message-Id: <slrncv8vhl.k71.tadmc@magna.augustmail.com>

Chris Mattern <matternc@comcast.net> wrote:
> yusufdestina wrote:
> 
>> newbie question... How do I subtitute all '\' with '/'?


> use the fact that you
> are not required to use "/" as your separator.  Now
> you don't have to escape "/" anymore:
> 
> s#\\#/#
> 
> Oh, and you said *all*--this only subs the first one.


But for character translations, there is no need for
regular expressions at all:

    tr#\\#/#;


-- 
    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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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