Config file

2003-12-02 Thread Rod
What is the best way to read a config file for a perl script.  I have 
some very ugly code that can do it, but I would like to find something 
cleaner.

Thanks,
Rod.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Match the first 3 characters of 2 words?

2003-12-10 Thread Rod
What is the easiest way to test the first 3 characters of two words for 
a match.

IE:  "dasf" test "dasg" to return positive.

rod.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



RE: Splitting string using split()

2001-07-17 Thread Crowder, Rod

There is a module Text::CSV_XS that handles (surprise!) CSV files, which
understands quoted strings with commas. I can make it work, so it must be
easy

-Original Message-
From: Mike Miller [mailto:[EMAIL PROTECTED]]
Sent: 18 July 2001 02:47
To: [EMAIL PROTECTED]
Subject: Splitting string using split()



Gurus:

I have a string like this:

$s = '[EMAIL PROTECTED], "Blow, Joe" <[EMAIL PROTECTED]>,Joe Blow
<[EMAIL PROTECTED]>'

And I want to be able to split it up.  Using split, like this:

my @addresses = split(/, ?/, $s);

But obviously this causes a problem because of the comma inside the
quotes.  I want three parts, and it splits it into four.  Is there
some module or nice way to have the commas inside quotes ignored?

Reply to [EMAIL PROTECTED] if possible as I'm only getting
the daily digest of this list.

Thanks,

-Mike

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Sending a mail using telnet 25 smtp(OT)

2001-07-24 Thread Crowder, Rod

A simple example of sending mail using telnet. this sends mail to
[EMAIL PROTECTED] The bits you send are in braces {},
you do not type these!! Some hosts may be more fussy, they check that the
hostname you give and the IP address match, and may only accept mail from a
restricted list of hosts. sendmail configuration is a black art all by
itself. 


{telnet remotehost.domainname.com 25}
220- remotehost.domainname.com Sendmail 940816.SGI.8.6.9/940406.SGI ready at
Tue, 24 Jul 2001 07:52:08 +0100
220 ESMTP spoken here
{HELO myhostname}
250 cadsrv1.amec-bkw.amec.co.uk Hello [10.18.254.151], pleased to meet you
{MAIL FROM: testuser}
250 testuser... Sender ok
{RCPT TO: receivername}
250 receivername... Recipient ok
{DATA}
354 Enter mail, end with "." on a line by itself
{THis}
{is}
{a}
{test}
{.}
250 HAA05197 Message accepted for delivery
{quit}
221 remotehost.domainname.com closing connection


-Original Message-
From: Ms takara us [mailto:[EMAIL PROTECTED]]
Sent: 21 July 2001 10:13
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE:Sending a mail using telnet 25 smtp(OT)


Hi Everyone,
 This is an off topic question. But i am curious
to know the solution and so please no flames!!!
  Few days back (6th july to be precise) Anton and
George S Pereira were discussing that  anyone can send
mails using the telnet 25 smtp. Can someone elaborate
on this. I mean what will you do to avoid this in your
mailserver.
Waiting for your replies/flames in anticipation
;- )

Takara

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Sending a mail using telnet 25 smtp(OT)

2001-07-24 Thread Crowder, Rod

A simple example of sending mail using telnet. this sends mail to
[EMAIL PROTECTED] The bits you send are in braces {},
you do not type these!! Some hosts may be more fussy, they check that the
hostname you give and the IP address match, and may only accept mail from a
restricted list of hosts. sendmail configuration is a black art all by
itself. 


{telnet remotehost.domainname.com 25}
220- remotehost.domainname.com Sendmail 940816.SGI.8.6.9/940406.SGI ready at
Tue, 24 Jul 2001 07:52:08 +0100
220 ESMTP spoken here
{HELO myhostname}
250 cadsrv1.amec-bkw.amec.co.uk Hello [10.18.254.151], pleased to meet you
{MAIL FROM: testuser}
250 testuser... Sender ok
{RCPT TO: receivername}
250 receivername... Recipient ok
{DATA}
354 Enter mail, end with "." on a line by itself
{THis}
{is}
{a}
{test}
{.}
250 HAA05197 Message accepted for delivery
{quit}
221 remotehost.domainname.com closing connection


-Original Message-
From: Ms takara us [mailto:[EMAIL PROTECTED]]
Sent: 21 July 2001 10:13
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE:Sending a mail using telnet 25 smtp(OT)


Hi Everyone,
 This is an off topic question. But i am curious
to know the solution and so please no flames!!!
  Few days back (6th july to be precise) Anton and
George S Pereira were discussing that  anyone can send
mails using the telnet 25 smtp. Can someone elaborate
on this. I mean what will you do to avoid this in your
mailserver.
Waiting for your replies/flames in anticipation
;- )

Takara

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: perl debugger

2001-08-03 Thread Crowder, Rod

-Original Message-
From: Ruth Albocher [mailto:[EMAIL PROTECTED]]
Sent: 02 August 2001 10:56
To: [EMAIL PROTECTED]
Subject: perl debugger


hi all.
Is there any good stable graphic debugger for perl?
thanks



Try the one in the ActiveState Perl Dev Kit. 
You can download and try it for free before you buy

http://www.activestate.com/Products/Productivity/Perl_Dev_Kit/index.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: inquiry

2001-08-21 Thread Crowder, Rod



> -Original Message-
> From: webmaster [mailto:[EMAIL PROTECTED]]
> Sent: 21 August 2001 14:48
> To: perl
> Subject: inquiry
> 
> 
> what does
> Global symbol "@ARG" requires explicit package name at 
> testbio1.pl line 4.
> Global symbol "$sbjct_scr" requires explicit package name at 
> testbio1.pl 
> line 29
> .
> Global symbol "%query_conunts" requires explicit package name at 
> testbio1.pl lin
> e 46.
> Global symbol "$sbjct_srs" requires explicit package name at 
> testbio1.pl 
> line 48
> mean?
You are using strict, which is checking that only declared variables are
being used,
and in your source these have been misspelt.  

> and why on this lines I am getting a comp error...
> {
>   while ($query_src=~ /$pattern/g)
>   {
> $query_conunts{$pattern}++;
>   }
>   wile ($sbjct_srs=~ /$pattern/g)
This should be while
>   {
> $sbjct_counts{ $pattern }++;
>   }
> }
>  the whole wource code is here:
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Strange foreach need..........

2001-08-24 Thread Crowder, Rod

Gary

Do you need to read the file into the array, why not process the file
directly

eg

while (<>) {
$first = $_;
$second = <>;
chomp $first;
chomp $second;
# Do your stuff here
printf ("First Line = %s, Second line = %s\n",$first, $second);
}



Rod the IFFO
 
Mailto:[EMAIL PROTECTED]
Tel: +44-1293-584145
Mob: +44-7711-553080
Fax: +44-1293-584994



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: sendmail and newlines

2001-08-24 Thread Crowder, Rod



