[23738] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5944 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 16 14:05:45 2003

Date: Tue, 16 Dec 2003 11:05:09 -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           Tue, 16 Dec 2003     Volume: 10 Number: 5944

Today's topics:
    Re: [HELP] code modification <asu1@c-o-r-n-e-l-l.edu>
    Re: Caching results (?) of lengthy cgi process...mirror <henryn@zzzspacebbs.com>
    Re: Caching results (?) of lengthy cgi process <henryn@zzzspacebbs.com>
    Re: Caching results (?) of lengthy cgi process <lv@aol.com>
    Re: Caching results (?) of lengthy cgi process <henryn@zzzspacebbs.com>
        Creating a list of HASHes (Patrick Paquet)
    Re: Creating a list of HASHes <richard@zync.co.uk>
    Re: Creating a list of HASHes <asu1@c-o-r-n-e-l-l.edu>
    Re: Creating a list of HASHes <nobull@mail.com>
    Re: encrypt email address to a string <sbryce@singlepoint.net>
    Re: encrypt email address to a string <test@test.com>
    Re: FILE parsing problems <nobull@mail.com>
    Re: getting error for modules <jwillmore@remove.adelphia.net>
    Re: getting error for modules <jwillmore@remove.adelphia.net>
        How to determine end-of-line sequence? <jill_krugman@yahoo.com>
    Re: How to make global vars? (Sam Holden)
    Re: How to make global vars? <nomorespam@nomorespam.nospam>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Dec 2003 17:54:33 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: [HELP] code modification
Message-Id: <Xns94538351D90AAasu1cornelledu@132.236.56.8>

Paul Sellis <paul.sellis@alussinan.org> wrote in news:paul.sellis-
6E998F.18505316122003@news1-2.free.fr:

> 
> I need your help :
> 
> I am newbie in coding. I use a free scrit "form_processor.pl 1.0"  to 
> make forms from my html pages. I am satisfied with it. 

Why don't you ask the author of the script?
-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Tue, 16 Dec 2003 16:43:17 GMT
From: Henry <henryn@zzzspacebbs.com>
Subject: Re: Caching results (?) of lengthy cgi process...mirroring
Message-Id: <BC047623.19918%henryn@zzzspacebbs.com>

Len:

Thanks for your response on this thread:

in article Q0xDb.3028$5M.81028@dfw-read.news.verio.net, l v at lv@aol.com
wrote on 12/15/03 9:48 PM:

<snip>...<snip> 
>> 
>> Side issue: "mirror" docs say it uses date information from the ultimate
>> document server to determine which is newer, local or remote.  How reliable
>> is this information?  Does it depend on someone purposefully enabling the
>> server to supply date stamp?  Or is it just a matter of the server handing
>> out the ordinary date attached to the file in which the data is stored?
>> 
> 
> My understanding is that the web server hands out the last modified
> date/time of the requested file in the http headers.

That would be the OS filesystem information, then?   Apparently this data is
part of the accompanying information that is not displayed as page source.
In my tests, anyway, local copies of mirrored files show a quite reasonable
October date. But there's nothing in the HTML source about any dates.

Is this "header" data?  I tried to get LWP::Simple to hand over header data,
but my first efforts were unsuccessful, and I gave up, since I don't really
need it.

> This allows 
> browsers to cache files in order to reduce network load and speed.

Right, reasonable.

> Best to test to verify the LWP mirroring is going to work for you.
> Specifically, what do you get while the update process is running?  Part of
> the file or the previous version?

So far so good. I appear to be getting intact pages.   The pages I'm reading
are pretty visible and people would be upset if they were not whole.  I
don't know much about the process the other end, except I've noticed that
the file dates+times, where visible, are pretty much identical, indicating a
unitary update process for the entire data set.   Is that what you were
getting at?

I'm working on the process that parses these files and transmogrifies their
data to a much more user-friendly format.  I'll know more about my success
at getting intact files when this is done.
> 
> My approach is a bit different and controlling.  At the end of my create
> process I create a trigger file indicating the updates are complete.  A
> simple text file with .done as the extension and the content is the
> output from scalar localtime().  Second process will look for the
> trigger file and delete it on the remote server when complete.  All of
> which I do via ftp.

