2 -D arry in perl

2005-03-08 Thread Adam Saeed
hi i am some new to per;. I want to get a day numbers by year and store them in e a 2 -d array, getting data from mysql. i.e data[dayofyear][year] BUT I COULD NOT GETTING THE DESIRE RESULT ... ANY HELP my snap code is: ... ... @year #have list of years my $i=0; my @dayofyear=([],[]); my @data

log rotate on multiple files

2005-03-08 Thread DBSMITH
Will someone provide clues as to how use logfile rotate on multiple files? I looked at the rotate.pm and did not see anything this the code. I tried one File => line followed by multipl scalers but that did not work then I tried multiple File => references and this did not work??? thank you,

Re: mail question

2005-03-08 Thread Marco Antonio Manzo
Or use the "new" collection of Email::* modules for handling Mime stuff. Email::Simple would do the job. On Tue, 2005-03-08 at 19:53 -0500, Peter Rabbitson wrote: > As stated earlier on the list I believe, I would not use an external program > call. Instead use the MIME::Lite - clean and simple

Re: mail question

2005-03-08 Thread Peter Rabbitson
As stated earlier on the list I believe, I would not use an external program call. Instead use the MIME::Lite - clean and simple: my $mail = MIME::Lite->new (From => $from_email, To => $to_email, Subject => 'Test',

Re: Counting Multiple lines of data with a unique column of information

2005-03-08 Thread Willy West
forgot to reply to all for the following *laugh* -- Forwarded message -- From: Willy West <[EMAIL PROTECTED]> Date: Tue, 8 Mar 2005 19:20:24 -0500 Subject: Re: Counting Multiple lines of data with a unique column of information To: "Wilson, Josh --- Systems Analyst --- GO" <[EMAI

Re: Counting Multiple lines of data with a unique column of information

2005-03-08 Thread John W. Krahn
Wilson, Josh --- Systems Analyst --- GO wrote: I have a scenario in which palettes are weighed prior to delivery and then that data is submitted to a server. Once the data is transferred, I have to parse a batch file and strip out information for each shipment number and format it for print. Th

mail question

2005-03-08 Thread Amy Kline
Hi, How do I modify the following code to email a file (textfile.txt) to [EMAIL PROTECTED] open (MAIL, "|/usr/bin/mail [EMAIL PROTECTED]"); print MAIL "Subject: test"; print MAIL "This is a test"; close MAIL; The above code works fine but instead of sending the text - "This is a test", I would li

Counting Multiple lines of data with a unique column of information

2005-03-08 Thread Wilson, Josh --- Systems Analyst --- GO
I have a scenario in which palettes are weighed prior to delivery and then that data is submitted to a server. Once the data is transferred, I have to parse a batch file and strip out information for each shipment number and format it for print. The problem is that one shipment might have more

Re: tricky hash

2005-03-08 Thread Ing. Branislav Gerzo
John W. Krahn [JWK], on Tuesday, March 08, 2005 at 12:58 (-0800) made these points: JWK> my $string = 'something/other/foo/bar'; JWK> my $count; JWK> my $kw = { map { 'cat' . ++$count, $_ } split /\//, $string }; this is really tricky reply I awaited, I like this solution, really nice. Also, in m

Re: tricky hash

2005-03-08 Thread John W. Krahn
Ing. Branislav Gerzo wrote: Hello beginners@perl.org, Hello, anyone could me help with: use strict; use warnings; my %kw = (); my $kw = \%kw; for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{cnt}++; $kw->{cat${kw->{cnt}}} = $cat } I get: Can't use bareword ("kw") as a HASH ref while "s

Re: Interpolation Problem with Matching

2005-03-08 Thread John W. Krahn
RICHARDS, JIM wrote: I am trying to compare files names listed in a file to the actual files in a directory. My code is as follows: Your "code" won't compile. Please add the following two lines: use warnings; use strict; to the top of your program and let perl help you find the mistakes. The best

Re: Regex Multi line match

2005-03-08 Thread Dave Gray
> > my (@lines, $num) = ((), 4); > > You are assigning the list ((), 4) to @lines and nothing to $num. Perhaps you > meant: > > my ( $num, @lines ) = ( 4, () ); > > Or simply: > > my ( $num, @lines ) = 4; Indeed, good catch. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman

Re: Pattern matching to identify comma separated text

2005-03-08 Thread Wiggins d'Anconia
Chris Schults wrote: I'm sending this on behalf of our intern Elmer. Thanks in advance for any assistance. Chris Hi there! If anyone out there is good with Perl's pattern matching, maybe you can help me out. I am trying to take a string and derive information from it that is separated by commas so

Pattern matching to identify comma separated text

2005-03-08 Thread Chris Schults
I'm sending this on behalf of our intern Elmer. Thanks in advance for any assistance. Chris Hi there! If anyone out there is good with Perl's pattern matching, maybe you can help me out. I am trying to take a string and derive information from it that is separated by commas so I can then analyze

Re: Regex Multi line match

2005-03-08 Thread Jay Savage
On Tue, 8 Mar 2005 15:26:28 -0500, Dave Gray <[EMAIL PROTECTED]> wrote: > > > Something like (untested): > > > > > > my (@lines, $num) = ((), 4); > > > while () { > > > push @lines, $_; > > > shift @lines if @lines == $num+1; > > > print 'lines '.($.-$num+1).' to '.($.)." match\n" > > > i

RE: Interpolation Problem with Matching

2005-03-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
RICHARDS, JIM wrote: > I am trying to compare files names listed in a file to the actual > files in a directory. My code is as follows: > > > > Opendir(DIR,"name"); > > @files=readdir(DIR); > > > > Open(IN," > > > While() { > > If(/^pattern/) { > >

Re: Regex Multi line match

2005-03-08 Thread John W. Krahn
Dave Gray wrote: This is the multi line pattern in which I wish to match: String 1.2.3.4.5.6 One way to solve this would be to read lines from the file and save chunks of N lines (4 in this case) in a temp variable. Then your regex would operate on enough of the file to have a chance of workin

Re: Regex Multi line match

2005-03-08 Thread Dave Gray
> > Something like (untested): > > > > my (@lines, $num) = ((), 4); > > while () { > > push @lines, $_; > > shift @lines if @lines == $num+1; > > print 'lines '.($.-$num+1).' to '.($.)." match\n" > > if join('',@lines) =~ /regex goes here/; > > } > > > > That assumes that the pattern bei

Re: Regex Multi line match

2005-03-08 Thread Jay Savage
On Tue, 8 Mar 2005 13:42:44 -0500, Dave Gray <[EMAIL PROTECTED]> wrote: > > This is the multi line pattern in which I wish to match: > > > > > > String 1.2.3.4.5.6 > > > > > > One way to solve this would be to read lines from the file and save > chunks of N lines (4 in this case) in a temp va

Re: How to remove everything after the last "." dot?

2005-03-08 Thread John W. Krahn
Bastian Angerstein wrote: I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last "." including the last ".". in this case ".tea" substr( $line, rindex( $line, '.' ) ) = '' if $line =~ tr/.//; John -- use Perl; program fulfillment -- To unsubscribe, e-

Interpolation Problem with Matching

2005-03-08 Thread RICHARDS, JIM
I am trying to compare files names listed in a file to the actual files in a directory. My code is as follows: Opendir(DIR,"name"); @files=readdir(DIR); Open(IN,") { If(/^pattern/) { moveFile($_); } } Close(IN); Sub moveFile() {

Re: Regex Multi line match

2005-03-08 Thread Dave Gray
> This is the multi line pattern in which I wish to match: > > > String 1.2.3.4.5.6 > > One way to solve this would be to read lines from the file and save chunks of N lines (4 in this case) in a temp variable. Then your regex would operate on enough of the file to have a chance of working.

Re: reading an file

2005-03-08 Thread Shiping Wang
Hi, At 11:51 AM 3/8/2005 +0100, E.Horn wrote: Hello! I want to read this file into an array. How can i just get 4, 5, 6,7,8 into an array? And later, how can i get the contents out of this array? 1)2)3) 4) 5)6) 7)8) 9)10)