> -Original Message-
> From: Wendy DeCora [mailto:[EMAIL PROTECTED]]
> Sent: 23 August 2001 16:13
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: sendmail and newlines
> 
> 
> Situation:  My perl script (see Code: below) is being
> handed a flatfile (see File: below) generated from a
> database to do a mass mailing that will send a message
> generic to the flatfile but with each recepient
> receiving a unique username and password.
> The message part of the file is being input by a list
> administrator through an oracle tool (I think, I
> didn't develop that in anyway) and the ability to have
> newlines is necessary for formatting.  The problem is
> when this message is dumped into the flatfile, the
> newlines are still in it and cause the script to go
> nuts.
> 
> My idea was to have the newlines in the message
> replaced with \\n before being put into the flatfile
> (which is what I have done in my test file).  I then
> attempt to replace the \\n with \n in the $message
> field for sending.
> 
> It kind of works. (see Output: below) I get the
> newlines now, but i also get one \ just out there.  I
> have tried many variations, but having \\n and
> replacing with \n seems to be the only way to get a
> newline to work, but how to get rid of the extra \?
> 
> Any suggestions would be very very appreciated.
> TIA


Wendy 

>   $message =~ s|\\n|\n|g;  #replace the escaped newlines with newlines
for formatting


The \\n in your expression is using the first backslash as a logical escape
character to make it literally a backslash, not part of a (\n) pair. Use 


$message =~ s|n|\n|g;  #replace the escaped newlines with
newlines for formatting
 
to represent the two backslashes in you input file

Hope this makes sense


Rod the IFFO
 
Mailto:[EMAIL PROTECTED]
Tel: +44-1293-584145
Mob: +44-7711-553080
Fax: +44-1293-584994

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: remote share disk usage for nt/win2k

2001-09-05 Thread Crowder, Rod

Here's something on those lines That I used with IIS

The user must be a member of "Domain Admins" group

It does a simple check of space left against a limit and highlights disks
under the limit

HTH

Rod


> -Original Message-
> From: John W. Sims [mailto:[EMAIL PROTECTED]]
> Sent: 30 August 2001 05:11
> To: [EMAIL PROTECTED]
> Subject: remote share disk usage for nt/win2k
> 
> 
> IN NT/WIN2K land -
> 
> What is the easiest way list out remote share directories AND 
> their disk
> space usage - similar to the du -s command in UNIX.
> 
> I have been looking at win32::? modules but nothing seems to 
> fit - or is it
> time to create a WSC?  UGH!
> 
> For example I want to UNC path into a server share and build 
> a list of what
> directories are consuming the most spacethis is easy with 
> VBScript using
> file system objects.
> 
> Once you get directories and usage summaries you can feed it 
> in to excel or
> whatever you want - I have that part figured out.  With 
> normal file and
> directory operations (opendir and readdir) I can list remote 
> directories to
> my hearts content - but can't get disk usage info.
> 
> Any ideas would are appreciated!
> 
> JWS
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


 DiskList
 check.pl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


IDE for perl?

2001-05-09 Thread Rod Suter

I'm using perl through emacs, but I want to bring along some people on NT4.0.  They're 
accustomed to Visual Studio, and want IDE features, such as project directories, 
global search and replace, debugger linking, source code error hilighting, etc. Can 
anyone suggest a good group environment for developing perl? My first urge is to set 
up Ultra-Edit with some appropriate customization.



Re: foo bar? -Reply

2001-05-16 Thread Rod Suter

Actually, the American military acronym 'fubar' goes back at least to World War II.  
The use of 'foo' and 'bar' as metasyntactic variables  probably dates to the the lisp 
hackers at the MIT AI lab in the 50's or 60's , before unix.  Foo and bar function 
like 'x'  or 'n' in the traditional mathematical exposition 'let x = n".  They remain 
in common usage in the unix world and its derivatives, because of their brevity and 
style.

>>> Jos Boumans <[EMAIL PROTECTED]> 05/16 8:33 am >>>
it comes from the vietnam war iirc (watch full metal jacket if you want some
'insight' ;-)

it is originally 'fubar' or Fucked Up Beyond Any Recognition (pardon the expletives)

so, us perl geeks use 'foo' and 'bar' as standard variable names in examples now...

So much for a short stroll thru history =)

Regards,

Jos Boumans

ber kessels wrote:

> Hi,
>
> Maybe a silly question but where does foo-bar or foobar refer to?
>
> Everyone uses it in perl, but I cannot find the origin of it.
> I am not english (I am Duch), but even my english teacher didn't know it, he had
>  even never heard of it.
>
> I am just curious that's all.
>
> Thanx for reading
>
> Ber
>
> _
>   STRUIKDUIK IS VERNIEUWD
>   (er staat nu dus iets)
>   http://struikduik.tripod.com
>
>   telefoon: ++31625181320
>   adres: Capadosestraat 51
> 2623 AD
> Den Haag
>
> Get your wireless addressbook at room33. http://room33.com





PPM Errors after update

2001-09-26 Thread Crowder, Rod

I am running Windows 98, a rebuild of my machine after total failure. 
I found discrepancies between the modules that I had installed and what was
showing in the on line docs. 

In an attempt to tidy up my configuration in PPM  I ran

verify --upgrade 

This seems to have broken PPM. It is reporting missing .pm files, which I
found in my temp directory and copied into place by hand but now i get

C:\WINDOWS>ppm
HTML::Parser object version 3.19 does not match bootstrap parameter 3.13 at
D:/P
erl/lib/DynaLoader.pm line 225.
Compilation failed in require at D:/Perl/site/lib/HTML/Entities.pm line 79.
Compilation failed in require at D:/Perl/site/lib/HTML/HeadParser.pm line
70.
BEGIN failed--compilation aborted at D:/Perl/site/lib/HTML/HeadParser.pm
line 70
.
Compilation failed in require at D:/Perl/site/lib/LWP/Protocol.pm line 47.
Compilation failed in require at D:/Perl/site/lib/LWP/UserAgent.pm line 103.
BEGIN failed--compilation aborted at D:/Perl/site/lib/LWP/UserAgent.pm line
103.

Compilation failed in require at D:/Perl/site/lib/PPM.pm line 12.
BEGIN failed--compilation aborted at D:/Perl/site/lib/PPM.pm line 12.
Compilation failed in require at D:\PERL\BIN/ppm line 8.
BEGIN failed--compilation aborted at D:\PERL\BIN/ppm line 8.


Any suggestions how to proceed, other than delete D:\PERL and start again??

Rod CROWDER

Mailto:[EMAIL PROTECTED]
Tel: +44-1293-584145
Mob: +44-7711-553080
Fax: +44-1293-584994
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




File::Basename Under W98

2001-09-27 Thread Crowder, Rod

I am trying to use the File::Basename module to strip off the suffix of a
file, and use the base with different suffixes for output and log files.

if I Give the file name "XYZData.txt", Basename returns the full name not
the "XYZData" string, leaving me with a log file "XYZData.txt.log"

Any Ideas as to what I am doing wrong?


Rod CROWDER

Mailto:[EMAIL PROTECTED]
Tel: +44-1293-584145
Mob: +44-7711-553080
Fax: +44-1293-584994
 



print ("Enter name of source file :");
$SourceFile = <>;
chomp $SourceFile;
open( STDIN, "<$SourceFile") or die;
File::Basename::fileparse_set_fstype("MSWin32");
$BaseName = File::Basename::basename($SourceFile, '\..*');
$ImportFile = $BaseName.".imp";
$LogFile = $BaseName.".log"; 





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Windows drive mapping in perl

2001-09-27 Thread Crowder, Rod

Try the Roth Consulting Win32::AdminMisc Module, there's a whole shedload of
W32 goodies

http://www.roth.net/perl/adminmisc

Don't know if this includes a "Map drive" function, but I have used some of
these with great success

Rod 

> -Original Message-
> From: Chris Garringer [mailto:[EMAIL PROTECTED]]
> Sent: 26 September 2001 17:10
> To: [EMAIL PROTECTED]
> Subject: Windows drive mapping in perl
> 
> 
> Recently I had a problem where I had to loop through a set of 
> shares (actually NetWare servers and volumes), map a drive, 
> execute a program (that requires a drive mapping, UNC will 
> not work), delete the drive mapping.  I could not find a way 
> to map/unmap a drive in Perl.  I ended up calling a batch 
> file and passing server and volume to it.  The batchfile then 
> mapped the drive, called the program , and deleted the drive. 
>  I had to use the same basic system for another purpose and 
> really would like to eliminate the batch file.  Under the 
> current setup, the success/failure of the program is not 
> available, nor any other debugging info.  Is there a call to 
> map a drive for Windows in Perl ?  I am using ActivePerl v5.
>  
> Chris D. Garringer
> LAN/WAN Manager
> Master Certified Netware Engineer
> Microsoft Certified Systems Engineer
> Certified Solaris Administrator
> Red Hat Certified Engineer
> [EMAIL PROTECTED] 
> fax 713-896-5266
> 
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: eval problem