Yeah, you need a bit more control.  My scheme is quite a bit looser.

I'm doing almost an identical thing with a file to provide information about
the last time the results were updated.

The primary data I'm talking about is all web pages. The underlying data is
all available as (poorly formatted) text data via ftp.   I'm hoping that I
can do everything I need via LWP::Simple.

Thanks,

Henry

henryn@zzzspacebbs.com  remove 'zzz'
> 
> Len
> 



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

Date: Tue, 16 Dec 2003 03:25:30 GMT
From: Henry <henryn@zzzspacebbs.com>
Subject: Re: Caching results (?) of lengthy cgi process
Message-Id: <BC03BB28.198D7%henryn@zzzspacebbs.com>

Len:

Thanks for your reply on this thread:

in article ZwrDb.3020$5M.80728@dfw-read.news.verio.net, l v at lv@aol.com
wrote on 12/15/03 3:33 PM:

<snip>
<snip>
>> 
>> 
>> Note to everyone on this thread:  In the cold light of Monday morning, I've
>> finally figured out that I haven't made clear my rather perverse design
>> requirement: 
>>  
>> I want the transition from page content 'n' to state 'm' to be visible, not
>> hidden as it would be in almost all other cases.  Thus, when the user hits
>> the button "update now" he/she might see an cgi-generated accounting of the
>> differences between state 'n' and state 'm', if the underlying data has
>> changed since the last update.  For this design, it's ok that the user
>> requesting the update would be the only one seeing this transition.
>> 
>> This sounds really strange, I imagine, but that's what I need.  And it's why
>> I've been resisting background (e.g. crontab) based updating.
>> 
>> Thanks,
>> 
>> Henry
>> 
>> henryn@zzzspacebbs.com  remove 'zzz'
>> 
> 
> I believe I have done something similar to what you are attempting.  My
> process was to allow users to selectively refresh MS SQL server database
> content with data from the mainframe.  As you might guess, no way of
> interactively *watching* the process as it ran.  Therefore I presented a
> perl generated html form with several check boxes (based on database
> data) and the all powerful submit button.  Clicking the submit button
> ran in background a batch file which submitted mainframe jobs, then
> proceeded to wait for the mainframe files to be ftp'd to the server.
> When the files arrive, I then started the 45 minute SQL server database
> load.  During the mainframe processing and the SQL server processing I
> wrote critical steps, date/time stamps, and status information to a log
> file.  If the user wanted to view the status, they could click the
> status update link which was to a shtml file (not html)  allowing me to
> have an html file which refreshed itself every 60 seconds and
> additionally allowed me to have a server side include of the log file.
> It was presented fairly nice.
> 
> This process also ran once a week from a scheduler like cron.  The above
> was for when the users knowingly made significant changes and wanted a
> refresh on the server.

Wow, that's an impressively complex system!
> 
> Perhaps something similar where on the status page (my shtml, your cgi)
> allows the user to accept the updates after seeing the differences by
> displaying the differences between the 2 log files.  Display the "I
> accept changes" button after the update process is complete (based on
> specific text in the log file???).

Right.  I finally did go ahead and enable SSI on my server.

At this point, I'm trying out running LWP::simple::mirror to download the
raw data...if and only if it is newer on the remote data source than the
previous local copy.   I'm using SSI to present the results, and there's a
"synch now" submit button just below.  It _is_ conceivable that something
might change, but not in a significant area, so it might be ok to defer
synch'ing.   

I've got a separate cgi script mapped out for the synch process itself,
which will display diff's and maybe even conclude with an "accept update"
button.

Side issue: "mirror" docs say it uses date information from the ultimate
document server to determine which is newer, local or remote.  How reliable
is this information?  Does it depend on someone purposefully enabling the
server to supply date stamp?  Or is it just a matter of the server handing
out the ordinary date attached to the file in which the data is stored?