Re: Changing the String of the file at one shot.

2005-03-08 Thread David Storrs
On Tue, Mar 08, 2005 at 12:02:09PM +0100, John Doe wrote: > Am Dienstag, 8. März 2005 02.04 schrieb David Storrs: > > > >Suneel Kumar B wrote: > > > >: Can i > > > >: have an option by which i could open a file for both read and > > > >: write simultaneously > > The lite

Re: tricky hash

2005-03-08 Thread Lawrence Statton
> Hello beginners@perl.org, > > > I get: Can't use bareword ("kw") as a HASH ref while "strict refs" in > use.. > The goal is to get something like: > $kw->{cat1} = 'something', > $kw->{cat2} = 'other', > $kw->{cat3} = 'foo', > $kw->{cat4} = 'bar' > Well, fixing the typo where you build the key

Re: output from system call

2005-03-08 Thread geraldine_1
Thanks everyone for the input. Getting the date output is much easier in perl than I originally thought. thanks! Geraldine > On Tue, 8 Mar 2005, Ankur Gupta wrote: > > > [EMAIL PROTECTED] wrote: > > > > > Hi, > > > Is there a way to store the output of a system call on unix? > > > > > > e

Re: tricky hash

2005-03-08 Thread Ankur Gupta
Ing. Branislav Gerzo wrote: Hello beginners@perl.org, anyone could me help with: use strict; use warnings; my %kw = (); my $kw = \%kw; for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{cnt}++; $kw->{cat${kw->{cnt}}} = $cat } Change this line to for my $cat (split(/\//, 'something/oth

Re: output from system call

2005-03-08 Thread Chris Devers
On Tue, 8 Mar 2005, Ankur Gupta wrote: > [EMAIL PROTECTED] wrote: > > > Hi, > > Is there a way to store the output of a system call on unix? > > > > eg. system("date"); > > > use backticks... > > $date = `date`; This is, of course, exactly the wrong way to solve this problem. Perl has date f

Re: tricky hash

2005-03-08 Thread Wiggins d'Anconia
Ing. Branislav Gerzo wrote: Hello beginners@perl.org, anyone could me help with: use strict; use warnings; my %kw = (); my $kw = \%kw; for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{cnt}++; $kw->{cat${kw->{cnt}}} = $cat } You don't have to accept the rope Perl will give you to hang y

RE: tricky hash

2005-03-08 Thread Manav Mathur
use strict; use warnings; use Data::Dumper ; my %kw = (); my $kw = \%kw; my $i = 1; for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{"cat".eval{$i++}} = $cat } print Dumper \%kw ; -Original Message- From: Ing. Branislav Gerzo [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08,

Re: output from system call

2005-03-08 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote: Hi, Is there a way to store the output of a system call on unix? eg. system("date"); I like to store the date output to a variable. The only way I know of is to open and write the output to a file and then read in to a variable. Is there a simpler way? Thanks in advance.

tricky hash

2005-03-08 Thread Ing. Branislav Gerzo
Hello beginners@perl.org, anyone could me help with: use strict; use warnings; my %kw = (); my $kw = \%kw; for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{cnt}++; $kw->{cat${kw->{cnt}}} = $cat } I get: Can't use bareword ("kw") as a HASH ref while "strict refs" in use.. The goal i