2001-10-02 Thread Crowder, Rod

 


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 01 October 2001 15:16
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: eval problem
> 
> 
> 
> 
> Hi everybody,
> 
> I am facing a little problem with eval in perl.
> 
> say I do the following:
> 
>  $a = "print \"hi\""
> > eval($a)
> hi> $b = eval($a)
> hi> print $b
> 1>
> 
> The above piece of code, prints the output of eval statement 
> on the STDOUT, and
> I only get the return status of the EXPR in eval statement.
> But I have no way to capture this output in some variable.
> 
> Instead of this behaviour of eval, Can I get what I want 
> .i.e.. Can I capture
> the output in some variable.
> Like here I am printing "hi" on stdout. But I want this "hi" 
> to be stored in
> some variable also.
> 
> Please help,
> 
> TIA,
> -Mini.


Rather than use the eval command, use backticks like this

$A = `echo "Hello World"`;
print "Command has run, \$A is:";
print $A;

$A will contain the output of the command executed inside the backticks

HTH


Rod the IFFO
 
Mailto:[EMAIL PROTECTED]
Tel: +44-1293-584145
Mob: +44-7711-553080
Fax: +44-1293-584994

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Copy file output to a text file

2001-10-04 Thread Crowder, Rod

Unless you need to create the file for any other reason, you should be able
to use backticks to capture the output of the command to a variable, the
simply ( yeah right :-) ), use a reg exp to strip it out

eg 

$ConfigString = `ifconfig ppp0`

The variable $ConfigString will now contain the output from the ifconfig
command.

You should now be able to separate the part you need with pattern matching.

HTH

Rod the IFFO

> -Original Message-
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: 04 October 2001 08:20
> To: [EMAIL PROTECTED]
> Subject: Copy file output to a text file
> 
> 
> > List,
> > 
> > I have this problem that has been bothering me all day.  
> All I want is
> > to be able to copy the out put of ifconfig to a text file
> > /etc/ppp/ppp.txt
> > 
> > I have tried so many things but I can't get it to work.  Once I have
> > done this I need to be able to extract the ADSL ip address from ppp0
> > and then store that in a variable.
> > 
> > Is this possible or am I wasting my time?
> > 
> > Dan
> > 
> > ==
> > VINTEK CONSULTING PTY LTD
> > (ACN 088 825 209)
> > Email:  [EMAIL PROTECTED]
> > WWW:http://www.vintek.net
> > Tel:(08) 8523 5035
> > Fax:(08) 8523 2104
> > Snail:  P.O. Box 312
> > Gawler   SA   5118
> > ==
> > 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Use of XML::Simple and hashrefs

2001-10-05 Thread Crowder, Rod

Folks, 

I am using XML::Simple to let me parse a config file. I include copies of
the code and the XML file in question.

My question is how to get at the Project name values, in a list or as the
keys to a hash.

I have tried perldoc perlref, which has not helped me.

Can anyone:

a) show me how to get this working
b) point me to a "Janet & John" type explanation of references


TIA

Rod the IFFO




===XML=




Transfer from Elsewhere


Transfer from Elsewhere



Code==

use strict;
use warnings;

use XML::Simple;
use Data::Dumper;

my $config = XMLin();

print Dumper($config);

my %ProjList = $config->{Project}->{name};


foreach my $key (keys %ProjList) {
print $ProjList{$_};
}

my $ConveroRmk = $config->{Project}->{EP1002}->{Rmk};
print $ConveroRmk;


Rod CROWDER

Mailto:[EMAIL PROTECTED]
Tel: +44-1293-584145
Mob: +44-7711-553080
Fax: +44-1293-584994
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Use of XML::Simple and hashrefs

2001-10-05 Thread Crowder, Rod

Answered thesemy self, but in case it helps any one else


> 
> Folks, 
> 
> I am using XML::Simple to let me parse a config file. I 
> include copies of
> the code and the XML file in question.
> 
> My question is how to get at the Project name values, in a 
> list or as the
> keys to a hash.
> 
> I have tried perldoc perlref, which has not helped me.
> 
> Can anyone:
> 
> a) show me how to get this working

use strict;
use warnings;

use XML::Simple;
use Data::Dumper;

my $config = XMLin();

print Dumper($config);

my %ProjList = %{$config->{Project}};


foreach my $key (keys %ProjList) {
print $key,"\n";
print   %{$ProjList{$key}}->{'Rmk'};
print "\n";
}

my $ConveroRmk = $config->{Project}->{EP1002}->{Rmk};
print $ConveroRmk;

> b) point me to a "Janet & John" type explanation of references
> 

perldoc perlreftut

Next time, like the FAQ says I will RTFM first

Rod

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Getting a module to work

2001-10-30 Thread Crowder, Rod



> -Original Message-
> From: Simon Rowan [mailto:[EMAIL PROTECTED]]
> Sent: 29 October 2001 16:43
> To: [EMAIL PROTECTED]
> Subject: Getting a module to work
> 
> 
> Ok, I give up. How do I install a new module?
> 
> I am using Activeperl 5.6 (Build 631) and have downloaded a module
> Win32:AdminMisc. This is not one of the modules you can 
> install simply using
> ppm.
> 

Try www.roth.net/perl/packages as your repository.

in ppm

PPM> install --location=http://www.roth.net/perl/packages Win32-AdminMisc
Install package 'Win32-AdminMisc?' (y/N): y
Installing package 'Win32-AdminMisc'...
.
..


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Off-Topic (200%) - Where are you from?

2001-11-12 Thread Crowder, Rod

Crawley, Sussex, UK (Next to Gatwick airport)

> -Original Message-
> From: PURMONEN, Joni [mailto:[EMAIL PROTECTED]]
> Sent: 12 November 2001 14:10
> To: '[EMAIL PROTECTED]'
> Subject: RE: Off-Topic (200%) - Where are you from?
> 
> 
> hey, Yet Another Finn here as well (although currently stuck 
> in Oxford,
> UK...).
> 
> Joni
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 11 November 2001 19:15
> To: [EMAIL PROTECTED]
> Subject: Re: Off-Topic (200%) - Where are you from?
> 
> 
> On Fri, 9 Nov 2001, Etienne Marcotte wrote:
> 
> Lapland, Finland!
> 
> Scott
> 
> 
> > By reading the messages everyday I can guess most of us are 
> from United
> > States right? And since there are not a lot of messages in 
> (my) morning
> > time, probably means most are from the west coast 
> (different timezone).
> >
> > Am I right?
> >
> > I'm from Quebec, Canada.. and you?
> >
> > Sorry if it's way off topic, I hope the ones that hate OT subject
> > filtered *off*topic* in their  emails!
> >
> > Etienne
> >
> >
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Redirecting STDERR to 2 locations simultaneously

2001-11-13 Thread Crowder, Rod

Try the Module IO::Tee, I haven't used it, but it's description sounds to be
what you need



> -Original Message-
> From: Peter Scott [mailto:[EMAIL PROTECTED]]
> Sent: 13 November 2001 07:01
> To: [EMAIL PROTECTED]
> Subject: Re: Redirecting STDERR to 2 locations simultaneously
> 
> 
> 
> >I have been trying to figure out if it possible to redirect 
> STDERR to 2 
> >locations at once.  Specifically, I want certain errors to 
> be redirected 
> >to both STDOUT and a log file.  I have been unable to do 
> this, and am not 
> >even sure it is possible.
> >
> >Redirecting to one or the other is now problem, but a 
> solution that allows 
> >me to redirect to both simultaneously remains elusive.  Any 
> thoughts or 
> >suggestions would be appreciated.  Thanks
> 
> If you're on Unix, look up the 'tee' command.
> --
> Peter Scott
> Pacific Systems Design Technologies
> http://www.perldebugged.com
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Off-Topic (200%) - Where are you from?

2001-11-14 Thread Crowder, Rod



> -Original Message-
> From: Michael Fowler [mailto:[EMAIL PROTECTED]]
> Sent: 13 November 2001 21:15
> To: Elliott, Don (Police)
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: Off-Topic (200%) - Where are you from?
> 
> 
> On Tue, Nov 13, 2001 at 02:51:01PM -0600, Elliott, Don (Police) wrote:
> > Having fun in Saskatoon, Saskatchewan, Canada
> > It's mid November, no snow and still above freezing
> 
> Oh ye of the Lesser North.  It's mid-November, our 
> temperatures are hovering
> between zero and freezing, and I believe we've had between 2 
> and 3 feet of
> snow so far.
> 
> I'm just glad I'm not in Fairbanks or, heaven forbid, 
> somewhere farther
> north.