> 
> Lots of options and lots of decisions.  I hope this gets you started in
> the direction you desire.

Yeah, thanks, I'm going great guns.  I'm glad to have found someone who has
done something similar.

Thanks,

Henry

henryn@zzzspacebbs.com  remove 'zzz'
> 
> Len
> 



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

Date: Mon, 15 Dec 2003 23:48:31 -0600
From: l v <lv@aol.com>
Subject: Re: Caching results (?) of lengthy cgi process
Message-Id: <Q0xDb.3028$5M.81028@dfw-read.news.verio.net>

Henry wrote:
> Len:
> 
> Thanks for your reply on this thread:
> 
> in article ZwrDb.3020$5M.80728@dfw-read.news.verio.net, l v at lv@aol.com
> wrote on 12/15/03 3:33 PM:
> 
> <snip>
> <snip>
  > Wow, that's an impressively complex system!
It was fun to design and build.  Doubly fun to watch it work.

<snip>
> 
> Side issue: "mirror" docs say it uses date information from the ultimate
> document server to determine which is newer, local or remote.  How reliable
> is this information?  Does it depend on someone purposefully enabling the
> server to supply date stamp?  Or is it just a matter of the server handing
> out the ordinary date attached to the file in which the data is stored?
> 

My understanding is that the web server hands out the last modified 
date/time of the requested file in the http headers.  This allows 
browsers to cache files in order to reduce network load and speed.  Best 
to test to verify the LWP mirroring is going to work for you. 
Specifically, what do you get while the update process is running?  Part 
of the file or the previous version?

My approach is a bit different and controlling.  At the end of my create 
process I create a trigger file indicating the updates are complete.  A 
simple text file with .done as the extension and the content is the 
output from scalar localtime().  Second process will look for the 
trigger file and delete it on the remote server when complete.  All of 
which I do via ftp.

Len



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

Date: Tue, 16 Dec 2003 16:51:39 GMT
From: Henry <henryn@zzzspacebbs.com>
Subject: Re: Caching results (?) of lengthy cgi process
Message-Id: <BC047818.1991A%henryn@zzzspacebbs.com>

Alan:

Thanks for your post:

in article Pine.LNX.4.53.0312161149080.11020@ppepc56.ph.gla.ac.uk, Alan J.
Flavell at flavell@ph.gla.ac.uk wrote on 12/16/03 3:52 AM:

> On Mon, 15 Dec 2003, l v wrote:
> 
>> My understanding is that the web server hands out the last modified
>> date/time of the requested file in the http headers.
> 
> There's a fine tutorial on cacheability validators (last-modified,
> ETag etc.) at http://www.mnot.net/cache_docs/ , with a link to the
> same author's "cacheability engine" which can be used online to study
> the cacheability of web resources.  Widely recommended.

Wow, that's a great tutorial, more than I ever wanted to know.  It seems to
confirm, indirectly, that LWP::Simple::mirror is leaving files on my disk
with last-modified dates that derive directly from the host file system, via
response headers that are not visible in the page source. Hurrah!
> 
> Of course, it's more on-topic for a web authoring group than for here,
> hence the brevity of this f'up.

Right, thanks for the slight digression.

Thanks,

Henry

henryn@zzzspacebbs.com  remove 'zzz'



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

Date: 16 Dec 2003 08:58:21 -0800
From: jack_luminous@hotmail.com (Patrick Paquet)
Subject: Creating a list of HASHes
Message-Id: <14e35cbb.0312160858.5f1e00c6@posting.google.com>

Hello everyone,

Not my first posting here, but the first one since I've read the
Posting Guidelines (hope I got it right) :-)

I read the docs on 'use strict', but still don't quite understand why
I get "Can't use string ("Machine1") as a HASH ref while "strict refs"
in use at ... line 43".

Also ran it with 'Perl -w' but that did not return any info regarding
the "Can't use string" error, just some "Use of uninitialized value
at..." (which I don't get either btw).