RE: output from system call

2005-03-08 Thread Manav Mathur
chomp($date=`date`) ; ##exploiting what Perl offers but C doesnt -Original Message- From: Ankur Gupta [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 10:03 PM To: [EMAIL PROTECTED] Cc: beginners@perl.org Subject: Re: output from system call [EMAIL PROTECTED] wrote: >Hi, >Is th

Re: output from system call

2005-03-08 Thread mgoland
- Original Message - From: [EMAIL PROTECTED] Date: Tuesday, March 8, 2005 11:29 am Subject: output from system call > Hi, Hello, > Is there a way to store the output of a system call on unix? > sure > eg. system("date"); my $Date = system("date"); > > I like to store the date output

Re: output from system call

2005-03-08 Thread Ankur Gupta
[EMAIL PROTECTED] wrote: Hi, Is there a way to store the output of a system call on unix? eg. system("date"); use backticks... $date = `date`; Don't forget to chomp the $date variable as I guess you just want the date, not the newline character with it... chomp($date); -- To unsubscribe, e-mail:

output from system call

2005-03-08 Thread geraldine_1
Hi, Is there a way to store the output of a system call on unix? eg. system("date"); I like to store the date output to a variable. The only way I know of is to open and write the output to a file and then read in to a variable. Is there a simpler way? Thanks in advance. Geraldine -- To un

