Jul 14
#!/usr/bin/perl
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const;
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
my $filename = 'C:\ist\Win32\OLE\ChartOLE\chart.xls';
my $filter = 'GIF'; # can be GIF, JPG, JPEG or PNG
my $count = 0;
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit'); # use the Excel application if it's open, otherwise open new
my $Book = $Excel->Workbooks->Open( $filename ); # open the file
foreach my $Sheet (in $Book->Sheets) { # loop through all sheets
foreach my $ChartObj (in $Sheet->ChartObjects) { # loop through all chartobjects in the sheet
my $savename = "$filename." . $count++ . ".$filter";
$ChartObj->Chart->Export({
FileName => $savename,
FilterName => $filter,
Interactive => 0});
}
}
$Book->Close;
Jul 14
This perl code running under Windows 32 operating systems, and requires the MS Office to be installed.
#!/usr/bin/perl
use Win32::OLE::Const 'Microsoft Excel';
printf "xlMarkerStyleDot = %d\n", xlMarkerStyleDot;
my $wd = Win32::OLE::Const->Load("Microsoft Word 9\\.0 Object Library");
foreach my $key (keys %$wd) {
printf "$key = %s\n", $wd->{$key};
}
Jul 14
#!/usr/bin/perl -n00
print "$2\n" while m{
< \s*
A \s+ HREF \s* = \s* (["']) (.*?) \1
\s* >
}gsix;
Jul 14
#!/usr/bin/perl
use LWP::Simple;
$count = 0;
$search = $#ARGV >= 0 ? $ARGV[1] : "author";
$server = $#ARGV >= 1 ? $ARGV[0] : "www.webhauser.com";
$page = get "http://$server";
@lines = split /[\n\r]+/, $page;
foreach $line (@lines) {
if ( $line =~ /$search/ ) {
print "found: $line\n";
$count++;
}
}
print '-'x70 ."\n";
print "internet szerver: $server\n";
print "keresett szo: $search\n";
print "Talalat $count sorban\n";
Jul 14
#!/usr/bin/perl
use LWP::Simple;
print $ARGV[0];
print "\n";
getprint "http://" . $ARGV[0];
May 17
To use a here-document to assign an array, one line per element, you might use an approach like this:
@sauces = <<End_lines =~ m/(\S.*\S)/g;
normal tomato
spicy tomato
green chile
pesto
white wine
End_Lines
May 17
open my $fh, "foo" or die $!;
local $/;
my $content = <$fh>;
close $fh;
May 17
@AoA = (
[ "fred", "barney" ],
[ "george", "jane", "elroy" ],
[ "homer", "marge", "bart" ],
);
print $AoA[2][2]; # bart
May 17
$x = "Calvin and Hobbes";
@words = split /\s+/, $x;
May 17
@words = ($x =~ /(\w+)/g);
Recent Comments