All the subroutines return data as expected and the program executes
normally until line 43.  This program is a bit lengthy to post in it's
entirety, so I snipped all irrelevant lines and modified the code so
that what is below replicates the error as I see it in the normal
version.

I am running on WinNT, perl version 5.005_02, ActivePerl(509).  I know
it's old, but since I don't manage the script servers here I'm using
the same version as the server.

If there's anything missing from this, it's purely accidental, and I
will do my best to provide all necessary information.

Thanks for your time.


Patrick Paquet

###################################################
use strict;
use Win32::ODBC;
use File::Find;
use Win32API::Net;
use Win32::NetAdmin;
use Net::ping;
use Net::hostent;
use Socket;

my @ListDOM = qw/Machine1 Machine2 Machine3/;  # This list is pulled
directly from the SAM on the PDC

my ($Machine, $ValeurCle, %MachineInfo, $CheckMachine, $Ping,
$ReverseLookup, $AdresseIP, $INTAdresseIP);
foreach $Machine (@ListDOM)
   {
   $CheckMachine = 0;
#  %MachineInfo = &ReadSQL($ConnectionSQL,$Machine);  # Commented to
allow
   execution, otherwise runs OK
      if ($MachineInfo{MachineName} ne $Machine) # Existe pas dans la
base
         {
         $CheckMachine = 1;
         print "$Machine n'existe pas dans la base.($CheckMachine)\n";
         }
      $ValeurCle = 123456; #&GetValeurCle($Machine);
      if ($MachineInfo{Valeur_CiPatches} != $ValeurCle)
         {
         $CheckMachine = 1;
         print "$Machine: valeur cle differente.($CheckMachine)\n";
         }
      ($Ping,$ReverseLookup,$AdresseIP)=("OK","OK","10.10.10.10");#&GetIP($Machine);
      if ($MachineInfo{IP_address} ne $AdresseIP)
         {
         $CheckMachine = 1;
         print "$Machine: adresse IP differente.($CheckMachine)\n";
         }
      if ($CheckMachine == 0)
         {
         print "Base a jour pour $Machine, machine suivante...\n\n";
         }
      else
         {
         print "Checks values on workstation...\n\n";

###  ERROR REPORTED ON FOLLOWING LINE
         &EcritureSQL(%$Machine);#Passes HASH to subroutine to write
to SQL db
###
         }  # Fin de la verification d'une machine

      } # Fermeture de la boucle de verification des machines, toutes
les machines ont etes processe


sub EcritureSQL # Ecriture des infos dans la base SQL
{
#	Doesn't do much at this point, until I get that error sorted out.
   my ($Key, $Value, $Pause);
   my %InfosMachine = %_;
   while (($Key, $Value)=each %InfosMachine){print "Key:$Key \->
Value: $Value\n";}
   $Pause = <STDIN>;
}


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

Date: Tue, 16 Dec 2003 17:40:38 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Creating a list of HASHes
Message-Id: <brng2n$omi$1@news.freedom2surf.net>

In article <14e35cbb.0312160858.5f1e00c6@posting.google.com>, "Patrick
Paquet" <jack_luminous@hotmail.com> wrote:
<SNIP explanation>
<SNIP valid looking code>
> ###  ERROR REPORTED ON FOLLOWING LINE

I'm not surprised! $Machine is an ordinary scalar variable. For this
syntax to work, $Machine must be a reference to a hash. Looking at your
code, are you sure you didn't mean to use %MachineInfo here instead of
%$Machine?

>          &EcritureSQL(%$Machine);#Passes HASH to subroutine to write
> to SQL db
> ###
>          }  # Fin de la verification d'une machine
> 
>       } # Fermeture de la boucle de verification des machines, toutes
> les machines ont etes processe
> sub EcritureSQL # Ecriture des infos dans la base SQL {
> #	Doesn't do much at this point, until I get that error sorted out.
>    my ($Key, $Value, $Pause);
>    my %InfosMachine = %_;

This would give an error too: %_ is not a global variable. When you pass
a hash by value it is flattened to a list, you can just use