thanks

2005-03-08 Thread eva . horn
Thanks everybody... The support was great!!! Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Regex Multi line match

2005-03-08 Thread John Doe
Am Dienstag, 8. März 2005 17.20 schrieb William Melanson: > Greetings, Greetings too :-) > > This is the multi line pattern in which I wish to match: > > > String 1.2.3.4.5.6 > > > > This is what I have: > > == > #!/usr/bin/perl -w > > m

Re: reading an file

2005-03-08 Thread John Doe
Hello again Steve Am Dienstag, 8. März 2005 15.46 schrieb John Doe: > Hello Steven [...] > > s/// operates by default on $_, as many other built-in functions do, > > thus: > > > > @parts = map { do { s/\s*$//; $_ } @parts; > > Thanks :-) > [just a very little typo note: one right '}' is missing] >

Regex Multi line match

2005-03-08 Thread William Melanson
Greetings, This is the multi line pattern in which I wish to match: String 1.2.3.4.5.6 This is what I have: == #!/usr/bin/perl -w my $file='./index.html'; open INFILE, $file or die "Can't open $file: $!"; while () { if (/^\n

Re: reading an file

2005-03-08 Thread John Doe
Hello Steven Am Dienstag, 8. März 2005 15.19 schrieb Steven Schubiger: > > # trim right space away. I'm shure there is a shorter > > # and more elegant solution > > # > > @parts= map { do {$_=~s/\s*$//; $_ } } @parts; > > Regular expressions have a tendency to be slower, than functions > that achi

Re: reading an file

2005-03-08 Thread Steven Schubiger
> # trim right space away. I'm shure there is a shorter > # and more elegant solution > # > @parts= map { do {$_=~s/\s*$//; $_ } } @parts; Regular expressions have a tendency to be slower, than functions that achieve aquivalent results; but, chop() cannot be considered being used in above stateme

RE: reading an file

2005-03-08 Thread Giff Hammar
One way: open(FOO,"filename") || die "Couldn't open filename: !$\n"; while() { chomp(); ($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) = split; $interestingdata = join("|",$t4,$t5,$t6,$t7,$t8); $atomhash{$t2} = $interestingdata; } It would be more enlightening to

Re: reading an file

2005-03-08 Thread John Doe
Hello E. > Hello! > I want to read this file into an array. > How can i just get 4, 5, 6,7,8 into an array? > And later, how can i get the contents out of this array? > 1)2)3) 4) 5)6) > 7)8) 9)10)11) > ATOM

Re: xml error

2005-03-08 Thread Gretar M Hreggvidsson
Have you tried to open that XML page in a browser? Do you write the XML to file before you parse it? Then this could have something to do with encoding, your computer might not support the encoding defined in the XML header. The XML source could also just be unreliable, lacking encoding of some

Re: reading an file

2005-03-08 Thread Steven Schubiger
On 8 Mar, E.Horn wrote: > Hello! > I want to read this file into an array. > How can i just get 4, 5, 6,7,8 into an array? > And later, how can i get the contents out of this array? > 1)2)3) 4) 5)6) > 7)8) 9)10)

Re: AW: How to remove everything after the last "." dot?

2005-03-08 Thread John Doe
Hi Bastian > Hmmm... Aaaarrgghh!! > use strict; use warnings; > my $a="i.like.donuts.but.only.with.tea"; > $a=~s/\.\w+$//; # < maybe w+ not d+??? > print $a, "\n"; Yes, of course it should be \w, not \d ! I made it wrong in the test code, then corrected, then pasted the wrong version...

Re: How to remove everything after the last "." dot?

2005-03-08 Thread Gretar Mar Hreggvidsson
Hi! There is actually slight error in this code. > $a=~s/\.\d+$//; # < this does the trick This handles only one or more digits (\d stand for digits), so unless the last part of the string is a number this won't work. Should be something like $a=~s/\.\w+$//; # (\w stands for word charachters

Re: How to remove everything after the last "." dot?