So where are you ?



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: witing to %ENV permanently

2001-11-19 Thread Crowder, Rod

The environment var you set is only available to the perl program and any
child processes it produces. 
Try calling the Tecplot macros from within your perl program using system()
or the backtick method. 

HTH

Rod C

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: writting in a file

2001-11-21 Thread Crowder, Rod



> -Original Message-
> From: Franck Collineau [mailto:[EMAIL PROTECTED]]
> Sent: 20 November 2001 13:57
> To: [EMAIL PROTECTED]
> Subject: writting in a file
> 
> 
> Hi!
> 
> I have the follwing code:
> 
> #!/usr/bin/perl -w
> open(FIC,"/home/collineau/Perl/Programmes/01_informatique/sauv
> e/c0111_05.htm") 
> || die "Impossible d'ouvrir $!\n";
> open 
> (TEMP,">/home/collineau/Perl/Programmes/01_informatique/sauve/
> temp.htm") 
> || die "Impossible d'ouvrir $!\n";
> while ()
> {
>   print  (TEMP $_);

Should be print TEMP $_;


>   
> }
> 
> 
> 
> The temp.htm file is empty !!
> 
> Can anybody help me ?
> 
> 
> Franck
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Outputing data for Excel / PDF

2001-11-26 Thread Crowder, Rod

Goto http://search.cpan.org and search for PDF, gives a number of modules
relating to PDF files. I have not used these, so I can't make any
recommendations.

-Original Message-
From: paul beckett (JIC) [mailto:[EMAIL PROTECTED]]
Sent: 26 November 2001 15:02
To: [EMAIL PROTECTED]
Subject: Outputing data for Excel / PDF
Importance: High


I need to write some data out in two different formats:
1) As a microsoft excel file
2) As an adobe acrobat PDF file
Does anybody know if there are modules that can do this? I've tried looking
at http://www.cpan.org without much success

Thanks

Paul

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Re[2]: create an NT user with Perl

2001-12-04 Thread Crowder, Rod


Here Is a sample user setup script (A work in progress) which I wrote for
setting up new users. 

Win32::AdminMIsc is available from www.roth.net and is well worth a look for
anyone involved in the admin of a M$ notwork.

Rod Crowder
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 04 December 2001 12:36
To: 'Maxim Berlin'; [EMAIL PROTECTED]
Subject: RE: Re[2]: create an NT user with Perl


Or take a look at the Win32::Lanman module. He asked for a solution in Perl
and there is one...

-Original Message-
From: Maxim Berlin [mailto:[EMAIL PROTECTED]]
Sent: 04 December 2001 12:37
To: [EMAIL PROTECTED]
Subject: Re[2]: create an NT user with Perl


Hello Jorge,

Tuesday, December 04, 2001, Jorge Goncalvez <[EMAIL PROTECTED]>
wrote:

JG> HI, I wonder if there is a way to create an NT user with Perl?

take a look at net.exe program.
try
net help
net help user

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




adduser.pl
Description: Binary data

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Working with Perl Modules

2001-12-07 Thread Crowder, Rod

Do you have Active State's perl? The package is available using PPM from
their repository, and shouldn't need any compilation.

-Original Message-
From: Sharat Hegde [mailto:[EMAIL PROTECTED]]
Sent: 07 December 2001 06:45
To: [EMAIL PROTECTED]
Subject: Working with Perl Modules


Hello,

I have been using Perl for some time but have not yet used the Perl modules.

I wanted to start off with the HTML::Template module - it will save me a lot

of effort if I can use it. I need to get this working on Windows (where I do

my development) as well as on my 3rd party shared host (where I do not have 
control over directories in my domain).

I have downloaded the template files to my Windows desktop but I am unable 
to "make" the module. I do not have a C compiler or the make utility. I 
downloaded the GNU make, but I think I will need to compile this with a C 
compiler which I do not have (-:

So the question is: how do I get the Perl module running on my Windows 
desktop as well as on the 3rd party shared host.

Thanks in advance.

With Regards,
Sharat


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: chomp

2001-12-19 Thread Crowder, Rod

No, 

chomp removes any "\n" at the end of a string. 

see perldoc -f chomp

Rod

-Original Message-
From: Purshottam Chandak [mailto:[EMAIL PROTECTED]]
Sent: 19 December 2001 08:05
To: [EMAIL PROTECTED]
Subject: chomp


If I type,  
$date = 19990417; 
chomp $date; - 
will every variable contain a newline after the semi-colon?

Pc
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Parsing binary file.

2004-06-15 Thread Rod Za
Hello all,

I am trying to read a binary file (HP-PCL file
(windows printer)) to count  the number of pages and
copies.

Can someone help me?

I got a C code that works good - but i want to do that
in Perl to learn.

thank you very much.

Rod Za



__
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




How to creating a package.

2004-06-16 Thread Rod Za
Hi, i like to create somethings like classes in an OOP language.
The code below is correct?

_BEGIN_
package PACKAGE_NAME;
use strict;
use warnings;
our $VERSION = '0.1';
sub new{
my $self = {};
 $self->{SOME_VAR} = undef; 
 $self->{SOME_VAR2} = undef;
bless $self;
return $self;
}

sub init{
my $self = shift;
$self->{SOME_VAR} = shift;
$self->{SOME_VAR2} = shift;
return $self;
}

sub SOME_SUB{
   my $self = shift;
   my $sum = ($self->{SOME_VAR} * $self->{SOME_VAR2});
   return $sum;
}
1;
_END_

what the 'bless' do?

thank you



__
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




regex in perl.

2004-06-17 Thread Rod Za
Hello,

Someone know how can i search this in a file using regex?
%! or \004%! or \033%-12345X%!PS or LANGUAGE=POSTSCRIPT or LANGUAGE = POSTSCRIPT or 
LANGUAGE =
Postscrip

Thank you

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Class to select/insert/delete/update

2004-06-24 Thread Rod Za
Hello,

i'm trying to make a class to do select/insert/delete/update on a MySQL table (via 
DBI).
this is a snip of code:

sub query{
my $self = shift;
my($sql) = @_;
my @result;
my $sth = $self->{dbh}->prepare($sql) or return undef;
if($sql =~ /delete|insert/gi){
$sth->execute() or return undef;
my $rows = $sth->rows;
($rows == 0) ? "0E0" : $rows;
} else {
$sth->execute() or return undef;
my @row;
while(@row = $sth->fetchrow_array){
foreach my $i (0..$#row){
push(@result,$row[$i]);
}
}
$sth->finish();
return @result;
}
}

I like to receive an opnion or someone to indicate me something similars.

Thnak you

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




ways to change the first char from a filename (with full path)

2004-06-29 Thread Rod Za
Hi all,

i'm trying to make a code that get a file name (with full path) and change the first 
char of the
filename. Someone can say me if there's a better way to do this?:

_BEGIN_
#!/usr/bin/perl -w
my($file) = $ARGV[0]; #receives the filename
my @tmp = split(/\//,$file);  #split the path
$tmp[$#tmp] =~ s/.(\w+)/c$1/g;#change the first char of the filename
my $IPPFile = join('/',@tmp); #join again path+'/'+filename
print "Original Filename: $file - Changed Filename: $IPPFile\n"; #print the result
_END_

e.g. ./filename.pl /var/spool/cups/d1
will print:

Original Filename: /var/spool/cups/d1 - Changed Filename: /var/spool/cups/c1

Thank you.

Rod






__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: ways to change the first char from a filename (with full path )

2004-06-29 Thread Rod Za
Bob and Thomas,

Thank you, very much.

Rod Za

--- Bob Showalter <[EMAIL PROTECTED]> wrote:
> Rod Za wrote:
> > Hi all,
> > 
> > i'm trying to make a code that get a file name (with full path) and
> > change the first char of the filename. Someone can say me if there's
> > a better way to do this?: 
> > 
> > _BEGIN_
> > #!/usr/bin/perl -w
> 
>   use strict;
> 
> > my($file) = $ARGV[0]; #receives the filename
> 
>   my $file = shift;(the traditional idiom)
> 
> > my @tmp = split(/\//,$file);  #split the path
> 
>   use File::Basename;
>   my ($name, $path) = fileparse($file);   (more portable)
> 
> > $tmp[$#tmp] =~ s/.(\w+)/c$1/g;#change the first char of the
> > filename 
> 
>   substr($name, 0, 1) = 'c';   (no need for regex)
> 
> > my $IPPFile = join('/',@tmp); #join again path+'/'+filename
> > print "Original Filename: $file - Changed Filename: $IPPFile\n";
> > #print the result _END_
> 
>   use File::Spec
>   print "Original name: ", $file,
> " Changed name: ", File::Spec->catfile($path, $name), "\n";
> 
> You might also have a look at the ubiquitous (and ancient) perl "rename"
> script: http://www.cpan.org/scripts/nutshell/ch6/rename
> 




__
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




how to load the printer jobs number.

2004-06-30 Thread Rod Za
Hi,

Anyone got a suggestion on how i can load the jobs in a printer?

i use somethings like this:
@jobs= `/usr/bin/lpstat -P HP2200V | cut -d"-" -f2 | cut -d" " -f1`;

this show me something like this:

3259
3260

that are the number of the job for the HP2200V

There are other way to do that?

thank you



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




function that returns a HASH.

2004-06-30 Thread Rod Za
Hi all,

I'm trying to use the Net::CUPS::Printer::cupsGetJobs() function. In theory this 
function returns
the jobs a cups printer got printed or to be printed.

I'm using this like:
_BEGIN_
use Net::CUPS::Printer;
my %jobs = cupsGetJobs('HP4100V',0,0);
foreach $key (keys %jobs){
print $jobs{$key};
}
_END_

and the function always returns somethings like this:
HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8)

How can i get this results in an human redable mode?

Thank's



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: function that returns a HASH.

2004-06-30 Thread Rod Za
Oliver, this is wanderful! :)

Thank you very much!

--- Oliver Schnarchendorf <[EMAIL PROTECTED]> wrote:
>   to see what's going on in structured data types I strongly recommend the use 
> of DATA::DUMPER.
> 
>   Just include the module into your source code and when you print the $jobs you 
> just change your
> line to the following:
> 
>   print Dumper( $jobs{$key} );
> 
>   The statement will print back the data structure with it's keys, instead of 
> just giving you the
> data type and it's position in memory. Once you know which data key you want to 
> access you can
> try the following:
> 
>   print $jobs{$key}->{$data_key};
> 
>   Hope this helps.
> 
> /oliver/
> 
> --
> "If you believe everything you read, you better not read." -Japanese Proverb
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 
> 




__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: function that returns a HASH.

2004-06-30 Thread Rod Za
ok, i got the response:

> > and the function always returns somethings like this:
> > HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8)

It's returning a reference to a hash. You can grab that reference into a scalar:

   my $hash_ref = function();

And then access it by de-referencing the reference:

   foreach my $key( keys %$hash_ref ) {
   print $hash_var->{$key};
   }

Or you can de-reference the hash ref when you call function:

my %hash_var = %{ function() };

and access the values of %hash_var as you've written above.

You may like to 'perldoc -f values' to see how to simplify both loops to something 
like this:

foreach my $val ( values %$hash_ref ) {
 print $val;
}

perlreftut and perlref, both available via perldoc, explain references in more detail. 
I'd suggest
starting with perlreftut;
you can skip straight to the section labeled 'Syntax' if the history of references in 
perl isn't
interesting to you.

at london.pm.org

--- Oliver Schnarchendorf <[EMAIL PROTECTED]> wrote:
> On Wed, 30 Jun 2004 11:44:53 -0700 (PDT), Rod Za wrote:
> > and the function always returns somethings like this:
> > HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8)
> > 
> > How can i get this results in an human redable mode?
> Hello Rod,
> 
>   to see what's going on in structured data types I strongly recommend the use 
> of DATA::DUMPER.
> 
>   Just include the module into your source code and when you print the $jobs you 
> just change your
> line to the following:
> 
>   print Dumper( $jobs{$key} );
> 
>   The statement will print back the data structure with it's keys, instead of 
> just giving you the
> data type and it's position in memory. Once you know which data key you want to 
> access you can
> try the following:
> 
>   print $jobs{$key}->{$data_key};
> 
>   Hope this helps.
> 
> /oliver/
> 
> --
> "If you believe everything you read, you better not read." -Japanese Proverb
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
> 




__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Fill a string with zeros.

2004-07-02 Thread Rod Za
Hi all,

Someone knows an way to do this more easy?

_BEGIN_
#!/usr/bin/perl
use warnings;
use strict;
my $job = 15;
my $job_name = 'd0';
print "JOBNAME $job_name LENGTH: ".length($job_name)."\n";
print "JOB...: $job  LENGTH: ".length($job)."\n";
print substr($job_name,-length($job_name),-length($job)).$job."-001\n";
_END_

_RESULT_
JOBNAME d0 LENGTH: 6
JOB...: 1  LENGTH: 1
d1-001
1JOBNAME d0 LENGTH: 6
JOB...: 10  LENGTH: 2
d00010-001
1JOBNAME d0 LENGTH: 6
JOB...: 100  LENGTH: 3
d00100-001
1JOBNAME d0 LENGTH: 6
JOB...: 1000  LENGTH: 4
d01000-001
1JOBNAME d0 LENGTH: 6
JOB...: 1  LENGTH: 5
d1-001
_RESULT_

thank's



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Fill a string with zeros.

2004-07-02 Thread Rod Za
Hey Philipp, this is was i need! :)

--- Philipp Traeder <[EMAIL PROTECTED]> wrote:
> On Friday 02 July 2004 15:55, Rod Za wrote:
> Hi Rod,
> 
> take a look at the sprintf function ("perldoc -f sprintf") - something like:
> 
> #!/usr/bin/perl -w
> use strict;
> my $shortnumber = '10';
> my $longnumber = '1000';
> print sprintf("shortnumber : %06d\n", $shortnumber);
> might do the trick.
> 
> BTW: It's easier to help if you specify what you want to do - in this case it 
> didn't matter much, but it can take some time to understand what a piece of 
> code should be doing... ;-)

Sorry, i'm not too much clear. What i'm needed is to fill a var (with fix length) with 
zeros and
the sprintf works perfectly. Thank you very much




__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Help with HASH.

2004-07-02 Thread Rod Za
Hello all,

I want to make a function to list all jobs name from a printer.
The format of the jobs name is like d1-001, d2-001.
To list all the jobs and get the correct job name, i use the lpstat command, that 
returns me lines
like this one: 
_DATA_
HP4100V-4   rodza  2597888   Seg 21 Jun 2004 12:56:56 BRT
_DATA_

in the first camp i got the printer name (HP4100V) followed by the job numer 
(separated by -), the
owner of the job, the job length in bytes and the started job data.

What i mean here is to use a hash with 2 camps: 'name' and 'jobs'. In the 'name' i put 
the printer
name. In the 'jobs' i put a hash reference that got the job name like his key 
associated with the
owner job name.

well, i write this code that are not working::

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

sub lst_job{ # this sub list all the jobs name from a printer
my ($printer) = @_;
my @lpstat = `lpstat -P $printer`;
my %jobs;
#here i assembly the job name (like d1-01) 
for(my $i=0; $i < @lpstat; $i++){
$lpstat[$i] =~ /\w+\-(\d+)\s+(\w+)\s+/;
$jobs{sprintf("d%05d-001",$1)} = $2;
} 
my %printer = ( name => $printer,
jobs => \%jobs,
);
   return %printer;
}

my %printers = lst_job("HP4100V");
print "The printers: ".$printers{name}." got this job(s):\n";
foreach my $keys (keys $printers{jobs}){
print $printers{jobs}->{$key}."\n";
};
_END_

this is the error i got:

_ERROR_
Type of arg 1 to keys must be hash (not hash element) at printer.pm line 61, near "})"
_ERROR_

Can someone help me?

Thanks



__
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Help with HASH.

2004-07-02 Thread Rod Za

--- Wiggins d Anconia <[EMAIL PROTECTED]> wrote:
[snip]
> > _BEGIN_
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
> 
> Excellent start...

:) thank you

[snip]
> > for(my $i=0; $i < @lpstat; $i++){
> > $lpstat[$i] =~ /\w+\-(\d+)\s+(\w+)\s+/;
> > $jobs{sprintf("d%05d-001",$1)} = $2;
> > } 
> 
> This will work and is very Cesque, to make it more Perlish you might
> consider a foreach loop,
> 
> foreach my $job (@lpstat) {
>   $job =~ /./;
>blah blah blah...
> }
> 
> For me it is a bit more readable, but to each their own.

:) i'm accustoming with perl :) sometimes foreach makes me confused :)

[snip]
> In the above line, as the error suggests 'keys' must take a hash as its
> argument, $printers{jobs} is a scalar, so essentially you need to
> dereference its value back into a hash, ending up with,
> 
> foreach my $keys (keys %{ $printers{jobs} }) {
[snip]

Was that! Every time a hash reference is returned i need to derefence! Oh! god! 
Is this kind of reference like the C pointer, or something like this?

> ...
> 
> > print $printers{jobs}->{$key}."\n";
> 
> If you use $keys in the loop, then $key will throw a syntax error with
> strict on, one should be plural the other shouldn't, which I was going
> to suggest for readability anyways (aka make $key singular).
[snip again]

Wiggins, thank you very much! 





__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Help with HASH.

2004-07-02 Thread Rod Za
--- Wiggins d Anconia <[EMAIL PROTECTED]> wrote:
> > You only have to dereference if you are trying to do something to the
> > structure in aggregate, aka you have to supply a hash, such as is the
> > case for 'keys', 'values', and 'each'.  If you want to access a single
> > value from the nested hash, you can access it directly using the little
> > arrow syntax,
> > 
> > $printers->{jobs}->{4};

Yes, now i got it.

> 
> Dammit, $printers is not a hash reference, so the above will not work
> (boy everyone can see how I normally do it ;-)), for your example that
> should read,
> 
> $printers{jobs}->{4};

Using my example, the followed works perfectly:

$printers{jobs}->{'d00011-001'};


> Which going back to your post, I see you already had. Sorry for the noise,

Thank you very much Wiggins.



__
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Help with HASH.

2004-07-02 Thread Rod Za
Wiggins,

just one more thing, how can i get the number of elements from an hash like this one 
that i'm
trying to use?

--- Wiggins d Anconia <[EMAIL PROTECTED]> wrote:
> > > > foreach my $keys (keys %{ $printers{jobs} }) {




__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Help with HASH.

2004-07-05 Thread Rod Za
Hey John, 

Thank you very much for the hints.

--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
[snipped]
> sub lst_job {
> my $printer = shift;
> my $flag;
> return name => $printer, jobs => {
> map +( $flag = !$flag ) ? sprintf( 'd%05d-001', $_ ) : $_,
> map /^\w+-(\d+)\s+(\w+)\s+/,
> `lpstat -P $printer`
> }
> }
> 
[snipped]

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




how to date/time transforming

2004-07-05 Thread Rod Za
How to transform a date in format:

Thu Jan 18 03:45:50 GMT 1973
or
Qui 01 Jul 2004 21:39:21 BRT

to format: 

1973-01-18  / 2004-06-01

thank you

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: how to date/time transforming

2004-07-05 Thread Rod Za
Gunnar, 

--- Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:
> Rod Za wrote:
> > How to transform a date in format:
> > Thu Jan 18 03:45:50 GMT 1973
> > or
> > Qui 01 Jul 2004 21:39:21 BRT
> > 
> > to format:
> > 
> > 1973-01-18  / 2004-06-01
> 
> Which language is the latter?

Brazilian portuguese.

> 
> You can create a hash "%months = ( Jan => '01', ... );", use a regex 
> to extract what you need and format the string using sprintf().
> 
> A module like Date::Parse might be useful.


Thank you very much.



__
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Help with array reference that has a HASH reference.

2004-07-05 Thread Rod Za
Hi,

I'm trying to do a function that load all the jobs from the printers on systems 
(Unix), and this
function returns a hash that has the printer name, the number of jobs and an array 
that got
another hash with the names of job, owner jobs, date of the job.

I thinks something like this:

my %hash = ( printer_name => 'PRINTER NAME',
 n_jobs => 'NUMBER OF JOBS',
 jobs_name => [EMAIL PROTECTED],
)

where @jobs = a hash with job_name, job_owner and job_date

so i make this code:

_BEGIN_
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
sub lst_job{
my $printer = shift;
my @lpstat = `lpstat -P $printer`;
my %job;
my @jobs;
foreach (@lpstat){

if(/^$printer\-(\d+)\s+(\w+)\s+(\d+)\s+\w+\s(\d+\s\w+\s\d+\s\d{2}:\d{2}:\d{2})/){
$job{job_name} = sprintf("d%05d-001",$1);
$job{job_owner} = $2;
$job{job_date} = $4;
}
push(@jobs,\%job);
}
my %printer = ( printer_name => $printer,   #printer name
n_jobs => scalar @jobs, #number of jobs in the printer
jobs_name => [EMAIL PROTECTED],#the name, owner 
and date
);
return %printer;
}

my %printers_job = lst_job("HP4100V");
printf "\nThe printer %s got %3d 
jobs\n",$printers_job{printer_name},$printers_job{n_jobs};
print Dumper @printers_job{jobs_name} ;

foreach(@printers_job{jobs_name}){
print [EMAIL PROTECTED]>[1]}->{job_name};
print [EMAIL PROTECTED]>[1]}->{job_owner};
print "\n";
}
_END_

The problem is that i can list all the jobs of a printer. 

this is the Dumper() result:

_RESULT_
The printer HP4100V got  18 jobs
$VAR1 = [
  {
'job_owner' => 'rodza',
'job_date' => '01 Jul 2004 21:39:21',
'job_name' => 'd00026-001'
  },
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0],
  $VAR1->[0]
];
_END_RESULT

What is wrong?

Thank you.




__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Help with array reference that has a HASH reference.

2004-07-06 Thread Rod Za
Hi Charles, thank you very much for the help and the hint:

--- "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote:
[snip]
> We really don't need %job at all:
> my @jobs;
> foreach ( @lpstat ) {
>  next unless
> /^
> \Q$printer\E-
> (\d+)\s+
> (\w+)\s+\d+\s+\w+\s
> (\d+\s\w+\s\d+\s\d{2}:\d{2}:\d{2})
> /ox;
> 
> push @jobs, {
> job_name=> sprintf 'd%05d-001', $1,
> job_owner   => $2,
> job_date=> $3,
> };
> }

What the \Q \E /ox in the regex does ?

HTH,

Rod




__
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Is "Thank you" okay? [was: where to put modules?]

2004-07-09 Thread Rod Za
--- jason corbett <[EMAIL PROTECTED]> wrote:
> One observation I have made is that this list sometimes looks like a
> help desk forum: Somebody asks a question, and get one or a few
> replies, and that's it. I don't know if that's how it's supposed to
> be, but personally I would like to see more of follow-up comments on
> posted suggestions, both from the original posters and from others. I
> believe that everyone would benefit from such exchange of thoughts.