my %InfosMachine = @_; # <-- Note the '@' sign, not '%'

But better would be to pass by reference. Call the sub like this:

EcritureSQL(\%MachineInfo)

and then pick up the reference inside the sub with:

my ($InfoMachine) = @_;

and then the loop below is written as:

while ( ($Key,$Value) = each %$InfoMachine) {
	print "Key:$key \-> Value: $Value\n";
}

>    while (($Key, $Value)=each %InfosMachine){print "Key:$Key \->
> Value: $Value\n";}
>    $Pause = <STDIN>;
> }

HTH
Rich


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

Date: 16 Dec 2003 17:51:15 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Creating a list of HASHes
Message-Id: <Xns945382C2614A2asu1cornelledu@132.236.56.8>

jack_luminous@hotmail.com (Patrick Paquet) wrote in
news:14e35cbb.0312160858.5f1e00c6@posting.google.com: 


> I ... don't quite understand why I get "Can't use string 
> ("Machine1") as a HASH ref while "strict refs" in use at
> ... line 43".
 ...

> my @ListDOM = qw/Machine1 Machine2 Machine3/;  # This list is pulled
> directly from the SAM on the PDC
> 
> my ($Machine, $ValeurCle, %MachineInfo, $CheckMachine, $Ping,
> $ReverseLookup, $AdresseIP, $INTAdresseIP);

You are defeating the purpose of using my by putting all variable
declarations here. Declare your variables in the smallest scope that
they apply to. For example: 

> foreach $Machine (@ListDOM)

Instead, use

foreach my $Machine (@ListDOM)

>    {
>    $CheckMachine = 0;

my $CheckMachine = 0;

etc. You get the idea.

> #  %MachineInfo = &ReadSQL($ConnectionSQL,$Machine);  # Commented to
> allow execution, otherwise runs OK

Please do not use margin comments that wrap in newsreaders. It makes it
too much work to copy and paste your code to try to run it. 

Also, do you know the difference between:

&ReadSQL($ConnectionSQL,$Machine);

and 

ReadSQL($ConnectionSQL,$Machine);

If not, do not prefix you subroutine calls with &. (I have to admit, 
however, that I am not familiar with such older versions of Perl, and maybe 
there is a reason to use it in that environment).

> ###  ERROR REPORTED ON FOLLOWING LINE
>          &EcritureSQL(%$Machine);#Passes HASH to subroutine to write
> to SQL db

First, see my previous two comments. 

Now, $Machine points an element of the array @ListDOM in each iteration
of the foreach above. Those elements are strings. You try to dereference
them as references to hashes. Why is the error message confusing? 


Did you mean to pass the %MachineInfo hash to EcritureSQL? In that case, 
btw, why pass the whole hash instead of just passing a reference to it? 
Here is a small example:

use strict;
use warnings;

my %MachineInfo = (
    'IP'   => '192.168.1.1',
    'Name' => 'Gateway',
    'Role' => 'Who knows?',
);

EcritureSQL(\%MachineInfo);

sub EcritureSQL {
    my $InfoMachine = shift;
    foreach my $key (keys %$InfoMachine) {
        print "Key: $key -> Value: $InfoMachine->{$key}\n";
    }
    my $pause = <STDIN>;
}

__END__

OTOH, when you want to dump data structures, you might just want to use 
Data::Dumper:

use Data::Dumper;
sub EcritureSQL {
    print Dumper(shift);
    my $pause = <STDIN>;
}

I understand the dumping of key-value pairs was for debuging, but even that 
purpose can be better served by using Data::Dumper.
 

-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: 16 Dec 2003 17:56:11 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Creating a list of HASHes
Message-Id: <u9u140hcjo.fsf@wcl-l.bham.ac.uk>

"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> writes:

> &ReadSQL($ConnectionSQL,$Machine);
> 
> and 
> 
> ReadSQL($ConnectionSQL,$Machine);
> 
> If not, do not prefix you subroutine calls with &. (I have to admit, 
> however, that I am not familiar with such older versions of Perl, and maybe 
> there is a reason to use it in that environment).

I believe it was required in Perl4.

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


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

Date: Mon, 15 Dec 2003 21:22:09 -0700
From: Scott Bryce <sbryce@singlepoint.net>
Subject: Re: encrypt email address to a string
Message-Id: <3FDE8871.7070704@singlepoint.net>

Fengshui wrote:

> Then, please tell me how the hack I can encode an all charactor thing to a
> letter and digital only thing

Since you aren't really asking a Perl question here, (This appears to be a
question about basic encryption algorithms.)let me suggest some
Perl that might do what I think you are asking to do. I'll let those
with more experience than I critique the code. I'll leave it to you to
write a decryption routine.