2005-03-08 Thread Ramprasad A Padmanabhan
Bastian Angerstein wrote: I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last "." including the last ".". in this case ".tea" Use Regex To read the manual perldoc perlre Of course In your case you could simply do something like this $line =~s/\.[^.

Re: AW: How to remove everything after the last "." dot?

2005-03-08 Thread Ramprasad A Padmanabhan
Bastian Angerstein wrote: Hmmm... use strict; use warnings; my $a="i.like.donuts.but.only.with.tea"; $a=~s/\.\w+$//; # < maybe w+ not d+??? Better still $a =~s/\.[^.]+$//; Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: reading an file

2005-03-08 Thread Ramprasad A Padmanabhan
E.Horn wrote: Hello! I want to read this file into an array. How can i just get 4, 5, 6,7,8 into an array? Post what you have already tried. What you want to do is not very clear. Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: AW: How to remove everything after the last "." dot?

2005-03-08 Thread Ing. Branislav Gerzo
Bastian Angerstein [BA], on Tuesday, March 8, 2005 at 12:19 (+0100) wrote: BA> use strict; use warnings; BA> my $a="i.like.donuts.but.only.with.tea"; BA> $a=~s/\.\w+$//; # < maybe w+ not d+??? BA> print $a, "\n"; correct code is: use strict; use warnings; my $a = 'i.like.donuts.but.only.with

AW: How to remove everything after the last "." dot?

2005-03-08 Thread Bastian Angerstein
Hmmm... use strict; use warnings; my $a="i.like.donuts.but.only.with.tea"; $a=~s/\.\w+$//; # < maybe w+ not d+??? print $a, "\n"; Deutsche Telekom AG T-Com, Technische Infrastruktur Niederlassung Überregional Bastian Angerstein Network Support Center - Network Management Support Maybachstr.5

Re: Changing the String of the file at one shot.

2005-03-08 Thread John Doe
Hello see inline comment Am Dienstag, 8. März 2005 02.04 schrieb David Storrs: > On Mon, Mar 07, 2005 at 11:00:49AM -0500, Wiggins d'Anconia wrote: > > Charles K. Clarkson wrote: > > >Suneel Kumar B wrote: > > >: I have a situation where in, iam updating a file by repla

Re: Changing the String of the file at one shot.

2005-03-08 Thread David Storrs
On Mon, Mar 07, 2005 at 11:00:49AM -0500, Wiggins d'Anconia wrote: > Charles K. Clarkson wrote: > >Suneel Kumar B wrote: > > > >: I have a situation where in, iam updating a file by replacing few > >: strings in some lines with another string. While doing this, Can i > >:

Re: Appending constant string to variable inside a here-document

2005-03-08 Thread David Storrs
On Sun, Mar 06, 2005 at 11:21:23PM -0600, Charles K. Clarkson wrote: > Harold Castro wrote: > : if the current content of $word is the word "big", and > : I would want to print a here document appending > : something to "big" like "foot": > : > : print < : > : $word."f

reading an file

2005-03-08 Thread E.Horn
Hello! I want to read this file into an array. How can i just get 4, 5, 6,7,8 into an array? And later, how can i get the contents out of this array? 1)2)3) 4) 5)6) 7)8) 9)10)11) ATOM 2909 CG1 VAL B 183

Re: How to remove everything after the last "." dot?

2005-03-08 Thread John Doe
Hi > I have a line: > i.like.donuts.but.only.with.tea > > now I want to remove everything that follows the last "." > including the last ".". > [...] you can use a regex for that. === Documentation (from command line:) perldoc perlre === Code: use strict; use warnings; my $a="i.like.donut

xml error

2005-03-08 Thread Octavian Rasnita
Hi, I am using a simple program that downloads an XML file from a web site, then gets the data from it using XML::Simple, but sometimes, it gives the following error: not well-formed (invalid token) at line 2, column 39381, byte 39420 at D:/usr/site/lib/XML/Parser.pm line 187 I have previously s

How to remove everything after the last "." dot?

2005-03-08 Thread Bastian Angerstein
I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last "." including the last ".". in this case ".tea" I hav absulte no idea. I tried something like: @parts = splite /\./, $line; $parts[-1] = undef; foreach $parts (@parts) { $newline .= "$pa