Jason, you are correct. 
I think that is more important to have others comments about the subject so someothers 
can learn
about. But i think that in this list the most people are Perl beginners (like me:), 
with the
desire to learn Perl, fast. So the list looks like a help desk :(

But, any way, you are right. I share yours ideas.

Thank's







__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regex help : find % not within <>

2004-07-09 Thread Rod Za
Try this:

_BEGIN_
#!/usr/bin/perl
use warnings;
use strict;
my $html = 'some value%';
$html =~ /(?:\<.+\>)?(.+\%)(?:\<.+\>)?/;
print $1;
_END_

HTH,

Rod

--- Wiggins d Anconia <[EMAIL PROTECTED]> wrote:
> > Hello,
> > 
> > I need to find all % characters in a string that are not element
> attributes. 
> > for syntax instance:
> > 
> > some value%
> > 
> > I need a regex that matches the % in value% but not in 100% because it is
> > within angle braces.
> > 
> > Is it possible or more complicated than regex?




__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Is the var recreated in a foreach loop using `my`?

2004-07-16 Thread Rod Za
Hi,

I have a doubt. If i create an array inside a foreach loop using `my`, is this array 
recreated
every time or every time the loop pass by i got a new array?

e.g.:
_BEGIN_
#!/usr/bin/perl
use warnings;
use strict;
my @array1 =(1,2,3,4,5,6,7,8,9);
foreach(@array1){
 my @array2 = ($_,'a','b','c','d','e'); #is a new the array reated here? or is the 
same array?
 print "$_ = @array2\n";
}
_END__

_RESULT_
1 = 1 a b c d e
2 = 2 a b c d e
3 = 3 a b c d e
4 = 4 a b c d e
5 = 5 a b c d e
6 = 6 a b c d e
7 = 7 a b c d e
8 = 8 a b c d e
9 = 9 a b c d e
_RESULT_

Thank you very much,

Rod



__
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Is the var recreated in a foreach loop using `my`?

2004-07-16 Thread Rod Za
Thank you, Bob and Chris Charley,

In the Bob's example:

e.g.
>for (1 .. 5) {
>my @arr = ($_) x $_;
>print [EMAIL PROTECTED], " = @arr\n";
>}
> 
>ARRAY(0x8103418) = 1
>ARRAY(0x80f827c) = 2 2
>ARRAY(0x8103490) = 3 3 3
>ARRAY(0x81034cc) = 4 4 4 4
>ARRAY(0x8103514) = 5 5 5 5 5

how can i access, for example, the array referenced by (0x80f827c)?

Thank you very much,

Rod


--- Bob Showalter <[EMAIL PROTECTED]> wrote:
> Rod Za wrote:
> > Hi,
> > 
> > I have a doubt. If i create an array inside a foreach loop using
> > `my`, is this array recreated every time or every time the loop pass
> > by i got a new array? 
> 
> Yes, it's a new array.
> 
> Try this:
> 
>for (1 .. 5) {
>my @arr = ($_) x $_;
>print [EMAIL PROTECTED], " = @arr\n";
>}
> 
> Output:
>ARRAY(0x81017e4) = 1
>ARRAY(0x81017e4) = 2 2
>ARRAY(0x81017e4) = 3 3 3
>ARRAY(0x81017e4) = 4 4 4 4
>ARRAY(0x81017e4) = 5 5 5 5 5
> 
> The address of the array never changes, so it looks like the same array.
> However, if you save a reference to the array inside the loop, watch what
> happens:
> 
>my @outer;
>for (1 .. 5) {
>my @arr = ($_) x $_;
>print [EMAIL PROTECTED], " = @arr\n";
>push @outer, [EMAIL PROTECTED];
>}
> 
> Output:
>ARRAY(0x8103418) = 1
>ARRAY(0x80f827c) = 2 2
>ARRAY(0x8103490) = 3 3 3
>ARRAY(0x81034cc) = 4 4 4 4
>ARRAY(0x8103514) = 5 5 5 5 5
> 
> Here it's proven that you create a new array each time. If you never take a
> reference to the "my" variable that lives beyond the scope of the loop, Perl
> can reuse the old array, and just put new contents into it. I'm not sure if
> down in the guts of perl it's actually releasing and then recreating the
> array or whether it's just reusing the old array. Really doesn't matter; the
> result is you always get a different array and they will be kept separate if
> necessary.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
> 




__
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




"or die" question

2005-01-25 Thread Rod Jenkins
After a failed open, I want to run two statements for an "or die".
Code Quesiton:
open (TEST, ">/tmp/test")
or {
die "Could not open test file\n";
syslog("LOG_ALERT","Could not open test file");
 };
This does not work, but what is the "right" way to do this?  I know I 
could write a MyDie sub and pass a string to it.


Rod Jenkins
Rod Jenkins
ISP Systems Engineer
Iowa Telecomunications Systems
Cell:  (641) 521-4423
PGP Key:  http://www.iowatelecom.net/~rodj/key.txt
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: "or die" question

2005-01-25 Thread Rod Jenkins
On Jan 25, 2005, at 8:33 AM, Bob Showalter wrote:
Rod Jenkins wrote:
After a failed open, I want to run two statements for an "or die".
Code Quesiton:
open (TEST, ">/tmp/test")
or {
die "Could not open test file\n";
syslog("LOG_ALERT","Could not open test file");
 };
This does not work, but what is the "right" way to do this?  I know I
could write a MyDie sub and pass a string to it.
You can't call die() before calling syslog(), since die() doesn't 
return. So
you need to swap those.

Then you can write it as:
 open (TEST, ">/tmp/test") or do {
 syslog("LOG_ALERT","Could not open test file");
 die "Could not open test file\n";
 };
Or,
 open (TEST, ">/tmp/test")
 or syslog("LOG_ALERT","Could not open test file"),
 die "Could not open test file\n";
Or,
 unless (open TEST, ">/tmp/test") {
 syslog("LOG_ALERT","Could not open test file");
 die "Could not open test file\n";
 }

I should have read my example before sending, yes the syslog entry 
would have to come before the die.  I was leaving out the "do".  Thanks 
for the help.

Rod
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



suidperl.

2005-03-25 Thread Rod Za
Hello all.

I'm trying to make changes in a file (smb.conf) that is owner by root 
(chmod=644). I'm using the
Config::IniFiles module to do the work and the script run as 'lp' user.

This is a piece of code:

if($self->{config}{AUTO_SMB_PRINTER}){
 $self->log_it('DEBUG',"(D): Auto SAMBA printer on.");
 my $smb_cfg = new Config::IniFiles( -file => '/etc/samba/smb.conf');
 if (!$smb_cfg){
$self->log_it('DEBUG',"(D) Error on open '/etc/samba/smb.conf'");
$self->log_it('DEBUG',Dumper(@Config::IniFiles::errors));
 }
 if(!$smb_cfg->SectionExists("$self->{printer}")){
$smb_cfg->AddSection($self->{printer});
$smb_cfg->newval($self->{printer},'comment','Auto printer');
$smb_cfg->newval($self->{printer},'path','/var/tmp');
$smb_cfg->newval($self->{printer},'printable','yes');
$smb_cfg->newval($self->{printer},'browseable','yes');
$smb_cfg->newval($self->{printer},'guest ok','yes');
$smb_cfg->newval($self->{printer},'public','yes');
if($smb_cfg->WriteConfig('/etc/samba/smb.conf')){
 $self->log_it('DEBUG',"(D): - Auto SAMBA printer OK.");
} else {
 $self->log_it('ERR',"(E): - Error on Auto SAMBA printer: $!");
}
 } else {
   $self->log_it('DEBUG',"The printer exists.");
 }
} else {
  $self->log_it('DEBUG',"Auto SAMBA printer off.");
}


This doesnt works becouse the owner of the file is 'root'. How can i solve 
this? using suidperl?

thank you very much

Rodrigo

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Many-to-many with Class::DBI how-to?

2005-04-09 Thread Rod Za
Hello,

Can someone help me with this? I'm trying to make the use of Class::DBI and i 
need to do a
many-to-many relationship. (an user has many groups and a group has many users, 
and an user with a
group has many history.) 

I think what i make was correct, i can access the group_name value of the 
relationship
(users->groups), but i can access the history of that USER with that GROUP. 

below is my tables and the classes that i make.

Thank you very much, any way.

Rodrigo Zadra.



+-++-+
|  users  ||   groups|
+-++-+
|*id_user |-+   +--| *id_group   |
| login   | |   |  |  group_name |
+-+ |   |  +-+ 
|   |
   ++   |
   |++
   |+---+|
   || relationship  ||
   |+---+|
   +---<|  *id_user ||
|  *id_group|>---+
+---+
   |   |
   |   |
  /|\ /|\
   +-+ +--+
   | history | |action|
   +-+ +--+
   |   *id_user  | |  *id_action  |
   |   *id_group |  +--|action|
   |   id_action |--+  +--+  
   | date|  
   +-+


and this classes defined:


package dbBase;
use base qw/Class::DBI/;
use base qw(Class::DBI);

__PACKAGE__->set_db( "Main", "dbi:mysql:Test", "TEST_USER", "TESTPASS" 
);
1;

package dbUser;
use lib '/home/rodza/perl_tests';
use base 'dbBase';
dbUser->table('users');
dbUser->columns( All => qw/id_user login/ );
dbUser->has_many( groups => [dbRelationship => 'id_group'] => 'id_user' );
1;

package dbGroup;
use lib '/home/rodza/perl_tests';
use base 'dbBase';
dbGroup->table('groups');
dbGroup->columns( All => qw/id_group group_name/ );
dbUser->has_many( users => [dbRelationship => 'id_user'] => 'id_group' );
1;

package dbRelationship;
use lib '/home/rodza/perl_tests';
use base 'dbBase';
dbRelationship->table('relationship');
dbRelationship->columns( All => qw/id_user id_group/ );
dbRelationship->has_a( id_group => dbGroup );
dbRelationship->has_a( id_user => dbUser );
dbRelationship->has_many( history => dbHistory );
1;

package dbHistory;
use lib '/home/rodza/perl_tests';
use base 'dbBase';
dbHistory->table('history');
dbHistory->columns( All => qw/id_user id_group action date/ );
dbHistory->has_a( id_action => dbAction );

1;

package dbAction;
use lib '/home/rodza/perl_tests';
use base 'dbBase';
dbAction->table('action');
dbAction->columns( All => qw/id_action action/ );
1;

package main;
use dbUser;
my ($info) = dbUser->retrieve(1);
foreach($info){
printf "UID: %d LOGIN: %S\nGID: %D GROUP_NAME: %S",
$info->id_user, $info->login, $info->id_group->group_name;
}





__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Newbie Perl Question

2006-07-17 Thread Rod Burgess

I am new to the Perl world and am trying to learn it.  A coworker tells me
that Perl will not work for what I am trying to do however, I think Perl
would be a great tool to use and  I feel this coworker is wrong.
I have a file that contains several lines all as below:
DR03555{tab}45600062888{tab} 8FLAT WASHER
DR03555{tab}228765329{tab}1GASKET

The meaning of the file is
DR03555 = order number
45600062888 = part number
8 = quantity
FLAT WASHER = Description

The lines all begin with the prefex DR  I would like to read this file and
produce the following output:

45600062888;8;FLAT WASHER
228765329;1;GASKET

basiclly I need a file that lists the following:  Part#;Quantity;Description

Is this possible with Perl?



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Newbie Perl Question

2006-07-17 Thread Rod Burgess

I am new to the Perl world and am trying to learn it.  A coworker tells me
that Perl will not work for what I am trying to do however, I think Perl
would be a great tool to use and  I feel this coworker is wrong.
I have a file that contains several lines all as below:
DR03555{tab}45600062888{tab} 8FLAT WASHER
DR03555{tab}228765329{tab}1GASKET

The meaning of the file is
DR03555 = order number
45600062888 = part number
8 = quantity
FLAT WASHER = Description

The lines all begin with the prefex DR  I would like to read this file and
produce the following output:

45600062888;8;FLAT WASHER
228765329;1;GASKET

basiclly I need a file that lists the following:  Part#;Quantity;Description

Is this possible with Perl?



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Thanks for newbie answer

2006-07-17 Thread Rod Burgess
I appreciate all of your assistance with my eariler question.  It is amazing 
how many different variations of Perl scripts that can be used to come up 
with the same results.

The best part was showing my co-worker just what Perl can do.
Thanks again.
Rod



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Help - Trying to use File::Spec module

2003-02-14 Thread Crowder, Rod


> -Original Message-
> From: Gazi, Nasser (London) [mailto:[EMAIL PROTECTED]]
> Sent: 14 February 2003 15:07
> To: [EMAIL PROTECTED]
> Subject: Help - Trying to use File::Spec module
> 
> 
> I'm trying to use the catfile method in the File::Spec 
> module. The following
> program (called test.pl):
> 
>   Use File::Spec::Unix;
>   $c = catfile("aa", "bb");   # line 2
try 

use File::Spec::Unix;
$c = File::Spec::Unix::catfile("aa", "bb");

I don't understand why sometimes it is possible to use functions from
another module without having to specify the module name in full

I would be grateful for an explanation



> 
> Gives this error: "Undefined subroutine &main::catfile at 
> test.pl line 4".
> 
> I've set PERL5LIB to the correct directory, but it still 
> doesn't work. Any
> ideas?
> 
> N.G.
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: substitute for NTs "net use"

2003-02-17 Thread Crowder, Rod
The Win32::NetResource Module will let you mount remote share


use Win32::NetResource;
use strict;
use warnings;

my$RemoteShare = {
'LocalName' => "Q:",
'RemoteName' => "server\\share",
};


my $UserName = "user";
my $Password = "password";
my $Connection = 1;
my $ErrorCode;


Win32::NetResource::AddConnection($RemoteShare,$Password,$UserName,$Connecti
on)
or die "unable to add share";

Win32::NetResource::GetError( $ErrorCode );
print $ErrorCode;




> -Original Message-
> From: Joe Mecklin [mailto:[EMAIL PROTECTED]]
> Sent: 17 February 2003 13:07
> To: [EMAIL PROTECTED]
> Subject: substitute for NTs "net use"
> 
> 
> I tried sending this last week and never saw it or any 
> response to it on the list, 
> so I'll try again:
> 
> 
> I'm tying to write a script which will connect to all PCs in 
> an internal
> network to update select files.  I currently have it working using
> 
> system("net use ...")
> 
> but I would like to use whatever module will replicate that
> connection/login/logout functionality; can anyone tell me which
> module(s) will allow me to do this?  Currently I have to run this from
> an NT box but would like to be able to move it to a Linux 
> server we are
> turning up so it will be available to anyone with permission 
> to perform
> this function w/o having to install Perl and this script on computers
> that would not otherwise need either..
> 
> TIA,
> Joe
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Test message plz delet without wasting time reading it

2003-02-19 Thread Crowder, Rod


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: bitwise?

2003-02-24 Thread Crowder, Rod
Hi

Your example is AND'ing the results of the two matches, so will return true
if both matches occur.

An example of comparing characters using the bitwise AND and the result
might help, or confuse you more thoroughly  :)

