was6guy has asked for the wisdom of the Perl Monks concerning the following question:
authDataAlias="cell-tstc-65_DM/userQ"
Sring will always be: authDataAlias="*-*-*_DM/*
Here's an example of the line containing the string:
<factories xmi:type="resources.jdbc:CMPConnectorFactory" xmi:id="CMPConnectorFactory_1195273978412" name="dataSource" authMechanismPreference="BASIC_PASSWORD" authDataAlias="cell-tstc-65_DM/userQ" connectionDefinition="ConnectionDefinition_1054132487569" cmpDatasource="DataSource_1195273954323">
An easy example, I can pull the line containing the string. If I knew where the sring would be each time in the line I could grab it, but since it's random... i'm lost. Could someone help me expand on this:
#!/usr/bin/perl my $data_file = '/home/resources.xml'; my $data_out = '/home/out.log'; open DATA, "$data_file" or die "can't open $data_file $!"; open DATA_OUT, ">>$data_out"; my @array_of_data = <DATA>; foreach my $line (@array_of_data) { if ($line =~ m/authDataAlias=.*-.*-.*_DM/i) { print DATA_OUT "$line\n"; } } close (DATA); close (DATA_OUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Some help with finding a word in a file
by jrsimmon (Hermit) on Nov 28, 2007 at 23:57 UTC | |
by was6guy (Initiate) on Nov 29, 2007 at 14:42 UTC | |
by jrsimmon (Hermit) on Nov 29, 2007 at 15:42 UTC | |
by was6guy (Initiate) on Nov 29, 2007 at 19:27 UTC | |
by jrsimmon (Hermit) on Nov 29, 2007 at 20:43 UTC | |
by was6guy (Initiate) on Nov 29, 2007 at 21:27 UTC | |
|
Re: Need Some help with finding a word in a file
by thundergnat (Deacon) on Nov 29, 2007 at 20:54 UTC | |
by was6guy (Initiate) on Nov 29, 2007 at 21:33 UTC | |
by was6guy (Initiate) on Nov 29, 2007 at 21:41 UTC |