use strict;
use warnings;

my $some_string = 'myuserid\@alocalisp.com';

print Encrypt($some_string, 'key');

sub Encrypt
{
	my $Rand;
	my %Lookup;	
	
	my ($string_to_encrypt, $key_as_string) = @_;
	
	my @EncChars = split //, q(!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ );
	my $EncCount = @EncChars;

	# Create a hash of encryptable characters and corresponding numbers
	# from the @EncChars array
	foreach my $i (0..($EncCount - 1))
	{
		$Lookup{$EncChars[$i]} = $i;
	}	
		
	# Key is a string. Use the EncChars hash to convert to an integer.
	# This will fail if any character in the key is not in the @EncChars array.	
	my $key_as_number = 0;
	foreach my $i (split //, $key_as_string)
	{		
		$key_as_number += $Lookup{$i};
	}
	
	# Break the string into individual characters
	# and encrypt each one using a different random number
	my $encrypted_string = '';
	
	foreach my $char (split //, $string_to_encrypt)
	{
		my $AsNumber;
		
		# Calculate a new random number based on the value of the key.
		$key_as_number = ($key_as_number * 3877 + 29573) % 139968;
		$Rand = int($EncCount * ($key_as_number / 139968)) + 1;
			
		# If this character is in the Lookup hash, encrypt it.
		# Otherwise, leave it as is. 	
		if (exists($Lookup{$char}))
		{			
			$AsNumber =  $Lookup{$char};
			$AsNumber = ($AsNumber + $Rand) % $EncCount;
			$char = $EncChars[$AsNumber];	
		}
		
		$encrypted_string .= $char;		
	}
		
	return ($encrypted_string);	
}



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

Date: Tue, 16 Dec 2003 04:23:31 GMT
From: "Reportor" <test@test.com>
Subject: Re: encrypt email address to a string
Message-Id: <7NvDb.464668$0v4.21160038@bgtnsc04-news.ops.worldnet.att.net>

>
> > What I need to do is pretty simple. I need to add email
> > address as a Referal, but I want it to look something
> > different, so that spammers will not know that is an
> > email. I don't want to keep a database to make member1 =
> > abc@abc.com, member2 = abe@abe.us
>
> Why not?
>
> Maintaining a map of opaque tokens to email addresses sounds
> like a really good solution.  You could simply create a
> configuration file to store this map, or even put it in the
> source code.
>

I hate to use flock(). I am trying my best to avoid any WRITE to disk.




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

Date: 16 Dec 2003 17:26:16 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FILE parsing problems
Message-Id: <u9he00ishz.fsf@wcl-l.bham.ac.uk>

bay_dar@yahoo.com (G) writes:

> Hi, I'm a newbie to Perl and find regular expressions a mystery.
> Anyway, I need to parse a file and display information in an HTML
> file. My problem is that I don't know how to parse this stuff.

> Below is the sample file showing 2 entries. After that I list my
> problem code snip.

> "Title1"	"Title2
> 
> "	"Page:1"	"Date: 12/15/2003               "	"Time: 11:28:05AM 
> "	"Sale
> Number
> "	"
> Sale Type
> "	"
> Date Assigned
> "	"
> Company  Name
> "	"S034521"	"Software Agreement"	11/08/2003	"Joes Garage"	"2 Years
> support"
> "Title1"	"Title2
> 
> "	"Page:1"	"Date: 12/15/2003               "	"Time: 11:28:05AM 
> "	"Sale
> Number
> "	"
> Sale Type
> "	"
> Date Assigned
> "	"
> Company  Name
> "	"S034522"	"Hardware"	12/11/2003	"JK & J INC."	"Backup Tape"
> 
> 
>    while (<FILE>) {
> 
> #HERE IS WHERE I AM HAVING MY PROBLEM - I can't get a match
> 	if ( ($snum, $type, $date, $comp_name) =
> /\"+\"\t+\"+\"\t+\"+\"\t+\"+\"\t+\"+\"\t+\"(.+)\"\t+\"(.+)\"(.+?)\"(.+)\"\s*$/ix

Is suspect this is FAQ: "How can I split a [character] delimited
string except when inside [character]?"

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


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

Date: Tue, 16 Dec 2003 06:06:19 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: getting error for modules
Message-Id: <20031216010618.3dfccf18.jwillmore@remove.adelphia.net>

On 15 Dec 2003 08:44:09 -0800
debhatta@hotmail.com (debraj) wrote:

> For eg. Say script is /etc/prog/script and lib at /etc/libs and I
> run from /etc/prog it works fine. But from /home/ngraving/scripts
> when I run it gives error that cant find module in @INC (
> /home/ngraving/../libs). Why is this? What is the best method of
> solving this and also of getting the library path without coding it?
> I know that I can set the PERL5LIB variable but thats not the option
> I am looking at. Or do I have to write a sub-routine to solve this ?

use lib '/home/ngraving/../libs';
-or-

BEGIN {
    unshift( @INC, '/home/ngraving/../libs );
}

perldoc perlfaq8
-or-
perldoc -q 'lib'

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
If the aborigine drafted an IQ test, all of Western civilization 
would presumably flunk it.   -- Stanley Garn 


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

Date: Tue, 16 Dec 2003 06:13:23 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: getting error for modules
Message-Id: <20031216011323.6aea7ba4.jwillmore@remove.adelphia.net>

On Tue, 16 Dec 2003 06:06:19 GMT
James Willmore <jwillmore@remove.adelphia.net> wrote:

> On 15 Dec 2003 08:44:09 -0800
> debhatta@hotmail.com (debraj) wrote:
> 
> > For eg. Say script is /etc/prog/script and lib at /etc/libs and I
> > run from /etc/prog it works fine. But from /home/ngraving/scripts
> > when I run it gives error that cant find module in @INC (
> > /home/ngraving/../libs). Why is this? What is the best method of
> > solving this and also of getting the library path without coding
> > it? I know that I can set the PERL5LIB variable but thats not the
> > option I am looking at. Or do I have to write a sub-routine to
> > solve this ?
> 
> use lib '/home/ngraving/../libs';
> -or-
> 
> BEGIN {
>     unshift( @INC, '/home/ngraving/../libs );
> }

You know ..... I gave this directory a second look after posting.  Are
you sure about the directory
/home/ngraving/../libs ?
Or did you just clip the path down?
 
> perldoc perlfaq8
> -or-
> perldoc -q 'lib'

Have a look at the above documents to (dis)prove the soulutions given.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Eat drink and be merry, for tomorrow they may make it illegal. 



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

Date: Tue, 16 Dec 2003 17:28:11 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: How to determine end-of-line sequence?
Message-Id: <brnfbb$7bn$1@reader2.panix.com>





I'm writing a cgi script that uploads and processes files.  These
files can come from Windows, Linux, or Macintosh machines, so the
script doesn't know ahead of time the end-of-line conventions used
by the uploaded files.  What is the best way for a script to
determine the end-of-line sequence used by a given text file?
 
TIA,

jill


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

Date: 16 Dec 2003 03:59:02 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to make global vars?
Message-Id: <slrnbtt0o5.bg2.sholden@flexal.cs.usyd.edu.au>

On Tue, 16 Dec 2003 03:16:08 GMT,
	Sebastien B. <nomorespam@nomorespam.nospam> wrote:
> I'm trying to figure out how to use/make simple global vars.
> 
> Since I have multiple scripts that connect to database, I want to use a
> seperate file that does the connection and call it in the other scripts; so
> something like:
> 
> dbiconnect.pl:
> use strict;
> use DBI;
> my $db=dbi_connect.....
> 1;
> 
> and then in the scripts:
> 
> use strict;
> require 'dbiconnect.pl';
> my $somevar=$db->select(...);
> 
> 
> problem is that $db isn't global; how do I make it global? Do I need to make
> the first script into a pakage? How? (tried it didn't work). None of the
> docs are clear on global (cross-file) vars specifically.

perldoc -f my

Notice it specifically says that my declares a local variable, hence
using my to create a global isn't going to work.

perldoc strict

Notice, the "strict vars" section and how to declare or use a non-my
variable when running under it.

perldoc -f our

Notice that while is declares a global variable, it only does so within
a scope, a sort of local global :)


So when under strict you can use "use vars" (which is marked as
obsolete, but the replcement, our, doesn't work for this case). Or you
can use the fully qualified name as in:

---DBIConnect.pm---
package DBIConnect;
use strict;
$DBIConnect::db = ...;
1;
---DBIConnect.pm---

---script---
use strict;
use DBIConnect;
my $sv = $DBIConnect::db->select(...);
---script---


Placing it in a package will make life easier later, trust me.

You could also use the Exporter module to export the db variable so
that you wouldn't have to use the package name in the scripts.

perldoc Exporter

-- 
Sam Holden


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

Date: Tue, 16 Dec 2003 06:41:45 GMT
From: "Sebastien B." <nomorespam@nomorespam.nospam>
Subject: Re: How to make global vars?
Message-Id: <JOxDb.39151$ea%.30290@news01.bloor.is.net.cable.rogers.com>

Ok I see; the $DBIConnect::db wasn't part of my earlier attempts; probably
why I couldn't get it to work.

I'll use a package as you've described. Thanks.



"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnbtt0o5.bg2.sholden@flexal.cs.usyd.edu.au...
> On Tue, 16 Dec 2003 03:16:08 GMT,
> Sebastien B. <nomorespam@nomorespam.nospam> wrote:
> > I'm trying to figure out how to use/make simple global vars.
> >
> > Since I have multiple scripts that connect to database, I want to use a
> > seperate file that does the connection and call it in the other scripts;
so
> > something like:
> >
> > dbiconnect.pl:
> > use strict;
> > use DBI;
> > my $db=dbi_connect.....
> > 1;
> >
> > and then in the scripts:
> >
> > use strict;
> > require 'dbiconnect.pl';
> > my $somevar=$db->select(...);
> >
> >
> > problem is that $db isn't global; how do I make it global? Do I need to
make
> > the first script into a pakage? How? (tried it didn't work). None of the
> > docs are clear on global (cross-file) vars specifically.
>
> perldoc -f my
>
> Notice it specifically says that my declares a local variable, hence
> using my to create a global isn't going to work.
>
> perldoc strict
>
> Notice, the "strict vars" section and how to declare or use a non-my
> variable when running under it.
>
> perldoc -f our
>
> Notice that while is declares a global variable, it only does so within
> a scope, a sort of local global :)
>
>
> So when under strict you can use "use vars" (which is marked as
> obsolete, but the replcement, our, doesn't work for this case). Or you
> can use the fully qualified name as in:
>
> ---DBIConnect.pm---
> package DBIConnect;
> use strict;
> $DBIConnect::db = ...;
> 1;
> ---DBIConnect.pm---
>
> ---script---
> use strict;
> use DBIConnect;
> my $sv = $DBIConnect::db->select(...);
> ---script---
>
>
> Placing it in a package will make life easier later, trust me.
>
> You could also use the Exporter module to export the db variable so
> that you wouldn't have to use the package name in the scripts.
>
> perldoc Exporter
>
> -- 
> Sam Holden




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

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


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