hth

Rod

my $a = "a";
my $A = "A";
my $B = "B";
foreach ($A,$B,$a) {
my $bittest  = ($A & $_);
my $logicaltest = ($A && $_);
print "Comparing ",$A," with ", $_,"\n"; 
printf("Bitwise\nResult is %s\tHex value %x\n\n",$bittest, ord
$bittest);
printf("Logical\nResult is %s\tHex value %x\n",$logicaltest, ord
$logicaltest);
print"\n";
};


OUTPUT

Comparing A with A
Bitwise
Result is A Hex value 41

Logical
Result is A Hex value 41

Comparing A with B
Bitwise
Result is @ Hex value 40

Logical
Result is B Hex value 42

Comparing A with a
Bitwise
Result is A Hex value 41

Logical
Result is a Hex value 61


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Help with learning VB Script (Please don't shout at me)

2003-02-25 Thread Crowder, Rod
As I said, please don't shout at me 

A situation has arisen at work, where a new application which has been
bought requires VB script to do pattern matching and string modification. 

Yes I know that it is easier in Perl, (and the app supports perl) but the
PHB has decreed that the VBscript route is the the one to take.

My question: 

Can anyone point me at a good VBScript book/Site that will help someone who
knows perl to adapt? (Changing jobs is not an option at this point)

Suggestions please folks 


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Help with learning VB Script (Please don't shout at me)

2003-02-25 Thread Crowder, Rod
Many thanks, this looks useful.

I appreciate the help as this is slightly OT

Regards

Rod Crowder


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]