Re: parsing text
A quick comment as I have not really been following this thread. A report is basically a formatted file with each row formatted differently based on something which is always relatively consistent regarding spacing and offsets. For example, in the report you sent, here are what look like some simple rules. the line below/OVERALL STATISTICS/ starts the labels the next line has a set format based on char pos i.e. totals is in columns 0 to 5 O-Reb is columns x to y. 2 lines after the this are the players detail ignore all blank lines line of /TEAM STATISTICS/ start a different set of rules. Yes it is basically brute forced and not really flexible and you might not get some pretty PERL code, but is will work as long as the report layout stays the same and I have found that once reports are generated inertia sets and they usually stay that way for a long, long time. This is basically what you mentioned below, you can use regexes to know when to start each new rule and mid statements or something else to implement the rule. |-OVERALL STATISTICS--| TOTALS O-REB D-REB TOTAL PF FOA TO A/TO Hi Pts --- Lowe, Kenneth... 01515 15 0 14 11 1.3 26 Teague, David... 616229 094 2.2 19 Booker, Chris...1321348 0 10 10 1.0 20 Buckley, Melvin. 51722 11 0 108 1.2 20 McKnight, Brandon... 11112 15 1 18 15 1.2 13 Buscher, Brett.. 1 910 15 099 1.0 10 Kartelo, Ivan...221941 14 027 0.3 12 Kiefer, Matt 91221 14 049 0.4 7 Parkinson, Austin... 3 5 84 0 207 2.9 8 Nwankwo, Ije 2 2 42 022 1.0 2 Carroll, Matt... 1 3 46 002 0.0 2 Ford, Andrew 0 1 12 001 0.0 0 Garrity, Kevin.. 0 1 10 000 0.0 0 Hartley, Chris.. 1 0 10 001 0.0 0 Total...72 143 215 115 1 98 86 1.1 78 Opponents...72 130 202 131 - 62 103 0.6 68 TEAM STATISTICS PUR OPP SCORING... 431 352 Points per game. 71.8 58.7 Scoring margin..+13.2- FIELD GOALS-ATT... 142-328 134-336 Field goal pct.. .433 .399 3 POINT FG-ATT 36-10225-99 3-point FG pct.. .353 .253 3-pt FG made per game... 6.0 4.2 FREE THROWS-ATT... 111-14759-99 Free throw pct.. .755 .596 REBOUNDS.. 215 202 Rebounds per game... 35.8 33.7 Rebounding margin... +2.2- ASSISTS... 98 62 Assists per game 16.3 10.3 TURNOVERS. 86 103 Turnovers per game.. 14.3 17.2 Turnover margin. +2.8- Assist/turnover ratio... 1.1 0.6 STEALS 44 31 Steals per game. 7.3 5.2 BLOCKS 23 23 Blocks per game. 3.8 3.8 WINNING STREAK6- Home win streak.3- ATTENDANCE3311823435 Home games-Avg/Game. 3-11039 0-0 Neutral site-Avg/Game...- 3-7812 BY PERIOD 1st 2ndTotal Team 203 228 - 431 Opponents... 164 188 - 352 Scott Sisson Phone: (215)-419-6728 Fax: (215)-640-3732 Joe Youngquist [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent by:cc:
Unable to open executable file:
I am trying to create a free standing exe using perl app. I am on old stuff, perlapp 2.1. Here is the output of what I am doing. Any help is appreciated. C:\Perlperlapp -s=GenDBLoad.pl -f -v -r -c -e=GenDBLoad Input script name: GenDBLoad.pl Output exe name: GenDBLoad.exe Exe Mode: Freestanding Building Console mode exe Temp files will be deleted on exit Failed 'use's will be reported Unable to open executable file: GenDBLoad.exe Scott Sisson Phone: (215)-419-6728 Fax: (215)-640-3732 *** This message and any information contained or attached is for the use only of the intended recipient. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution,or the taking of any action in reliance on the contents is strictly prohibited. *** ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: getopt arrgh!!
Here is a snippet use Date::Manip; use MIME::Lite; use Net::FTP; # # set time zone so Unix Date calls work # Date_Init (TZ=EST5EDT); use vars qw($user, $pass, $server, $filena, $timeout, $passive, $renwdone, $pause, $nretries, $emailto, $tmploc, $snduser, $sndpass, $sndserver, $sndfilena, $sndtimeout, $sndpassive, $sndpause, $sndntries, $sndren2, $qmark); # # get command line options # # -T and -t are different # Getopt::Long::config(no_ignore_case); GetOptions( 'U=s' = \$user, 'P=s' = \$pass, 'S=s' = \$server, 'F=s' = \$filena, 'T=s' = \$timeout, 'V' = \$passive, 'R=s' = \$renwdone, 'A=i' = \$pause, 'N=s' = \$nretries, 'E=s' = \$emailto, 'l=s' = \$tmploc, 'u=s' = \$snduser, 'p=s' = \$sndpass, 's=s' = \$sndserver, 'f=s' = \$sndfilena, 't=s' = \$sndtimeout, 'v' = \$sndpassive, 'a=s' = \$sndpause, 'n=s' = \$sndnretries, 'r=s' = \$sndren2, 'H' = \$qmark); All the options are in the various fields i.e. what you enter for -n is in $sndnretries. Marcos Lorenzo [EMAIL PROTECTED] Sent by:To: [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] eState.com cc: Subject: getopt arrgh!! 11/14/02 11:10 AM I've been trying for an hour or so to use Getopt::Long, but I just don't get it... I've been reading FAQ's docs but I need some more examples to know how it works. Well, I want to process arguments like: perl command.pl arg_needed [ --flag1 one=something two=otherthing | --flag2 | --flag3 ] and I get: $var=arg_needed $one=something $two=otherthing How can I achieve this? TIA, m4c. __ Marcos Lorenzo de Santiago (Labs Technician) Departament of Telematic Engineering University Carlos III Av.Universidad 30 Leganés (Madrid). Torres Quevedo Building 4.1A01 E-mail: [EMAIL PROTECTED], Telephone: (+34)91-624-8757 Homepage: http://www.it.uc3m.es/marcos __ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Unable to get Attachment working w/Lotus Notes
I have had success using MIME::Lite. Here is code from a script that works in production today. Some of the names have been changed to protect the innocent. The script generates a log while processing and then e-mails it to a list of users. use MIME::Lite; . .. . sub SendEmail { my ($ernum,$emsg,$emailto) = @_; my $errorline,$prog,$dir,$type; $subj = $emsg processing $0 activity for $fullpath\n; ($prog,$dir,$type) = fileparse($0,'\..*'); $msg = new MIME::Lite From =$prog\@opalias.com, Subject = $subj, Type = 'multipart/mixed'; attach $msg Type = 'text', Data = PrintParams; # #do not really understand why I have to parse and send seperate To lines. #It works this way and not with a , or ; seperated list - oh well # foreach $to (split /,/, $emailto) { $msg-add (To = $to); } print \n$subj; close OUT; select (STDOUT); # print \nAttaching file $ol size (-s $ol); @stats = stat ($ol); #print \n\$stats[7] is $stats[7]; if (-s $ol) { # print \nattempting to attach file\n; attach $msg Path = $ol, Type = 'file/text', Encoding = 'quoted-printable'; } #Debug= 1 MIME::Lite-send(smtp,your smtp server name, Timeout=30 ); $x = $msg-send; # print \n, 'Command MIME::Lite-send(smtp, your smtpserver name , Timeout=30)'; # print \n x is $x; # print \n \$! is $!; # print \n \$@ is $@; # unlink $msgdir$hashkey.txt; } Brad Currens [EMAIL PROTECTED] Sent by: To: [EMAIL PROTECTED] [EMAIL PROTECTED]cc: eState.com Subject: Unable to get Attachment working w/Lotus Notes 06/18/01 01:54 PM Has anyone had success attaching a file to a Lotus Notes email using Perl? I have the following script which sends the email, but, so far no attachment. TIA Brad use Win32::OLE; use Win32::OLE::Variant; $file = c:\\sstrm60\\batch\\pcareport.xls; send_mail('Brad Currens','@anywhere.com'); sub send_mail { my($name, $notesdomain) = @_; my($session, $db, $doc, $body); $session = Win32::OLE-new('Notes.NotesSession') or die Cannot start Lotus Notes Session object.\n; $db = $session-GetDatabase( '' , ''); $db-OpenMail; $doc = $db-CreateDocument; $doc-{'Form'} = 'Memo'; $doc-{'SendTo'} = [$name$notesdomain]; $doc-{'CopyTo'} = []; $doc-{'Subject'} = 'PCA Interface Report'; $body = '__STOP_IT'; PCA Interface attachment. __STOP_IT $doc-{'Body'} = $body; $rtitem = $doc-CreateRichTextItem( PCA Report ); $object = $rtitem-EmbedObject(EMBED_ATTACHMENT,,c: \\sstmr60\\batch\\pcareport.xls); $doc-save(1,1); $doc-send(1); return(); } __ Do You Yahoo!? Spot the hottest trends in music, movies, and more. http://buzz.yahoo.com/ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: $1 question
This may be written cleaner, but it works ($tarfile) = $tarfile =~ /\.(.*)$/; "Purcell, Scott" [EMAIL PROTECTED] To: Sent by: "'[EMAIL PROTECTED]'" [EMAIL PROTECTED] [EMAIL PROTECTED] eState.com cc: Subject: $1 question 04/19/01 03:32 PM Hello, I don't know why I can't ever do this, but I know I have seen what I am trying to accomplish done in one line. I have a line that looks like the following: my $tarFile = 1234567_six12.tar And I want to strip off the '.tar' So I know I can catch everything up to the first '.' in a () $tarFile =~ s/^(\w+)\./$1/; print "$tarFile; gives me 1234567_six12tar, it just removes the period? What the heck am I doing wrong today? Any ideas? Or does this have to be done on two lines like my next eg. which works. $tarFile =~ s/^(\w+)\./$1/; my $tmpGoodFile = $1; That just doesn't seem proper to me. Thanks Scott Purcell ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: $1 question
With s/// this works $tarfile =~ s/(.*)\.(.*)$/\2/; Notice the "\2" vs the $2 since we are using what has been group as a replacement string "Purcell, Scott" [EMAIL PROTECTED] To: Sent by: "'[EMAIL PROTECTED]'" [EMAIL PROTECTED] [EMAIL PROTECTED] eState.com cc: Subject: $1 question 04/19/01 03:32 PM Hello, I don't know why I can't ever do this, but I know I have seen what I am trying to accomplish done in one line. I have a line that looks like the following: my $tarFile = 1234567_six12.tar And I want to strip off the '.tar' So I know I can catch everything up to the first '.' in a () $tarFile =~ s/^(\w+)\./$1/; print "$tarFile; gives me 1234567_six12tar, it just removes the period? What the heck am I doing wrong today? Any ideas? Or does this have to be done on two lines like my next eg. which works. $tarFile =~ s/^(\w+)\./$1/; my $tmpGoodFile = $1; That just doesn't seem proper to me. Thanks Scott Purcell ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: Duplicating Excel Spreadsheet with Perl
The functionality you are talking about is strictly and Excel issue. Given that this is a perl mail list the question probably should not be posted here. The functionality accomplished by activating the cell where you want the colums to remain static and then use the tab Window |Freeze Panes menu options. You probably already know to run an Excel macro to get the exact commands you need. Good luck "Cornish, Merrill" [EMAIL PROTECTED]To: [EMAIL PROTECTED] Sent by: cc: Perl Win32 Users Mailing List [EMAIL PROTECTED] [EMAIL PROTECTED] eState.com Subject: Duplicating Excel Spreadsheet with Perl 04/03/01 09:24 AM Jan, Given a lot of research, I have been able to duplicate most of an Excel spreadsheet one of my manager's uses with Perl and OLE. The one item I haven't be able to duplicate is that when you scroll horizontally, the first two columns stay in place and only the other columns move. As nearly as I can tell, this is a vertical page break. I've tried defining it and it doesn't work--it doesn't give any errors--but the whole spreadsheet still scrolls. I'm running with Perl strict and warnings turned on plus an OLE warning level of 2, so "it should have said something" if I got the syntax wrong. Can you give my any suggestions? Merrill ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: Reading from SQL, Writing to CSV ...
Try Text::CSV_XS; Jones Robert Contr 81 CS/SCK [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent by: cc: [EMAIL PROTECTED]Subject: Reading from SQL, Writing to CSV ... eState.com 03/21/01 04:18 PM I'm running the following snippet of code below. Every time I read a field in that has a series of alpha with commas in it there are problems. After each of these multiple comma fields is read, the next field is skipped. For example, if a field contains 'john, henry, III' then my next field is omitted. Are there any characters which when read into a list will screw it up ?? while (@import=$sth-fetchrow_array) { $count++; $tmpcount = 0; foreach $holder (@import) { $tmpcount++; $ota[$count][$tmpcount] = $holder; } } open(FHCSV, " ota.csv") || die "Ouch !!!\n $!\n"; for ($xx=1; $xx = $count; $xx++) { for ($yy=1; $yy = $tfields-1; $yy++) { if ($ota[$xx][$yy] =~ /\,/) { print FHCSV "\"$ota[$xx][$yy],\""; } else { print FHCSV "$ota[$xx][$yy],"; } } if ($ota[$xx][$tfields] =~ /\,/) { print FHCSV "\"$ota[$xx][$tfields]\"\n"; } else { print FHCSV "$ota[$xx][$yy]\n"; } } close(FHCSV); ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: Install PM
Instead of worrying about what is is not installed you can try using Perlapp to create freestanding exes. Just a thought "Mauricio Lairet P." [EMAIL PROTECTED]To: "Perl Users Mailing List" Sent by: [EMAIL PROTECTED] [EMAIL PROTECTED]cc: eState.com Subject: Install PM 03/06/01 06:01 PM Hi! First of all I wanted to thak all who helped me with my Questions about SQL and ODBC. Now, Im thinking of using DBI module to work with databases intead of using Win32::ODBC but my hosting provider has only the typical extensions of Perl installed and they are not helping so much. So I wanted to know if there is a way to tell a script that the PM file is in other directory so it will not look for it in the standard Perl directory. I want ot know this not only for the mentioned DBI module but also to use any module I'd like to use without asking the hosting provider to install it for me. I'd really appreciate if you could help me here. Thank you so much! ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: I need Faster way than s/bla/bla/i to remove string. Does tha t exist?
if you are building for speed avoid $, $' and $` as they make copies of the variable being manipulated (see Freidl's Mastering Regular Expressions ppgs. 273-278 and 281-282). "you could try changing your substitute to a match and either using parens with $1 $2 and so on or you could use $ with $` (back tick) and $' (forward tick)" Mark Meyer [EMAIL PROTECTED] Sent by: To: "Perl-win32-users (E-mail)" [EMAIL PROTECTED] [EMAIL PROTECTED] eState.com cc: Subject: RE: I need Faster way than s/bla/bla/i to remove string. Does tha t exist? 02/28/01 06:12 PM Is there a faster way to remove the javascripts (of a HTML file put in a $string var) than mine? It's for a Html search engine. Here are what I do: $string =~ s/.*[\s]*script.*.*[\s]*\/script//ie; It is because I do not want to find text which is inside the javascripts. i don't have time to work with this at the moment - but i can make a suggestion: why not change the goal from: "I want to get rid of everything in between a leading and ending marker" to... "i want to keep everything before and after a leading and ending marker" you could try changing your substitute to a match and either using parens with $1 $2 and so on or you could use $ with $` (back tick) and $' (forward tick) hth mark ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: Help getting rid of duplicate entires in a datafile
A quick suggestion is to put the headlines in a hash and subsequently check if they exist, i.e. something like the following: if ( not exists $headlinelist{$headline} ) { do _your_stuff; } Gary Nielson [EMAIL PROTECTED]To: [EMAIL PROTECTED] Sent by: cc: [EMAIL PROTECTED]Subject: Help getting rid of duplicate entires in a eState.com datafile 02/19/01 04:01 PM I think I have written myself into a box (again!) I though the logic of the following makes sense but it isn't doing what I want to do. As some of you may know from reading this list, I have been writing a script to process headlines by section. Thanks to the help of many of you, the program is working great. But I found a new twist: Duplicate headlines. Sometimes duplicate headlines, with DIFFERENT urls, come over, or stories that are updated but basically say the same thing, come over. I want to use the first instance of the headline (the one most at the top of the file is the most recent) and delete all other instances of a headline where the first two words are the same as that first instance. (Explained below.) Well, I wrote a way to get rid of duplicates. My problem is the program is getting rid of ALL instances of the headline rather than just the 2nd and later instances of it. I don't know why. Here is the script, in its entirety, comments interspersed, and an example data file. (I hesitate to post such a long email, but have been told its much more helpful to post the entire script): #!/usr/bin/perl -w use strict; use diagnostics; use vars qw(@A); use FileHandle; # edit config here my $location_of_templates = "./tmp"; my $location_of_input_file = "./tmp"; my $location_of_output_file = "./tmp"; my $site_location = "/tmp"; my @sections = ('Nation','Business','Life','Sports'); # end edit config # variables initialized my $section; my $outputfile; my $field; my @fields; my $url; my $headline; my $summary; my $filename; my $old; my $new; my $bak; my @array; my $check_for; my @allheadlines; my $pattern; my $found; # begin program foreach $section (@sections) { # we're going to write the file in place, thanks to an example in # Perl Cookbook $old = "$location_of_output_file\/$section.output.txt"; $new = "$location_of_output_file\/$section.output.txt.tmp.$$"; $bak = "$location_of_output_file\/$section.output.txt.orig"; open(OLD, " $old") or die "can't open $old: $!"; open(NEW, " $new") or die "can't open $new: $!"; @fields = OLD; foreach $field (@fields) { #split each line ($section,$url,$headline,$summary)=split('\|',$field); # i need to create another variable for headline because i # want to get just the first two words. sometimes # headlines come over with changes toward the end of the # headline, but the first two or three words are the # same. It's basically the same story. $pattern = $headline; # split the headline pattern up by spaces. I tried to # write a regular expression to do this, had trouble and # this at least works @array = split(' ',$pattern); # grab those first two words and put in a check for variable $check_for = "$array[0] $array[1]"; # my understanding is the only way to check through an # array for a match is to loop through. This foreach loop # runs through an array called @allheadlines that I do not # push into until the end because I don't want to #
Re: Rounding numbers
Here is something directly from the Perl Cookbook (Ram). FYI - The O'Reilly Perl CD Bookshelf is a valuable reference source. It has 6 Perl books on 1 CD with an index for all books. Chapter 2 Numbers 2.3. Rounding Floating-Point Numbers Problem You want to round a floating-point value to a certain number of decimal places. This problem arises as a result of the same inaccuracies in representation that make testing for equality difficult (see Recipe 2.2), as well as in situations where you must reduce the precision of your answers for readability. Solution Use the Perl function sprintf, or printf if you're just trying to produce output: $rounded = sprintf("%FORMATf", $unrounded); Discussion Rounding can seriously affect some algorithms, so the rounding method used should be specified precisely. In sensitive applications like financial computations and thermonuclear missiles, prudent programmers will implement their own rounding function instead of relying on the programming language's built-in logic, or lack thereof. Usually, though, we can just use sprintf. The f format lets you specify a particular number of decimal places to round its argument to. Perl looks at the following digit, rounds up if it is 5 or greater, and rounds down otherwise. $a = 0.255; $b = sprintf("%.2f", $a); print "Unrounded: $a\nRounded: $b\n"; printf "Unrounded: $a\nRounded: %.2f\n", $a; Unrounded: 0.255 Rounded: 0.26 Unrounded: 0.255 Rounded: 0.26 Three functions that may be useful if you want to round a floating-point value to an integral value are int, ceil, and floor. int, built into Perl, returns the integral portion of the floating-point number passed to it (int will use $_ if it was called without an argument). The POSIX module's floor and ceil functions round their argument down and up to the next integer, respectively. use POSIX; print "number\tint\tfloor\tceil\n"; @a = ( 3.3 , 3.5 , 3.7, -3.3 ); foreach (@a) { printf( "%.1f\t%.1f\t%.1f\t%.1f\n", $_, int($_), floor($_), ceil($_) ); } number int floor ceil 3.3 3.0 3.0 4.0 3.5 3.0 3.0 4.0 3.7 3.0 3.0 4.0 -3.3-3.0-4.0-3.0 See Also The sprintf and int functions in perlfunc (1) and Chapter 3 of Programming Perl; the floor and ceil entries in the documentation for the standard POSIX module (also in Chapter 7 of Programming Perl); we introduced the sprintf technique in Recipe 2.2 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: More efficient way to write?
It looks like you got you answer, but here are a couple of other ideas. Instead of using /i in your regex - you can uc() or lc() the string first - I think this may be more efficient. Also, ['html', 'htm', 'doc'] can be written somehting like /\.htm[l]|\.doc/ (not tested- I think it is the correct format) "jim" [EMAIL PROTECTED] Sent by: To: [EMAIL PROTECTED] [EMAIL PROTECTED]cc: eState.com Subject: More efficient way to write? 02/02/01 10:46 PM hi perl friends, is there a more efficient/elegant way to write line no. 11 below? thanks! #!perl.exe -w use File::Find; #line 1 use strict; #line 2 my %dir; #line3 my $suffix = ['html', 'htm', 'doc']; #line 4 my $path = 'c:/hdb'; #line 5 find(\wanted, $path); #line 6 foreach (keys %dir) { #line 7 print "$_ - $dir{$_} $$suffix[0] files\n" #line 8 }#line 9 sub wanted { #line 10 return unless /\.$$suffix[0]|\.$$suffix[1]|\.$$suffix[2]|/i; #line 11 $dir{"$File::Find::dir"}++; #line 12 1; #line 13 } #line 14 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: MS Access List other questions
Try www.ezboard.com. I have used it for some VBA questions, I think it may have other MS product boards.. It is not as good as this board but what is? Here is a general question. Recently there was a discussion here on the merits of VB vs. Perl. I do not want to rehash that but I do have a somewhat related question. I recently read in MSDN that VB supports regular expressions. Does anybody know how it compares to Perl's regex engine in terms of speed and functionality, whether it is DFA or NFA? Another totally unrelated question to the above topic. I may soon have to take data from web pages. i.e. get to a page and take data from it. What Perl module would I use and where is a good place to read about this. I have O'Reilly's Perl CD bookshelf which I think should be sufficient, is this correct? Thanks, Scott [EMAIL PROTECTED] Sent by: To: [EMAIL PROTECTED] [EMAIL PROTECTED]cc: eState.com Subject: MS Access List 01/03/01 06:00 PM Could someone give me a way to access a "MS Access" mailing list? ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: regex - conditionals?
I do not think you need to write a regex. I think one of the data modules can do the conversions for you. Try Date-Manip using UnixDate ($olddate"%m/%d/%y %r"). This is the slowest of the Date routines so there may be another one to try. Scott "Doug Brewer" [EMAIL PROTECTED] Sent by: To: "perl-win32-users" [EMAIL PROTECTED] [EMAIL PROTECTED] eState.com cc: Subject: regex - conditionals? 01/04/01 10:22 AM I have a regex question. I need to convert a tab delimited file of date and time values to a different format. I need to get to: -MM-DD HH:MM:SS what i'm starting with is: 4/23/19984:55:37 PM ^^ these need to be 2 digits The difficulty I'm having is not reversing the date value, or converting the time value to 24 hours from a 12 hour am/pm. I am having difficulty making sure that the HH:MM:SS are all two digits, and the same with the MM-DD portion of the date. For instance, I am using this to reverse the date (and change the separators): $line =~ s|(.*)/(.*)/(.*)\t|$3-$2-$1\t|g; but how do I conditionally add a leading zero if $2 or $1 are of length==1? TIA, Doug Brewer ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: regex - conditionals?
Sorry my example got the dates backwards. Try this use Date::Manip; Date_Init ("TZ=EST5EDT"); $sdate = '4/23/1998 4:55:37 PM'; $edate = '6/30/2000'; # -MM-DD HH:MM:SS $edate = UnixDate($sdate,"%Y-%m-%d %H:%M:%S"); print "\n start date=$sdate, end date=$edate"; gives start date=4/23/1998 4:55:37 PM, end date=1998-04-23 16:55:37 Scott ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: Getting date from a file and writing data to a file . . .
You can use the regex that was already suggested or use the unpack statement if the file format will not change. I am not sure which is more efficient (I think unpack is) or if you even care about efficiency. H23234 2000.12.11 00.15.00 10.254.345.345 $TMPLT = "A6 A1 A4 A1 A2 A1 A2 A1 A2 A1 A2 A1 A2 A1 A* a1"; @cols = unpack ($TMPLT,$_); # puts all in an array ($num,$sp,$yr,$sp,$mm,$sp,$dd,$sp,$hh,$sp,$mm,$sp,$ss,$sp,$ip) = ($TMPLT, $_unpack); Scott "Doug C. Fisher" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent by: cc: [EMAIL PROTECTED]Subject: RE: Getting date from a file and writing eState.com data to a file . . . 12/13/00 04:53 PM use arrays and hashes. -Original Message- From: Alloun, Jonathan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 4:46 PM To: [EMAIL PROTECTED] Subject: Re: Getting date from a file and writing data to a file . . . Importance: High Hello, There is a file with the following info: H23234 2000.12.11 00.15.00 10.254.345.345 H54544 2000.12.12 06.15.00 10.254.345.456 --- some number .mm.dd hh.mm.ss ip address = year mm = month dd = day hh = hour mm = minutes ss = seconds From a perl script I need to read the contents of this file, one line at a time and store the information for later use within the script. Further down the script I will also need to update the date and time of the file with the current date and time as of that point. Thanks in advance. Jonathan ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ** ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: Grasping input parameter off the command line . . .
You can use the Getopt module myscript.pl use Getopt::Long; use vars qw($date); GetOptions('D=s' = \$date); print "\n date is $date"; *** $perl myscript.pl -D="12/21/00" should print date is 12/21/00 "Alloun, Jonathan" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent by: cc: [EMAIL PROTECTED]Subject: RE: Grasping input parameter off the eState.com command line . . . 12/13/00 01:09 PM Hello, I need to give my script a run date parameter i.e. script_name date="13.12.2000" I have seen how to use STDIN to grasp user input but this script will be run as a batch job and therefore will need to pass the parameter in when the script is called. How would I capture the date that is passed in?? Thanks in advance. Jonathan ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ** ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: reading hash from file did not produce expected results
You can also try using a regex $x = '8114,[EMAIL PROTECTED]'; $x =~ /(.*),(.*)/; print "\n \$1 = $1 , \$2 = $2"; produces $1 = 8114 , $2 = [EMAIL PROTECTED] # note comma is from print statement no regex parsing. Jon Bjornstad [EMAIL PROTECTED] Sent by: To: "Rogers, John" [EMAIL PROTECTED] [EMAIL PROTECTED]cc: "'[EMAIL PROTECTED]'" eState.com [EMAIL PROTECTED] Subject: Re: reading hash from file did not produce expected results 12/05/00 07:25 PM try this instead: ($number, $email) = split /,/; $ext{$number} = $email; you may want the regular expression to be /[,\s]+/ instead so that 4154 , [EMAIL PROTECTED] would parse properly. "Rogers, John" wrote: Howdy all, I have simple comma delimited file that looks like this, ext no,email 8114,[EMAIL PROTECTED] 5678,[EMAIL PROTECTED] 7890,[EMAIL PROTECTED] now I want to read this file into a hash, so I wrote, (with the aid of much reading) #-start #!perl -w $extnum='8114'; # at the moment. open(ADDR, "addressbook.txt") or die "cant open $!\n"; while(ADDR) { chomp; ($number)=(split(/\,/)); $ext{$number}=$_; } close (ADDR); #now if i print "$ext{$extnum}\n"; #end The print produces, G:\s2eperl hashtry.pl 8114,[EMAIL PROTECTED] I was expecting just [EMAIL PROTECTED] if I look at the Hash with perl -d DB1 x %ext 0 5678 1 '5678,[EMAIL PROTECTED]' 2 'ext no' 3 'ext no,email' 4 7890 5 '7890,[EMAIL PROTECTED]' 6 8114 7 '8114,[EMAIL PROTECTED]' Now I can "clean" it up by adding, $ext{$number}=~(s/$extnum\, //); to the while loop. is this Normal ? I want to Know why the values also have the keys, and what Ive done wrong. not yet a Perl legend. John Rogers System Engineer OCE Australia Todays Quote, "We want a few mad people now. See where the sane ones have landed us!" George Bernard Shaw (1856-1950) ## Disclaimer If this e-mail has been sent to you in error, please notify Océ-Australia Limited immediately and delete this e-mail from your system. Any views expressed in this e-mail are those of the individual sender and may not necessarily reflect the views of Océ-Australia Limited. ## ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: Help with or
Sorry about the typos - I had d/b string inserts on my mind. I don't know where the "=!~" came from - fat fingers I guess. Carl Jolley [EMAIL PROTECTED] Sent by: To: [EMAIL PROTECTED] [EMAIL PROTECTED]cc: "Paul G. Weiss" [EMAIL PROTECTED], "'byron wise'" eState.com [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: Help with or 11/30/00 12:21 PM On Wed, 29 Nov 2000 [EMAIL PROTECTED] wrote: Looks like a case for a regex How about if ($code =!~ /APM|CHN|CN|MN'|'N'|'NP'|'NPR'|'NRN'|'NS'|'PMD'|'RNR' |'SCI/) Only if you lose all the quotes and change the regex operator to =~. [EMAIL PROTECTED] Carl Jolley All opinions are my own and not necessarily those of my employer ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users